code
stringlengths
1
1.73M
language
stringclasses
1 value
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
require 'sinatra.rb' # Sinatra defines #set at the top level as a way to set application configuration set :run, false set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development) require './main' run Sinatra::Application
Ruby
require 'sinatra/activerecord/rake' require './main'
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
require 'sinatra.rb' # Sinatra defines #set at the top level as a way to set application configuration set :run, false set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development) require './main' run Sinatra::Application
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
require 'sinatra.rb' # Sinatra defines #set at the top level as a way to set application configuration set :run, false set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development) require './main' run Sinatra::Application
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require File.dirname(__FILE__) + '/../vendor/plugins/carry_on/lib/commands/gem'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require File.dirname(__FILE__) + '/../vendor/plugins/carry_on/lib/commands/gem'
Ruby
require 'fileutils' gem_dir = File.join(RAILS_ROOT, 'vendor/gems') FileUtils.mkdir(gem_dir) unless File.exist?(gem_dir) gem_src = File.join(File.dirname(__FILE__), 'scripts/gem') gem_dest = File.join(RAILS_ROOT, 'script/gem') FileUtils.cp(gem_src, gem_dest) FileUtils.chmod(0755, gem_dest)
Ruby
require 'carry_on' CarryOn::add_to_load_path
Ruby
# desc "Explaining what the task does" # task :carry_on do # # Task goes here # end
Ruby
# Uninstall hook code here
Ruby
require 'rake' require 'rake/testtask' require 'rake/rdoctask' desc 'Default: run unit tests.' task :default => :test desc 'Test the carry_on plugin.' Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.pattern = 'test/**/*_test.rb' t.verbose = true end desc 'Generate documentation for the carry_on plugin.' Rak...
Ruby
require 'rbconfig' require 'rubygems' require 'fileutils' module CarryOn module_function # +CarryOn+'s canonical name for the current architecture/OS. def canonical_arch Config::CONFIG['arch'].sub(/[\.0-9]*$/, '') end # The path to architecture-neutral gems installed by +CarryOn+. def ruby_spec_p...
Ruby
require File.join(File.dirname(__FILE__), '../carry_on') module CarryOn # :nodoc: module Commands # :nodoc: module_function def dispatch(args) case args.first when 'install' args.shift while gem = args.shift CarryOn::install_gem(gem) end ...
Ruby
class AddPlacenameData < ActiveRecord::Migration def self.up Placename.delete_all Placename.create(:name => '北九州') Placename.create(:name => '筑豊') Placename.create(:name => '福岡') Placename.create(:name => '久留米') Placename.create(:name => '門司') Placename.create(:name => '下関') Placename....
Ruby
class CreateOrderItems < ActiveRecord::Migration def self.up create_table :order_items do |t| t.integer :order_id, :null => false t.string :task_type t.string :direction t.string :side t.integer :position_id t.integer :inside_position_id t.string :damage_shape ...
Ruby
class CreateCuts < ActiveRecord::Migration def self.up create_table :cuts do |t| t.string :part t.string :car_size t.float :cut_index t.float :metal_putty_index t.timestamps end end def self.down drop_table :cuts end end
Ruby
class DeleteOrdersData < ActiveRecord::Migration def self.up Order.delete_all end def self.down end end
Ruby
class AddCutData < ActiveRecord::Migration def self.up Cut.delete_all Cut.create(:part => "リアクォータ", :car_size => "軽自動車", :cut_index => 4, :metal_putty_index => 2) Cut.create(:part => "リアクォータ", :car_size => "普通車", :cut_index => 6, :metal_putty_index => 3) Cut.create(:part => "リアクォータ", :car_size => "大型車...
Ruby
class CreatePlacenames < ActiveRecord::Migration def self.up create_table :placenames do |t| t.string :name t.timestamps end end def self.down drop_table :placenames end end
Ruby
class AddPositionsData < ActiveRecord::Migration def self.up Position.delete_all Position.create(:part => 'フロントバンパー', :rear => false, :side => false, :twosides => false, :material => '樹脂') Position.create(:part => 'フロントスポイラー', :rear => false, :side => false, :twosides => false, :material => '樹脂', ...
Ruby
class DeleteDatas < ActiveRecord::Migration def self.up Order.delete_all OrderItem.delete_all end def self.down end end
Ruby
class ChangeOrdersColumn < ActiveRecord::Migration def self.up change_column :orders, :placename, :string end def self.down change_column :orders, :placename, :integer end end
Ruby
class AddInsidePositionData < ActiveRecord::Migration def self.up InsidePosition.delete_all InsidePosition.create(:part => "ラジエターサポート", :direction_side => "前方", :metal_index => 1.5, :exchange_index => 1.2) InsidePosition.create(:part => "フロントクロスメンバー", :direction_side => "前方", :metal_index => 1.0, :exchang...
Ruby
class CreateTypesizes < ActiveRecord::Migration def self.up create_table :typesizes do |t| t.string :type t.string :size t.timestamps end end def self.down drop_table :typesizes end end
Ruby
class AddPaintingData < ActiveRecord::Migration def self.up Painting.delete_all Painting.create(:part => "ボンネット", :car_size => "軽自動車", :paint_type => "ソリッド", :paint_index => 1.55) Painting.create(:part => "ボンネット", :car_size => "普通車", :paint_type => "ソリッド", :paint_index => 2.3) Painting.create(:part =>...
Ruby
class CreateInsidePositions < ActiveRecord::Migration def self.up create_table :inside_positions do |t| t.string :part t.string :direction_side t.float :metal_index t.float :exchange_index t.timestamps end end def self.down drop_table :inside_positions end end
Ruby
class CreatePaintings < ActiveRecord::Migration def self.up create_table :paintings do |t| t.string :part t.string :car_size t.string :paint_type t.float :paint_index t.timestamps end end def self.down drop_table :paintings end end
Ruby
class CreateOrders < ActiveRecord::Migration def self.up create_table :orders do |t| t.string :identity_number t.integer :placename_id t.string :identity_letter t.string :plate_number t.string :car_type t.string :car_size t.string :paint_type t.boolean :use_amend_se...
Ruby
class ChangeColumn < ActiveRecord::Migration def self.up change_column :orders, :identity_number, :string end def self.down change_column :orders, :identity_number, :integer end end
Ruby
class AddTypesizeData < ActiveRecord::Migration def self.up Typesize.delete_all Typesize.create(:car_type => 'RV', :car_size => '軽自動車') Typesize.create(:car_type => 'RV', :car_size => '普通車') Typesize.create(:car_type => 'RV', :car_size => '大型車') Typesize.create(:car_type => 'ワゴン', :car_size => '軽自...
Ruby
class AddUninstallData < ActiveRecord::Migration def self.up Uninstall.delete_all Uninstall.create(:part => "ボンネット", :car_size => "軽自動車", :disassemble_time => 0.1, :assemble_time => 0.2, :recombine_time => 0.3) Uninstall.create(:part => "ボンネット", :car_size => "普通車", :disassemble_time => 0.17, :assemble_tim...
Ruby
class CreatePositions < ActiveRecord::Migration def self.up create_table :positions do |t| t.string :part t.boolean :front, :default => true t.boolean :rear, :default => true t.boolean :side, :default => true t.boolean :twosides, :default => true t.boolean :t_rv, :default => tr...
Ruby
class Renametypesizecolumn < ActiveRecord::Migration def self.up rename_column :typesizes, :type, :car_type rename_column :typesizes, :size, :car_size end def self.down rename_column :typesizes, :car_type, :type rename_column :typesizes, :car_size, :size end end
Ruby
class CreateUninstalls < ActiveRecord::Migration def self.up create_table :uninstalls do |t| t.string :part t.string :car_size t.float :disassemble_time, :default => 0 t.float :assemble_time, :default => 0 t.float :recombine_time, :default => 0 t.timestamps end end def...
Ruby
class RenameOrdersColumn < ActiveRecord::Migration def self.up rename_column :orders, :placename_id, :placename end def self.down rename_column :orders, :placename, :placename_id end end
Ruby
class CreateSessions < ActiveRecord::Migration def self.up create_table :sessions do |t| t.string :session_id, :null => false t.text :data t.timestamps end add_index :sessions, :session_id add_index :sessions, :updated_at end def self.down drop_table :sessions end end
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'test_help' class ActiveSupport::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 da...
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/generate'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/plugin'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/dbconsole'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/dbconsole'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/plugin'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/generate'
Ruby
module DamageJudge1Helper end
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper #因为在order第一次被存储后session中的值就被替换成它的id,所以在此需要根据session中值的类型来判断采取哪种方法取得order的值 #此方法是提供给共享模板_car_info来调用order的 def order_info Order.find(session[:order]) end end
Ruby
module OrdersHelper end
Ruby
module DamageJudgeHelper end
Ruby
module AdminHelper end
Ruby
module InternalDamageJudgeHelper end
Ruby
module DamageJudge3Helper end
Ruby
module OrderItemsHelper end
Ruby
module DamageJudge2Helper end
Ruby
class Placename < ActiveRecord::Base end
Ruby
class Cut < ActiveRecord::Base end
Ruby
class Painting < ActiveRecord::Base end
Ruby
class Position < ActiveRecord::Base has_many :order_items has_many :orders, :through => :order_items def self.get_positions(dir,order) direction = "" car_type = "" car_size = "" case dir when "前方" direction = "front" when "後方" direction = "rear" when "側面" dir...
Ruby
class InsidePosition < ActiveRecord::Base has_many :order_items def self.find_inside_position_in_dir(direction_sides) inside_positions_in_direction_side = {} positions_in_same_dir = [] direction_sides.each do |direction_side| positions_in_same_dir = InsidePosition.find(:all,:conditions => ["dir...
Ruby
class Uninstall < ActiveRecord::Base end
Ruby
class Order < ActiveRecord::Base has_many :order_items, :dependent => :destroy has_many :positions, :through => :order_items has_many :inside_positions, :through => :order_items validates_presence_of :plate_number,:message => "プレートナンバを入力してください" validates_presence_of :identity_number,:message => "識別番号を入...
Ruby
class Typesize < ActiveRecord::Base end
Ruby
class OrderItem < ActiveRecord::Base belongs_to :order belongs_to :position belongs_to :inside_position #交换指数 def get_exchange_index(position,order,spoiler) self.recombine = 0.0 self.cut_index = 0.0 part = position.part car_size = order.car_size uninstall = Uninstall.find(:first, :condi...
Ruby
class DamageJudgeController < ApplicationController def index @order_item = get_order_item if request.get? @position = get_position car_size = get_order.car_size @spoiler_select = false case car_size when "軽自動車" @spoiler_select = @position.spoiler_mini when "普通車...
Ruby
class InternalDamageJudgeController < ApplicationController def part_selector get_order_item @order = get_order @order.use_amend_set = params[:frame] @order.save @direction_sides = @order.get_direction_side @positions_in_direction_side = @order.find_positions_in_dir(@direction_sides) @i...
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 helper :all # include all helpers, all the time protect_from_forgery # See ActionController::RequestForgeryPr...
Ruby
class DamageJudge2Controller < ApplicationController def index @order_item = get_order_item if request.post? position = get_position work_judge = @order_item.work_judge damage_degree = params[:damage_degree] if damage_degree == "塗膜のみ" work_judge = "サフから" end if dama...
Ruby
class OrderItemsController < ApplicationController # GET /order_items # GET /order_items.xml def index @order_items = OrderItem.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @order_items } end end # GET /order_items/1 # GET /order_items/...
Ruby
class DamageJudge3Controller < ApplicationController def index order_item = get_order_item position = get_position order = get_order spoiler = session[:spoiler] order_item.area_x = 0.0 order_item.area_y = 0.0 order_item.get_exchange_index(position,order,spoiler) redirect_to :controlle...
Ruby
class OrdersController < ApplicationController # GET /orders # GET /orders.xml #把session清空,保证进入index时session中的信息全部清除 def index @orders = Order.all clean_session respond_to do |format| format.html # index.html.erb format.xml { render :xml => @orders } end end # GET /orders/1 ...
Ruby
class AdminController < ApplicationController def index clean_session @order = Order.new end #根据车种选择不同来改变车辆大小选择框内的待选项 def display_size_column car_type = params[:car_type] car_sizes = Typesize.find(:all,:select => "car_size", :conditions => ["car_type = ?",car_type]) render :update do |pa...
Ruby
class DamageJudge1Controller < ApplicationController def index @order_item = get_order_item @position = get_position if request.post? @order_item.damage_degree = params[:damage_degree] if @order_item.damage_degree == "えぐれ" @order_item.damage_degree = "へこみ5mm以下" 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
# Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # You can also remove all the silencers if you're trying do debug a probl...
Ruby
# Be sure to restart your server when you modify this file. # 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. ActiveReco...
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
# Be sure to restart your server when you modify this file. # Your secret key for verifying cookie session data integrity. # If you change this key, all old sessions will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. Act...
Ruby
ActionController::Routing::Routes.draw do |map| map.resources :orders map.resources :order_items map.resources :orders # The priority is based upon order of creation: first created -> highest priority. # Sample of regular route: # map.connect 'products/:id', :controller => 'catalog', :action => 'view'...
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