diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/app/presenters/announcements_presenter.rb b/app/presenters/announcements_presenter.rb index abc1234..def5678 100644 --- a/app/presenters/announcements_presenter.rb +++ b/app/presenters/announcements_presenter.rb @@ -34,9 +34,13 @@ @announcements ||= Services.cached_search( count: 10, order: "-public_timestamp", - filter_people: slug, + filter_people: slug_without_locale, reject_content_purpose_supergroup: "other", fields: %w[title link content_store_document_type public_timestamp], - )["results"] + )["results"] + end + + def slug_without_locale + slug.split(".").first end end
Support showing announcements for all locales Search API only supports documents written in English so we should remove the locale from the slug when querying for documents.
diff --git a/lib/whatsapp/protocol/nodes/sync_node.rb b/lib/whatsapp/protocol/nodes/sync_node.rb index abc1234..def5678 100644 --- a/lib/whatsapp/protocol/nodes/sync_node.rb +++ b/lib/whatsapp/protocol/nodes/sync_node.rb @@ -27,7 +27,8 @@ private def generate_sid - ((Time.new.to_f + 11644477200) * 10000000).to_i.to_s + #((Time.new.to_f + 11644477200) * 10000000).to_i.to_s + ((Time.new.to_i + 11644477200) * 10000000).to_s end end
Change sid to match the php implementation
diff --git a/rails-dom-testing.gemspec b/rails-dom-testing.gemspec index abc1234..def5678 100644 --- a/rails-dom-testing.gemspec +++ b/rails-dom-testing.gemspec @@ -18,7 +18,7 @@ spec.test_files = Dir["test/**/*"] spec.require_paths = ["lib"] - spec.add_dependency "nokogiri", "~> 1.5.9" + spec.add_dependency "nokogiri", "~> 1.6.0" spec.add_dependency "activesupport" spec.add_development_dependency "bundler", "~> 1.3"
Update Nokogiri version to 1.6.0.
diff --git a/spec/lib/task_helpers/exports/alerts_spec.rb b/spec/lib/task_helpers/exports/alerts_spec.rb index abc1234..def5678 100644 --- a/spec/lib/task_helpers/exports/alerts_spec.rb +++ b/spec/lib/task_helpers/exports/alerts_spec.rb @@ -1,21 +1,43 @@-describe 'TaskHelpers::Exports::Alerts' do - let(:data_dir) { File.join(File.expand_path(__dir__), '..', 'imports', 'data', 'alerts') } - let(:alert) { 'Alert_Import_Test.yaml' } +describe TaskHelpers::Exports::Alerts do + let(:guid) { "8f0d49a0-22b0-0135-5de8-54ee7549b627" } + + let(:alert_export_attrs) do + [ + { + "MiqAlert" => { + "guid" => "8f0d49a0-22b0-0135-5de8-54ee7549b627", + "description" => "Alert Export Test", + "options" => nil, + "db" => nil, + "expression" => nil, + "responds_to_events" => nil, + "enabled" => true, + "read_only" => nil + } + } + ] + end + + let(:alert_create_attrs) do + { + :description => "Alert Export Test", + :guid => guid, + :enabled => true + } + end before(:each) do + FactoryGirl.create(:miq_alert, alert_create_attrs) @export_dir = Dir.mktmpdir('miq_exp_dir') end after(:each) do - FileUtils.remove_entry @export_dir + FileUtils.remove_entry(@export_dir) end it 'should export alerts to a given directory' do - options = { :source => "#{data_dir}/#{alert}" } - TaskHelpers::Imports::Alerts.new.import(options) - - options = { :directory => @export_dir } - TaskHelpers::Exports::Alerts.new.export(options) - expect((Dir.entries(@export_dir) - %w(. ..))).not_to be_empty + TaskHelpers::Exports::Alerts.new.export(:directory => @export_dir) + file_contents = File.read("#{@export_dir}/Alert_Export_Test.yaml") + expect(YAML.safe_load(file_contents)).to eq(alert_export_attrs) end end
Use FactoryGirl to create alerts to test exports
diff --git a/libraries/docker_installation_tarball.rb b/libraries/docker_installation_tarball.rb index abc1234..def5678 100644 --- a/libraries/docker_installation_tarball.rb +++ b/libraries/docker_installation_tarball.rb @@ -20,6 +20,8 @@ ######### action :create do + package 'tar' + # Pull a precompiled binary off the network remote_file docker_tarball do source new_resource.source
Make sure tar is installed to decompress the tarball It won't always be there on RHEL Signed-off-by: Tim Smith <764ef62106582a09ed09dfa0b6bff7c05fd7d1e4@chef.io>
diff --git a/filmbuff.gemspec b/filmbuff.gemspec index abc1234..def5678 100644 --- a/filmbuff.gemspec +++ b/filmbuff.gemspec @@ -1,25 +1,27 @@ # -*- encoding: utf-8 -*- -$:.push File.expand_path("../lib", __FILE__) -require "filmbuff/version" +$:.push File.expand_path('../lib', __FILE__) +require 'filmbuff/version' Gem::Specification.new do |s| - s.name = "filmbuff" + s.name = 'filmbuff' s.version = FilmBuff::VERSION s.platform = Gem::Platform::RUBY - s.authors = ["Kristoffer Sachse"] - s.email = ["hello@kristoffer.is"] - s.homepage = "https://github.com/sachse/filmbuff" - s.summary = %q{A Ruby wrapper for IMDb's JSON API} - s.description = %q{Film Buff provides a Ruby wrapper for IMDb's JSON API, which is the fastest and easiest way to get information from IMDb.} + s.authors = ['Kristoffer Sachse'] + s.email = ['hello@kristoffer.is'] + s.homepage = 'https://github.com/sachse/filmbuff' + s.summary = 'A Ruby wrapper for IMDb\'s JSON API' + s.description = 'Film Buff provides a Ruby wrapper for IMDb\'s JSON API, ' << + 'which is the fastest and easiest way to get information ' << + 'from IMDb.' - s.rubyforge_project = "filmbuff" + s.rubyforge_project = 'filmbuff' - s.add_dependency("httparty", "~> 0.8.3") - s.add_dependency("httparty-icebox", "~> 0.0.4") + s.add_dependency('httparty', '~> 0.8.3') + s.add_dependency('httparty-icebox', '~> 0.0.4') - s.add_development_dependency("minitest", "~> 3.2.0") + s.add_development_dependency('minitest', '~> 3.2.0') s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- {test}/*`.split("\n") - s.require_paths = ["lib"] + s.require_paths = ['lib'] end
Change double quotes to single quotes
diff --git a/engines/standard_tasks/spec/features/reviewer_report_task_spec.rb b/engines/standard_tasks/spec/features/reviewer_report_task_spec.rb index abc1234..def5678 100644 --- a/engines/standard_tasks/spec/features/reviewer_report_task_spec.rb +++ b/engines/standard_tasks/spec/features/reviewer_report_task_spec.rb @@ -2,25 +2,21 @@ feature "Reviewer Report", js: true do let(:journal) { FactoryGirl.create :journal } - let!(:reviewer) { FactoryGirl.create :user } - - let!(:paper) do - FactoryGirl.create(:paper, :with_tasks, user: reviewer, journal: journal, submitted: true) - end + let(:paper) { FactoryGirl.create(:paper) } + let(:task) { FactoryGirl.create(:reviewer_report_task, paper: paper) } before do - assign_journal_role(journal, reviewer, :reviewer) - paper_reviewer_task = paper.phases.where(name: 'Assign Reviewers').first.tasks.where(type: 'StandardTasks::PaperReviewerTask').first - paper_reviewer_task.reviewer_ids = [reviewer.id.to_s] + paper.paper_roles.create!(user: reviewer, role: PaperRole::COLLABORATOR) + task.participants << reviewer sign_in_page = SignInPage.visit sign_in_page.sign_in reviewer end scenario "Reviewer can write a reviewer report" do dashboard_page = DashboardPage.new - manuscript_page = dashboard_page.view_submitted_paper paper - manuscript_page.view_card 'Reviewer Report' do |overlay| + manuscript_page = dashboard_page.view_submitted_paper(paper) + manuscript_page.view_card(task.title) do |overlay| overlay.mark_as_complete expect(overlay).to be_completed end
Simplify reviewer report task spec
diff --git a/breezy_rails/lib/tasks/install.rake b/breezy_rails/lib/tasks/install.rake index abc1234..def5678 100644 --- a/breezy_rails/lib/tasks/install.rake +++ b/breezy_rails/lib/tasks/install.rake @@ -27,12 +27,6 @@ template = File.expand_path("../install/web.rb", __dir__) exec "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{template}" end - - desc "Install everything needed for breezy mobile" - task 'mobile' => ["breezy:verify_yarn"] do - template = File.expand_path("../install/mobile.rb", __dir__) - exec "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{template}" - end end end
Remove old react native task
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index abc1234..def5678 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -8,7 +8,8 @@ # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. -Rails.application.config.assets.precompile += %w( print.css chosen-sprite.png jquery-ui/* ) +Rails.application.config.assets.precompile += %w( print.css chosen-sprite.png jquery-ui/* +webflow.css.scss normalize.css.scss webflow_stronarm.css.scss ) # Don't initialize Rails environment Rails.application.config.assets.initialize_on_precompile = false
Add new stylesheets to be precompiled
diff --git a/config/software/libsqlite3.rb b/config/software/libsqlite3.rb index abc1234..def5678 100644 --- a/config/software/libsqlite3.rb +++ b/config/software/libsqlite3.rb @@ -1,7 +1,7 @@ name "libsqlite3" default_version "3.7.7.1" -source :git => 'git@github.com:LuaDist/libsqlite3.git' +source :git => 'git://github.com/LuaDist/libsqlite3.git' relative_path 'libsqlite3'
Fix git url for libsqlite
diff --git a/flotilla-rails.gemspec b/flotilla-rails.gemspec index abc1234..def5678 100644 --- a/flotilla-rails.gemspec +++ b/flotilla-rails.gemspec @@ -12,7 +12,7 @@ s.description = s.summary s.authors = ["Hannes Gustafsson", "Joshua Miller", "Mathias Sulser", "Jerry Cheung", "Logan Leger"] - s.files = Dir["{lib,vendor}/**/*"] + ["LICENSE", "README"] + s.files = Dir["{lib,vendor}/**/*"] + ["LICENSE", "README.md"] s.add_dependency "json", Flotilla::Rails::JSON_VERSION s.add_dependency "flot-rails", Flotilla::Rails::FLOT_RAILS_VERSION
Change included file to reflect extension change
diff --git a/lib/example_group_timer/timed_group.rb b/lib/example_group_timer/timed_group.rb index abc1234..def5678 100644 --- a/lib/example_group_timer/timed_group.rb +++ b/lib/example_group_timer/timed_group.rb @@ -26,8 +26,7 @@ def report super puts "<ol>" - examples.sort_by { |o| o.duration }.reverse.each(&:report) - subgroups.sort_by { |o| o.duration }.reverse.each(&:report) + (examples + subgroups).sort_by(&:duration).reverse.each(&:report) puts "</ol>" end end
Sort examples and groups combined
diff --git a/app/channels/handshakes_channel.rb b/app/channels/handshakes_channel.rb index abc1234..def5678 100644 --- a/app/channels/handshakes_channel.rb +++ b/app/channels/handshakes_channel.rb @@ -4,6 +4,6 @@ end def receive(payload) - handshake = Handshakes.create(challenge_id: payload["challenge_id"] user_id: current_user.id) + handshake = Handshakes.create(challenge_id: payload["challenge_id"], user_id: current_user.id) end end
Add comma to handshake channel
diff --git a/app/controllers/cart_controller.rb b/app/controllers/cart_controller.rb index abc1234..def5678 100644 --- a/app/controllers/cart_controller.rb +++ b/app/controllers/cart_controller.rb @@ -11,11 +11,7 @@ order.cap_quantity_at_stock! order.recreate_all_fees! - variant_ids = order.line_items.pluck(:variant_id) - - render json: { error: false, - stock_levels: VariantsStockLevels.new.call(order, variant_ids) }, - status: :ok + render json: { error: false, stock_levels: stock_levels(order) }, status: :ok else render json: { error: cart_service.errors.full_messages.join(",") }, status: :precondition_failed @@ -23,6 +19,13 @@ end private + + def stock_levels(order) + variants_in_cart = order.line_items.pluck(:variant_id) + variants_in_request = raw_params[:variants]&.map(&:first) || [] + + VariantsStockLevels.new.call(order, (variants_in_cart + variants_in_request).uniq) + end def check_authorization session[:access_token] ||= params[:token]
Refactor stock levels check in CartController
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index abc1234..def5678 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -1,6 +1,6 @@ class TagsController < ApplicationController def index - @tags = ActsAsTaggableOn::Tag.all + @tags = ActsAsTaggableOn::Tag.most_used end def search
Sort tags by most used.
diff --git a/spec/helper.rb b/spec/helper.rb index abc1234..def5678 100644 --- a/spec/helper.rb +++ b/spec/helper.rb @@ -17,7 +17,7 @@ LogBuddy.init :logger => Log -connection = Mongo::Connection.new('127.0.0.1', 27017, :logger => Log) +connection = Mongo::MongoClient.new('127.0.0.1', 27017, :logger => Log) DB = connection.db('test') RSpec.configure do |config| @@ -27,15 +27,15 @@ config.run_all_when_everything_filtered = true config.before(:suite) do - DB.collections.map do |collection| - collection.drop_indexes - end + DB.collections.reject { |collection| + collection.name =~ /system\./ + }.map(&:drop_indexes) end config.before(:each) do - DB.collections.map do |collection| - collection.remove - end + DB.collections.reject { |collection| + collection.name =~ /system\./ + }.map(&:remove) end end
Use mongo client and don't attempt to fudge with system collections.
diff --git a/gemspecs/m4dbi.gemspec b/gemspecs/m4dbi.gemspec index abc1234..def5678 100644 --- a/gemspecs/m4dbi.gemspec +++ b/gemspecs/m4dbi.gemspec @@ -16,13 +16,13 @@ #s.platform = Gem::Platform::RUBY s.files = [ - 'README.rdoc', - 'CHANGELOG', - 'LICENCE', + # 'README.rdoc', + # 'CHANGELOG', + # 'LICENCE', *( Dir[ 'lib/**/*.rb', 'spec/**/*.rb' ] ) ] - s.extra_rdoc_files = [ - 'README.rdoc', 'CHANGELOG', 'LICENCE', - ] + # s.extra_rdoc_files = [ + # 'README.rdoc', 'CHANGELOG', 'LICENCE', + # ] s.test_files = Dir.glob( 'spec/*.rb' ) end
Remove doc files from gemspec, since Bundler or Rubygems seems to get confused.
diff --git a/ruby/triangle/triangle.rb b/ruby/triangle/triangle.rb index abc1234..def5678 100644 --- a/ruby/triangle/triangle.rb +++ b/ruby/triangle/triangle.rb @@ -10,19 +10,11 @@ end def equilateral? - true if equialateral - end - - def equialateral return false if invalid_lengths? true if sorted_lengths.uniq.size == 1 end def isosceles? - true if isosceles - end - - def isosceles return false if invalid_lengths? true if sorted_lengths.uniq.size <= 2 end
Remove methods that simply call other methods
diff --git a/features/step_definitions/analyics_steps.rb b/features/step_definitions/analyics_steps.rb index abc1234..def5678 100644 --- a/features/step_definitions/analyics_steps.rb +++ b/features/step_definitions/analyics_steps.rb @@ -4,7 +4,7 @@ expect(page).to have_selector('ul[data-module="track-click"]') document_links = page.all('li.document a') - expect(document_links.count).to be > 0 + expect(document_links.count).to be_positive first_link = document_links.first
Change .to be > 0 to be_positive
diff --git a/features/step_definitions/feedback_steps.rb b/features/step_definitions/feedback_steps.rb index abc1234..def5678 100644 --- a/features/step_definitions/feedback_steps.rb +++ b/features/step_definitions/feedback_steps.rb @@ -1,11 +1,13 @@ Given(/^I visit the feedback tool$/) do - pending # express the regexp above with the code you wish you had + visit feedback.submissions_path end When(/^I leave feedback about savings and account creation$/) do - pending # express the regexp above with the code you wish you had + @feedback ||= 'Thanks for letting us know Your feedback will be viewed by the team.' + page.fill_in 'submission_body', with: @feedback + page.click_button 'Create Submission' end Then(/^I should see a confirmation message$/) do - pending # express the regexp above with the code you wish you had + expect(page).to have_content(@feedback) end
Add cuke test for feedback feature
diff --git a/config/environments/test.rb b/config/environments/test.rb index abc1234..def5678 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -13,7 +13,7 @@ config.eager_load = false # Configure static asset server for tests with Cache-Control for performance. - config.serve_static_assets = true + config.serve_static_files = true config.static_cache_control = "public, max-age=3600" # Show full error reports and disable caching.
Change config since variable name got deprecated
diff --git a/app/controllers/facebooked/api_controller.rb b/app/controllers/facebooked/api_controller.rb index abc1234..def5678 100644 --- a/app/controllers/facebooked/api_controller.rb +++ b/app/controllers/facebooked/api_controller.rb @@ -3,26 +3,32 @@ def albums return render :inline => 'false' unless self.provider.token - response = JSON.parse(self.provider.get('/me/albums', {:fields => 'id,photos,privacy,count,link,name,from'})) - return render :inline => '[]' unless response['data'] + albums = [] + begin + response = JSON.parse(self.provider.get('/me/albums', {:fields => 'id,photos,privacy,count,link,name,from'})) + return render :inline => '[]' unless response['data'] - albums = response['data'].collect do |album| - if album['privacy'] == 'everyone' && album['count'] - { - :id => album['id'], - :name => album['name'], - :link => album['link'], - :count => album['count'], - :picture => album['photos']['data'][0]['source'], - :width => album['photos']['data'][0]['width'], - :height => album['photos']['data'][0]['height'], - :author_name => album['from']['name'], - :author_id => album['from']['id'], - } - else - nil - end - end.compact + albums = response['data'].collect do |album| + if album['privacy'] == 'everyone' && album['count'] + { + :id => album['id'], + :name => album['name'], + :link => album['link'], + :count => album['count'], + :picture => album['photos']['data'][0]['source'], + :width => album['photos']['data'][0]['width'], + :height => album['photos']['data'][0]['height'], + :author_name => album['from']['name'], + :author_id => album['from']['id'], + } + else + nil + end + end.compact + rescue OAuth2::HTTPError + # most likely the token expired + return render :inline => 'false' + end return render :inline => albums.to_json end
Make sure token is valid.
diff --git a/plugins/commands/plugin/gem_helper.rb b/plugins/commands/plugin/gem_helper.rb index abc1234..def5678 100644 --- a/plugins/commands/plugin/gem_helper.rb +++ b/plugins/commands/plugin/gem_helper.rb @@ -26,6 +26,11 @@ # Clear paths so that it reads the new GEM_HOME setting Gem.paths = ENV + # Clear the sources so that installation uses custom sources + old_sources = Gem.sources + Gem.sources = Gem.default_sources + Gem.sources << "http://gems.hashicorp.com" + # Use a silent UI so that we have no output Gem::DefaultUserInteraction.use_ui(Gem::SilentUI.new) do return yield @@ -36,7 +41,8 @@ ENV["GEM_PATH"] = old_gem_path # Reset everything - Gem.paths = ENV + Gem.paths = ENV + Gem.sources = old_sources.to_a end end end
Use the HashiCorp gem source for plugin installs
diff --git a/test/functional/roadmap_controller_test.rb b/test/functional/roadmap_controller_test.rb index abc1234..def5678 100644 --- a/test/functional/roadmap_controller_test.rb +++ b/test/functional/roadmap_controller_test.rb @@ -0,0 +1,15 @@+require "test_helper" + +class RoadmapControllerTest < ActionController::TestCase + context "GET index" do + setup do + content_store_has_random_item(base_path: "/roadmap", schema: "special_route") + end + + should "set the cache expiry headers" do + get :index + + assert_equal "max-age=1800, public", response.headers["Cache-Control"] + end + end +end
Add missing test for Roadmap controller This covers a lot of the allegedly 'unused' i18n keys.
diff --git a/benchmarks.rb b/benchmarks.rb index abc1234..def5678 100644 --- a/benchmarks.rb +++ b/benchmarks.rb @@ -5,7 +5,7 @@ HtmlSource.new( 'overnight', 'Target Overnight Lending Rate', - 'http://www.bankofcanada.ca/rates/daily-digest/', + 'http://bankofcanada.ca/en/rates/digest.html', nil, nil, '//td[text() = "Target for the overnight rate"]' + @@ -14,7 +14,7 @@ HtmlSource.new( 'prime', 'Prime Rate', - 'http://www.bankofcanada.ca/rates/daily-digest/', + 'http://bankofcanada.ca/en/rates/digest.html', nil, nil, '//td[text() = "Prime business rate"]' +
Fix Bank of Canada URLs
diff --git a/src/command.rb b/src/command.rb index abc1234..def5678 100644 --- a/src/command.rb +++ b/src/command.rb @@ -3,6 +3,17 @@ # Class to store user commands class Command + class Token + def initialize value, types=[:unknown] + @value = value + @type = types + end + + def to_s + @value + end + end + def initialize(tokens = []) @tokens = tokens end @@ -36,10 +47,26 @@ str = "move south" end + verb = %w( move ) + direction = %w( move ) + noun = %w( ) + noun += direction + words = str.split("\s") + + words.collect! do |word| + types = [] + + types << :verb if verb.include? word + types << :noun if verb.include? word + types << :direction if verb.include? word + + types = [:unknown] if types.empty? + + Token.new(word, types) + end # split the string on whitespace Command.new words end end -
Use tokens in Command to add extra information to words
diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index abc1234..def5678 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -10,9 +10,7 @@ # Make sure your secret_key_base is kept private # if you're sharing your code publicly. if Rails.env.production? && ENV['SECRET_TOKEN'].blank? - raise 'The SECRET_TOKEN environment variable is not set.\n - To generate it, run "rake secret", then set it on the production server.\n - If you\'re using Heroku, you do this with "heroku config:set SECRET_TOKEN=the_token_you_generated"' + raise 'The SECRET_TOKEN environment variable is not set. To generate it, run "rake secret", then set it on the production server. If you\'re using Heroku, you do this with "heroku config:set SECRET_TOKEN=the_token_you_generated"' end Automidnight::Application.config.secret_key_base = ENV['SECRET_TOKEN'] || '4b1e071e0c6f4774088668dd143b1192d762a23d7b14d27f90e8297d48b8dde273d8172454ad9ce91db20b7fcb3e544be2c3cdc28443d5a3f64f31f31b649a95'
Remove spaces from secret token error message
diff --git a/src/passage.rb b/src/passage.rb index abc1234..def5678 100644 --- a/src/passage.rb +++ b/src/passage.rb @@ -2,6 +2,9 @@ # A passage's condition must return a truthy value, or the passage is # inaccessible. + + #FIXME: some_passage.description + # some_passage.descriptions attr_accessor :option, :destination, :descriptions, :departure_descriptions, :arrival_descriptions,
Add FIXME for poor Passage property/method names
diff --git a/spec/tic_tac_toe_spec.rb b/spec/tic_tac_toe_spec.rb index abc1234..def5678 100644 --- a/spec/tic_tac_toe_spec.rb +++ b/spec/tic_tac_toe_spec.rb @@ -1,10 +1,12 @@ require_relative '../lib/tic_tac_toe.rb' describe TicTacToe do + let(:ttt){TicTacToe.new} + describe '#initialize' do it 'creates a empty board represented by an array of 9 slots' do - ttt = TicTacToe.new - expect(ttt.instance_variable_get(:@board)).to eq([" ", " ", " ", " ", " ", " ", " ", " ", " "]) + expect(ttt.board).to eq([" ", " ", " ", " ", " ", " ", " ", " ", " "]) end end + end
Refactor test to reduce instantitiating a new TicTacToe for each test
diff --git a/handlers/other/graceful-shutdown.rb b/handlers/other/graceful-shutdown.rb index abc1234..def5678 100644 --- a/handlers/other/graceful-shutdown.rb +++ b/handlers/other/graceful-shutdown.rb @@ -0,0 +1,67 @@+#! /usr/bin/env ruby +# +# Graceful Shutdown Handler +# === +# +# DESCRIPTION: +# This handler is responsible for handling graceful shutdown messages. +# Upon receipt of the message a stash entry is created, signifying +# that the client is starting to shutdown. +# +# This stash entry can be used as metadata by keepalive handlers +# to determine if a machine was gracefully shutdown or not. +# +# OUTPUT: +# plain-text +# +# PLATFORMS: +# all +# +# DEPENDENCIES: +# gem: sensu-handler +# +# Requires a Sensu configuration snippet: +# { +# "graceful-shutdown": { +# "expires": 120, +# "keyspace": "graceful-shutdown", +# } +# } +# +# EXAMPLES: +# +# +# NOTES: +# +# LICENSE: +# Copyright 2014 Yieldbot, Inc <devops@yieldbot.com> +# Released under the same terms as Sensu (the MIT license); see LICENSE +# for details. +# + +require 'sensu-handler' +require 'json' + +class GracefulShutdownHandler < Sensu::Handler + + def filter; end + + def handle + # Get the data we need to build the stash + client = @event['client']['name'] + check = @event['check'] + expires = settings['graceful-shutdown']['expires'] + keyspace = settings['graceful-shutdown']['keyspace'] + + body = { + 'path' => "#{keyspace}/#{client}", + 'expire' => expires, + 'content' => check + } + + # Create a stash for the node via the HTTP API + res = api_request(:POST, '/stashes') do |req| + req.body = body.to_json + end + end +end
Add a graceful shutdown handler. This handler creates a stash to be used as metadata to other handlers/processes.
diff --git a/spec/geezeo_spec.rb b/spec/geezeo_spec.rb index abc1234..def5678 100644 --- a/spec/geezeo_spec.rb +++ b/spec/geezeo_spec.rb @@ -5,7 +5,7 @@ @geezeo = Geezeo.client(credentials["api_key"], credentials["user_id"]) end - it "gets a list of accounts" do + it "gets a list of all accounts" do account = @geezeo.accounts.all.first account.id.should_not be_nil @@ -17,3 +17,15 @@ balance.should be_kind_of(Float) end end + +describe "Geezeo transactions" do + before(:each) do + @geezeo = Geezeo.client(credentials["api_key"], credentials["user_id"]) + end + + it "gets a list of all transactions" do + transaction = @geezeo.transactions.all.first + + transaction.id_should_not be_nil + end +end
Add third test 'it gets a list of all transactions'
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,11 +2,10 @@ require "coveralls" Coveralls.wear! -require "active_record" - case ENV["DB"] when "postgres" require "pg" + require "active_record" ActiveRecord::Base.establish_connection( adapter: "postgresql", database: "simple_taggable", @@ -14,12 +13,14 @@ ) when "mysql" require "mysql2" + require "active_record" ActiveRecord::Base.establish_connection( adapter: "mysql2", database: "simple_taggable", username: "root" ) else + require "active_record" ActiveRecord::Base.establish_connection( adapter: "sqlite3", database: ":memory:"
Load database driver before load activerecord
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -14,18 +14,5 @@ config.include DataMapper::Matchers config.include FactoryGirl::Syntax::Methods config.include Rack::Test::Methods - - config.before(:suite) do - DatabaseCleaner.strategy = :transaction - DatabaseCleaner.clean_with(:truncation) - end - - config.before(:each) do - DatabaseCleaner.start - end - - config.after(:each) do - DatabaseCleaner.clean - end end
Remove database cleaner initialization for specs
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -35,7 +35,7 @@ RSpec::Matchers.define :be_well_formed do match do |doc| begin - Nokogiri::XML(doc) { |config| config.strict } + Nokogiri::XML(doc, &:strict) true rescue false
Use unary ampersand for trivial block. Signed-off-by: brian m. carlson <738bdd359be778fee9f0fc4e2934ad72f436ceda@crustytoothpaste.net>
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,4 +1,10 @@ require 'overcommit' + +RSpec.configure do |config| + config.color_enabled = true + config.tty = true + config.formatter = :documentation +end def exit(*args) ; end
Configure rspec for documentation + color This provides nicer output in e.g. jenkins. Change-Id: I422249b7e227c3e2064eaf1ad7186a271ada5597 Reviewed-on: https://gerrit.causes.com/23045 Tested-by: jenkins <d95b56ce41a2e1ac4cecdd398defd7414407cc08@causes.com> Reviewed-by: Shane da Silva <6f6e68d1df92f30cb4b3ce35260ddf94a402f33d@causes.com>
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -23,3 +23,24 @@ PuppetlabsSpec::Files.cleanup end end + +require 'pathname' +dir = Pathname.new(__FILE__).parent +Puppet[:modulepath] = File.join(dir, 'fixtures', 'modules') + +# There's no real need to make this version dependent, but it helps find +# regressions in Puppet +# +# 1. Workaround for issue #16277 where default settings aren't initialised from +# a spec and so the libdir is never initialised (3.0.x) +# 2. Workaround for 2.7.20 that now only loads types for the current node +# environment (#13858) so Puppet[:modulepath] seems to get ignored +# 3. Workaround for 3.5 where context hasn't been configured yet, +# ticket https://tickets.puppetlabs.com/browse/MODULES-823 +# +ver = Gem::Version.new(Puppet.version.split('-').first) +if Gem::Requirement.new("~> 2.7.20") =~ ver || Gem::Requirement.new("~> 3.0.0") =~ ver || Gem::Requirement.new("~> 3.5") =~ ver + puts "augeasproviders: setting Puppet[:libdir] to work around broken type autoloading" + # libdir is only a single dir, so it can only workaround loading of one external module + Puppet[:libdir] = "#{Puppet[:modulepath]}/augeasproviders_core/lib" +end
Use modulesync to manage meta files
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -7,7 +7,7 @@ WebMock.disable_net_connect!(allow: 'codeclimate.com') -CodeClimate::TestReporter.start +CodeClimate::TestReporter.start if RUBY_ENGINE == 'ruby' SimpleCov.start do add_filter '/spec'
Send test coverage to codeclimate only for cruby
diff --git a/lib/cloud_conductor/adapters/abstract_adapter.rb b/lib/cloud_conductor/adapters/abstract_adapter.rb index abc1234..def5678 100644 --- a/lib/cloud_conductor/adapters/abstract_adapter.rb +++ b/lib/cloud_conductor/adapters/abstract_adapter.rb @@ -19,7 +19,7 @@ fail "Can't instantiate abstract adapter" end - def create_stack + def create_stack(name, template, parameters, options = {}) fail 'Unimplement method' end end
Add arguments to abstract method
diff --git a/lib/cocoapods/external_sources/podspec_source.rb b/lib/cocoapods/external_sources/podspec_source.rb index abc1234..def5678 100644 --- a/lib/cocoapods/external_sources/podspec_source.rb +++ b/lib/cocoapods/external_sources/podspec_source.rb @@ -15,7 +15,7 @@ open(podspec_uri) { |io| store_podspec(sandbox, io.read, is_json) } rescue OpenURI::HTTPError => e status = e.io.status.join(' ') - raise Informative, "Failed to fetch podspec for `#{name}` at #{podspec_uri}. Error: #{status}" + raise Informative, "Failed to fetch podspec for `#{name}` at `#{podspec_uri}`.\n Error: #{status}" end end end
[PodspecSource] Update message for informative error if fetch fails
diff --git a/sparkle_formation.gemspec b/sparkle_formation.gemspec index abc1234..def5678 100644 --- a/sparkle_formation.gemspec +++ b/sparkle_formation.gemspec @@ -10,7 +10,7 @@ s.description = 'Ruby DSL for programmatic orchestration API template generation' s.license = 'Apache-2.0' s.require_path = 'lib' - s.add_dependency 'attribute_struct', '~> 0.2.2' + s.add_dependency 'attribute_struct', '>= 0.2.23', '< 0.4' s.add_dependency 'multi_json' s.add_dependency 'bogo' s.add_development_dependency 'minitest'
Update attribute_struct constraint to require traversal fixed version
diff --git a/lib/_grid_one.rb b/lib/_grid_one.rb index abc1234..def5678 100644 --- a/lib/_grid_one.rb +++ b/lib/_grid_one.rb @@ -9,7 +9,8 @@ {'V'=>0, 'g'=>1, '.'=>nil}, 'media/background.png') - @program_1 = Program.new(@window, 416, 160, 'media/grid_one_program_1.txt') + @program_1 = Program.new(@window, 416, 160, + 'media/grid_one_program_1_path.txt') end def update
Update parameter to reflect new filename
diff --git a/lib/crono/job.rb b/lib/crono/job.rb index abc1234..def5678 100644 --- a/lib/crono/job.rb +++ b/lib/crono/job.rb @@ -19,7 +19,10 @@ def perform Crono.logger.info "Perform #{performer}" self.last_performed_at = Time.now - Thread.new { performer.new.perform } + Thread.new do + performer.new.perform + Crono.logger.info "Finished #{performer} in %.2f seconds" % (Time.now - last_performed_at) + end end end end
Add to log information about performing time
diff --git a/lib/discordrb.rb b/lib/discordrb.rb index abc1234..def5678 100644 --- a/lib/discordrb.rb +++ b/lib/discordrb.rb @@ -4,5 +4,13 @@ # All discordrb functionality, to be extended by other files module Discordrb - # Your code goes here... + # Simple Levenshtein distance (slow) + def levenshtein(one, two) + return two.size if one.size == 0 + return one.size if two.size == 0 + + [levenshtein(one.chop, two) + 1, + levenshtein(one, two.chop) + 1, + levenshtein(one.chop, two.chop) + (one[-1, 1] == two[-1, 1] ? 0 : 1)].min + end end
Implement a Levenshtein distance for the fuzzy finder
diff --git a/lib/chelsy/ast.rb b/lib/chelsy/ast.rb index abc1234..def5678 100644 --- a/lib/chelsy/ast.rb +++ b/lib/chelsy/ast.rb @@ -6,6 +6,7 @@ class Element < Node end + # 6.4.4.1 Integer constants module Constant class Integral < Element @@ -13,12 +14,12 @@ def initialize(value, unsigned: false, base: 10) @value = value - @unsigned = unsigned + @unsigned = !!unsigned @base = base end def unsigned? - !!@unsigned + @unsigned end end
Convert boolean value on initialization
diff --git a/lib/sumo_seed.rb b/lib/sumo_seed.rb index abc1234..def5678 100644 --- a/lib/sumo_seed.rb +++ b/lib/sumo_seed.rb @@ -6,7 +6,10 @@ end def self.run_task - seed_path = [Rails.root, ENV['seed_path'].split('/')].flatten || self.seed_path + seed_path = ENV['seed_path'] ? + [Rails.root, ENV['seed_path'].split('/')].flatten : + self.seed_path + model_collection = ENV['model'] || '*' models_collection = ENV['models'] ? ENV['models'].split(',') : [model_collection] upsert = ENV['upsert'] == '1'
:bug: Fix accessing nil seed path env variable
diff --git a/lib/app/controllers/nodefiles_controller.rb b/lib/app/controllers/nodefiles_controller.rb index abc1234..def5678 100644 --- a/lib/app/controllers/nodefiles_controller.rb +++ b/lib/app/controllers/nodefiles_controller.rb @@ -1,6 +1,6 @@ class NodefilesController < InheritedResources::Base - self.append_view_path("vendor/plugins/nodefiles/lib/app/views") + self.append_view_path(File.join(RAILS_ROOT, "vendor/plugins/nodefiles/lib/app/views")) def nodefiles @node = Node.find(params[:node_id])
Fix views path for production
diff --git a/lib/joker-api/operations/result_retrieve.rb b/lib/joker-api/operations/result_retrieve.rb index abc1234..def5678 100644 --- a/lib/joker-api/operations/result_retrieve.rb +++ b/lib/joker-api/operations/result_retrieve.rb @@ -6,9 +6,9 @@ proc_id = proc_id.proc_id if proc_id.kind_of?(Response) response = perform_request('result-retrieve', {'Proc-ID' => proc_id}) - results = response.body.split("\n\n", 2)[0] + results, body = response.body.split("\n\n", 2) - results.split("\n").inject({}) do |hash, result| + results.split("\n").inject({'body' => body}) do |hash, result| hash.store(*result.split(": ",2)) hash end
Include "body" in results-retrieve return val.
diff --git a/lib/memory_analyzer/heap_analyzer/parser.rb b/lib/memory_analyzer/heap_analyzer/parser.rb index abc1234..def5678 100644 --- a/lib/memory_analyzer/heap_analyzer/parser.rb +++ b/lib/memory_analyzer/heap_analyzer/parser.rb @@ -39,6 +39,7 @@ node.tap do |n| n.deep_symbolize_keys! n[:type] = n[:type].to_sym + n[:node_type] = n[:node_type].to_sym if n.key?(:node_type) n[:references] = Array(n[:references]).uniq end end
Save a little more memory by symbolizing more common strings.
diff --git a/test/unit/round_test.rb b/test/unit/round_test.rb index abc1234..def5678 100644 --- a/test/unit/round_test.rb +++ b/test/unit/round_test.rb @@ -15,4 +15,15 @@ assert_not_nil r.expire_time assert Time.now + 1.hours - r.expire_time < 1 # fuzzy time comparison end + + test "url and expire_time persist on save" do + r = Round.new + url = r.url + r.save + + r2 = Round.where(url: url).first + + assert_equal r2.url, r.url + assert_equal r2.expire_time, r.expire_time + end end
Test Round url and expire_time persist on save
diff --git a/db/migrate/20210227144926_migrate_payment_fees_to_payments.rb b/db/migrate/20210227144926_migrate_payment_fees_to_payments.rb index abc1234..def5678 100644 --- a/db/migrate/20210227144926_migrate_payment_fees_to_payments.rb +++ b/db/migrate/20210227144926_migrate_payment_fees_to_payments.rb @@ -0,0 +1,22 @@+class MigratePaymentFeesToPayments < ActiveRecord::Migration + class Spree::Adjustment < ActiveRecord::Base + belongs_to :originator, polymorphic: true + end + + def up + # Payment fee adjustments currently have the order as the `adjustable` and the payment as + # the `source`. Both `source` and `adjustable` will now be the payment. The `originator` is + # the payment method, and this is unchanged. + Spree::Adjustment.where(originator_type: 'Spree::PaymentMethod').update_all( + "adjustable_id = source_id, adjustable_type = 'Spree::Payment'" + ) + end + + def down + # Just in case: reversing this migration requires setting the `adjustable` back to the order. + # The type is 'Spree::Order', and the order's id is still available on the `order_id` field. + Spree::Adjustment.where(originator_type: 'Spree::PaymentMethod').update_all( + "adjustable_id = order_id, adjustable_type = 'Spree::Order'" + ) + end +end
Migrate payment fee adjustments to payment objects
diff --git a/lib/cc/engine/analyzers/php/main.rb b/lib/cc/engine/analyzers/php/main.rb index abc1234..def5678 100644 --- a/lib/cc/engine/analyzers/php/main.rb +++ b/lib/cc/engine/analyzers/php/main.rb @@ -24,10 +24,6 @@ sexp.flatter end - def use_sexp_lines? - false - end - private def process_file(path)
Use `SexpLines` for PHP parser Since we're reverting back to the old PHP parser, we need to restore the use of `SexpLines`.
diff --git a/lib/hanzo/modules/install.rb b/lib/hanzo/modules/install.rb index abc1234..def5678 100644 --- a/lib/hanzo/modules/install.rb +++ b/lib/hanzo/modules/install.rb @@ -18,7 +18,7 @@ method = "install_#{@type}" if self.respond_to?(method) - send "install_#{@type}" + send(method) else initialize_help end
Use 'method' variable instead of String
diff --git a/lib/rack/dev-mark/railtie.rb b/lib/rack/dev-mark/railtie.rb index abc1234..def5678 100644 --- a/lib/rack/dev-mark/railtie.rb +++ b/lib/rack/dev-mark/railtie.rb @@ -20,7 +20,7 @@ racks << theme end - app.config.app_middleware.send(insert_method, *racks) + app.config.middleware.send(insert_method, *racks) end end
Insert into the correct middleware in spec
diff --git a/lib/tasks/organisations.rake b/lib/tasks/organisations.rake index abc1234..def5678 100644 --- a/lib/tasks/organisations.rake +++ b/lib/tasks/organisations.rake @@ -2,6 +2,13 @@ namespace :organisations do + #work around that heroku schedule only allows up to daily + task :weekly_import => :environment do + if Time.now.monday? + Rake::Task["organisations:import"].execute + end + end + desc "Imports organisations from the data.gov.uk hierarchy" task :import => :environment do response = Net::HTTP.get_response("data.gov.uk","/api/action/group_tree?type=organization")
Add rake task to be called by heroku scheduler
diff --git a/lib/tootsie/configuration.rb b/lib/tootsie/configuration.rb index abc1234..def5678 100644 --- a/lib/tootsie/configuration.rb +++ b/lib/tootsie/configuration.rb @@ -20,10 +20,6 @@ end end @queue_options = (config[:queue] ||= {}).symbolize_keys - - # Backwards compatibility with old options - @queue_options[:adapter] ||= 'sqs' - @queue_options[:queue] ||= config[:sqs_queue_name] end def load_from_file(file_name)
Remove some old SQS backward compatibility stuff.
diff --git a/lib/facter/freeradius_version.rb b/lib/facter/freeradius_version.rb index abc1234..def5678 100644 --- a/lib/facter/freeradius_version.rb +++ b/lib/facter/freeradius_version.rb @@ -1,7 +1,9 @@ # Grab the FreeRADIUS version from the output of radiusd -v -Facter.add(:freeradius_version) do - setcode do - Facter::Core::Execution.exec('radiusd -v').split(/\n/)[0].match(/FreeRADIUS Version (\d\.\d\.\d)/)[1] +if %x{which radiusd 2>/dev/null | wc -l}.chomp.to_i > 0 + Facter.add(:freeradius_version) do + setcode do + Facter::Core::Execution.exec('radiusd -v').split(/\n/)[0].match(/FreeRADIUS Version (\d\.\d\.\d)/)[1] + end end end
Make the fact work gracefully on systems that don't have FreeRADIUS installed
diff --git a/lib/subdomain_fu/url_rewriter.rb b/lib/subdomain_fu/url_rewriter.rb index abc1234..def5678 100644 --- a/lib/subdomain_fu/url_rewriter.rb +++ b/lib/subdomain_fu/url_rewriter.rb @@ -6,8 +6,7 @@ def url_for_with_subdomains(options, path_segments=nil) if SubdomainFu.needs_rewrite?(options[:subdomain], options[:host] ) || options[:only_path] == false options[:only_path] = false if SubdomainFu.override_only_path? - options[:host] = SubdomainFu.rewrite_host_for_subdomains(options.delete(:subdomain), options[:host] || "#{host}#{port_string}") - # puts "options[:host]: #{options[:host].inspect}" + options[:host] = SubdomainFu.rewrite_host_for_subdomains(options.delete(:subdomain), options[:host]) else options.delete(:subdomain) end
Remove reference to host/ port
diff --git a/test/mail_form_test.rb b/test/mail_form_test.rb index abc1234..def5678 100644 --- a/test/mail_form_test.rb +++ b/test/mail_form_test.rb @@ -9,4 +9,16 @@ sample.email = "user@example.com" assert_equal "user@example.com", sample.email end + test "sample mail can clear attributes using clear_prefix" do + sample = SampleMail.new + sample.name = "User" + sample.email = "user@example.com" + assert_equal "User", sample.name + assert_equal "user@example.com", sample.email + + sample.clear_name + sample.clear_email + assert_nil sample.name + assert_nil sample.email + end end
Add test 'sample mail can clear attributes using clear_prefix'
diff --git a/lib/generators/rails_admin/utils.rb b/lib/generators/rails_admin/utils.rb index abc1234..def5678 100644 --- a/lib/generators/rails_admin/utils.rb +++ b/lib/generators/rails_admin/utils.rb @@ -9,7 +9,7 @@ def ask_for(wording, default_value = nil, override_if_present_value = nil) override_if_present_value.present? ? display("Using [#{override_if_present_value}] for question '#{wording}'") && override_if_present_value : - ask(" ? #{wording} Press <enter> for [#{default_value}] >", :yellow).presence.try(:parameterize) || default_value + ask(" ? #{wording} Press <enter> for [#{default_value}] >", :yellow).presence || default_value end end
Fix for SuperUser => superuser closes #720
diff --git a/lib/rip/parsers/block_expression.rb b/lib/rip/parsers/block_expression.rb index abc1234..def5678 100644 --- a/lib/rip/parsers/block_expression.rb +++ b/lib/rip/parsers/block_expression.rb @@ -10,6 +10,8 @@ rule(:block_expression) { condition | loop_block | exception_handling } - rule(:block) { surround_with('{', statements.as(:body), '}') } + def block(body = statements) + surround_with('{', body.as(:body), '}') + end end end
Refactor block rule to allow custom body
diff --git a/lib/sass/globbing/monkey_patches.rb b/lib/sass/globbing/monkey_patches.rb index abc1234..def5678 100644 --- a/lib/sass/globbing/monkey_patches.rb +++ b/lib/sass/globbing/monkey_patches.rb @@ -6,7 +6,7 @@ def initialize(template, options={}) old_initialize(template, options) unless self.options[:load_paths].include?(Sass::Globbing::Importer.instance) - self.options[:load_paths].unshift Sass::Globbing::Importer.instance + self.options[:load_paths].push Sass::Globbing::Importer.instance end end -end+end
Change the globbing importer to be at the end of the load paths instead of the front. This prevents the globbing from picking up compass sprite imports.
diff --git a/lib/geojson_model/base.rb b/lib/geojson_model/base.rb index abc1234..def5678 100644 --- a/lib/geojson_model/base.rb +++ b/lib/geojson_model/base.rb @@ -9,6 +9,8 @@ included do include Virtus.model include ActiveModel::Serializers::JSON + + alias_method :to_geojson, :to_json end def attributes=(hash) @@ -20,7 +22,5 @@ def attributes instance_values end - - alias_method :to_geojson, :to_json end end
Move alias_method into included block
diff --git a/JSONRequest.podspec b/JSONRequest.podspec index abc1234..def5678 100644 --- a/JSONRequest.podspec +++ b/JSONRequest.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "JSONRequest" - s.version = "0.6.0" + s.version = "0.7.0" s.summary = "JSONRequest is a tiny Swift library for Synchronous and Asynchronous HTTP JSON requests." s.homepage = "http://github.com/hathway/JSONRequest" s.license = { :type => "MIT", :file => "LICENSE" } @@ -15,5 +15,5 @@ s.source = { :git => "https://github.com/hathway/JSONRequest.git", :tag => s.version } s.source_files = "Sources/*.swift" - + s.swift_version = '4.0' end
Set swift version in podspec file
diff --git a/lib/kosmos/git_adapter.rb b/lib/kosmos/git_adapter.rb index abc1234..def5678 100644 --- a/lib/kosmos/git_adapter.rb +++ b/lib/kosmos/git_adapter.rb @@ -6,6 +6,10 @@ def init_repo(path) Dir.chdir(path) do `git init` + + File.open('.gitignore', 'w') do |file| + file.write "!*\n" + end end end
Make sure git ignores nothing.
diff --git a/lib/locations_ng/state.rb b/lib/locations_ng/state.rb index abc1234..def5678 100644 --- a/lib/locations_ng/state.rb +++ b/lib/locations_ng/state.rb @@ -1,46 +1,52 @@ module LocationsNg class State - def self.all - load_states.map{ |s| {name: s['name'], capital: s['capital']} } - end + class << self + def all + load_states.map{ |s| {name: s['name'], capital: s['capital']} } + end - def self.details(state) - state = state.downcase.gsub(' ', '_') - all_states = load_states + def details(state) + state = state.downcase.gsub(' ', '_') + all_states = load_states - state_index = all_states.index{|s| s['alias'] == state} + state_index = all_states.index{|s| s['alias'] == state} - if state_index.nil? - {message: "No state found for '#{state}'", status: 404} - else - res = all_states[state_index].with_indifferent_access - res['cities'] = LocationsNg::City.cities(state) - res['lgas'] = LocationsNg::Lga.lgas(state) - res + if state_index.nil? + {message: "No state found for '#{state}'", status: 404} + else + res = all_states[state_index].with_indifferent_access + res['cities'] = LocationsNg::City.cities(state) + res['lgas'] = LocationsNg::Lga.lgas(state) + res + end end - end - def self.capital(state) - state = state.downcase.gsub(' ', '_') - all_states = load_states + def capital(state) + state = state.downcase.gsub(' ', '_') + all_states = load_states - state_index = all_states.index{|s| s['alias'] == state} + state_index = all_states.index{|s| s['alias'] == state} - if state_index.nil? - {message: "No state found for '#{state}'", status: 404} - else - all_states[state_index]['capital'] + if state_index.nil? + {message: "No state found for '#{state}'", status: 404} + else + all_states[state_index]['capital'] + end end - end - private + private - def self.load_states - YAML.load(File.read(files_location 'states')) - end + def load_states + YAML.load(File.read(files_location 'states')) + end - def self.files_location(file) - File.expand_path("../locations/#{file}.yml", __FILE__) + def files_location(file) + File.expand_path("../locations/#{file}.yml", __FILE__) + end + + def format_query(query) + query ? query.downcase.gsub(' ', '_') : query + end end end end
Refactor State class methods definition.
diff --git a/db/data_migration/20190507120922_add_tags_to_specialist_sectors.rb b/db/data_migration/20190507120922_add_tags_to_specialist_sectors.rb index abc1234..def5678 100644 --- a/db/data_migration/20190507120922_add_tags_to_specialist_sectors.rb +++ b/db/data_migration/20190507120922_add_tags_to_specialist_sectors.rb @@ -0,0 +1,26 @@+linkable_topics = LinkableTopics.new + +linkable_topic_items = linkable_topics.send(:fetch_linkables_from_publishing_api, document_type: 'topic') +linkable_topic_items = linkable_topics.send(:change_separator, linkable_topic_items) + +specialist_sectors = SpecialistSector.where(tag: nil) + +puts 'Found %<count>d Specialist Sectors with a missing `tag`' % + { count: specialist_sectors.count } + +specialist_sectors.each do |specialist_sector| + puts '- Processing %<specialist_sector>s' % { specialist_sector: specialist_sector.inspect } + + if (topic = linkable_topic_items.find { |item| item['content_id'] == specialist_sector['topic_content_id'] }) + puts ' Found topic %<topic>s' % { topic: topic.inspect } + puts ' %<status>s `tag` %<tag>s' % + # Remove "/topic/" from beginning of base path (but only from beginning) + { tag: specialist_sector.tag = topic['base_path'].gsub(/\A\/topic\//, ""), + status: specialist_sector.save ? 'Assigned' : 'Failed to assign' } + else + puts ' No topic found' + end +end + +puts 'Now %<count>d Specialist Sectors with a missing `tag`' % + { count: specialist_sectors.count }
Add tag to specialist sectors missing it There are 19779 specialist sectors which correctly link to a topic but their tag field is empty. A user wanted to use specialist sector tags in a CSV file to help find content but cannot as so many have their tags missing. This adds the tag field in to all but 35 of those items. Zendesk: https://govuk.zendesk.com/agent/tickets/3663248
diff --git a/core/lib/spree/core/controller_helpers/strong_parameters.rb b/core/lib/spree/core/controller_helpers/strong_parameters.rb index abc1234..def5678 100644 --- a/core/lib/spree/core/controller_helpers/strong_parameters.rb +++ b/core/lib/spree/core/controller_helpers/strong_parameters.rb @@ -27,7 +27,8 @@ def permitted_order_attributes permitted_checkout_attributes + [ - :line_items_attributes => permitted_line_item_attributes + :gift_message, + {:line_items_attributes => permitted_line_item_attributes} ] end
Add gift_message to the parameter whitelist
diff --git a/lib/mina/unicorn/tasks.rb b/lib/mina/unicorn/tasks.rb index abc1234..def5678 100644 --- a/lib/mina/unicorn/tasks.rb +++ b/lib/mina/unicorn/tasks.rb @@ -9,7 +9,7 @@ set :unicorn_env, -> { fetch(:rails_env) == "development" ? "development" : "deployment" } set :unicorn_config, -> { "#{fetch(:current_path)}/config/unicorn.rb" } set :unicorn_pid, -> { "#{fetch(:current_path)}/tmp/pids/unicorn.pid" } - set :unicorn_cmd, -> { "#{fetch(:bundle_prefix)} unicorn" } + set :unicorn_cmd, -> { "#{fetch(:bundle_prefix, "#{fetch(:bundle_bin)} exec")} unicorn" } set :unicorn_restart_sleep_time, -> { 2 } set :bundle_gemfile, -> { "#{fetch(:current_path)}/Gemfile" }
Use bundle_prefix for unicorn_cmd if available Commit 7cc5272 removed mina/rails dependency, so 'bundle_prefix' could not be set. Use it if available, otherwise default to 'bundle exec'.
diff --git a/lib/miniphonic/helpers.rb b/lib/miniphonic/helpers.rb index abc1234..def5678 100644 --- a/lib/miniphonic/helpers.rb +++ b/lib/miniphonic/helpers.rb @@ -1,15 +1,30 @@ require 'mime/types' module Miniphonic::Helpers + + # TODO: abstract to and from server into something like "request(verb, url, payload)" + # Problem: Passing the blocks around in a performing way (&block is sloooow) + # Posts data to the server and executes a given block on success - def to_server(url, payload = nil) + def to_server(url, payload = {}) connection = Miniphonic.connect - raw_response = connection.post do |req| - req.url url - req.body = payload + raw_response = connection.post url, payload + response = Miniphonic::Response.new(raw_response) + + if response.success? + yield(response) if block_given? + response + else + raise server_error(response) end + end + # Gets data from the server and executes a given block on success + def from_server(url, payload = {}) + connection = Miniphonic.connect + + raw_response = connection.get url, payload response = Miniphonic::Response.new(raw_response) if response.success?
Add from_server (not very dry, sry)
diff --git a/lib/react/jsx/template.rb b/lib/react/jsx/template.rb index abc1234..def5678 100644 --- a/lib/react/jsx/template.rb +++ b/lib/react/jsx/template.rb @@ -1,3 +1,5 @@+require 'tilt' + module React module JSX
Fix uninitialized constant React::JSX::Tilt in 3.2.x
diff --git a/lib/rubella/input/base.rb b/lib/rubella/input/base.rb index abc1234..def5678 100644 --- a/lib/rubella/input/base.rb +++ b/lib/rubella/input/base.rb @@ -1,41 +1,13 @@ module Rubella module Input - # Gets the rwa data and translate it into a by the Rubella::Weighting::Base - # class readable format. + # Gets the raw data and translate it into a readable format for the + # Rubella::Weighting::Base class. # This must be an array within subarrays, which have all the same lenght # and contains only numeric data. # - # TODO The validation of the data should happen here - # Check if data is array, with subarrays. Check, that all sub array have - # the same size. Check that all the content are numeric values between 0 - # and 100. - # class Base attr_reader :data - - # Constructor - # Creates a new Rubella::Input::Base object, from the given data. - # - # @param value string A string, which contains the data - # @return Rubella::Input::Base - # - def self.string value - raise NotImplementedError.new "Please override 'self.string' in your "+ - "concrete implementation" - end - - # Constructor - # Creates a new Rubella::Input::Base object, from the given file. - # Only the file name is required. - # - # @param file_name string The name of the file - # @return Rubella:Input::Base - # - def self.file file_name - raise NotImplementedError.new "Please override 'self.file' in your "+ - "concrete implementation" - end # Passes each dataset trought the given block. #
Remove not needed abstract classes The constructor classes are not needed for making the library work. So I removed them.
diff --git a/moodle2cc.gemspec b/moodle2cc.gemspec index abc1234..def5678 100644 --- a/moodle2cc.gemspec +++ b/moodle2cc.gemspec @@ -2,10 +2,10 @@ require File.expand_path('../lib/moodle2cc/version', __FILE__) Gem::Specification.new do |gem| - gem.authors = ["Christopher Durtschi"] - gem.email = ["christopher.durtschi@gmail.com"] - gem.description = %q{TODO: Write a gem description} - gem.summary = %q{TODO: Write a gem summary} + gem.authors = ["Christopher Durtschi", "Kevin Carter"] + gem.email = ["christopher.durtschi@gmail.com", "cartkev@gmail.com"] + gem.description = %q{Migrates Moodle backup ZIP to IMS Common Cartridge package} + gem.summary = %q{Migrates Moodle backup ZIP to IMS Common Cartridge package} gem.homepage = "" gem.add_runtime_dependency "rubyzip"
Add Kevin to authors, add summary and description
diff --git a/Casks/android-studio.rb b/Casks/android-studio.rb index abc1234..def5678 100644 --- a/Casks/android-studio.rb +++ b/Casks/android-studio.rb @@ -1,7 +1,7 @@ class AndroidStudio < Cask - url 'http://dl.google.com/dl/android/studio/ide-zips/0.5.3/android-studio-ide-135.1092050-mac.zip' + url 'http://dl.google.com/dl/android/studio/ide-zips/0.5.4/android-studio-ide-135.1101912-mac.zip' homepage 'https://developer.android.com/sdk/installing/studio.html' - version '0.5.3 build-135.1092050' - sha256 '8558836c6a2e0108fceded0af7a01ac6896f20a25bb00ef2184817acfaa91c2d' + version '0.5.4 build-135.1101912' + sha256 'ac1b6cd9276dab859afa4e32eb9bb7171ee635bb1a337b2b3c255249d4fe7732' link 'Android Studio.app' end
Upgrade Android Studio.app to v0.5.4 build-135.1101912
diff --git a/Casks/omnifocus-beta.rb b/Casks/omnifocus-beta.rb index abc1234..def5678 100644 --- a/Casks/omnifocus-beta.rb +++ b/Casks/omnifocus-beta.rb @@ -1,6 +1,6 @@ cask :v1 => 'omnifocus-beta' do - version '2.2.x-r235511' - sha256 '5f11983b2d4ec9e447a5b69dd3c09e70a100f9434fd6bcb8ad98f4bfe82f071c' + version '2.2.x-r238263' + sha256 '2524ac2ec3541bd65a5aabac111c72f47a05d589b17e313ea37668a498476f58' url "http://omnistaging.omnigroup.com/omnifocus-2.2.x/releases/OmniFocus-#{version}-Test.dmg" name 'OmniFocus'
Update OmniFocus beta to 2.2.3 This commit freshens up the OmniFocus beta by changing the version to include a more recent build number, and updates the sha256 stanza as well.
diff --git a/files/default/tests/minitest/default_test.rb b/files/default/tests/minitest/default_test.rb index abc1234..def5678 100644 --- a/files/default/tests/minitest/default_test.rb +++ b/files/default/tests/minitest/default_test.rb @@ -19,6 +19,16 @@ require 'minitest/spec' require File.expand_path('../support/helpers', __FILE__) +sleep(5) + describe_recipe 'npm_registry::default' do include Helpers::NPM_Registry + + it 'should query the registry database endpoints' do + assert_equal JSON.parse(Net::HTTP.get(URI.parse('http://localhost:5984/registry')))['db_name'], 'registry' + assert_equal JSON.parse(Net::HTTP.get(URI.parse('http://localhost:5984/registry/_design/app')))['_id'], '_design/app' + assert_equal JSON.parse(Net::HTTP.get(URI.parse('http://localhost:5984/registry/_design/ghost')))['_id'], '_design/ghost' + assert_equal JSON.parse(Net::HTTP.get(URI.parse('http://localhost:5984/registry/_design/scratch')))['_id'], '_design/scratch' + assert_equal JSON.parse(Net::HTTP.get(URI.parse('http://localhost:5984/registry/_design/ui')))['_id'], '_design/ui' + end end
Add integration tests to check for the registry endpoints.
diff --git a/test/generators/install_generator_test.rb b/test/generators/install_generator_test.rb index abc1234..def5678 100644 --- a/test/generators/install_generator_test.rb +++ b/test/generators/install_generator_test.rb @@ -8,16 +8,18 @@ test "install generator insert require underscore into application.js" do run_generator - assert_file "app/assets/javascripts/application.js", /\/\/= require\sunderscore/ end test "install generator inserts require backbone into application.js" do run_generator - assert_file "app/assets/javascripts/application.js", /\/\/= require\sbackbone/ end + test "install generator injects backbone dependencies in the right order: first underscore then backbone" do + run_generator + assert_file "app/assets/javascripts/application.js", /\/\/= require\sunderscore\n\/\/= require\sbackbone/ + end private
Make sure that the assets are being loaded in the right order: first underscore then backbone
diff --git a/app.rb b/app.rb index abc1234..def5678 100644 --- a/app.rb +++ b/app.rb @@ -22,6 +22,11 @@ @barber = params[:barber] @color = params[:color] + if @username == '' + @error = 'Введите имя' + return erb :visit + end + erb "OK, username is #{@username}, #{@phone}, #{@datetime}, #{@barber}, #{@color}" end
Add simple name parameter validation
diff --git a/test/spec/spec_helper.rb b/test/spec/spec_helper.rb index abc1234..def5678 100644 --- a/test/spec/spec_helper.rb +++ b/test/spec/spec_helper.rb @@ -16,3 +16,5 @@ require 'poise_boiler/spec_helper' require 'poise_application_ruby' +require 'poise_application/cheftie' +require 'poise_ruby/cheftie'
Load dependent resources, normally handled by Chef.
diff --git a/compo.gemspec b/compo.gemspec index abc1234..def5678 100644 --- a/compo.gemspec +++ b/compo.gemspec @@ -22,9 +22,12 @@ spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ['lib'] + spec.add_development_dependency 'backports' spec.add_development_dependency 'bundler', '~> 1.3' + spec.add_development_dependency 'fuubar' spec.add_development_dependency 'rake' spec.add_development_dependency 'rspec' + spec.add_development_dependency 'simplecov' spec.add_development_dependency 'yard' spec.add_development_dependency 'yardstick' end
Include fuubar and simplecov in gemspec.
diff --git a/lib/geoscript/geom/multipolygon.rb b/lib/geoscript/geom/multipolygon.rb index abc1234..def5678 100644 --- a/lib/geoscript/geom/multipolygon.rb +++ b/lib/geoscript/geom/multipolygon.rb @@ -27,6 +27,18 @@ super(polys.to_java(com.vividsolutions.jts.geom.Polygon), GEOM_FACTORY) end + def polygons + [].tap do |g| + for i in 0...num_geometries do + g << geometry_n(i) + end + end + end + + def <<(*new_polygons) + MultiPolygon.new *(polygons << new_polygons) + end + def buffer(dist) Polygon.new super end
Add n polygons to MultiPolygon with << operator
diff --git a/services/QuillLMS/app/graphql/types/user_type.rb b/services/QuillLMS/app/graphql/types/user_type.rb index abc1234..def5678 100644 --- a/services/QuillLMS/app/graphql/types/user_type.rb +++ b/services/QuillLMS/app/graphql/types/user_type.rb @@ -11,6 +11,8 @@ field :notifications, [Types::NotificationType], null: true field :activity_scores, [Types::ActivityScoreType], null: true + field :recommended_activities, [Int], null: true + field :completed_diagnostic, Boolean, null: false def notifications object.notifications.order("created_at DESC").limit(10) @@ -30,4 +32,12 @@ ") end + def recommended_activities + return [1] + end + + def completed_diagnostic + ActivitySession.where(user_id: object.id, activity_id: 413, state: "finished").any? + end + end
Support checking if a user has completed the diagnositic.
diff --git a/week-4/simple-string.rb b/week-4/simple-string.rb index abc1234..def5678 100644 --- a/week-4/simple-string.rb +++ b/week-4/simple-string.rb @@ -0,0 +1,31 @@+# Solution Below + +old_string = "Ruby is cool" +new_string = old_string.reverse +new_string.upcase! +puts "old string: " + old_string +puts "new string: " + new_string + + +# RSpec Tests. They are included in this file because the local variables you are creating are not accessible across files. If we try to run these files as a separate file per normal operation, the local variable checks will return nil. + + +describe "old_string" do + it 'is defined as a local variable' do + expect(defined?(old_string)).to eq 'local-variable' + end + + it "has the value 'Ruby is cool'" do + expect(old_string).to eq "Ruby is cool" + end +end + +describe 'new_string' do + it 'is defined as a local variable' do + expect(defined?(new_string)).to eq 'local-variable' + end + + it 'has the value "LOOC SI YBUR"' do + expect(new_string).to eq "LOOC SI YBUR" + end +end
Add complete 4.2.2 simple string
diff --git a/RPJSContext.podspec b/RPJSContext.podspec index abc1234..def5678 100644 --- a/RPJSContext.podspec +++ b/RPJSContext.podspec @@ -5,7 +5,7 @@ s.homepage = "http://github.com/RobotsAndPencils/RPJSContext" s.license = 'MIT' s.author = { "Brandon Evans" => "brandon.evans@robotsandpencils.com" } - s.source = { :git => "http://EXAMPLE/NAME.git", :tag => s.version.to_s } + s.source = { :git => "https://github.com/RobotsAndPencils/RPJSContext.git", :tag => s.version.to_s } s.social_media_url = 'https://twitter.com/RobotsNPencils' s.ios.deployment_target = '7.0'
Put a real source URL in the podspec
diff --git a/test/test_get_feature.rb b/test/test_get_feature.rb index abc1234..def5678 100644 --- a/test/test_get_feature.rb +++ b/test/test_get_feature.rb @@ -1,8 +1,8 @@ require File.join(File.dirname(__FILE__), 'helper') -class Get_bug_test < Test::Unit::TestCase +class Get_feature_test < Test::Unit::TestCase - def test_get_bug + def test_get_feature DataMapper::Logger.new(STDOUT, :debug) keeper = DataMapper.setup(:default, :adapter => 'keeper',
Fix name (bug -> feature)
diff --git a/samples/sample_simple.rb b/samples/sample_simple.rb index abc1234..def5678 100644 --- a/samples/sample_simple.rb +++ b/samples/sample_simple.rb @@ -13,11 +13,13 @@ a sample command to show off Cri! EOS - option :a, :aaa, 'opt a', :argument => :optional - required :b, :bbb, 'opt b' - optional :c, :ccc, 'opt c' - flag :d, :ddd, 'opt d' - forbidden :e, :eee, 'opt e' + option :a, :aaa, 'opt a', :argument => :optional + required :b, :bbb, 'opt b' + optional :c, :ccc, 'opt c' + flag :d, :ddd, 'opt d' + forbidden :e, :eee, 'opt e' + flag :s, nil, 'option with only a short form' + flag nil, 'long', 'option with only a long form' run do |opts, args| puts "Executing!"
Add optional options to simple example
diff --git a/Library/Contributions/examples/brew-bottle.rb b/Library/Contributions/examples/brew-bottle.rb index abc1234..def5678 100644 --- a/Library/Contributions/examples/brew-bottle.rb +++ b/Library/Contributions/examples/brew-bottle.rb @@ -3,19 +3,19 @@ destination = HOMEBREW_PREFIX + "Bottles" if not File.directory?(destination) - Dir.mkdir destination + Dir.mkdir destination end ARGV.each do|formula| - # Get the latest version - version = `brew list --versions #{formula}`.split.last + # Get the latest version + version = `brew list --versions #{formula}`.split.last source = HOMEBREW_CELLAR + formula + version - filename = formula + '-' + version + '.tar.gz' - ohai "Bottling #{formula} #{version}..." - HOMEBREW_CELLAR.cd do - # Use gzip, much faster than bzip2 and hardly any file size difference - # when compressing binaries. - safe_system "tar czf #{destination}/#{filename} #{formula}/#{version}" - end - ohai "Bottled #{filename}" + filename = formula + '-' + version + '.tar.gz' + ohai "Bottling #{formula} #{version}..." + HOMEBREW_CELLAR.cd do + # Use gzip, much faster than bzip2 and hardly any file size difference + # when compressing binaries. + safe_system "tar czf #{destination}/#{filename} #{formula}/#{version}" + end + ohai "Bottled #{filename}" end
Change tabs to spaces in brew bottle.
diff --git a/lib/puppet/provider/chronos_job.rb b/lib/puppet/provider/chronos_job.rb index abc1234..def5678 100644 --- a/lib/puppet/provider/chronos_job.rb +++ b/lib/puppet/provider/chronos_job.rb @@ -26,6 +26,8 @@ response = HTTParty.post("#{resource[:host]}/#{job_type}", job) rescue HTTParty::Error raise Puppet::Error, "Error while connecting to Chronos host #{resource[:host]}" + rescue HTTParty::ResponseError => e + raise Puppet::Error, "Failed to create Chronos job with HTTP error : #{e}" end end @@ -34,6 +36,8 @@ response = HTTParty.delete("#{resource[:host]}/job/#{resource[:name]}") rescue HTTParty::Error raise Puppet::Error, "Error while connecting to Chronos host #{resource[:host]}" + rescue HTTParty::ResponseError => e + raise Puppet::Error, "Failed to delete Chronos job with HTTP error : #{e}" end end end
Add http specific error handling.
diff --git a/lib/buckaruby/ideal.rb b/lib/buckaruby/ideal.rb index abc1234..def5678 100644 --- a/lib/buckaruby/ideal.rb +++ b/lib/buckaruby/ideal.rb @@ -8,6 +8,7 @@ "BUNQNL2A" => "bunq", "INGBNL2A" => "ING", "KNABNL2H" => "Knab bank", + "MOYONL21" => "Moneyou", "RABONL2U" => "Rabobank", "RBRBNL21" => "RegioBank", "SNSBNL2A" => "SNS Bank",
Add Moneyou to the list of iDEAL issuers.
diff --git a/lib/bugsnag/helpers.rb b/lib/bugsnag/helpers.rb index abc1234..def5678 100644 --- a/lib/bugsnag/helpers.rb +++ b/lib/bugsnag/helpers.rb @@ -31,7 +31,7 @@ "#{request.request_method} #{request.path}" if request end - # Helper function to work around MultiJson changes in 1.3+ + # Helper functions to work around MultiJson changes in 1.3+ def self.dump_json(object, options={}) if MultiJson.respond_to?(:adapter) MultiJson.dump(object, options) @@ -39,5 +39,13 @@ MultiJson.encode(object, options) end end + + def self.load_json(json, options={}) + if MultiJson.respond_to?(:adapter) + MultiJson.load(json, options) + else + MultiJson.decode(json, options) + end + end end end
Add MultiJson load_json helper for future use
diff --git a/script/convert-smart-answer-landing-pages-from-yaml-to-erb.rb b/script/convert-smart-answer-landing-pages-from-yaml-to-erb.rb index abc1234..def5678 100644 --- a/script/convert-smart-answer-landing-pages-from-yaml-to-erb.rb +++ b/script/convert-smart-answer-landing-pages-from-yaml-to-erb.rb @@ -0,0 +1,26 @@+SmartAnswer::FlowRegistry.instance.flows.each do |flow| + dummy_request = OpenStruct.new(params: {}) + flow_presenter = SmartAnswerPresenter.new(dummy_request, flow) + start_node = flow_presenter.start_node + + blocks = [] + if start_node.has_title? + blocks << "<% content_for :title do %>\n#{start_node.title.indent(2)}\n<% end %>\n" + end + if start_node.has_meta_description? + blocks << "<% content_for :meta_description do %>\n#{start_node.meta_description.indent(2)}\n<% end %>\n" + end + if start_node.has_body? + blocks << "<% content_for :body do %>\n#{start_node.body(html: false).chomp.indent(2)}\n<% end %>\n" + end + if start_node.has_post_body? + blocks << "<% content_for :post_body do %>\n#{start_node.post_body(html: false).chomp.indent(2)}\n<% end %>\n" + end + + directory = start_node.template_directory + basename = directory.join(flow.name.underscore) + filename = "#{basename}.govspeak.erb" + File.open(filename, 'w') do |file| + file.puts(blocks.join("\n")) + end +end
Add script to build ERB templates for landing pages from YAML * I've used the NodePresenter methods to access the content from the locale YAML files. * If any landing page content uses interpolation this script will fail fast with a `I18n::MissingInterpolationArgument` exception. * Currently none of them do use interpolation. * This script writes the ERB template files, but does not remove the content the locale YAML files. I plan to do this manually.
diff --git a/dsd.rb b/dsd.rb index abc1234..def5678 100644 --- a/dsd.rb +++ b/dsd.rb @@ -2,6 +2,13 @@ require 'eventmachine' require 'date' +require 'ffi' + +module Xname + extend FFI::Library + ffi_lib 'xname' + attach_function :xname, [ :string ], :int +end $a = [] @@ -9,5 +16,5 @@ EM.add_periodic_timer(1) { $a[0] = DateTime.now.to_s } EM.add_periodic_timer(5) { $a[1] = File.read("/proc/loadavg").split[0..2].join " " } - EM.add_periodic_timer(0.1) { puts $a.join " " } + EM.add_periodic_timer(0.1) { Xname.xname $a.join " " } end
Make it actually do something.
diff --git a/lib/tasks/active_record_views.rake b/lib/tasks/active_record_views.rake index abc1234..def5678 100644 --- a/lib/tasks/active_record_views.rake +++ b/lib/tasks/active_record_views.rake @@ -1,8 +1,18 @@ Rake::Task['db:structure:dump'].enhance do if ActiveRecord::Base.connection.table_exists?('active_record_views') filename = ENV['DB_STRUCTURE'] || File.join(Rails.root, "db", "structure.sql") - config = current_config - set_psql_env(config) + + if defined? ActiveRecord::Tasks::DatabaseTasks + tasks = ActiveRecord::Tasks::DatabaseTasks + config = tasks.current_config + tasks.send(:class_for_adapter, config.fetch('adapter')).new(config) + pg_tasks = tasks.send(:class_for_adapter, config.fetch('adapter')).new(config) + pg_tasks.send(:set_psql_env) + else + config = current_config + set_psql_env(config) + end + system("pg_dump --data-only --table=active_record_views #{Shellwords.escape config['database']} >> #{Shellwords.escape filename}") raise 'active_record_views metadata dump failed' unless $?.success? end
Fix structure dumping on Rails 4.2
diff --git a/scratch/read_activity.rb b/scratch/read_activity.rb index abc1234..def5678 100644 --- a/scratch/read_activity.rb +++ b/scratch/read_activity.rb @@ -15,6 +15,23 @@ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'githubarchive' +# e.g. +# @github_auth = ['username', 'password'] +class Configuration + def Configuration.load(path) + c = Configuration.new() + begin + c.instance_eval(File.read(path)) + rescue SystemCallError + end + return c + end + + attr_reader :github_auth +end + +conf = Configuration.load(File.join(ENV['HOME'], '.githubarchiverc')) + ARGV.each do |src| js = open(src) if src =~ /\.gz\Z/ @@ -22,8 +39,13 @@ end Yajl::Parser.parse(js) do |ev| - GitHubArchive::EventParser.parse(ev, dry_run: true) do |event| + GitHubArchive::EventParser.parse(ev, dry_run: false, auth: conf.github_auth) do |event| puts event.type + puts event.timestamp + puts event.location + puts event.gravatar_id + puts event.comment + puts end end end
Use config file for user authentication
diff --git a/spec/helpers/configuration_job_helper/textual_summary_spec.rb b/spec/helpers/configuration_job_helper/textual_summary_spec.rb index abc1234..def5678 100644 --- a/spec/helpers/configuration_job_helper/textual_summary_spec.rb +++ b/spec/helpers/configuration_job_helper/textual_summary_spec.rb @@ -0,0 +1,14 @@+describe ConfigurationJobHelper::TextualSummary do + include CompressedIds + include ApplicationHelper + + let(:zone) { EvmSpecHelper.local_miq_server.zone } + let(:automation_provider) { FactoryGirl.create(:provider_ansible_tower, :name => "ansibletest", :url => "test", :zone => zone) } + + it "#textual_provider" do + manager = ManageIQ::Providers::AnsibleTower::AutomationManager.find_by(:provider_id => automation_provider.id) + @record = FactoryGirl.create(:ansible_tower_job, :ext_management_system => manager) + expect(textual_provider[:image]).to eq("svg/vendor-ansible.svg") + expect(textual_provider[:link]).to eq("/automation_manager/explorer/at-#{to_cid(manager.id)}") + end +end
Add specs for configuration job textual_provider
diff --git a/lib/fpm/package/zip.rb b/lib/fpm/package/zip.rb index abc1234..def5678 100644 --- a/lib/fpm/package/zip.rb +++ b/lib/fpm/package/zip.rb @@ -0,0 +1,63 @@+require "backports" # gem backports +require "fpm/package" +require "fpm/util" +require "fileutils" +require "fpm/package/dir" + +# Use a zip as a package. +# +# This provides no metadata. Both input and output are supported. +class FPM::Package::Zip < FPM::Package + + # Input a zipfile. + def input(input_path) + # use part of the filename as the package name + self.name = File.extname(input_path)[1..-1] + + realpath = Pathname.new(input_path).realpath.to_s + ::Dir.chdir(build_path) do + safesystem("unzip", realpath) + end + + # use dir to set stuff up properly, mainly so I don't have to reimplement + # the chdir/prefix stuff special for zip. + dir = convert(FPM::Package::Dir) + if attributes[:chdir] + dir.attributes[:chdir] = File.join(build_path, attributes[:chdir]) + else + dir.attributes[:chdir] = build_path + end + + cleanup_staging + # Tell 'dir' to input "." and chdir/prefix will help it figure out the + # rest. + dir.input(".") + @staging_path = dir.staging_path + dir.cleanup_build + end # def input + + # Output a tarball. + # + # If the output path ends predictably (like in .tar.gz) it will try to obey + # the compression type. + def output(output_path) + output_check(output_path) + + files = Find.find(staging_path).to_a + safesystem("zip", output_path, *files) + end # def output + + # Generate the proper tar flags based on the path name. + def tar_compression_flag(path) + case path + when /\.tar\.bz2$/ + return "-j" + when /\.tar\.gz$|\.tgz$/ + return "-z" + when /\.tar\.xz$/ + return "-J" + else + return nil + end + end # def tar_compression_flag +end # class FPM::Package::Tar
Use ::Dir so we get ruby core's Dir, not FPM::Package::Dir
diff --git a/lib/formtastic/i18n.rb b/lib/formtastic/i18n.rb index abc1234..def5678 100644 --- a/lib/formtastic/i18n.rb +++ b/lib/formtastic/i18n.rb @@ -1,3 +1,4 @@+# coding: utf-8 module Formtastic module I18n
Fix another coding issue with HAML + Rails 3 + Ruby 1.9.1
diff --git a/lib/github_uploader.rb b/lib/github_uploader.rb index abc1234..def5678 100644 --- a/lib/github_uploader.rb +++ b/lib/github_uploader.rb @@ -0,0 +1,89 @@+require "rest-client" +require "github_api" +# We can stop requiring nokogiri when github_api is updated +require "nokogiri" + +class GithubUploader + + def initialize(login, username, repo, root=Dir.pwd) + @login = login + @username = username + @repo = repo + @root = root + @token = check_token + end + + def authorized? + !!@token + end + + def token_path + File.expand_path(".github-upload-token", @root) + end + + def check_token + File.exist?(token_path) ? File.open(token_path, "rb").read : nil + end + + def authorize + return if authorized? + + puts "There is no file named .github-upload-token in this folder. This file holds the OAuth token needed to communicate with GitHub." + puts "You will be asked to enter your GitHub password so a new OAuth token will be created." + print "GitHub Password: " + system "stty -echo" # disable echoing of entered chars so password is not shown on console + pw = STDIN.gets.chomp + system "stty echo" # enable echoing of entered chars + puts "" + + # check if the user already granted access for Ember.js Uploader by checking the available authorizations + response = RestClient.get "https://#{@login}:#{pw}@api.github.com/authorizations" + JSON.parse(response.to_str).each do |auth| + if auth["note"] == "Ember.js Uploader" + # user already granted access, so we reuse the existing token + @token = auth["token"] + end + end + + ## we need to create a new token + unless @token + payload = { + :scopes => ["public_repo"], + :note => "Ember.js Uploader", + :note_url => "https://github.com/#{@username}/#{@repo}" + } + response = RestClient.post "https://#{@login}:#{pw}@api.github.com/authorizations", payload.to_json, :content_type => :json + @token = JSON.parse(response.to_str)["token"] + end + + # finally save the token into .github-upload-token + File.open(".github-upload-token", 'w') {|f| f.write(@token)} + end + + def upload_file(filename, description, file) + return false unless authorized? + + gh = Github.new :user => @username, :repo => @repo, :oauth_token => @token + + # remvove previous download with the same name + gh.repos.downloads do |download| + if filename == download.name + gh.repos.delete_download @username, @repo, download.id + break + end + end + + # step 1 + hash = gh.repos.create_download @username, @repo, + "name" => filename, + "size" => File.size(file), + "description" => description, + "content_type" => "application/json" + + # step 2 + gh.repos.upload hash, file + + return true + end + +end
Include lib files for uploader
diff --git a/lib/haml_lint/utils.rb b/lib/haml_lint/utils.rb index abc1234..def5678 100644 --- a/lib/haml_lint/utils.rb +++ b/lib/haml_lint/utils.rb @@ -3,33 +3,33 @@ module HamlLint # A miscellaneous set of utility functions. module Utils - class << self - def extract_files_from(list) - files = [] + module_function - list.each do |file| - begin - Find.find(file) do |f| - files << f if haml_file?(f) - end - rescue Errno::ENOENT - # One of the paths specified does not exist; raise a more - # descriptive exception so we know which one - raise HamlLint::Exceptions::InvalidFilePath, - "File path '#{file}' does not exist" + def extract_files_from(list) + files = [] + + list.each do |file| + begin + Find.find(file) do |f| + files << f if haml_file?(f) end + rescue Errno::ENOENT + # One of the paths specified does not exist; raise a more + # descriptive exception so we know which one + raise HamlLint::Exceptions::InvalidFilePath, + "File path '#{file}' does not exist" end - - files.uniq end - private + files.uniq + end - def haml_file?(file) - return false unless FileTest.file?(file) + private - File.extname(file) == '.haml' - end + def haml_file?(file) + return false unless FileTest.file?(file) + + File.extname(file) == '.haml' end end end
Use module_function instead of class << self The `Utils` module had an unnecessary extra level of indention due to its use of `class << self` to make its helpers all class-level functions. Fix this by using the `module_function` helper, which accomplishes the same thing. Change-Id: I6194f394e111a6e7dac2672189472eb53ae62f04 Reviewed-on: http://gerrit.causes.com/42352 Tested-by: jenkins <d95b56ce41a2e1ac4cecdd398defd7414407cc08@causes.com> Reviewed-by: Shane da Silva <67fb7bfe39f841b16a1f86d3928acc568d12c716@brigade.com>
diff --git a/app/controllers/users/questions_controller.rb b/app/controllers/users/questions_controller.rb index abc1234..def5678 100644 --- a/app/controllers/users/questions_controller.rb +++ b/app/controllers/users/questions_controller.rb @@ -1,7 +1,4 @@ class Users::QuestionsController < ApplicationController - inherit_resources - belongs_to :user - def new @project = Project.find(params[:project_id]) @@ -24,4 +21,10 @@ flash.notice = "#{parent.display_name} received your question and will be in touch shortly." redirect_to project_path(project) end + + private + + def parent + @user ||= User.find(params[:user_id]) + end end
Remove inherit_resources from user questions controller
diff --git a/test/helper.rb b/test/helper.rb index abc1234..def5678 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -1,6 +1,6 @@ require 'bundler/setup' +require 'minitest/autorun' require 'minitest/spec' -require 'minitest/autorun' require 'active_record/like' ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
Fix warning for loading order in MiniTest