Instruction
stringlengths
14
778
input_code
stringlengths
0
4.24k
output_code
stringlengths
1
5.44k
Fix indentation and move irrelevant configs.
# Set the host name for URL creation SitemapGenerator::Sitemap.default_host = "http://www.example.com" SitemapGenerator::Sitemap.create do # Put links creation logic here. # # The root path '/' and sitemap index file are added automatically for you. # Links are added to the Sitemap in the order they are specif...
# Set the host name for URL creation SitemapGenerator::Sitemap.default_host = "https://yande.re" SitemapGenerator::Sitemap.create_index = true SitemapGenerator::Sitemap.namer = SitemapGenerator::SimpleNamer.new(:sitemap, :zero => "_index") SitemapGenerator::Sitemap.create do # Put links creation logic here. # # ...
Set year to a string for now
class ShowsController < ApplicationController def index @year = params[:year] || DateTime.now.year @shows = Show.performed.for_year(@year) end def show @show = Show.performed.find_by_performed_at!(DateTime.parse(params[:id])) end def new @show = Show.new end def create @show = Parse...
class ShowsController < ApplicationController def index @year = params[:year] || DateTime.now.year.to_s @shows = Show.performed.for_year(@year) end def show @show = Show.performed.find_by_performed_at!(DateTime.parse(params[:id])) end def new @show = Show.new end def create @show = ...
Exclude Node.js specific file from gemspec
# coding: utf-8 lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "drugs/version" Gem::Specification.new do |spec| spec.name = "drugs" spec.version = Drugs::VERSION spec.authors = ["Martin Andert"] spec.email = ["mandert@gmai...
# coding: utf-8 lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "drugs/version" Gem::Specification.new do |spec| spec.name = "drugs" spec.version = Drugs::VERSION spec.authors = ["Martin Andert"] spec.email = ["mandert@gmai...
Change users to user on belongs_to
class Game < ActiveRecord::Base has_many :gamevenues had_many :venues, through: :gamevenues has_many :usergames has_many :users, through: :usergames belongs_to :users end
class Game < ActiveRecord::Base has_many :gamevenues had_many :venues, through: :gamevenues has_many :usergames has_many :users, through: :usergames belongs_to :user end
Disable inactive test for JRuby
require 'spec_helper' describe "Inactive Appsignal::Railtie" do it "should not insert itself into the middleware stack" do # This uses a hack because Rails really dislikes you trying to # start multiple applications in one process. It is reliable though. pid = fork do Appsignal.stub(:active => fals...
require 'spec_helper' describe "Inactive Appsignal::Railtie" do it "should not insert itself into the middleware stack" do # This uses a hack because Rails really dislikes you trying to # start multiple applications in one process. This works decently # on every platform except JRuby, so we're disabling ...
Add note to self about refactoring Homework
module Xapi # Homework gets all of a user's currently pending problems. class Homework attr_reader :key, :languages, :path def initialize(key, languages, path) @key = key @languages = languages @path = path end def problems_in(language) problems = slugs_in(language).map do |...
module Xapi # Homework gets all of a user's currently pending problems, # marking any new ones as fetched. # TODO: this class violates command/query separation. Refactor. class Homework attr_reader :key, :languages, :path def initialize(key, languages, path) @key = key @languages = languages...
Create an idea to show in idea view test.
require 'spec_helper' describe "IdeaViews" do describe "ideas/index.html.haml" do it "renders ideas/index" do render :template => "ideas/index" expect(rendered).to render_template("ideas/index") end end describe "ideas/new.html.haml" do it "renders ideas/new" do render :template =>...
require 'spec_helper' describe "IdeaViews" do describe "ideas/index.html.haml" do it "renders ideas/index" do render :template => "ideas/index" expect(rendered).to render_template("ideas/index") end end describe "ideas/new.html.haml" do it "renders ideas/new" do render :template =>...
Fix ElectricMarket => ElectricUtility relationship
require 'earth/locality' class ElectricUtility < ActiveRecord::Base self.primary_key = "eia_id" belongs_to :state, :foreign_key => 'state_postal_abbreviation' has_many :electric_markets has_many :zip_codes, :through => :electric_markets col :eia_id, :type => :integer col :name col :nickname col :...
require 'earth/locality' class ElectricUtility < ActiveRecord::Base self.primary_key = "eia_id" belongs_to :state, :foreign_key => 'state_postal_abbreviation' has_many :electric_markets, :foreign_key => :electric_utility_eia_id has_many :zip_codes, :through => :electric_markets col :eia_id, :type => :i...
Add source requirement to fileutils module.
require 'logging' require 'optparse' require 'raml_parser' require 'json' module RamlPoliglota module Support class SourceLoader def initialize @ignorable_source_files = [File.join('support', 'requires.rb'), File.join('raml_poliglota.rb')] @dir_order = [ 'configuration', 'model'...
require 'logging' require 'optparse' require 'raml_parser' require 'json' require 'fileutils' module RamlPoliglota module Support class SourceLoader def initialize @ignorable_source_files = [File.join('support', 'requires.rb'), File.join('raml_poliglota.rb')] @dir_order = [ 'con...
Use unicode replacement character for invalid data
module Slack class Notifier class LinkFormatter class << self def format string LinkFormatter.new(string).formatted end end def initialize string @orig = fix_encoding string end def formatted @orig.gsub( html_pattern ) do |match| ...
module Slack class Notifier class LinkFormatter class << self def format string LinkFormatter.new(string).formatted end end def initialize string @orig = fix_encoding string end def formatted @orig.gsub( html_pattern ) do |match| ...
Set the header dir and exclude private headers. Bump version.
Pod::Spec.new do |s| s.name = 'libPusher' s.version = '1.4' s.license = 'MIT' s.summary = 'An Objective-C client for the Pusher.com service' s.homepage = 'https://github.com/lukeredpath/libPusher' s.author = 'Luke Redpath' s.source = { :git => 'git://github.com/luker...
Pod::Spec.new do |s| s.name = 'libPusher' s.version = '1.5' s.license = 'MIT' s.summary = 'An Objective-C client for the Pusher.com service' s.homepage = 'https://github.com/lukeredpath/libPusher' s.author = 'Luke Redpath' s.source = { :git => 'https://github.com/luk...
Package version is increased from 0.29.0.11 to 0.29.0.12
# -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = 'evt-messaging' s.version = '0.29.0.11' s.summary = 'Common primitives for platform-specific messaging implementations for Eventide' s.description = ' ' s.authors = ['The Eventide Project'] s.email = 'opensource@eventide-project.org' s.home...
# -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = 'evt-messaging' s.version = '0.29.0.12' s.summary = 'Common primitives for platform-specific messaging implementations for Eventide' s.description = ' ' s.authors = ['The Eventide Project'] s.email = 'opensource@eventide-project.org' s.home...
Test to verify Typus::I18n.t interpolation.
require "test_helper" class I18nTest < ActiveSupport::TestCase test "t" do assert_equal "Hello", Typus::I18n.t("Hello") assert_equal "Hello", Typus::I18n.t(".hello", :default => "Hello") end test "default_locale" do assert_equal :en, Typus::I18n.default_locale end test "available_locales" do ...
require "test_helper" class I18nTest < ActiveSupport::TestCase test "t" do assert_equal "Hello", Typus::I18n.t("Hello") assert_equal "Hello", Typus::I18n.t(".hello", :default => "Hello") assert_equal "Hello @fesplugas", Typus::I18n.t("Hello %{human}!", :human => "@fesplugas") end test "default_loca...
Fix to use slug to find posts. Remove unused routes.
class PostsController < ApplicationController before_action :set_post, only: [:show, :edit, :update, :destroy] # GET /posts # GET /posts.json def index @posts = Post.all end # GET /posts/1 # GET /posts/1.json def show end # GET /posts/new def new @post = Post.new end # GET /posts/1...
class PostsController < ApplicationController before_action :set_post, only: [:show] # GET /posts # GET /posts.json def index @posts = Post.all end # GET /posts/1 # GET /posts/1.json def show end private # Use callbacks to share common setup or constraints between actions. def set_pos...
Add edit and update actions
class UsersController < ApplicationController before_filter :authenticate_user! def show @user = User.find(params[:id]) @questions_asked = @user.questions.page(params[:page]).per(3) @questions_answered = Question.includes({:answers => :user}).where(:answers => {:user_id => @user.id}).page(params[:page]...
class UsersController < ApplicationController before_filter :authenticate_user! def show @user = User.find(params[:id]) @questions_asked = @user.questions.page(params[:page]).per(3) @questions_answered = Question.includes({:answers => :user}).where(:answers => {:user_id => @user.id}).page(params[:page]...
Add the activerecord 3 development dependency.
# -*- encoding: utf-8 -*- $:.push File.expand_path('../lib', __FILE__) require 'periscope/version' Gem::Specification.new do |s| s.name = 'periscope' s.version = Periscope::VERSION s.platform = Gem::Platform::RUBY s.authors = ['Steve Richert'] s.email = ['steve.richert@gmail.com'] s...
# -*- encoding: utf-8 -*- $:.push File.expand_path('../lib', __FILE__) require 'periscope/version' Gem::Specification.new do |s| s.name = 'periscope' s.version = Periscope::VERSION s.platform = Gem::Platform::RUBY s.authors = ['Steve Richert'] s.email = ['steve.richert@gmail.com'] s...
Migrate remove_products: no down defined
class RemoveProducts < ActiveRecord::Migration def up drop_table :ordered_products drop_table :product_types end def down end end
class RemoveProducts < ActiveRecord::Migration def up drop_table :ordered_products drop_table :product_types end def down create_table "ordered_products", :force => true do |t| t.integer "attendee_id" t.integer "product_type_id" t.integer "amount" t.datetime "created_at" ...
Add validations to Post model
class Post < ActiveRecord::Base belongs_to :user delegate :username, to: :user end
class Post < ActiveRecord::Base validates :title, :body, :user_id, presence: true belongs_to :user delegate :username, to: :user end
Remove male pronoun in comment
module React module JSX # A {React::JSX}-compliant transformer which uses the deprecated `JSXTransformer.js` to transform JSX. class JSXTransformer DEFAULT_ASSET_PATH = 'JSXTransformer.js' def initialize(options) @transform_options = { stripTypes: options.fetch(:strip_types, fal...
module React module JSX # A {React::JSX}-compliant transformer which uses the deprecated `JSXTransformer.js` to transform JSX. class JSXTransformer DEFAULT_ASSET_PATH = 'JSXTransformer.js' def initialize(options) @transform_options = { stripTypes: options.fetch(:strip_types, fal...
Update spec to match new masthead search
# -*- coding: utf-8 -*- require 'spec_helper' describe "Global assets javascript" do let(:user) { create(:user) } before(:each) do login(user.username, "") # Stubbed auth end it "should have injected the masthead", js: true do page.should have_selector('header#malmo-masthead') end it "should have...
# -*- coding: utf-8 -*- require 'spec_helper' describe "Global assets javascript" do let(:user) { create(:user) } before(:each) do login(user.username, "") # Stubbed auth end it "should have injected the masthead", js: true do page.should have_selector('header#malmo-masthead') end it "should have...
Prepare to introduce locator resolver.
module Cucumber module Salad module Widgets class Form < Widget def self.check_box(name, label = nil) define_method "#{name}=" do |val| l = label || name_to_label(name) if val root.check l else root.uncheck l end ...
module Cucumber module Salad module Widgets class Form < Widget def self.check_box(name, label = nil) define_method "#{name}=" do |val| l = label || name_to_locator(name) if val root.check l else root.uncheck l en...
Test that selecting Rust 2021 works
require 'spec_helper' require 'support/editor' require 'support/playground_actions' RSpec.feature "Multiple Rust editions", type: :feature, js: true do include PlaygroundActions before do visit '/' editor.set(rust_2018_code) end scenario "using the 2015 edition" do in_advanced_options_menu { sele...
require 'spec_helper' require 'support/editor' require 'support/playground_actions' RSpec.feature "Multiple Rust editions", type: :feature, js: true do include PlaygroundActions before do visit '/' editor.set(rust_edition_code) end scenario "using the 2015 edition" do in_advanced_options_menu { s...
Use version 2, and provide a window
# encoding: utf-8 $LOAD_PATH.unshift File.dirname(__FILE__) $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) require 'rspec' require 'guards' require 'server' require 'operawatir/helper' OperaWatir.newandshinyplease! RSpec.configure do |config| config.mock_with :rr end module WatirSpec extend self ...
# encoding: utf-8 $LOAD_PATH.unshift File.dirname(__FILE__) $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) require 'rspec' require 'guards' require 'server' require 'operawatir/helper' OperaWatir.use_version 2 RSpec.configure do |config| config.mock_with :rr end module WatirSpec extend self attr...
Bump parser dependency to ~> 2.5
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'synvert/core/version' Gem::Specification.new do |spec| spec.name = "synvert-core" spec.version = Synvert::Core::VERSION spec.authors = ["Richard Huang"] spec.email ...
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'synvert/core/version' Gem::Specification.new do |spec| spec.name = "synvert-core" spec.version = Synvert::Core::VERSION spec.authors = ["Richard Huang"] spec.email ...
Remove cleanup commands; Use installed cabal path
name "cabal-update" build do # clean out any previous installation details command "rm -rf ~/.cabal ~/.ghc" # pull in latest package db command "/usr/bin/cabal update" end
name "cabal-update" build do # pull in latest package db command "#{install_dir}/embedded/bin/cabal update" end
Rename manifest file to .manifest.json
module Chest PLUGINS_FOLDER = File.expand_path('~/Library/Containers/com.bohemiancoding.sketch3/Data/Library/Application Support/com.bohemiancoding.sketch3/Plugins') MANIFEST_PATH = File.join(PLUGINS_FOLDER, 'plugins.json') end require 'chest/version' require 'chest/config' require 'chest/manifest' require 'chest/...
module Chest PLUGINS_FOLDER = File.expand_path('~/Library/Containers/com.bohemiancoding.sketch3/Data/Library/Application Support/com.bohemiancoding.sketch3/Plugins') MANIFEST_PATH = File.join(PLUGINS_FOLDER, '.manifest.json') end require 'chest/version' require 'chest/config' require 'chest/manifest' require 'ches...
Remove Rakefile from files to include
# -*- encoding: utf-8 -*- require File.expand_path("../lib/jssignals/rails/version", __FILE__) Gem::Specification.new do |s| s.name = "jssignals-rails" s.version = Jssignals::Rails::VERSION s.platform = Gem::Platform::RUBY s.author = "Phil Ostler" s.email = "philostler@gmail.com" s...
# -*- encoding: utf-8 -*- require File.expand_path("../lib/jssignals/rails/version", __FILE__) Gem::Specification.new do |s| s.name = "jssignals-rails" s.version = Jssignals::Rails::VERSION s.platform = Gem::Platform::RUBY s.author = "Phil Ostler" s.email = "philostler@gmail.com" s...
Enable running spec/core in CI set.
class MSpecScript # An ordered list of the directories containing specs to run # as the CI process. set :ci_files, [ 'spec/frozen/1.8/core', 'spec/frozen/1.8/language', # These additional directories will be enabled as the # specs in them are updated for the C++ VM. # 'spec/compiler', # '...
class MSpecScript # An ordered list of the directories containing specs to run # as the CI process. set :ci_files, [ 'spec/frozen/1.8/core', 'spec/frozen/1.8/language', 'spec/core', # These additional directories will be enabled as the # specs in them are updated for the C++ VM. # 'spec/c...
Fix a bug of GOD script.
# -*- ruby -*- DIR = File.join(File.dirname(__FILE__), "..") # Watch `pione-webclient` command. # # @param env_name [Symbol] # running environment name, e.g. `:production`, `:development`. def watch_pione_webclient(additional_options="") God.watch do |w| w.name = "pione-webclient" w.start = "bundle exec p...
# -*- ruby -*- DIR = File.join(File.dirname(__FILE__), "..") # Watch `pione-webclient` command. # # @param env_name [Symbol] # running environment name, e.g. `:production`, `:development`. def watch_pione_webclient(additional_options="") God.watch do |w| w.name = "pione-webclient" w.start = "ruby -I lib b...
Use count instead of reject!..size
# encoding: utf-8 module RuboCop module Cop module Metrics # This cop checks if the length a method exceeds some maximum value. # Comment lines can optionally be ignored. # The maximum allowed length is configurable. class MethodLength < Cop include OnMethodDef include Cod...
# encoding: utf-8 module RuboCop module Cop module Metrics # This cop checks if the length a method exceeds some maximum value. # Comment lines can optionally be ignored. # The maximum allowed length is configurable. class MethodLength < Cop include OnMethodDef include Cod...
Fix ModifierOrFileCreator to require 'file_modifier'
#! /bin/env ruby require File.dirname(__FILE__) + '/stream_editor' require File.dirname(__FILE__) + '/command_line_argument_parser' class ModifierOrFileCreator < FileModifier def initialize(argv, no_modify=false) @no_modify = no_modify dirname, __dump = parse_argv(argv.dup) target_filename_full = dir...
#! /bin/env ruby require File.dirname(__FILE__) + '/file_modifier' require File.dirname(__FILE__) + '/stream_editor' require File.dirname(__FILE__) + '/command_line_argument_parser' class ModifierOrFileCreator < FileModifier def initialize(argv, no_modify=false) @no_modify = no_modify dirname, __dump = p...
Add manual run integration test
require 'test_helper' class ManualRunTest< ActionDispatch::IntegrationTest def test_running_commits_manually @repo = create(:repo) ManualRunner.any_instance.expects(:run_last).with(100) post(admin_repo_run_path(@repo.name), params: { count: 100 }) end end
Add require of pathname to Rugged::Diff::Delta
module Rugged class Diff class Delta def repo diff.tree.repo end def new_file_full_path repo_path = Pathname.new(repo.path).parent repo_path.join(new_file[:path]) end end end end
require 'pathname' module Rugged class Diff class Delta def repo diff.tree.repo end def new_file_full_path repo_path = Pathname.new(repo.path).parent repo_path.join(new_file[:path]) end end end end
Stop the extra full stop appearing in emails:
class Action include Mongoid::Document CREATED, REVIEW_REQUESTED, PUBLISHED, NEW_VERSION, OKAYED, REVIEWED = "created", "review_requested", "published", "new_version", "okayed", "reviewed" embedded_in :edition field :requester_id, :type => Integer field :approver_id, :type => Integer field :a...
class Action include Mongoid::Document CREATED, REVIEW_REQUESTED, PUBLISHED, NEW_VERSION, OKAYED, REVIEWED = "created", "review_requested", "published", "new_version", "okayed", "reviewed" embedded_in :edition field :requester_id, :type => Integer field :approver_id, :type => Integer field :a...
Switch to using rake to determine gemspec files - git ls-files not well-supported on windows.
require File.expand_path('lib/rhubarb/version', File.dirname(__FILE__)) Gem::Specification.new do |s| s.name = %q{rhubarb} s.version = Rhubarb::Version::STRING s.authors = ["Dan Swain"] s.date = Time.now.utc.strftime("%Y-%m-%d") s.email = %q{dan.t.swain@gmail.com} s.files = `git ls-files`.split("\n") s.h...
require File.expand_path('lib/rhubarb/version', File.dirname(__FILE__)) require 'rake' Gem::Specification.new do |s| s.name = %q{rhubarb} s.version = Rhubarb::Version::STRING s.authors = ["Dan Swain"] s.date = Time.now.utc.strftime("%Y-%m-%d") s.email = %q{dan.t.swain@gmail.com} s.files = FileList['lib/**/...
Fix test failure due to test interference
require 'test_helper' class AuthenticationTest < ActionDispatch::IntegrationTest setup do ENV['GDS_SSO_MOCK_INVALID'] = '1' end test "should use GDS SSO to authenticate" do get admin_people_path assert_redirected_to "/auth/gds" end test "should allow access when already logged in" do login...
require 'test_helper' class AuthenticationTest < ActionDispatch::IntegrationTest setup do User.delete_all ENV['GDS_SSO_MOCK_INVALID'] = '1' end test "should use GDS SSO to authenticate" do get admin_people_path assert_redirected_to "/auth/gds" end test "should allow access when already log...
Add Kensington TrackballWorks for Mac 1.1.2
class KensingtonTrackballWorks < Cask version '1.1.2' sha256 '02e3fed2fe01c234206d3fcf2c85f71f10aa2a3bc3d3dd6f4694ac41b725e3df' url 'http://accoblobstorageus.blob.core.windows.net/software/38c5e777-b2ef-4434-8091-6290cb41fc16.dmg' homepage 'http://www.kensington.com/' install 'Kensington TrackballWorks.pkg'...
Change gemspec info and add dependencies.
# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "admin_view/version" Gem::Specification.new do |s| s.name = "admin_view" s.version = AdminView::VERSION s.platform = Gem::Platform::RUBY s.authors = ["RT"] s.email = ["devs@"] s.homepage = "" s.summa...
# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "admin_view/version" Gem::Specification.new do |s| s.name = "admin_view" s.version = AdminView::VERSION s.platform = Gem::Platform::RUBY s.authors = ["Marko Anastasov", "Darko Fabijan"] s.email = ["devs@ren...
Add index to make statistic compilation scalable
class Repository include Mongoid::Document validates_presence_of :url, :type, :name embeds_many :snapshots, :order => :date.asc field :url field :type field :name field :latitude field :longitude index({ 'snapshots.date' => 1 }) ## # Returns a list of records sorted in descending by the score...
class Repository include Mongoid::Document validates_presence_of :url, :type, :name embeds_many :snapshots, :order => :date.asc field :url field :type field :name field :latitude field :longitude index({ 'snapshots.date' => 1 }) index({ 'snapshot.statistics.resources' => 1 }) ## # Returns a...
Debug - Fix spelling mistake
require 'rapgenius' class Lyric include Cinch::Plugin match /(lyric) (.+)/, prefix: /^(\.)/ match /(help lyric)$/, method: :help, prefix: /^(\.)/ def execute(m, command, lyric, keywords) RapGenius::Client.access_token = "#{ENV['RAPGENIUS']}" return m.reply 'no song found :(' if RapGenius.search_by_ly...
require 'rapgenius' class Lyric include Cinch::Plugin match /(lyric) (.+)/, prefix: /^(\.)/ match /(help lyric)$/, method: :help, prefix: /^(\.)/ def execute(m, command, lyric, keywords) RapGenius::Client.access_token = "#{ENV['RAPGENIUS']}" return m.reply 'no song found :(' if RapGenius.search_by_ly...
Disable gem log runner unless production
module NapaReserve class Initializer def self.run Napa::Logger.logger.info NapaReserve::GemDependency.log_all end end end
module NapaReserve class Initializer def self.run Napa::Logger.logger.info NapaReserve::GemDependency.log_all if Napa.env.production? end end end
Define a default configuration loader and add a method to load the configuration
require 'configuration/yaml' class TmuxPowerline def initialize(configuration_loader) if configuration_loader.nil? raise ArgumentError, "The configuration loader can't be nil" end @configuration_loader = configuration_loader end end
require 'configuration/yaml' class TmuxPowerline def initialize(configuration_loader=Configuration::Yaml.new) if configuration_loader.nil? raise ArgumentError, "The configuration loader can't be nil" end @configuration_loader = configuration_loader end def load_config(config) @configuratio...
Allow single strings for operations.
module Swagger class Api def initialize path, opts defaults = { :path => path, :operations => []} @values = defaults.merge opts end def path @values[:path] end def operations http_methods, opts = {} operations = http_methods.map { |m| Operation.new self, ...
module Swagger class Api def initialize path, opts defaults = { :path => path, :operations => []} @values = defaults.merge opts end def path @values[:path] end def operations http_methods, opts = {} operations = Array(http_methods).map { |m| Operation.new...
Use full name, prevents empty list items
ActiveAdmin.register Venue do menu parent: "Kalender" index do column :id column :location column :street column :zipcode column :city column :country default_actions end show do h3 venue.location div do simple_format venue.street simple_format venue.zipco...
ActiveAdmin.register Venue do menu parent: "Kalender" index do column :id column :location column :street column :zipcode column :city column :country default_actions end show do h3 venue.location div do simple_format venue.street simple_format venue.zipco...
Add in a refactored version of let it be
# Lesson 6 - Gospel Song Chord Progression # Let It Be - Refactor use_synth :piano define :gospel_chord do |pitch, pitch_scale = :major| play pitch 2.times do play chord(pitch.succ, pitch_scale) sleep 0.5 end end [:C3, :G3, [:A3, :minor], :F3, :C3, :G3].each do |pitch| gospel_chord(*pitch) end play :...
Refactor rake task a little
namespace :datagrid do def copy_template(path) gem_app = File.expand_path("../../../app", __FILE__) rails_app = (Rails.root + "app").to_s puts "* copy (#{path})" sh "mkdir -p #{rails_app}/#{File.dirname path}" cp "#{gem_app}/#{path}", "#{rails_app}/#{path}" end desc "Copy table partials in...
namespace :datagrid do desc "Copy table partials into rails application" task :copy_partials do def copy_template(path) gem_app = File.expand_path("../../../app", __FILE__) rails_app = (Rails.root + "app").to_s puts "* copy (#{path})" sh "mkdir -p #{rails_app}/#{File.dirname path}" ...
Remove regexps de Token. Elas devem estar em cli.rb
module Relex class Token attr_reader :palavras_reservadas, :delimitadores, :operadores_aritmeticos, :identificadores, :strings_numericas, :comando_atribuicao, :operador_relacional def initialize(valor, classificacao) self.palavras_reservadas = /program|var|begin|end|integer|if|then|else/ self.del...
module Relex class Token def initialize(valor, classificacao) @valor = valor @classificacao = classificacao end def to_s "#{@valor} #{@classificao}" end end end
Test if logic on timezone.
# Cookbook Name:: rs_utils # Recipe:: setup_timezone # # Copyright (c) 2011 RightScale Inc # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitatio...
# Cookbook Name:: rs_utils # Recipe:: setup_timezone # # Copyright (c) 2011 RightScale Inc # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitatio...
Update Mini Metro to Alpha 12a
class MiniMetro < Cask url 'http://static.dinopoloclub.com/minimetro/builds/alpha12/MiniMetro-alpha12-osx.zip' homepage 'http://dinopoloclub.com/minimetro/' version 'Alpha 12' sha256 '0c81781fff8984f41276fe2c9c0a1da7bdfd18c8970fbe4b8c4ff2376936e7bd' link 'MiniMetro-alpha12-osx.app', :target => 'Mini Metro.app...
class MiniMetro < Cask url 'http://static.dinopoloclub.com/minimetro/builds/alpha12/MiniMetro-alpha12a-osx.zip' homepage 'http://dinopoloclub.com/minimetro/' version 'Alpha 12a' sha256 'cbbf5e60c39bb4d850e65703e220d41a0410212fc6f87d997abe36dc2d7658f9' link 'MiniMetro-alpha12a-osx.app', :target => 'Mini Metro....
Update fake Intervention to look like ATP w/ number of hours
class FakeIntervention def initialize(student) @student = student @start_date = Date.new( (2010..2015).to_a.sample, (1..12).to_a.sample, (1..28).to_a.sample ) @educator = Educator.first_or_create! @intervention_type = InterventionType.all.sample end def next { sta...
class FakeIntervention def initialize(student) @student = student @start_date = Date.new( (2010..2015).to_a.sample, (1..12).to_a.sample, (1..28).to_a.sample ) @educator = Educator.first_or_create! @intervention_type = InterventionType.atp end def next { start_date...
Update posspec version to 0.50
Pod::Spec.new do |s| s.name = "NTAnalytics" s.version = "0.15" s.summary = "NTAnalytics - A Provider-based system to integrate Analytics systems such at Flurry or Google Analytics" s.homepage = "https://github.com/NagelTech/NTAnalytics" s.license = { :type => 'MIT', :file => 'licens...
Pod::Spec.new do |s| s.name = "NTAnalytics" s.version = "0.50" s.summary = "NTAnalytics - A Provider-based system to integrate Analytics systems such at Flurry or Google Analytics" s.homepage = "https://github.com/NagelTech/NTAnalytics" s.license = { :type => 'MIT', :file => 'licens...
Add cmake to build server
%w{ant ant-contrib autoconf autopoint bison libtool libssl1.0.0 libssl-dev maven javacc python git-core mercurial subversion bzr git-svn make perlmagick pkg-config zip ruby rubygems librmagick-ruby}.each do |pkg| package pkg do action :install end end
%w{ant ant-contrib autoconf autopoint bison cmake libtool libssl1.0.0 libssl-dev maven javacc python git-core mercurial subversion bzr git-svn make perlmagick pkg-config zip ruby rubygems librmagick-ruby}.each do |pkg| package pkg do action :install end end
Make repo attr_reader on Grit::Diff
module Grit class Diff def hunks header_lines.each_with_index .map { |header, index| next_header = header_lines[index + 1] next_line_number = next_header ? next_header[1] : lines.count DiffHunk.new(header[0], lines[header[1], next_line_number - 1]) } end ...
module Grit class Diff attr_reader :repo def hunks header_lines.each_with_index .map { |header, index| next_header = header_lines[index + 1] next_line_number = next_header ? next_header[1] : lines.count DiffHunk.new(header[0], lines[header[1], next_line_number ...
Use push helpers to format Talker messages
class Service::Talker < Service string :url, :token boolean :digest def receive_push repository = payload['repository']['name'] branch = branch_name commits = payload['commits'] token = data['token'] http.ssl[:verify] = false http.headers["X-Talker-Token"] = token http.u...
class Service::Talker < Service string :url, :token boolean :digest def receive_push repository = payload['repository']['name'] branch = branch_name commits = payload['commits'] token = data['token'] http.ssl[:verify] = false http.headers["X-Talker-Token"] = token http.u...
Add test for lexical variables.
require "ikra" require_relative "unit_test_template" class LexicalVariableTest < UnitTestCase def test_simple_lexical_variable_int var1 = 10 base_array = Array.pnew(100) do |j| var1 end assert_equal(1000, base_array.reduce(:+)) end def test_simple_lexical_vari...
Remove reference to @path_enabled. Let's make things less efficient!
module Pacer::Pipes class ExpandablePipe < RubyPipe def initialize super() @queue = java.util.LinkedList.new end def add(element, metadata = nil, path = nil) @queue.add [element, metadata, path] end def metadata @metadata end def next super rescue Nativ...
module Pacer::Pipes class ExpandablePipe < RubyPipe def initialize super() @queue = java.util.LinkedList.new end def add(element, metadata = nil, path = nil) @queue.add [element, metadata, path] end def metadata @metadata end def next super rescue Nativ...
Add a user agent parser for iTunes
class UserAgent module Browsers # The user agent for iTunes # # Some user agents: # iTunes/10.6.1 (Macintosh; Intel Mac OS X 10.7.3) AppleWebKit/534.53.11 # iTunes/12.0.1 (Macintosh; OS X 10.10) AppleWebKit/0600.1.25 # iTunes/11.1.5 (Windows; Microsoft Windows 7 x64 Business Edition Service P...
Comment /signout route back in
Rails.application.routes.draw do resources :users resources :conversations # match '/auth/:provider/callback', :via => [:get], :to => 'sessions#create' match '/auth/failure', :via => [:get], :to => 'sessions#failure' get '/auth/:provider/callback' => 'sessions#create' get '/signin' => 'sessions#new', :as ...
Rails.application.routes.draw do resources :users resources :conversations # match '/auth/:provider/callback', :via => [:get], :to => 'sessions#create' match '/auth/failure', :via => [:get], :to => 'sessions#failure' get '/auth/:provider/callback' => 'sessions#create' get '/signin' => 'sessions#new', :as ...
Clean up MacOS version method usage
require 'formula' class Abyss < Formula homepage 'http://www.bcgsc.ca/platform/bioinfo/software/abyss' url 'http://www.bcgsc.ca/downloads/abyss/abyss-1.3.4.tar.gz' sha1 '763dc423054421829011844ceaa5e18dc43f1ca9' head 'https://github.com/sjackman/abyss.git' # Only header files are used from these packages, s...
require 'formula' class Abyss < Formula homepage 'http://www.bcgsc.ca/platform/bioinfo/software/abyss' url 'http://www.bcgsc.ca/downloads/abyss/abyss-1.3.4.tar.gz' sha1 '763dc423054421829011844ceaa5e18dc43f1ca9' head 'https://github.com/sjackman/abyss.git' # Only header files are used from these packages, s...
Convert project name integration test to RSpec
require 'spec_helper' require './features/step_definitions/testing_dsl' describe "Project name" do # As a developer # I want to assign a name for my project # So that the reports show it let(:user) { LicenseFinder::TestingDSL::User.new } before { user.create_empty_project } specify "appears in the HTML ...
Remove restriction on json version
require './lib/diplomat/version' Gem::Specification.new "diplomat", Diplomat::VERSION do |spec| spec.authors = ["John Hamelink"] spec.email = ["john@johnhamelink.com"] spec.description = spec.summary = "Diplomat is a simple wrapper for Consul" spec.homepage = "https://github.com/johnhameli...
require './lib/diplomat/version' Gem::Specification.new "diplomat", Diplomat::VERSION do |spec| spec.authors = ["John Hamelink"] spec.email = ["john@johnhamelink.com"] spec.description = spec.summary = "Diplomat is a simple wrapper for Consul" spec.homepage = "https://github.com/johnhameli...
Add dragonfly image upload/view/removal feature test
require 'spec_helper' feature "Dragonfly integration", js: true do background do auth_as_admin end scenario "Upload, view and remove image" do visit new_admin_book_path fill_in "Title", with: "xx" attach_file "resource_cover_image", File.expand_path('../fixtures/cs.png', __dir__) click_button...
Update the SlugMigration for the tech code of practise
desc "This is a one off task to redirect tech code of practise" task redirect_tech_code_of_practise: :environment do old_paths = [ "/service-manual/technology/code-of-practice.html", "/service-manual/technology/code-of-practice", ] new_path = "/government/publications/technology-code-of-practice/technolog...
desc "This is a one off task to redirect tech code of practise" task redirect_tech_code_of_practise: :environment do old_paths = [ "/service-manual/technology/code-of-practice.html", "/service-manual/technology/code-of-practice", ] new_path = "/government/publications/technology-code-of-practice/technolog...
Delete uneccessary creation of a UserInvite in the test
require 'test_helper' class UserInviteTest < ActiveSupport::TestCase def setup # create a mailer here and use it to call private functions @user_invite = UserInvite.create!( email: users(:user_two).email, team: teams(:team_one) ) end test "send email" do assert_difference 'ActionMai...
require 'test_helper' class UserInviteTest < ActiveSupport::TestCase test "send email" do assert_difference 'ActionMailer::Base.deliveries.size', +1 do user_invites(:invite_one).send(:send_email) end email = ActionMailer::Base.deliveries.last assert_equal "MITRE CTF: Invite to join team #{teams...
Remove signal handlers. Let the OS kill EM
require 'eventmachine' module Combi class Reactor def self.start(&block) EM::error_handler do |error| STDERR << "ERROR IN EM\n" STDERR << "\t#{error.inspect}" STDERR << "\t#{error.backtrace.join("\t\n")}" << "\n" end log "-EM.start- the reactor is running: #{EM::reactor_...
require 'eventmachine' module Combi class Reactor def self.start(&block) EM::error_handler do |error| STDERR << "ERROR IN EM\n" STDERR << "\t#{error.inspect}" STDERR << "\t#{error.backtrace.join("\t\n")}" << "\n" end log "-EM.start- the reactor is running: #{EM::reactor_...
Add author and bump up version
Gem::Specification.new do |spec| spec.name = "lita-weather" spec.version = "0.1.0" spec.authors = ["Gou Furuya"] spec.email = ["innocent.zero@gmail.com"] spec.description = "Respond weather infromation" spec.summary = "Respond weather infromation" spec.homepage = ...
Gem::Specification.new do |spec| spec.name = "lita-weather" spec.version = "0.1.1" spec.authors = ["Gou Furuya", "darkcat666"] spec.email = ["innocent.zero@gmail.com", "holycat666@gmail.com"] spec.description = "Respond weather infromation" spec.summary = "Respond weathe...
Add Appledoc 2.2 (build 961).
require 'formula' # 2.2 (build 961) introduces support for documenting enumerated and # bitmask types, and will emit warnings on encountering undocumented # instances of those types. An archived release is provided as a stable # dependency for e.g. continuous integration environments. class Appledoc22 < Formula hom...
Create directories in HDFS as superuser, which already belongs to certs group and has the correct permissions to use the certificates
libpath = File.expand_path '../../../kagent/libraries', __FILE__ begin master_ip = private_recipe_ip("hops","nn") rescue master_ip = private_recipe_ip("hops","nn") end remote_file "#{Chef::Config.file_cache_path}/apache.txt" do source "https://www.apache.org/licenses/LICENSE-2.0.txt" end hops_hdfs_directory "...
libpath = File.expand_path '../../../kagent/libraries', __FILE__ begin master_ip = private_recipe_ip("hops","nn") rescue master_ip = private_recipe_ip("hops","nn") end remote_file "#{Chef::Config.file_cache_path}/apache.txt" do source "https://www.apache.org/licenses/LICENSE-2.0.txt" end hops_hdfs_directory "...
Fix skip_authorization_check gone missing for switch_circle.
class User::AccountsController < ApplicationController before_action :ensure_logged_in before_action :ensure_circle before_action { load_user_instance } layout 'internal' def change_password authorize! :edit, @user, current_circle end def update_password authorize! :edit, @user, current_circle...
class User::AccountsController < ApplicationController skip_authorization_check, only: :switch_circle before_action :ensure_logged_in before_action :ensure_circle before_action { load_user_instance } layout 'internal' def change_password authorize! :edit, @user, current_circle end def update_pa...
Update the test for recoveries
require 'spec_helper' feature "Resetting your password" do scenario "with a valid passowrd" do user = FactoryGirl.create(:user) recovery = FactoryGirl.create(:recovery, user: user, email_or_username: [user.email, user.username].sample) visit recovery_url(user.recovery_key) expect(page).to_not have_l...
require 'spec_helper' feature "Resetting your password" do scenario "with a valid passowrd" do user = FactoryGirl.create(:user) recovery = FactoryGirl.create(:recovery, user: user, email_or_username: [user.email, user.username].sample) visit recovery_url(user.recovery_key) #expect(page).to_not have_...
Fix candidates || candidates used to transaction
# frozen_string_literal: true module RubyRabbitmqJanus module Tools module Replaces # Format message request with good data to HASH format # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv> class Handle < Session private # Replace classic elements def replace_element_...
# frozen_string_literal: true module RubyRabbitmqJanus module Tools module Replaces # Format message request with good data to HASH format # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv> class Handle < Session private # Replace classic elements def replace_element_...
Add code wars (8) - leonardo dicaprio
# http://www.codewars.com/kata/56d49587df52101de70011e4 # --- iteration 1 --- def leo(oscar) return "Leo got one already!" if oscar > 88 case oscar when 88 then "Leo finally won the oscar! Leo is happy" when 86 then "Not even for Wolf of wallstreet?!" else "When will you give Leo an Oscar?" end end
Change session validity to 1 month
# Be sure to restart your server when you modify this file. Rails.application.config.session_store :cookie_store, key: '_code_ocean_session'
# Be sure to restart your server when you modify this file. Rails.application.config.session_store :cookie_store, key: '_code_ocean_session', expire_after: 1.month
Support socket path when initializing dogstatsd
module Datadog class Notifications class Config attr_accessor :hostname, :namespace, :tags, :statsd_host, :statsd_port, :reporter, :plugins def initialize @hostname = ENV['INSTRUMENTATION_HOSTNAME'] || Socket.gethostname @statsd_host = ENV['STATSD_HOST'] || ::Datadog::Statsd::DEFAU...
module Datadog class Notifications class Config attr_accessor :hostname, :namespace, :tags, :statsd_host, :statsd_port, :reporter, :plugins, :socket_path def initialize @hostname = ENV['INSTRUMENTATION_HOSTNAME'] || Socket.gethostname @statsd_host = ENV['STATSD_HOST'] || ::Datadog:...
Handle lack of schema gracefully while booting
module ROM # @api private class Registry include Enumerable attr_reader :elements def initialize(elements = {}) @elements = elements end def each(&block) return to_enum unless block elements.each(&block) end def [](name) elements[name] end def respon...
module ROM # @api private class Registry include Enumerable include Equalizer.new(:elements) attr_reader :elements def initialize(elements = {}) @elements = elements end def each(&block) return to_enum unless block elements.each(&block) end def [](name) e...
Remove a case of the doc_values
module ElasticRecord class Index module Mapping def mapping=(custom_mapping) mapping.deep_merge!(custom_mapping) end def update_mapping(index_name = alias_name) connection.json_put "/#{index_name}/#{type}/_mapping", type => mapping end def get_mapping(index_name = a...
module ElasticRecord class Index module Mapping def mapping=(custom_mapping) mapping.deep_merge!(custom_mapping) end def update_mapping(index_name = alias_name) connection.json_put "/#{index_name}/#{type}/_mapping", type => mapping end def get_mapping(index_name = a...
Fix the Rails 6 ActionView::Base instantiation deprecations
# frozen_string_literal: true module WebConsole # A facade that handles template rendering and composition. # # It introduces template helpers to ease the inclusion of scripts only on # Rails error pages. class Template # Lets you customize the default templates folder location. cattr_accessor :templ...
# frozen_string_literal: true module WebConsole # A facade that handles template rendering and composition. # # It introduces template helpers to ease the inclusion of scripts only on # Rails error pages. class Template # Lets you customize the default templates folder location. cattr_accessor :templ...
Convert monkey module to new format
require "yaml" class Bot def monkey_initialize(bot) @monkey = Monkey.new(@base_path, @module_config["monkey_file"]) end def monkey_privmsg(bot, from, reply_to, msg) @monkey.privmsg(bot, from, reply_to, msg) end end class Monkey def initialize(base_path, filename) cfg_file = base_path + "/" + fil...
require "yaml" class Module_Monkey def init_module(bot) filename = bot.module_config["monkey_file"] cfg_file = bot.base_path + "/" + filename puts "Reading monkey config from '#{cfg_file}'" @expressions = YAML.load_file(cfg_file) puts "Read" end def privmsg(bot, from, reply_to, msg) @exp...
Simplify license regex and replace . with _ character
module Licensee module Matchers class DistZilla < Package attr_reader :file LICENSE_REGEX = / ^license\s*=\s*([a-z\-0-9\.]+) /ix private def license_property match = @file.content.match LICENSE_REGEX match[1].downcase if match && match[1] end end ...
module Licensee module Matchers class DistZilla < Package attr_reader :file LICENSE_REGEX = /^license\s*=\s*([a-z\-0-9_]+)/i private def license_property match = @file.content.match LICENSE_REGEX match[1].downcase if match && match[1] end end end end
Remove unused `rank_to_s` from `Placement`
class Placement < ActiveRecord::Base belongs_to :couple belongs_to :event # Returns a string representation of the rank suitable for display to the # user. Present to match the signature of {SubPlacement::rank_to_s} def rank_to_s rank.to_s end end
class Placement < ActiveRecord::Base belongs_to :couple belongs_to :event end
Remove validations from Event model
class Event < ApplicationRecord has_many :shifts, dependent: :destroy validates :volunteers_needed, :starts_at, :ends_at, presence: true validates :shift_length, :address, presence: true end
class Event < ApplicationRecord has_many :shifts, dependent: :destroy validates :shift_length, :address, presence: true end
Make thumbnail a little bigger
module PhotoswipeHelpers def gallery_image_tag(image) size = image_size(image.url) w = size.w h = size.h link = link_to thumbnail(image, w: 200), image.url, 'data-size': "#{w}x#{h}", itemprop: 'contentUrl' #content_tag(:figure, link, itemprop: 'associatedMedia', ...
module PhotoswipeHelpers def gallery_image_tag(image) size = image_size(image.url) w = size.w h = size.h link = link_to thumbnail(image, w: 800), image.url, 'data-size': "#{w}x#{h}", itemprop: 'contentUrl' #content_tag(:figure, link, itemprop: 'associatedMedia', ...
Use a case/when statement in QueryParams.dump.
require 'uri' module URI module QueryParams # # Parses a URI query string. # # @param [String] query_string # The URI query string. # # @return [Hash{String => String}] # The parsed query parameters. # def QueryParams.parse(query_string) query_params = {} if q...
require 'uri' module URI module QueryParams # # Parses a URI query string. # # @param [String] query_string # The URI query string. # # @return [Hash{String => String}] # The parsed query parameters. # def QueryParams.parse(query_string) query_params = {} if q...
Update plugin output pattern to include global context
require "vagrant-spec/acceptance/output" module Vagrant module Spec # Default plugins within plugin list when run mode # is set as "plugin" DEFAULT_PLUGINS = ["vagrant-share".freeze].freeze # Tests the Vagrant plugin list output has no plugins OutputTester[:plugin_list_none] = lambda do |text| ...
require "vagrant-spec/acceptance/output" module Vagrant module Spec # Default plugins within plugin list when run mode # is set as "plugin" DEFAULT_PLUGINS = ["vagrant-share".freeze].freeze # Tests the Vagrant plugin list output has no plugins OutputTester[:plugin_list_none] = lambda do |text| ...
Allow both should and expect for now
require 'rubygems' require 'bundler/setup' require 'chunky_png' module PNGSuite def png_suite_file(kind, file) File.join(png_suite_dir(kind), file) end def png_suite_dir(kind) File.expand_path("./png_suite/#{kind}", File.dirname(__FILE__)) end def png_suite_files(kind, pattern = '*.png') ...
require 'rubygems' require 'bundler/setup' require 'chunky_png' module PNGSuite def png_suite_file(kind, file) File.join(png_suite_dir(kind), file) end def png_suite_dir(kind) File.expand_path("./png_suite/#{kind}", File.dirname(__FILE__)) end def png_suite_files(kind, pattern = '*.png') Dir[F...
Tweak for new dispatch system.
require 'rubygems' require 'spec' require 'set' $: << File.dirname(__FILE__) $: << File.join(File.dirname(__FILE__),'../lib') # Loads uppercut and jabber require 'uppercut' # Unloads jabber, replacing it with a stub require 'jabber_stub' class TestAgent < Uppercut::Agent command 'hi' do |c| c.instance_eval { ...
require 'rubygems' require 'spec' require 'set' $: << File.dirname(__FILE__) $: << File.join(File.dirname(__FILE__),'../lib') # Loads uppercut and jabber require 'uppercut' # Unloads jabber, replacing it with a stub require 'jabber_stub' class TestAgent < Uppercut::Agent command 'hi' do |c,args| c.instance_ev...
Update fabricator to follow fabrication syntax.
Fabricator(:grade) do form :number mark rand(1..10) comment Faker::HTMLIpsum.body user classroom { |attr| Fabricate(:classroom, :owner => attr[:user]) } assignment { |attr| Fabricate( :assignment, :user => attr[:user], :classroom => attr[:classroom]) } receiver { |attr| Fabrica...
Fabricator(:grade) do form :number mark { rand(1..10) } comment Faker::HTMLIpsum.body user classroom { |attr| Fabricate(:classroom, :owner => attr[:user]) } assignment { |attr| Fabricate( :assignment, :user => attr[:user], :classroom => attr[:classroom]) } receiver { |attr| Fab...
Fix load error on heroku
module Remitano class RemiAccounts < Remitano::Collection def me Remitano::Net.get("/remi_accounts/me").execute end end end
require_relative "collection" module Remitano class RemiAccounts < Remitano::Collection def me Remitano::Net.get("/remi_accounts/me").execute end end end
Rename some methods for clarity.
require "simplecov" module SimpleCov::Formatter::CompactJSON def self.new ::CompactJSON::Formatter.new end end module CompactJSON class Formatter attr_reader :result def format(result) @result = result File.open("./coverage/results.json", "w") do |file| file.print(parsed_resu...
require "simplecov" module SimpleCov::Formatter::CompactJSON def self.new ::CompactJSON::Formatter.new end end module CompactJSON class Formatter attr_reader :result def format(result) @result = result File.open("./coverage/results.json", "w") do |file| file.print(formatted_r...
Make redirect go to group page
class TopicsController < ApplicationController before_action :set_topic, only: [:show, :edit, :update, :destroy] def index @topics = Topic.all end def show end def new @topic = Topic.new end def edit end def create @topic = Topic.new(topic_params) respond_to do |format| i...
class TopicsController < ApplicationController before_action :set_topic, only: [:show, :edit, :update, :destroy] def index @topics = Topic.all end def show end def new @topic = Topic.new end def edit end def create @topic = Topic.new(topic_params) respond_to do |format| i...
Fix pending specs under rspec2 runner
require 'rspec/core/formatters/base_text_formatter' module RSpec module Core module Formatters class AugmentedTextFormatter < BaseTextFormatter def initialize(output) super(output) end def self.configure buffet_server, slave_name @@buffet_server = buffet_server ...
require 'rspec/core/formatters/base_text_formatter' module RSpec module Core module Formatters class AugmentedTextFormatter < BaseTextFormatter def initialize(output) super(output) end def self.configure buffet_server, slave_name @@buffet_server = buffet_server ...
Add comment explaining regex intent
class RootController < ApplicationController before_filter :validate_template_param rescue_from ActionView::MissingTemplate, :with => :error_404 caches_page :template, :raw_template def raw_template file_path = Rails.root.join("app", "views", "root", "#{params[:template]}.raw.html.erb") error_404 an...
class RootController < ApplicationController before_filter :validate_template_param rescue_from ActionView::MissingTemplate, :with => :error_404 caches_page :template, :raw_template def raw_template file_path = Rails.root.join("app", "views", "root", "#{params[:template]}.raw.html.erb") error_404 an...
Add test to show we can get schedules for a single day
require 'test_helper' class ActivitiesControllerTest < ActionController::TestCase test "creating an activity" do assert_difference('Activity.count') do post :create, activity: {name: "Surfing"} end assert assigns(:activity) end test "creating an activity without name must fail" do assert_...
require 'test_helper' class ActivitiesControllerTest < ActionController::TestCase test "creating an activity" do assert_difference('Activity.count') do post :create, activity: {name: "Surfing"} end assert assigns(:activity) end test "creating an activity without name must fail" do assert_...
Raise original coercion error if known.
module Domain module CoercionMethods def coercions(&bl) @coercions ||= ::Myrrha::Coercions.new{|c| c.main_target_domain = self} @coercions.append(&bl) if bl @coercions end def coerce(arg) coercions.coerce(arg, self) rescue Myrrha::Error => ex domain_error!(arg) end ...
module Domain module CoercionMethods def coercions(&bl) @coercions ||= ::Myrrha::Coercions.new{|c| c.main_target_domain = self} @coercions.append(&bl) if bl @coercions end def coerce(arg) coercions.coerce(arg, self) rescue Myrrha::Error => ex raise ex.cause if ex.cause ...
Fix missing dependency on ruby 1.9.2
# -*- encoding: utf-8 -*- lib = File.expand_path('../lib/', __FILE__) $:.unshift lib unless $:.include?(lib) require "spambust/version" Gem::Specification.new do |s| s.name = "spambust" s.version = Spambust::VERSION s.authors = ["Chirantan Mitra"] s.email...
# -*- encoding: utf-8 -*- lib = File.expand_path('../lib/', __FILE__) $:.unshift lib unless $:.include?(lib) require "spambust/version" Gem::Specification.new do |s| s.name = "spambust" s.version = Spambust::VERSION s.authors = ["Chirantan Mitra"] s.email...
Exit with failure code for any error
require 'thor' module Vim module Flavor class CLI < Thor def self.common_options_to_deploy method_option :vimfiles_path, :desc => 'Where to install Vim plugins.', :banner => 'DIR' end desc 'install', 'Install Vim plugins according to VimFlavor file.' common_op...
require 'thor' module Vim module Flavor class CLI < Thor def self.common_options_to_deploy method_option :vimfiles_path, :desc => 'Where to install Vim plugins.', :banner => 'DIR' end desc 'install', 'Install Vim plugins according to VimFlavor file.' common_op...
Update Window to use pixel dimensions
class Window < Gosu::Window include Poke include Dimensions attr_reader :current_map, :controls attr_accessor :paused def initialize @width = WIDTH * GRID @height = HEIGHT * GRID super(@width, @height, false) self.caption = 'Poke' @paused = false @player = User.new(self, ...
class Window < Gosu::Window include Poke include Dimensions attr_reader :current_map, :controls attr_accessor :paused def initialize @width = WIDTH @height = HEIGHT super(@width, @height, false) self.caption = 'Poke' @paused = false @player = User.new(self, 416, 288) ...
Edit de profile de user funcionando ok
class Api::Users::ProfileController < Api::ApiController def show @profile = Profile.find_by!( user_id: params[:id].to_i ) @nationality = Nationality.find_by!( profile_id: @profile.id ) @city = City.find_by!( profile_id: @profile.id ) @phone = Phone.find_by!( profile_id: @profile.id ) @jobs ...
class Api::Users::ProfileController < Api::ApiController def show @profile = Profile.find_by!( user_id: params[:id].to_i ) @nationality = Nationality.find_by!( profile_id: @profile.id ) @city = City.find_by!( profile_id: @profile.id ) @phone = Phone.find_by!( profile_id: @profile.id ) @jobs ...
Make debug_ip_address account for the nil case
# encoding : utf-8 module GeoHelper def self.get_ip_address request ip_address = Rails.application.secrets["debug_ip_address"] != "" ? Rails.application.secrets["debug_ip_address"] : request.remote_ip if request.env['HTTP_X_FORWARDED_FOR'] ip_address = request.env['HTTP_X_FORWARDED_FOR'].split(',')[0]...
# encoding : utf-8 module GeoHelper def self.get_ip_address request ip_address = Rails.application.secrets["debug_ip_address"].presence || request.remote_ip if request.env['HTTP_X_FORWARDED_FOR'] ip_address = request.env['HTTP_X_FORWARDED_FOR'].split(',')[0] || ip_address end ip_address end ...
Add spec for product pages translation
RSpec.feature "Translations" do context 'product' do let!(:product) do create(:product, name: 'Antimatter', translations: [ Spree::Product::Translation.new(locale: 'pt-BR', name: 'Antimatéria') ]) end before do ...