code
stringlengths
1
1.73M
language
stringclasses
1 value
class AppsController < ApplicationController # GET /apps # GET /apps.xml # GET /apps.json def index @apps = App.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @apps } format.json { render :json => @apps } end end # GET /apps/1 ...
Ruby
class Record attr_accessor :id, :exists end
Ruby
class PermissionsController < ApplicationController # POST /permission.xml # POST /permission.json def create @permission = Permission.new(:name => params[:permission]) respond_to do |format| if @permission.save format.xml { render :xml => @permission, :status => :created, :location => @...
Ruby
class CommentsController < ApplicationController # POST /comments.xml # POST /comments.json def create @app = App.find(params[:app_id]) @comment = @app.comments.new(params[:comment]) respond_to do |format| if @comment.save format.xml { render :xml => @comment, :status => :...
Ruby
class VisualsController < ApplicationController # POST /visuals def create @app = App.find(params[:app_id]) @visual = @app.visuals.new(:image => params[:image]) respond_to do |format| if @visual.save format.html { render :json => @visual, :status => :created} else ...
Ruby
class ApplicationController < ActionController::Base # protect_from_forgery end
Ruby
class AppTargetsController < ApplicationController # POST /app_targets.xml # POST /app_targets.json def create @app_target = AppTarget.new(params[:app_target]) respond_to do |format| if @app_target.save format.xml { render :xml => @app_target, :status => :created, :location => @app_targ...
Ruby
class AppPermissionsController < ApplicationController # POST /app_permissions/update_permissions.xml # POST /app_permissions/update_permissions.json def update_permissions app = App.find(params[:app_id]) app.permission_ids = params[:permissions] respond_to do |format| if app.save! ...
Ruby
# Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require File.expand_path('../config/application', __FILE__) require 'rake' Marketplace::Application.load_tasks
Ruby
#!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands'
Ruby
source 'http://rubygems.org' gem 'rails', '3.0.3' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'mysql2' gem 'paperclip' gem 'will_paginate' gem 'vestal_versions', :git => 'git://github.com/adamcooper/vestal_versions' # Use unicorn as the web server # gem 'unicorn' # D...
Ruby
class CreateVestalVersions < ActiveRecord::Migration def self.up create_table :versions do |t| t.belongs_to :versioned, :polymorphic => true t.belongs_to :user, :polymorphic => true t.string :user_name t.text :modifications t.integer :number t.integer :reverted_from t...
Ruby
class CreateVisuals < ActiveRecord::Migration def self.up create_table :visuals do |t| t.references :app t.timestamps end add_index :visuals, :app_id end def self.down drop_table :visuals end end
Ruby
class CreateRatings < ActiveRecord::Migration def self.up create_table :ratings do |t| t.string :rating t.integer :ratingCount t.integer :downloadCount t.string :downloadCountText t.references :app t.timestamps end add_index :ratings, :app_id, :unique => true end ...
Ruby
class CreateAppPermissions < ActiveRecord::Migration def self.up create_table :app_permissions do |t| t.references :app t.references :permission t.timestamps end add_index :app_permissions, :app_id add_index :app_permissions, :permission_id end def self.down drop_table :ap...
Ruby
class CreateAppTargets < ActiveRecord::Migration def self.up create_table :app_targets do |t| t.references :app t.references :target t.timestamps end add_index :app_targets, :app_id add_index :app_targets, :target_id end def self.down drop_table :app_targets end end
Ruby
class CreateComments < ActiveRecord::Migration def self.up create_table :comments do |t| t.integer :rating t.string :creationTime t.string :authorName t.string :text t.string :authorId t.references :app t.timestamps end add_index :comments, :app_id add_index ...
Ruby
class CreateApps < ActiveRecord::Migration def self.up create_table :apps do |t| t.string :creator t.string :packageName t.string :title t.text :description t.string :appId t.string :category t.text :recentChanges t.string :email t.string :phone t.string...
Ruby
class CreateTargets < ActiveRecord::Migration def self.up create_table :targets do |t| t.string :name t.timestamps end add_index :targets, :name, :unique => true end def self.down drop_table :targets end end
Ruby
class CreatePermissions < ActiveRecord::Migration def self.up create_table :permissions do |t| t.string :name t.timestamps end add_index :permissions, :name, :unique => true end def self.down drop_table :permissions end end
Ruby
class AddAttachmentImageToVisual < ActiveRecord::Migration def self.up add_column :visuals, :image_file_name, :string add_column :visuals, :image_content_type, :string add_column :visuals, :image_file_size, :integer add_column :visuals, :image_updated_at, :datetime end def self.down remove_co...
Ruby
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) # Mayor.create(:name =>...
Ruby
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run Marketplace::Application
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. # # Note: You'll currently still have to declare fixtures explicitly in integrati...
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "theme/css" sass_dir = "theme/scss" images_dir = "images" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): output_style = :co...
Ruby
#!/usr/bin/env ruby #require 'rubygems' require 'hpricot' require 'json' def read_json name return JSON.parse( File.open( name, 'r' ).read ) end STATES = read_json 'states.json' class Quit < Exception end def make_hash( root, fields ) result = {} fields.each { |field| add_hash( result, field, root, field ) } r...
Ruby
require 'mkmf' $CPPFLAGS = $CPPFLAGS + " -I../../include" $LDFLAGS = $LDFLAGS + " -L../../" $LIBS = $LIBS + " -lhpdf -lpng -lz" create_makefile 'hpdf'
Ruby
# # << Haru Free PDF Library 2.0.0 >> -- demo.rb # # Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appea...
Ruby
# # << Haru Free PDF Library 2.0.0 >> -- encryption.rb # # Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice...
Ruby
# # << Haru Free PDF Library 2.0.0 >> -- font_example.rb # # Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright noti...
Ruby
# # << Haru Free PDF Library 2.0.2 >> -- arc_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appear ...
Ruby
# # << Haru Free PDF Library 2.0.6 >> -- ext_gstate_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice ...
Ruby
# # << Haru Free PDF Library 2.0.2 >> -- ttfont_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appe...
Ruby
# # << Haru Free PDF Library 2.0.0 >> -- text_demo2.rb # # Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice...
Ruby
# # << Haru Free PDF Library 2.0.2 >> -- line_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appear...
Ruby
# # << Haru Free PDF Library 2.0.6 >> -- slideshow_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice a...
Ruby
class CreateProjects < ActiveRecord::Migration def self.up create_table :projects do |t| t.integer :project_id t.string :name_th t.string :name_eng t.text :description t.text :abstract t.integer :author_id t.integer :advisor_id t.integer :year t.integer :categ...
Ruby
class CreateMembers < ActiveRecord::Migration def self.up create_table :members do |t| t.string :username t.string :passwd end end def self.down drop_table :members end end
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'test_help' class Test::Unit::TestCase # Transactional fixtures accelerate your tests by wrapping each test method # in a transaction that's rolled back on completion. This ensures that the # test datab...
Ruby
#!/usr/bin/ruby1.8 require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired...
Ruby
#!/usr/bin/ruby1.8 # # You may specify the path to the FastCGI crash log (a log of unhandled # exceptions which forced the FastCGI instance to exit, great for debugging) # and the number of requests to process before running garbage collection. # # By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log #...
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/generate'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/plugin'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/dbconsole'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/dbconsole'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/plugin'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/spawner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/spawner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/inspector'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/reaper'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/reaper'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/inspector'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/request'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/request'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/generate'
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
module ProjectHelper end
Ruby
module AuthHelper end
Ruby
class Member < ActiveRecord::Base end
Ruby
class Project < ActiveRecord::Base end
Ruby
class AuthController < ApplicationController def index end def login if request.post? @current_member = Member.find_by_username_and_passwd(params[:username], params[:passwd]) unless @current_member.nil? session[:user_id]=@current_member.id redirect_to :controller => 'project' ...
Ruby
# Filters added to this controller apply to all controllers in the application. # Likewise, all the methods added will be available for all controllers. class ApplicationController < ActionController::Base before_filter :fetch_logged_in_user protected def fetch_logged_in_user return if session[:user_id].blan...
Ruby
class ProjectController < ApplicationController def index @p=Project.find(:all); end def show @pid=Project.find_by_id(params[:id]) end end
Ruby
# Be sure to restart your server when you modify this file. # Add new inflection rules using the following format # (all these examples are active by default): # ActiveSupport::Inflector.inflections do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person',...
Ruby
# These settings change the behavior of Rails 2 apps and will be defaults # for Rails 3. You can remove this initializer when Rails 3 is released. if defined?(ActiveRecord) # Include Active Record class name as root for JSON serialized output. ActiveRecord::Base.include_root_in_json = true # Store the full clas...
Ruby
# Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf # Mime::Type.register_alias "text/html", :iphone
Ruby
ActionController::Routing::Routes.draw do |map| # The priority is based upon order of creation: first created -> highest priority. # Sample of regular route: # map.connect 'products/:id', :controller => 'catalog', :action => 'view' # Keep in mind you can assign values other than :controller and :action # ...
Ruby
# Don't change this file! # Configure your app in config/environment.rb and config/environments/*.rb RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) module Rails class << self def boot! unless booted? preinitialize pick_boot.run end end def booted? ...
Ruby
# Be sure to restart your server when you modify this file # Uncomment below to force Rails into production mode when # you don't control web/app server and can't set it the proper way # ENV['RAILS_ENV'] ||= 'production' # Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VERSION = '2.2...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true # Enable threaded mode # config.threadsafe! # Use a different logger for distributed setups # config....
Ruby
# Settings specified here will take precedence over those in config/environment.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the webserver when you make code changes. config.ca...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between...
Ruby
# Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require(File.join(File.dirname(__FILE__), 'config', 'boot')) require 'rake' require 'rake/testtask' require 'rake/rdoctask' require 'tasks/rails'
Ruby
#!/usr/bin/env ruby # encoding: utf-8 # ruby version of Unicode table converter require 'rubygems' begin require 'bundler/setup' rescue LoadError puts "You should install Bundler using 'gem install bundler' and run 'bundle install'" end require 'yajl' require 'fastercsv' ## These four elements are also valid in...
Ruby
source :rubygems gem 'yajl-ruby', '>= 0.7.8' gem 'fastercsv', :platforms => :ruby_18
Ruby
#!/usr/bin/env ruby # encoding: utf-8 # ruby version of Unicode table converter require 'rubygems' begin require 'bundler/setup' rescue LoadError puts "You should install Bundler using 'gem install bundler' and run 'bundle install'" end require 'yajl' require 'fastercsv' ## These four elements are also valid in...
Ruby
#!/usr/bin/env ruby require 'socket' require 'ipaddr' port = 5350 print "Listening for NAT-PMP public IP changes:\n" socket = UDPSocket.new socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true) socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEPORT, true) socket.bind("224.0.0.1",port) addr = '0.0.0...
Ruby
#!/usr/bin/env ruby require 'socket' require 'ipaddr' port = 5350 # A compatible NAT gateway MUST generate a response with the following # format: # # 0 1 2 3 # 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 # +-+-+-+-+-+-+-+-+-+-+-+-+...
Ruby
#!/usr/bin/env ruby require 'socket' require 'ipaddr' port = 5350 print "Listening for NAT-PMP public IP changes:\n" socket = UDPSocket.new while true do begin # socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true) # socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEPORT, true) socket...
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "theme/css" sass_dir = "theme/scss" images_dir = "images" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): output_style = :co...
Ruby
# Copyright (C) 2012 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
Ruby
source :gemcutter gem 'sinatra', :require => 'sinatra/base' gem 'thin', '~> 1.3' gem 'pg' gem 'data_mapper', '~> 1.2' gem 'dm-postgres-adapter' gem 'google-api-client', '>= 0.4.3' group :development do gem 'dm-sqlite-adapter', '~> 1.2' gem 'do_sqlite3', '~> 0.10' end
Ruby
require 'sinatra/activerecord/rake' require './main'
Ruby
source :gemcutter gem 'sinatra', :require => 'sinatra/base' gem 'thin', '~> 1.3' gem 'pg' gem 'sinatra-activerecord' gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client' group :development do gem 'rake' gem 'sqlite3-ruby' end
Ruby
class CreateUsers < ActiveRecord::Migration def up create_table :users do |t| t.string :profile_id t.string :email t.string :refresh_token end add_index :users, :profile_id end def down drop_table :users end end
Ruby
# Copyright (C) 2012 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
Ruby