diff
stringlengths 65
26.7k
| message
stringlengths 7
9.92k
|
---|---|
diff --git a/has_vcards.gemspec b/has_vcards.gemspec
index abc1234..def5678 100644
--- a/has_vcards.gemspec
+++ b/has_vcards.gemspec
@@ -14,7 +14,7 @@ s.description = "vCard like contact and address models and helpers for Rails."
s.license = "MIT"
- s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
+ s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
s.test_files = Dir["spec/**/*"]
s.add_dependency "rails", "> 3.2.0"
|
Fix gemspec to use README.md, not .rdoc.
|
diff --git a/lib/extensions/ar_number_of.rb b/lib/extensions/ar_number_of.rb
index abc1234..def5678 100644
--- a/lib/extensions/ar_number_of.rb
+++ b/lib/extensions/ar_number_of.rb
@@ -2,7 +2,7 @@ class Base
def number_of(assoc)
@number_of ||= {}
- @number_of[assoc.to_sym] ||= send(assoc).size
+ @number_of[assoc.to_sym] ||= send(assoc).try!(:size) || 0
end
end
end
|
Handle gracefully missing number_of nil
Handle gracefully missing number_of nil, which can occur when
we delegate association and the receiving object is nil.4
Fixes BZ:
https://bugzilla.redhat.com/show_bug.cgi?id=1364458
|
diff --git a/lib/parker/server/user_data.rb b/lib/parker/server/user_data.rb
index abc1234..def5678 100644
--- a/lib/parker/server/user_data.rb
+++ b/lib/parker/server/user_data.rb
@@ -1,7 +1,7 @@ module Parker
def self._load(name)
- load File.join(File.expand_path("../../../../user_data", __FILE__), "#{name}.rb")
+ load File.join(File.expand_path("../../../../recipes/server.yaml", __FILE__), "#{name}.rb")
end
def self.user_data(name, domain, host)
|
Fix relative path for the userdata
|
diff --git a/lib/second_base/databases.rake b/lib/second_base/databases.rake
index abc1234..def5678 100644
--- a/lib/second_base/databases.rake
+++ b/lib/second_base/databases.rake
@@ -11,17 +11,15 @@ SecondBase.on_base { Rake::Task['db:drop'].execute }
end
+ namespace :schema do
+ task :load do
+ SecondBase.on_base { Rake::Task['db:schema:load'].execute }
+ end
+ end
+
namespace :test do
task :purge do
SecondBase.on_base { Rake::Task['db:test:purge'].execute }
- end
-
- task :load_schema do
- SecondBase.on_base { Rake::Task['db:test:load_schema'].execute }
- end
-
- task :load_structure do
- SecondBase.on_base { Rake::Task['db:test:load_structure'].execute }
end
end
end
@@ -30,5 +28,4 @@ Rake::Task['db:migrate'].enhance { Rake::Task['second_base:migrate'].invoke }
Rake::Task['db:drop'].enhance { Rake::Task['second_base:drop'].invoke }
Rake::Task['db:test:purge'].enhance { Rake::Task['second_base:test:purge'].invoke }
-Rake::Task['db:test:load_schema'].enhance { Rake::Task['second_base:test:load_schema'].invoke }
-Rake::Task['db:test:load_structure'].enhance { Rake::Task['second_base:test:load_structure'].invoke }
+Rake::Task['db:schema:load'].enhance { Rake::Task['second_base:schema:load'].invoke }
|
Fix schema dump/load for test
|
diff --git a/recipes/cli.rb b/recipes/cli.rb
index abc1234..def5678 100644
--- a/recipes/cli.rb
+++ b/recipes/cli.rb
@@ -17,6 +17,11 @@ # limitations under the License.
#
+# Install Java, unless skip_prerequisites
+unless node['cdap'].key?('skip_prerequisites') && node['cdap']['skip_prerequisites'].to_s == 'true'
+ include_recipe 'java'
+end
+
include_recipe 'cdap::repo'
package 'cdap-cli' do
|
Include Java in CLI recipe, unless skip is requested
|
diff --git a/app/controllers/spree/admin/subscriptions/customer_details_controller.rb b/app/controllers/spree/admin/subscriptions/customer_details_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/spree/admin/subscriptions/customer_details_controller.rb
+++ b/app/controllers/spree/admin/subscriptions/customer_details_controller.rb
@@ -12,9 +12,9 @@ def edit
@subscription.build_ship_address(:country_id => Spree::Config[:default_country_id]) if @subscription.ship_address.nil?
end
-
+
def update
- if @subscription.update_attributes(params[:subscription])
+ if @subscription.update_attributes(customer_params)
flash[:notice] = t('customer_details_updated')
redirect_to edit_admin_subscription_path(@subscription)
else
@@ -23,9 +23,26 @@ end
private
-
+
def load_subscription
@subscription = Subscription.find(params[:subscription_id])
+ end
+
+ def customer_params
+ params.require(:subscription).
+ permit(:email, ship_address_attributes: [
+ :firstname,
+ :lastname,
+ :address1,
+ :address2,
+ :city,
+ :zipcode,
+ :state_id,
+ :country_id,
+ :phone,
+ :id
+ ]
+ )
end
end
end
|
Add strong params to CustomerdetailsController
|
diff --git a/app/models/auto_deployment.rb b/app/models/auto_deployment.rb
index abc1234..def5678 100644
--- a/app/models/auto_deployment.rb
+++ b/app/models/auto_deployment.rb
@@ -32,7 +32,7 @@ end
def create_deployment
- description = :description => "Heaven auto deploy triggered by a commit status change"
+ description = "Heaven auto deploy triggered by a commit status change"
api.create_deployment(name_with_owner, sha, :payload => updated_payload, :description => description )
end
|
Fix issue with description for deployment
|
diff --git a/db/data_migration/20191115150548_update_sarah_albon_role.rb b/db/data_migration/20191115150548_update_sarah_albon_role.rb
index abc1234..def5678 100644
--- a/db/data_migration/20191115150548_update_sarah_albon_role.rb
+++ b/db/data_migration/20191115150548_update_sarah_albon_role.rb
@@ -0,0 +1,16 @@+ActiveRecord::Base.transaction do
+ sarah_albon = Person.find_by(forename: "Sarah", surname: "Albon")
+ correct_role = Role.find_by(name: "Chief Executive Officer, The Insolvency Service ")
+ incorrect_role = Role.find_by(name: "Interim Chief Executive Officer, The Insolvency Service ")
+
+ correct_role_appointment = sarah_albon.role_appointments.find_by(role_id: correct_role.id)
+ incorrect_role_appointment = sarah_albon.role_appointments.find_by(role_id: incorrect_role.id)
+
+ # Update consulations, publications etc. for old role appointments that must now go to the current role appointment
+ Edition.where(role_appointment_id: incorrect_role_appointment.id).each do |edition|
+ edition.role_appointment_id = correct_role_appointment.id
+ edition.save!(validate: false)
+ end
+
+ incorrect_role_appointment.delete
+end
|
Update previous role appointment for Sarah Albon
It seems the Person Sarah Albon was assigned an incorrect role appointment. The
correct role appointment has now been created, however we also need to update
all content tagged to Sarah and the incorrect role appointment.
|
diff --git a/jbuilder.gemspec b/jbuilder.gemspec
index abc1234..def5678 100644
--- a/jbuilder.gemspec
+++ b/jbuilder.gemspec
@@ -1,8 +1,8 @@ Gem::Specification.new do |s|
s.name = 'jbuilder'
s.version = '2.0.6'
- s.author = 'David Heinemeier Hansson'
- s.email = '[email protected]'
+ s.authors = ['David Heinemeier Hansson', 'Pavel Pravosud']
+ s.email = ['[email protected]', '[email protected]']
s.summary = 'Create JSON structures via a Builder-style DSL'
s.homepage = 'https://github.com/rails/jbuilder'
s.license = 'MIT'
|
Add Pavel to gemspec as an author
|
diff --git a/app/services/periodic_task.rb b/app/services/periodic_task.rb
index abc1234..def5678 100644
--- a/app/services/periodic_task.rb
+++ b/app/services/periodic_task.rb
@@ -7,7 +7,7 @@ @thread = Thread.new do
Thread.stop unless run_immediately
- while true
+ loop do
block.call
sleep every
|
Use loop for infinite loops
|
diff --git a/app/services/route_service.rb b/app/services/route_service.rb
index abc1234..def5678 100644
--- a/app/services/route_service.rb
+++ b/app/services/route_service.rb
@@ -21,8 +21,8 @@ find_shortest
end
- def load_paths(place, path = Path)
- Distance.where(origin: place).each do |distance|
+ def load_paths(point, path = Path)
+ Distance.where(origin: point).each do |distance|
@paths << path.create_new(distance)
end
end
|
Change place to point in RouteService
|
diff --git a/db/migrate/20150712194411_change_task_end_date_from_date_to_date_time.rb b/db/migrate/20150712194411_change_task_end_date_from_date_to_date_time.rb
index abc1234..def5678 100644
--- a/db/migrate/20150712194411_change_task_end_date_from_date_to_date_time.rb
+++ b/db/migrate/20150712194411_change_task_end_date_from_date_to_date_time.rb
@@ -0,0 +1,10 @@+class ChangeTaskEndDateFromDateToDateTime < ActiveRecord::Migration
+
+ def up
+ change_column :tasks, :end_date, :datetime
+ end
+
+ def down
+ change_column :tasks, :end_date, :date
+ end
+end
|
Change task end_date field from date to datetime
|
diff --git a/frontend/app/controllers/spree/admin/overview_controller.rb b/frontend/app/controllers/spree/admin/overview_controller.rb
index abc1234..def5678 100644
--- a/frontend/app/controllers/spree/admin/overview_controller.rb
+++ b/frontend/app/controllers/spree/admin/overview_controller.rb
@@ -6,12 +6,8 @@
def index
@users = User.all
- #@users = User.find_with_deleted(:all, :order => 'updated_at desc')
- # going to list today's orders, yesterday's orders, older orders
- # have a filter / search at the top
- # @orders, @
end
end
end
-end+end
|
[frontend] Remove useless comments in Admin::OverviewController
|
diff --git a/lib/action_view/form_helper.rb b/lib/action_view/form_helper.rb
index abc1234..def5678 100644
--- a/lib/action_view/form_helper.rb
+++ b/lib/action_view/form_helper.rb
@@ -15,5 +15,20 @@ end
end
+
+ module Tags
+ class TextField < Base # :nodoc:
+ def render
+ options = @options.stringify_keys
+ options["size"] = options["maxlength"] unless options.key?("size")
+ options["type"] ||= field_type
+ options["value"] = options.fetch("value") { value_before_type_cast(object) } unless field_type == "file"
+ options["value"] &&= ERB::Util.html_escape(options["value"])
+ options["aria-labelledby"] = ["label_#{add_default_name_and_id(options)}"]
+ add_default_name_and_id(options)
+ tag("input", options)
+ end
+ end
+ end
end
-end+end
|
Implement the aria-labelledby attribute in the text_field helper method. ooverride the render method to waiable gem.
|
diff --git a/lib/amazing/widgets/battery.rb b/lib/amazing/widgets/battery.rb
index abc1234..def5678 100644
--- a/lib/amazing/widgets/battery.rb
+++ b/lib/amazing/widgets/battery.rb
@@ -9,6 +9,7 @@ class Battery < Widget
description "Remaining battery power in percentage"
option :battery, "Battery number", 1
+ field :state, "Charging state, :charged, :charging or :discharging"
field :percentage, "Power percentage"
default { @percentage.to_i }
@@ -17,6 +18,7 @@ batstate = ProcFile.parse_file("acpi/battery/BAT#@battery/state")[0]
remaining = batstate["remaining capacity"].to_i
lastfull = batinfo["last full capacity"].to_i
+ @state = batstate["charging state"].to_sym
@percentage = (remaining * 100) / lastfull.to_f
end
end
|
Add @state field to Battery widget
|
diff --git a/test/support/mongrel_helper.rb b/test/support/mongrel_helper.rb
index abc1234..def5678 100644
--- a/test/support/mongrel_helper.rb
+++ b/test/support/mongrel_helper.rb
@@ -5,12 +5,13 @@
def setup
check_mongrel
- Process.spawn("bundle exec foreman start --procfile=example/Procfile", pgroup: true, out: "/dev/null", err: "/dev/null")
- self.pid = read_pid_from_file('example/tmp/mongrel2.pid')
+ self.pid = Process.spawn("bundle exec foreman start --procfile=example/Procfile", pgroup: true, out: "/dev/null", err: "/dev/null")
+ wait_for_pid('example/tmp/mongrel2.pid')
end
def teardown
Process.kill("SIGTERM", pid) if pid
+ sleep 1
end
def check_mongrel
@@ -34,4 +35,5 @@ rescue Timeout::Error
raise "Unable to read PID from file #{pidfile}."
end
+ alias :wait_for_pid :read_pid_from_file
end
|
Kill proper process parent and wait after tests to shutdown.
|
diff --git a/app/models/spree/stock/quantifier_decorator.rb b/app/models/spree/stock/quantifier_decorator.rb
index abc1234..def5678 100644
--- a/app/models/spree/stock/quantifier_decorator.rb
+++ b/app/models/spree/stock/quantifier_decorator.rb
@@ -2,7 +2,7 @@ module Stock
Quantifier.class_eval do
durably_decorate :can_supply?, mode: 'soft', sha: '2759d397d8dafe5bc3e5eed2d881fa0ab3a1a7c9' do |required|
- original_can_supply?(required) || Spree::Variant.find(@variant).product.is_gift_card?
+ original_can_supply?(required) || Spree::Variant.find(@variant.id).product.is_gift_card?
end
end
end
|
Update .find to work with rails 4.2
|
diff --git a/reagan.gemspec b/reagan.gemspec
index abc1234..def5678 100644
--- a/reagan.gemspec
+++ b/reagan.gemspec
@@ -16,6 +16,7 @@ s.add_dependency 'chef', '>= 11.0'
s.add_dependency 'ridley', '~> 4.0'
s.add_development_dependency 'rake', '~> 10.0'
+ s.add_development_dependency 'rubocop', '~> 0.28.0'
s.files = `git ls-files -z`.split("\x0")
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
Add rubocop as a dev dependency
|
diff --git a/recipes/deb.rb b/recipes/deb.rb
index abc1234..def5678 100644
--- a/recipes/deb.rb
+++ b/recipes/deb.rb
@@ -11,3 +11,12 @@ dpkg_package "#{Chef::Config[:file_cache_path]}/#{filename}" do
action :install
end
+
+ruby_block "Set heap size in /etc/default/elasticsearch" do
+ block do
+ fe = Chef::Util::FileEdit.new("/etc/default/elasticsearch")
+ fe.insert_line_if_no_match(/ES_HEAP_SIZE=/, "ES_HEAP_SIZE=#{node.elasticsearch[:allocated_memory]}")
+ fe.search_file_replace_line(/ES_HEAP_SIZE=/, "ES_HEAP_SIZE=#{node.elasticsearch[:allocated_memory]}") # if the value has changed but the line exists in the file
+ fe.write_file
+ end
+end
|
Use the heap size set in Chef via /etc/default/elasticsearch
Closes: #170
|
diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/posts_controller.rb
+++ b/app/controllers/posts_controller.rb
@@ -1,5 +1,5 @@ class PostsController < ApplicationController
- before_action :set_post, only: [:show, :edit, :update, :destroy]
+ before_action :set_post, only: [:show]
# GET /posts
# GET /posts.json
@@ -12,63 +12,9 @@ def show
end
- # GET /posts/new
- def new
- @post = Post.new
- end
-
- # GET /posts/1/edit
- def edit
- end
-
- # POST /posts
- # POST /posts.json
- def create
- @post = Post.new(post_params)
-
- respond_to do |format|
- if @post.save
- format.html { redirect_to @post, notice: 'Post was successfully created.' }
- format.json { render action: 'show', status: :created, location: @post }
- else
- format.html { render action: 'new' }
- format.json { render json: @post.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # PATCH/PUT /posts/1
- # PATCH/PUT /posts/1.json
- def update
- respond_to do |format|
- if @post.update(post_params)
- format.html { redirect_to @post, notice: 'Post was successfully updated.' }
- format.json { head :no_content }
- else
- format.html { render action: 'edit' }
- format.json { render json: @post.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # DELETE /posts/1
- # DELETE /posts/1.json
- def destroy
- @post.destroy
- respond_to do |format|
- format.html { redirect_to posts_url }
- format.json { head :no_content }
- end
- end
-
private
# Use callbacks to share common setup or constraints between actions.
def set_post
@post = Post.find(params[:id])
end
-
- # Never trust parameters from the scary internet, only allow the white list through.
- def post_params
- params[:post]
- end
end
|
Remove unneeded code in controller
|
diff --git a/app/controllers/offers_controller.rb b/app/controllers/offers_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/offers_controller.rb
+++ b/app/controllers/offers_controller.rb
@@ -20,9 +20,20 @@ end
def create
- @offer = Offer.new
+ @offer = Offer.new(offer_params)
+ @offer.posting = Posting.unscoped.find(params[:posting_id])
#authorize @offer
- @offer.posting = Posting.unscoped.find(params[:posting_id])
+ #authorize @offer.posting, :update?
+
+ respond_to do |format|
+ if @offer.save
+ format.html { redirect_to [@offer.posting], notice: 'Hey, way to go! That offer has been saved.' }
+ format.json { render action: 'show', status: :created, location: @offer }
+ else
+ format.html { render action: 'new' }
+ format.json { render json: @offer.errors, status: :unprocessable_entity }
+ end
+ end
end
def update
|
Allow offers to be posted to database.
|
diff --git a/app/controllers/tagger_controller.rb b/app/controllers/tagger_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/tagger_controller.rb
+++ b/app/controllers/tagger_controller.rb
@@ -4,7 +4,6 @@
# Saves a string to a file named filename on a user's machine
def save_local
- Tag.new(:session_id => request.session_options[:id], :data => params[:data]).save
send_data("#{params[:data]}", :filename => "#{params[:filename]}", :type => "text/plain")
end
|
Remove save from export needs to be on push to lri
|
diff --git a/app/controllers/traces_controller.rb b/app/controllers/traces_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/traces_controller.rb
+++ b/app/controllers/traces_controller.rb
@@ -3,7 +3,7 @@ @traces = Trace
.joins(:spans)
.includes(:spans)
- .where(name: 'app.rack.request')
+ .where(name: 'app.web.request.rack')
.order(start: :desc)
.limit(200)
.uniq
|
Fix name filter in web traces
|
diff --git a/lib/capybara/angular/waiter.rb b/lib/capybara/angular/waiter.rb
index abc1234..def5678 100644
--- a/lib/capybara/angular/waiter.rb
+++ b/lib/capybara/angular/waiter.rb
@@ -34,7 +34,7 @@ end
def angular_app?
- page.evaluate_script "(typeof $ != 'undefined') && $('[ng-app]')"
+ page.evaluate_script "(typeof $ != 'undefined') && $('[ng-app]').length > 0"
end
def setup_ready
|
Check if ng-app exists without returning large object
In my app, returning the hash slowed down the tests caused a lot of timeout errors
|
diff --git a/lib/ci_in_a_can/test_result.rb b/lib/ci_in_a_can/test_result.rb
index abc1234..def5678 100644
--- a/lib/ci_in_a_can/test_result.rb
+++ b/lib/ci_in_a_can/test_result.rb
@@ -18,6 +18,10 @@ CiInACan::Persistence.find PERSISTENCE_TYPE, id
end
+ def to_json
+ { id: id, passed: passed, output: output }.to_json
+ end
+
private
def self.create_the_test_result_from values
|
Add a to_json that returns real data.
|
diff --git a/app/presenters/courses_presenter.rb b/app/presenters/courses_presenter.rb
index abc1234..def5678 100644
--- a/app/presenters/courses_presenter.rb
+++ b/app/presenters/courses_presenter.rb
@@ -30,7 +30,7 @@ end
def courses_by_recent_edits
- courses.sort_by(&:recent_edit_count)
+ courses.sort_by(&:recent_edit_count).reverse
end
def word_count
|
Sort courses from high to low recent edits
|
diff --git a/lib/filters/post/admonition.rb b/lib/filters/post/admonition.rb
index abc1234..def5678 100644
--- a/lib/filters/post/admonition.rb
+++ b/lib/filters/post/admonition.rb
@@ -4,8 +4,8 @@ html.gsub!(/<p>#{Filters.front_wrap}\s*#tip\s*#{Filters.end_wrap}<\/p>/, '<div class="alert tip">')
html.gsub!(/<p>#{Filters.front_wrap}\s*#note\s*#{Filters.end_wrap}<\/p>/, '<div class="alert note">')
html.gsub!(/<p>#{Filters.front_wrap}\s*#warning\s*#{Filters.end_wrap}<\/p>/, '<div class="alert warning">')
- html.gsub!(/<p>#{Filters.front_wrap}\s*#error\s*#{Filters.end_wrap}<\/p>/, '<div class="alert error">')
- html.gsub!(/<p>#{Filters.front_wrap}\s*\/(tip|note|warning|error)\s*#{Filters.end_wrap}<\/p>/, '</div>')
+ html.gsub!(/<p>#{Filters.front_wrap}\s*#danger\s*#{Filters.end_wrap}<\/p>/, '<div class="alert danger">')
+ html.gsub!(/<p>#{Filters.front_wrap}\s*\/(tip|note|warning|danger)\s*#{Filters.end_wrap}<\/p>/, '</div>')
end
end
end
|
Rename 'error' to 'danger', take it or leave it
|
diff --git a/app/serializers/event_serializer.rb b/app/serializers/event_serializer.rb
index abc1234..def5678 100644
--- a/app/serializers/event_serializer.rb
+++ b/app/serializers/event_serializer.rb
@@ -4,6 +4,6 @@ has_many :performances, embed: :ids, include: true
def performances
- object.performances.select { |performance| performance.artist.image }.sort_by(&:id)
+ object.performances.select { |performance| performance.artist.image.present? }.sort_by(&:id)
end
end
|
Load performances having artist with image
|
diff --git a/app/services/create_subscription.rb b/app/services/create_subscription.rb
index abc1234..def5678 100644
--- a/app/services/create_subscription.rb
+++ b/app/services/create_subscription.rb
@@ -3,7 +3,7 @@ def self.call(params)
# plan is object with data relative to plan, stated in seed.
plan_id = Plan.find_by_amount(params[:plan]).id
- instance = Instance.find_by_name(params[:instance][:name])
+ instance = Instance.find_by_name(params[:instance])
sub = Subscription.new do |s|
s.plan_id = plan_id
|
Modify access to instance in params
|
diff --git a/lib/phil_columns/seed_utils.rb b/lib/phil_columns/seed_utils.rb
index abc1234..def5678 100644
--- a/lib/phil_columns/seed_utils.rb
+++ b/lib/phil_columns/seed_utils.rb
@@ -22,7 +22,7 @@ end
def seed_filepaths
- seeds = Dir.glob( "#{seeds_path}/*" )
+ seeds = Dir.glob( "#{seeds_path}/**/*.rb" )
if config.down
seeds.sort { |a,b| b <=> a }
else
|
Change glob to return only ruby files so that other assets may be pu under db/seeds without causing problems.
|
diff --git a/app/controllers/choices_controller.rb b/app/controllers/choices_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/choices_controller.rb
+++ b/app/controllers/choices_controller.rb
@@ -7,8 +7,11 @@
post '/choices' do
@survey = Survey.find_by(id: params[:survey_id])
+ @question = Question.find_by(id: params[:question_id])
@choice = Choice.new(params[:choice])
- unless @choice.save
+ if @choice.save
+ PotentialReply.create(choice: @choice, question: @question)
+ else
@errors = @choice.errors
end
erb :'/choices/new'
|
Update choices controller to create new potential reply
|
diff --git a/app/controllers/resumes_controller.rb b/app/controllers/resumes_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/resumes_controller.rb
+++ b/app/controllers/resumes_controller.rb
@@ -44,6 +44,6 @@ end
def resume_params
- params.require(:resume).permit(:name, :description, :published, education_experience_ids: [], project_ids: [], skills_ids: [], work_experience_ids: [])
+ params.require(:resume).permit(:name, :description, :published, education_experience_ids: [], project_ids: [], skill_ids: [], work_experience_ids: [])
end
end
|
Fix typo in resume_params. Should be skill_ids, not skills_ids
Signed-off-by: Max Fierke <[email protected]>
|
diff --git a/app/controllers/scripts_controller.rb b/app/controllers/scripts_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/scripts_controller.rb
+++ b/app/controllers/scripts_controller.rb
@@ -8,11 +8,11 @@ end
cmd = "#{Rails.root}/lib/scripts/#{ params[:script] }"
- cmd = "#{Rails.root}/script/runner -e #{ Rails.env } #{ cmd }"
-
-
+ cmd = "#{Rails.root}/script/rails runner -e #{ Rails.env } #{ cmd }"
+
+
result = ""
- Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thread|
+ Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thread|
result += stdout.read
errors = stderr.read
if !errors.blank?
|
Update scripts controller to work with Rails 3.
|
diff --git a/spec/controllers/apidocs_controller_spec.rb b/spec/controllers/apidocs_controller_spec.rb
index abc1234..def5678 100644
--- a/spec/controllers/apidocs_controller_spec.rb
+++ b/spec/controllers/apidocs_controller_spec.rb
@@ -39,5 +39,12 @@ Project.count.should == 1
Person.count.should == 1
end
+
+ it 'should show documentation for all documented models' do
+ ApidocsController::DOCUMENTED_MODELS.each do |model|
+ get :model, :model => model
+ response.should be_success
+ end
+ end
end
|
Add spec for viewing the apidocs models
|
diff --git a/app/controllers/sitemap_controller.rb b/app/controllers/sitemap_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/sitemap_controller.rb
+++ b/app/controllers/sitemap_controller.rb
@@ -1,11 +1,16 @@ class SitemapController < ApplicationController
def index
- @static_pages = [root_url, about_url, contact_url, faq_url, login_url, signup_url]
- @frequently_updated_pages = [forum_url]
+ @static_pages = static_pages
@courses = Course.all
respond_to do |format|
format.xml
end
end
- end+
+ private
+
+ def static_pages
+ [root_url, about_url, contact_url, faq_url, login_url, signup_url].freeze
+ end
+ end
|
Move the static pages array to the private method, remove the @frequently_updated_pages
|
diff --git a/lib/tablexi/logger/standard.rb b/lib/tablexi/logger/standard.rb
index abc1234..def5678 100644
--- a/lib/tablexi/logger/standard.rb
+++ b/lib/tablexi/logger/standard.rb
@@ -8,7 +8,9 @@ attr_reader :logger
attr_reader :severity
- def initialize(logger, options = { severity: :unknown })
+ def initialize(logger, options = {})
+ defaults = { severity: :unknown }
+ options = defaults.merge(options)
severity = options[:severity]
raise ArgumentError, "Severity `#{severity}` must be one of #{SEVERITIES}" unless SEVERITIES.include?(severity)
|
Rework options hash to potentially handle multiples
|
diff --git a/app/views/api/v1/sessions/base.rabl b/app/views/api/v1/sessions/base.rabl
index abc1234..def5678 100644
--- a/app/views/api/v1/sessions/base.rabl
+++ b/app/views/api/v1/sessions/base.rabl
@@ -2,9 +2,13 @@ node(:client_id) { SecureRandom.hex(16) }
child(current_user) do
extends 'api/v1/users/private'
-
+
child :clouds => :clouds do
extends 'api/v1/clouds/base'
end
-
-end+
+ child :bans => :bans do
+ extends 'api/v1/bans/base'
+ end
+
+end
|
Return an array of bans on the session user.
|
diff --git a/app/presenters/tree_node/menu/item.rb b/app/presenters/tree_node/menu/item.rb
index abc1234..def5678 100644
--- a/app/presenters/tree_node/menu/item.rb
+++ b/app/presenters/tree_node/menu/item.rb
@@ -3,7 +3,7 @@ class Item < TreeNode::Menu::Node
set_attribute(:key) { "#{@tree.node_id_prefix}__#{@object.feature}" }
- set_attribute(:text, :tooltip) do
+ set_attributes(:text, :tooltip) do
details = ::MiqProductFeature.obj_features[@object.feature].try(:[], :feature).try(:details)
[_(details[:name]), _(details[:description]) || _(details[:name])]
end
|
Fix the title/tooltip attribute setting for TreeNode::Menu::Item
|
diff --git a/app/models/manageiq/providers/container_manager/metrics_capture.rb b/app/models/manageiq/providers/container_manager/metrics_capture.rb
index abc1234..def5678 100644
--- a/app/models/manageiq/providers/container_manager/metrics_capture.rb
+++ b/app/models/manageiq/providers/container_manager/metrics_capture.rb
@@ -11,7 +11,7 @@
def with_archived(scope)
# We will look also for freshly archived entities, if the entity was short-lived or even sub-hour
- archived_from = targets_archived_from
+ archived_from = Metric::Targets.targets_archived_from
scope.where(:deleted_on => nil).or(scope.where(:deleted_on => (archived_from..Time.now.utc)))
end
end
|
Fix targets_archived_from after refactoring to MetricsCapture
When we moved the capture_ems_targets out of Metrics::Capture and into
provider subclasses we didn't catch that this method being called is
still in Metric::Capture
|
diff --git a/test/integration/smoke_test.rb b/test/integration/smoke_test.rb
index abc1234..def5678 100644
--- a/test/integration/smoke_test.rb
+++ b/test/integration/smoke_test.rb
@@ -8,15 +8,17 @@
def test_simple_zip_code_search
result = Geocoder.search "27701"
- assert_equal "Durham", result.first.city
- assert_equal "North Carolina", result.first.state
+ assert_not_nil (r = result.first)
+ assert_equal "Durham", r.city
+ assert_equal "North Carolina", r.state
end
def test_simple_zip_code_search_with_ssl
Geocoder::Configuration.use_https = true
result = Geocoder.search "27701"
- assert_equal "Durham", result.first.city
- assert_equal "North Carolina", result.first.state
+ assert_not_nil (r = result.first)
+ assert_equal "Durham", r.city
+ assert_equal "North Carolina", r.state
ensure
Geocoder::Configuration.use_https = false
end
|
Add separate assertion for getting a result at all.
|
diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/home_controller.rb
+++ b/app/controllers/home_controller.rb
@@ -10,7 +10,6 @@ @events = meetup_api.open_events(params) ## Currently events just gets
end ## dumped straight into the page. It is ugly, but there is information,
## and we can get better information out of it :)
-
def about
end
end
|
Fix breaky function by changing nothing
|
diff --git a/lib/bowery/executable.rb b/lib/bowery/executable.rb
index abc1234..def5678 100644
--- a/lib/bowery/executable.rb
+++ b/lib/bowery/executable.rb
@@ -24,12 +24,7 @@ eval assetfile
%w(stylesheets javascripts).each do |type|
manifest = Manifest.new type, components, options
-
- if manifest.save
- say "Saved #{type} manifest to #{manifest.path}."
- else
- say "Error saving #{type} manifest."
- end
+ create_file manifest.path, manifest.contents
end
end
|
Create manifest file in init
|
diff --git a/library/openssl/cipher_spec.rb b/library/openssl/cipher_spec.rb
index abc1234..def5678 100644
--- a/library/openssl/cipher_spec.rb
+++ b/library/openssl/cipher_spec.rb
@@ -0,0 +1,17 @@+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/constants'
+require 'openssl'
+
+describe "OpenSSL::Cipher's CipherError" do
+ ruby_version_is "" ... "1.8.7" do
+ it "exists under OpenSSL namespace" do
+ OpenSSL.should have_constant :CipherError
+ end
+ end
+
+ ruby_version_is "1.8.7" do
+ it "exists under OpenSSL::Cipher namespace" do
+ OpenSSL::Cipher.should have_constant :CipherError
+ end
+ end
+end
|
Add a trivial spec for the location of CipherError in OpenSSL (JRUBY-3163)
|
diff --git a/app/controllers/gms_by_scenario_controller.rb b/app/controllers/gms_by_scenario_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/gms_by_scenario_controller.rb
+++ b/app/controllers/gms_by_scenario_controller.rb
@@ -7,7 +7,7 @@ # have to put things in a hash, so that we can deal with it.
@tables_by_scenario = {}
@event.unique_scenarios.each { |scenario| @tables_by_scenario[scenario] = [] }
- @event.tables.each do |table|
+ @event.player_tables.each do |table|
@tables_by_scenario[table.scenario] << table
end
|
Remove HQ from list of tables for scenarios
Will need to add back later
|
diff --git a/lib/braingasm/tokenizer.rb b/lib/braingasm/tokenizer.rb
index abc1234..def5678 100644
--- a/lib/braingasm/tokenizer.rb
+++ b/lib/braingasm/tokenizer.rb
@@ -35,7 +35,11 @@
private
def read_token(scanner)
- simple_tokens = { '+' => :plus,
+ return scanner.matched.to_i if scanner.scan(/\d+/)
+ @@simple_tokens[scanner.scan(/\S/)] || :unknown
+ end
+
+ @@simple_tokens = { '+' => :plus,
'-' => :minus,
'<' => :left,
'>' => :right,
@@ -48,11 +52,6 @@ '[' => :loop_start,
']' => :loop_end }
- return scanner.matched.to_i if scanner.scan(/\d+/)
-
- simple_tokens[scanner.scan(/\S/)] || :unknown
- end
-
end
end
|
Initialize tokens hash outside method
|
diff --git a/spec/github_cli/commands/references_spec.rb b/spec/github_cli/commands/references_spec.rb
index abc1234..def5678 100644
--- a/spec/github_cli/commands/references_spec.rb
+++ b/spec/github_cli/commands/references_spec.rb
@@ -0,0 +1,42 @@+# encoding: utf-8
+
+require 'spec_helper'
+
+describe GithubCLI::Commands::References do
+ let(:format) { 'table' }
+ let(:user) { 'peter-murach' }
+ let(:repo) { 'github_cli' }
+ let(:ref) { 'refs/master' }
+ let(:sha) { '3a0f86fb8db8eea7ccbb9a95f325ddbedfb25e15' }
+ let(:api_class) { GithubCLI::Reference }
+
+ it "invokes ref:list" do
+ api_class.should_receive(:list).with(user, repo, {}, format)
+ subject.invoke "ref:list", [user, repo]
+ end
+
+ it "invokes ref:list --ref" do
+ api_class.should_receive(:list).with(user, repo, {"ref" => ref}, format)
+ subject.invoke "ref:list", [user, repo], :ref => ref
+ end
+
+ it "invokes ref:get" do
+ api_class.should_receive(:get).with(user, repo, ref, {}, format)
+ subject.invoke "ref:get", [user, repo, ref]
+ end
+
+ it "invokes ref:create --ref --sha" do
+ api_class.should_receive(:create).with(user, repo, {"ref" => ref, "sha" => sha}, format)
+ subject.invoke "ref:create", [user, repo], :ref => ref, :sha => sha
+ end
+
+ it "invokes ref:update --sha -f" do
+ api_class.should_receive(:update).with(user, repo, ref, {"sha" => sha, "force" => false}, format)
+ subject.invoke "ref:update", [user, repo, ref], :sha => sha
+ end
+
+ it "invokes ref:delete" do
+ api_class.should_receive(:delete).with(user, repo, ref, {}, format)
+ subject.invoke "ref:delete", [user, repo, ref]
+ end
+end
|
Add specs for references commands.
|
diff --git a/spec/lib/generators/admin_generator_spec.rb b/spec/lib/generators/admin_generator_spec.rb
index abc1234..def5678 100644
--- a/spec/lib/generators/admin_generator_spec.rb
+++ b/spec/lib/generators/admin_generator_spec.rb
@@ -37,4 +37,31 @@ expect(User.count).to eq(0)
end
end
+
+ context "with attributes from stdin" do
+ before(:each) do
+ admin = FactoryBot.build(:user)
+
+ fake_stdin(admin.slice(:email, :username, :password).values) do
+ run_generator ["admin"]
+ end
+ end
+
+ it "creates a user admin" do
+ created_admin = User.last
+ expect(created_admin).not_to be_nil
+ expect(created_admin.is_admin).to be true
+ end
+ end
+
+ private
+
+ def fake_stdin(*args)
+ $stdin = StringIO.new
+ $stdin.puts(args.shift) until args.empty?
+ $stdin.rewind
+ yield
+ ensure
+ $stdin = STDIN
+ end
end
|
Test admin generator with fake stdin
|
diff --git a/lib/specjour/db_scrub.rb b/lib/specjour/db_scrub.rb
index abc1234..def5678 100644
--- a/lib/specjour/db_scrub.rb
+++ b/lib/specjour/db_scrub.rb
@@ -9,6 +9,7 @@ load 'tasks/misc.rake'
load 'tasks/databases.rake'
Rake::Task["db:structure:dump"].clear
+ Rake::Task["environment"].clear
end
extend self
|
Fix load exceptions by not reloading environment
|
diff --git a/lib/state_machine_job.rb b/lib/state_machine_job.rb
index abc1234..def5678 100644
--- a/lib/state_machine_job.rb
+++ b/lib/state_machine_job.rb
@@ -19,6 +19,7 @@ perform_with_result(record, payload)
rescue Exception => e
logger.error "#{self.name} - exception for #{model_name} #{id}: #{e.inspect}"
+ e.backtrace.each { |line| logger.info(line) }
:error
end
|
Add backtrace info to exception logging
|
diff --git a/lib/string_extensions.rb b/lib/string_extensions.rb
index abc1234..def5678 100644
--- a/lib/string_extensions.rb
+++ b/lib/string_extensions.rb
@@ -1,3 +1,5 @@+# Here are some test comments...
+
class String
# Duplicates the current string by count and returns that as a new string.
|
Test change commit with tortoise.
|
diff --git a/lib/workers/scheduler.rb b/lib/workers/scheduler.rb
index abc1234..def5678 100644
--- a/lib/workers/scheduler.rb
+++ b/lib/workers/scheduler.rb
@@ -1,6 +1,7 @@ module Workers
class Scheduler
def initialize(options = {})
+ @logger = options[:logger]
@pool = options[:pool] || Workers::Pool.new
@schedule = SortedSet.new
@mutex = Mutex.new
|
Add missing logger option to Scheduler.
|
diff --git a/services/libratometrics.rb b/services/libratometrics.rb
index abc1234..def5678 100644
--- a/services/libratometrics.rb
+++ b/services/libratometrics.rb
@@ -1,7 +1,8 @@ # encoding: utf-8
class Service::LibratoMetrics < Service
def receive_logs
- name = settings[:name].gsub(/ +/, '_')
+ name = settings[:name] || payload[:saved_search][:name]
+ name = name.gsub!(/ +/, '_')
# values[hostname][time]
values = Hash.new do |h,k|
|
Use saved search name as default value for Librato Metrics gauge name
|
diff --git a/services/libratometrics.rb b/services/libratometrics.rb
index abc1234..def5678 100644
--- a/services/libratometrics.rb
+++ b/services/libratometrics.rb
@@ -0,0 +1,30 @@+# encoding: utf-8
+class Service::LibratoMetrics < Service
+ def receive_logs
+ values = Hash.new { |h,k| h[k] = 0 }
+
+ payload[:events].each do |event|
+ time = Time.parse(event[:received_at])
+ time = time.to_i - (time.to_i % 60)
+ values[time] += 1
+ end
+
+ gauges = values.collect do |time, count|
+ {
+ :name => settings[:name],
+ :value => count,
+ :measure_time => time
+ }
+ end
+
+ http.basic_auth settings[:user], settings[:token]
+
+ res = http_post 'https://metrics-api.librato.com/v1/metrics.json' do |req|
+ req.headers[:content_type] = 'application/json'
+
+ req.body = {
+ :gauges => gauges
+ }.to_json
+ end
+ end
+end
|
Rename Silverline service to LibratoMetrics
|
diff --git a/db/migrate/20170210192526_bigbluebutton_rails200_recording_size.rb b/db/migrate/20170210192526_bigbluebutton_rails200_recording_size.rb
index abc1234..def5678 100644
--- a/db/migrate/20170210192526_bigbluebutton_rails200_recording_size.rb
+++ b/db/migrate/20170210192526_bigbluebutton_rails200_recording_size.rb
@@ -0,0 +1,5 @@+class BigbluebuttonRails200RecordingSize < ActiveRecord::Migration
+ def change
+ change_column :bigbluebutton_recordings, :size, :integer, limit: 8, default: 0
+ end
+end
|
Add missing migration from BigbluebuttonRails 2.0.0
The column size was ok in most of the servers but not in others, where the
migration to BigbluebuttonRails was done in several steps.
|
diff --git a/lib/icsfilter.rb b/lib/icsfilter.rb
index abc1234..def5678 100644
--- a/lib/icsfilter.rb
+++ b/lib/icsfilter.rb
@@ -10,12 +10,14 @@ @output = output ? output : calendar
end
- def filter#(filters, replacements)
- filters = Regexp.union(/\AKSA \/ fri\z/, /\AKSA \/ Lukket\z/)
- replacements = Regexp.union(/\AKSA \/ /, /\AStudy Activity\, : /)
+ def filter(filters)
+ @events.reject! { |event| event.summary.match(filters) }
- @events.reject! { |event| event.summary.match(filters) }
- @events.each { |event| event.summary.gsub!(replacements, '') }
+ self
+ end
+
+ def replace(targets, substitute = '')
+ @events.each { |event| event.summary.gsub!(targets, substitute) }
self
end
|
Split filter into two functions: filter and replace
The new filter function rejects whole events.
The replace function replaces regular expression matches with the
provided substitute.
|
diff --git a/db/migrations/015_add_amount_paid_to_orders.rb b/db/migrations/015_add_amount_paid_to_orders.rb
index abc1234..def5678 100644
--- a/db/migrations/015_add_amount_paid_to_orders.rb
+++ b/db/migrations/015_add_amount_paid_to_orders.rb
@@ -1,7 +1,7 @@ Sequel.migration do
up do
- add_column :orders, :amount_paid, :Bignum
+ add_column :orders, :amount_paid, Bignum
end
down do
|
Revert "Fix bug 'Unsupported ruby class used as database type: Bignum'"
This reverts commit dd345e564912d0892dd79b15fe815c7169293284.
|
diff --git a/lib/nifty-report/report.rb b/lib/nifty-report/report.rb
index abc1234..def5678 100644
--- a/lib/nifty-report/report.rb
+++ b/lib/nifty-report/report.rb
@@ -9,7 +9,7 @@ end
def filename
- @name.downcase.gsub(' ', '.') + ".#{Time.now.strftime('%F')}.csv"
+ @name.downcase.gsub(' ', '.') + ".#{Time.now.strftime('%F.%H:%M')}.csv"
end
def csv
|
Include hours and minutes in filename
|
diff --git a/lib/rack-canonical-host.rb b/lib/rack-canonical-host.rb
index abc1234..def5678 100644
--- a/lib/rack-canonical-host.rb
+++ b/lib/rack-canonical-host.rb
@@ -2,7 +2,8 @@ class CanonicalHost
def initialize(app, host=nil, &block)
@app = app
- @host = (block_given? && block.call) || host
+ @host = host
+ @block = block
end
def call(env)
@@ -14,11 +15,16 @@ end
def url(env)
- if @host && env['SERVER_NAME'] != @host
+ if (host = host(env)) && env['SERVER_NAME'] != host
url = Rack::Request.new(env).url
- url.sub(%r{\A(https?://)(.*?)(:\d+)?(/|$)}, "\\1#{@host}\\3/")
+ url.sub(%r{\A(https?://)(.*?)(:\d+)?(/|$)}, "\\1#{host}\\3/")
end
end
private :url
+
+ def host(env)
+ @block ? @block.call(env) || @host : @host
+ end
+ private :host
end
end
|
Allow env to be passed to the optional block.
|
diff --git a/lib/resume/file_fetcher.rb b/lib/resume/file_fetcher.rb
index abc1234..def5678 100644
--- a/lib/resume/file_fetcher.rb
+++ b/lib/resume/file_fetcher.rb
@@ -17,6 +17,9 @@ end
def fetch
+ # Specifically uses Kernel here in order to allow it to determine
+ # the return file type: for this resume, it could be File, TempFile,
+ # or StringIO
Kernel.open(file, &block)
rescue SocketError, OpenURI::HTTPError, Errno::ECONNREFUSED
raise NetworkConnectionError
|
Add comment about using Kernel in file fetcher
|
diff --git a/lib/tasks/import_sic_codes.rake b/lib/tasks/import_sic_codes.rake
index abc1234..def5678 100644
--- a/lib/tasks/import_sic_codes.rake
+++ b/lib/tasks/import_sic_codes.rake
@@ -0,0 +1,14 @@+require 'csv'
+desc "Import SIC Codes from /app/assets/csv/sic_codes.csv"
+namespace :import do
+ task :sic_codes => :environment do
+ counter = 0
+ CSV.foreach("#{Rails.root}/app/assets/csv/sic_codes.csv", :headers => false) do |row|
+ unless row[0].blank?
+ counter += 1
+ SicCode.create(:code => row[0], :industry => row[1], :subindustry => row[2])
+ end
+ end
+ puts "#{counter} SIC Codes imported"
+ end
+end
|
Create import SicCode rake task
|
diff --git a/lib/stash_engine/engine.rb b/lib/stash_engine/engine.rb
index abc1234..def5678 100644
--- a/lib/stash_engine/engine.rb
+++ b/lib/stash_engine/engine.rb
@@ -5,7 +5,11 @@
# Initializer to combine this engines static assets with the static assets of the hosting site.
initializer 'static assets' do |app|
- app.middleware.insert_before(::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public")
+ # in production these should be served by the web server? we think? (DM 2016-11-09)
+ # see http://stackoverflow.com/questions/30563342/rails-cant-start-when-serve-static-assets-disabled-in-production
+ if Rails.application.config.serve_static_files
+ app.middleware.insert_before(::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public")
+ end
end
end
# see http://stackoverflow.com/questions/20734766/rails-mountable-engine-how-should-apps-set-configuration-variables
|
Check serve_static_files before trying to load ActionDispatch::Static
|
diff --git a/lib/syoboemon/connector.rb b/lib/syoboemon/connector.rb
index abc1234..def5678 100644
--- a/lib/syoboemon/connector.rb
+++ b/lib/syoboemon/connector.rb
@@ -5,45 +5,43 @@ DB_PATH = "/db.php"
JSON_PATH = "/json.php"
- class << self
- def rss2_get(query)
- connection.get(rss2_path, query)
+ def rss2_get(query)
+ connection.get(rss2_path, query)
+ end
+
+ def db_get(query)
+ connection.get(db_path, query)
+ end
+
+ def json_get(query)
+ connection.get(json_path, query)
+ end
+
+ private
+
+ def connection
+ connection ||= Faraday::Connection.new(url: url) do |c|
+ c.request :url_encoded
+ c.response :logger
+ c.adapter :net_http
+ c.response :raise_error
end
+ end
- def db_get(query)
- connection.get(db_path, query)
- end
+ def url
+ URL
+ end
- def json_get(query)
- connection.get(json_path, query)
- end
+ def rss2_path
+ RSS2_PATH
+ end
- private
+ def db_path
+ DB_PATH
+ end
- def connection
- connection ||= Faraday::Connection.new(url: url) do |c|
- c.request :url_encoded
- c.response :logger
- c.adapter :net_http
- c.response :raise_error
- end
- end
-
- def url
- URL
- end
-
- def rss2_path
- RSS2_PATH
- end
-
- def db_path
- DB_PATH
- end
-
- def json_path
- JSON_PATH
- end
+ def json_path
+ JSON_PATH
end
end
end
|
Change to class from module(Syoboemon::Connector)
|
diff --git a/lib/trlo/list_presenter.rb b/lib/trlo/list_presenter.rb
index abc1234..def5678 100644
--- a/lib/trlo/list_presenter.rb
+++ b/lib/trlo/list_presenter.rb
@@ -1,6 +1,7 @@ module Trlo
class ListPresenter
def initialize(board_id)
+ raise BoardNotFound, "No board specified, no lists found." if board_id.nil?
@board_id = board_id
end
|
Raise exception if a board_id is not provided.
We ought to validate board_ids.
|
diff --git a/lib/wulin_master/engine.rb b/lib/wulin_master/engine.rb
index abc1234..def5678 100644
--- a/lib/wulin_master/engine.rb
+++ b/lib/wulin_master/engine.rb
@@ -4,5 +4,8 @@
class Engine < Rails::Engine
engine_name :wulin_master
+ initializer "add assets to precompile" do |app|
+ app.config.assets.precompile += %w( master/master.js master.css )
+ end
end
end
|
Configure wulin_master to precompile master.js and master.css
|
diff --git a/lib/xclisten/shell_task.rb b/lib/xclisten/shell_task.rb
index abc1234..def5678 100644
--- a/lib/xclisten/shell_task.rb
+++ b/lib/xclisten/shell_task.rb
@@ -4,7 +4,7 @@
def self.run(args)
puts args + "\n\n"
- `#{args}`
+ fork { exec args }
end
end
|
Use fork and exec instead of backticks for subprocesses
|
diff --git a/lib/rack/spec.rb b/lib/rack/spec.rb
index abc1234..def5678 100644
--- a/lib/rack/spec.rb
+++ b/lib/rack/spec.rb
@@ -2,8 +2,8 @@ require "json_schema"
require "multi_json"
+require "rack/spec/error"
require "rack/spec/error_handler"
-require "rack/spec/error"
require "rack/spec/request_validation"
require "rack/spec/schema"
require "rack/spec/version"
|
Sort loaded files in ABC-order
|
diff --git a/app.rb b/app.rb
index abc1234..def5678 100644
--- a/app.rb
+++ b/app.rb
@@ -28,6 +28,13 @@ # ...
end
+ configure do
+ Braintree::Configuration.environment = :sandbox
+ Braintree::Configuration.merchant_id = ENV['BRAINTREE_MERCHANT']
+ Braintree::Configuration.public_key = ENV['BRAINTREE_PUBLIC']
+ Braintree::Configuration.private_key = ENV['BRAINTREE_PRIVATE']
+ end
+
helpers do
include Rack::Utils
alias_method :h, :escape_html
|
Add global config for braintree
|
diff --git a/app.rb b/app.rb
index abc1234..def5678 100644
--- a/app.rb
+++ b/app.rb
@@ -22,14 +22,14 @@ "https://img.shields.io/badge/#{badge}.svg"
end
-def redirect_to_badge
+def redirect_to_badge(query)
begin
status_code = open(heroku_url).status.first
rescue OpenURI::HTTPError => error
response = error.io
status_code = response.status.first
end
- redirect badge_url(badge status_code)
+ redirect badge_url(badge status_code) + query
end
get '/' do
@@ -46,5 +46,5 @@ response.headers['Last-Modified'] = Time.now.httpdate
response.headers['ETag'] = Time.now.utc.strftime("%s%L")
- redirect_to_badge
+ redirect_to_badge request.env['rack.request.query_string']
end
|
Support querystrings in badge URL
This allows the use of the other shields.io badge styles.
|
diff --git a/config/environments/development.rb b/config/environments/development.rb
index abc1234..def5678 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -14,7 +14,8 @@ config.action_controller.perform_caching = false
# Don't care if the mailer can't send.
- config.action_mailer.raise_delivery_errors = false
+ config.action_mailer.raise_delivery_errors = true
+ config.action_mailer.default_url_options = { host: 'example.com' }
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
@@ -38,4 +39,5 @@
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
+ #
end
|
Add Dev Config To Deliver Emails For Testing
|
diff --git a/config/initializers/carrierwave.rb b/config/initializers/carrierwave.rb
index abc1234..def5678 100644
--- a/config/initializers/carrierwave.rb
+++ b/config/initializers/carrierwave.rb
@@ -6,7 +6,7 @@ :aws_secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'],
:region => 'us-east-1',
}
- config.fog_directory = 'speakerinnen'
+ config.fog_directory = ENV['AWS_BUCKET_NAME']
config.fog_public = false
config.fog_attributes = {'Cache-Control'=>'max-age=315576000'}
config.storage = :fog
|
Change the aws bucket name to a env variable
|
diff --git a/config/initializers/carrierwave.rb b/config/initializers/carrierwave.rb
index abc1234..def5678 100644
--- a/config/initializers/carrierwave.rb
+++ b/config/initializers/carrierwave.rb
@@ -1,7 +1,6 @@ CarrierWave.configure do |config|
- if ENV.fetch('S3_BUCKET').present?
- IMAGE_UPLOAD = true
-
+ IMAGE_UPLOAD = false
+ begin
config.storage = :fog
config.fog_credentials = {
provider: 'AWS',
@@ -10,7 +9,7 @@ region: 'us-east-1'
}
config.fog_directory = ENV.fetch('S3_BUCKET')
- else
- IMAGE_UPLOAD = false
+ IMAGE_UPLOAD = true
+ rescue KeyError
end
end
|
Use rescue as conditional on environment variable
|
diff --git a/roles/grisu.rb b/roles/grisu.rb
index abc1234..def5678 100644
--- a/roles/grisu.rb
+++ b/roles/grisu.rb
@@ -30,6 +30,9 @@ :squid => {
:cache_mem => "9000 MB",
:cache_dir => "coss /store/squid/coss-01 128000 block-size=8192 max-size=262144 membufs=80"
+ },
+ :tilecache => {
+ :tile_parent => "beauharnois.render.openstreetmap.org"
}
)
|
Switch beauharnois cache to use render.openstreetmap.org
|
diff --git a/lsd.rb b/lsd.rb
index abc1234..def5678 100644
--- a/lsd.rb
+++ b/lsd.rb
@@ -5,7 +5,7 @@ MUSIC_DIRECTORY = File.expand_path '~/test_music/'
get '/songs' do
- Dir[MUSIC_DIRECTORY + '/*'].join ' '
+ @songs = Dir[MUSIC_DIRECTORY + '/*']
end
get '/' do
|
Put contents of music dir in @songs
|
diff --git a/benchmark-ips/bm_is_number.rb b/benchmark-ips/bm_is_number.rb
index abc1234..def5678 100644
--- a/benchmark-ips/bm_is_number.rb
+++ b/benchmark-ips/bm_is_number.rb
@@ -0,0 +1,29 @@+# Why .$$is_number is better than isNaN:
+#
+#
+# Warming up --------------------------------------
+# .$$is_number 106.722k i/100ms
+# isNaN() 105.040k i/100ms
+# obj.$$is_number 106.864k i/100ms
+# isNaN(obj) 89.287k i/100ms
+# Calculating -------------------------------------
+# .$$is_number 12.052M (± 6.6%) i/s - 59.978M in 5.002614s
+# isNaN() 12.338M (± 5.4%) i/s - 61.448M in 4.997957s
+# obj.$$is_number 12.514M (± 6.8%) i/s - 62.302M in 5.005715s
+# isNaN(obj) 4.211M (± 5.9%) i/s - 20.982M in 5.001643s
+#
+# Comparison:
+# obj.$$is_number: 12513664.2 i/s
+# isNaN(): 12338259.3 i/s - same-ish: difference falls within error
+# .$$is_number: 12051756.8 i/s - same-ish: difference falls within error
+# isNaN(obj): 4211175.7 i/s - 2.97x slower
+#
+Benchmark.ips do |x|
+ number = 123
+ number_obj = 123.itself
+ x.report(".$$is_number") { number.JS['$$is_number'] }
+ x.report("isNaN()") { `!isNaN(number)` }
+ x.report("obj.$$is_number") { number_obj.JS['$$is_number'] }
+ x.report("isNaN(obj)") { `!isNaN(number_obj)` }
+ x.compare!
+end
|
Add a bm-ips that compares .$$is_number to isNaN()
|
diff --git a/spec/features/likeable_spec.rb b/spec/features/likeable_spec.rb
index abc1234..def5678 100644
--- a/spec/features/likeable_spec.rb
+++ b/spec/features/likeable_spec.rb
@@ -6,35 +6,35 @@ let(:post) { FactoryBot.create(:post) }
context 'logged in member' do
- before do
- login_as member
- visit post_path(post)
- end
+ before { login_as member }
- it 'can be liked' do
- expect(page).to have_link 'Like'
- click_link 'Like'
- expect(page).to have_content '1 like'
+ describe 'posts' do
+ before { visit post_path(post) }
+ it 'can be liked' do
+ expect(page).to have_link 'Like'
+ click_link 'Like'
+ expect(page).to have_css(".like-count", text: "1")
- visit post_path(post)
+ visit post_path(post)
- expect(page).to have_link 'Unlike'
- click_link 'Unlike'
- expect(page).to have_content '0 likes'
- end
+ expect(page).to have_link 'Unlike'
+ click_link 'Unlike'
+ expect(page).to have_css(".like-count", text: "0")
+ end
- it 'displays correct number of likes' do
- expect(page).to have_link 'Like'
- click_link 'Like'
- expect(page).to have_content '1 like'
- logout(member)
+ it 'displays correct number of likes' do
+ expect(page).to have_link 'Like'
+ click_link 'Like'
+ expect(page).to have_css(".like-count", text: "1")
- login_as(another_member)
- visit post_path(post)
+ logout(member)
+ login_as(another_member)
+ visit post_path(post)
- expect(page).to have_link 'Like'
- click_link 'Like'
- expect(page).to have_content '2 likes'
+ expect(page).to have_link 'Like'
+ click_link 'Like'
+ expect(page).to have_css(".like-count", text: "2")
+ end
end
end
end
|
Update posts liking spec to find where the count moved to
|
diff --git a/spec/lib/staging/model_spec.rb b/spec/lib/staging/model_spec.rb
index abc1234..def5678 100644
--- a/spec/lib/staging/model_spec.rb
+++ b/spec/lib/staging/model_spec.rb
@@ -1,7 +1,10 @@ require 'rails_helper'
describe Stagehand::Staging::Model do
- let(:klass) { Klass = Class.new(SourceRecord) }
+ let(:klass) do
+ Object.send(:remove_const, :Klass) if Object.const_defined?(:Klass)
+ Klass = Class.new(SourceRecord)
+ end
context 'when included in a model' do
before { klass.establish_connection(Stagehand.configuration.production_connection_name) }
|
Fix const redefinition warning in model spec
|
diff --git a/spec/models/user_model_spec.rb b/spec/models/user_model_spec.rb
index abc1234..def5678 100644
--- a/spec/models/user_model_spec.rb
+++ b/spec/models/user_model_spec.rb
@@ -7,7 +7,10 @@ end
it "is invalid without an email address" do
- user = User.new(email: nil)
+ user = User.new(
+ username:"honeybadger",
+ password_digest: "ilikedacoco",
+ email: nil)
user.valid?
expect(User.all).not_to include user
end
|
Edit test to make sure it passes because email was missing.
|
diff --git a/spec/support/authentication.rb b/spec/support/authentication.rb
index abc1234..def5678 100644
--- a/spec/support/authentication.rb
+++ b/spec/support/authentication.rb
@@ -21,12 +21,8 @@ @stub_user ||= FactoryBot.create(:user)
end
- def login_as_user(user)
+ def login_as_user(user = stub_user)
GDS::SSO.test_user = user
- end
-
- def login_as_stub_user
- GDS::SSO.test_user = stub_user
end
end
@@ -38,6 +34,6 @@
config.include AuthenticationFeatureHelpers, :type => :feature
config.before(:each, type: :feature) do
- login_as_stub_user
+ login_as_user
end
end
|
Replace two login_as methods with a single method
The default behaviour of login_as_user will login as the stub user,
else it will use the defined user.
|
diff --git a/cookbooks/role-monitoring/metadata.rb b/cookbooks/role-monitoring/metadata.rb
index abc1234..def5678 100644
--- a/cookbooks/role-monitoring/metadata.rb
+++ b/cookbooks/role-monitoring/metadata.rb
@@ -1,4 +1,4 @@-name 'role_monitoring'
+name 'role-monitoring'
maintainer 'Tim Smith'
maintainer_email '[email protected]'
license 'Apache 2.0'
|
Fix name of monitoring role
|
diff --git a/db/post_migrate/20190102152410_delete_inconsistent_internal_id_records2.rb b/db/post_migrate/20190102152410_delete_inconsistent_internal_id_records2.rb
index abc1234..def5678 100644
--- a/db/post_migrate/20190102152410_delete_inconsistent_internal_id_records2.rb
+++ b/db/post_migrate/20190102152410_delete_inconsistent_internal_id_records2.rb
@@ -0,0 +1,43 @@+# frozen_string_literal: true
+class DeleteInconsistentInternalIdRecords2 < ActiveRecord::Migration[5.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ # This migration cleans up any inconsistent records in internal_ids.
+ #
+ # That is, it deletes records that track a `last_value` that is
+ # smaller than the maximum internal id (usually `iid`) found in
+ # the corresponding model records.
+
+ def up
+ disable_statement_timeout do
+ delete_internal_id_records('milestones', 'project_id')
+ delete_internal_id_records('milestones', 'namespace_id', 'group_id')
+ end
+ end
+
+ class InternalId < ActiveRecord::Base
+ self.table_name = 'internal_ids'
+ enum usage: { issues: 0, merge_requests: 1, deployments: 2, milestones: 3, epics: 4, ci_pipelines: 5 }
+ end
+
+ private
+
+ def delete_internal_id_records(base_table, scope_column_name, base_scope_column_name = scope_column_name)
+ sql = <<~SQL
+ SELECT id FROM ( -- workaround for MySQL
+ SELECT internal_ids.id FROM (
+ SELECT #{base_scope_column_name} AS #{scope_column_name}, max(iid) as maximum_iid from #{base_table} GROUP BY #{scope_column_name}
+ ) maxima JOIN internal_ids USING (#{scope_column_name})
+ WHERE internal_ids.usage=#{InternalId.usages.fetch(base_table)} AND maxima.maximum_iid > internal_ids.last_value
+ ) internal_ids
+ SQL
+
+ InternalId.where("id IN (#{sql})").tap do |ids| # rubocop:disable GitlabSecurity/SqlInjection
+ say "Deleting internal_id records for #{base_table}: #{ids.map { |i| [i.project_id, i.last_value] }}" unless ids.empty?
+ end.delete_all
+ end
+end
|
Add migration to cleanup iid records
|
diff --git a/app/helpers/devise_helper.rb b/app/helpers/devise_helper.rb
index abc1234..def5678 100644
--- a/app/helpers/devise_helper.rb
+++ b/app/helpers/devise_helper.rb
@@ -8,8 +8,8 @@ resource: resource.class.model_name.human.downcase)
html = <<-HTML
- <div class="alert alert-danger">
- <button type="button" class="close" data-dismiss="alert">×</button>
+ <div class="alert alert-danger alert-dismissable fade in">
+ <button type="button" class="close" data-dismiss="alert" aria-hidden="true"><span class="glyphicon glyphicon-remove-circle"></span></button>
<h4>#{sentence}</h4>
#{messages}
</div>
|
Fix Devise flash alert classes
|
diff --git a/samples/ec2.rb b/samples/ec2.rb
index abc1234..def5678 100644
--- a/samples/ec2.rb
+++ b/samples/ec2.rb
@@ -11,13 +11,31 @@
ec2 = AWS::EC2.new ENV["AWS_KEY"], ENV["AWS_SECRET"]
-ec2.describe_addresses.addresses_set.each do |address|
+puts "", "Standard Only Addresses", ""
+
+ec2.describe_addresses("Filter" => {"domain" => "standard"}).addresses_set.each do |address|
puts "IP: #{address.public_ip}"
puts "Instance ID: #{address.instance_id}"
puts "Domain: #{address.domain}"
- if address.domain == "vpc"
- puts "Allocation ID: #{address.allocation_id}"
- puts "Association ID: #{address.association_id}"
- end
puts ""
end
+
+puts "", "VPC Only addresses", ""
+
+ec2.describe_addresses("Filter" => {"domain" => "vpc"}).addresses_set.each do |address|
+ puts "IP: #{address.public_ip}"
+ puts "Instance ID: #{address.instance_id}"
+ puts "Domain: #{address.domain}"
+ puts "Allocation ID: #{address.allocation_id}"
+ puts "Association ID: #{address.association_id}"
+ puts ""
+end
+
+puts "", "Ask for both explicitly", ""
+
+ec2.describe_addresses("Filter" => {"domain" => ["standard", "vpc"]}).addresses_set.each do |address|
+ puts "IP: #{address.public_ip}"
+ puts "Instance ID: #{address.instance_id}"
+ puts "Domain: #{address.domain}"
+ puts ""
+end
|
Update sample to show parameter usage
|
diff --git a/routes/test.rb b/routes/test.rb
index abc1234..def5678 100644
--- a/routes/test.rb
+++ b/routes/test.rb
@@ -1,7 +1,7 @@ # The main class for the TravisWebhook
class KWApi < Sinatra::Base
get '/test' do
- title = 'Haml Test'
+ @title = 'Haml Test'
haml :test
end
end
|
Change variable to instance variable
|
diff --git a/test/models/car_test.rb b/test/models/car_test.rb
index abc1234..def5678 100644
--- a/test/models/car_test.rb
+++ b/test/models/car_test.rb
@@ -3,9 +3,7 @@ class CarTest < ActiveSupport::TestCase
test "at least one field is filled" do
refute Car.new().valid?
- assert Car.new({description: 'A shitty van hit me'}).valid?
- assert cars(:volvo).valid?
- assert cars(:bmw).valid?
+ assert Car.new({description: 'A shitty van hit me', incident: incidents(:one)}).valid?
end
test "license plate always in uppercase" do
|
Update validation test with assoc. constraint
|
diff --git a/week-6/nested_data_solution.rb b/week-6/nested_data_solution.rb
index abc1234..def5678 100644
--- a/week-6/nested_data_solution.rb
+++ b/week-6/nested_data_solution.rb
@@ -0,0 +1,47 @@+# RELEASE 2: NESTED STRUCTURE GOLF
+# Hole 1
+# Target element: "FORE"
+
+array = [[1,2], ["inner", ["eagle", "par", ["FORE", "hook"]]]]
+
+# attempts:
+# ============================================================
+
+
+
+# ============================================================
+
+# Hole 2
+# Target element: "congrats!"
+
+hash = {outer: {inner: {"almost" => {3 => "congrats!"}}}}
+
+# attempts:
+# ============================================================
+
+
+
+# ============================================================
+
+
+# Hole 3
+# Target element: "finished"
+
+nested_data = {array: ["array", {hash: "finished"}]}
+
+# attempts:
+# ============================================================
+
+
+
+# ============================================================
+
+# RELEASE 3: ITERATE OVER NESTED STRUCTURES
+
+number_array = [5, [10, 15], [20,25,30], 35]
+
+
+
+# Bonus:
+
+startup_names = ["bit", ["find", "fast", ["optimize", "scope"]]]
|
Create file for pairing session
|
diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb
index abc1234..def5678 100644
--- a/app/models/media_attachment.rb
+++ b/app/models/media_attachment.rb
@@ -12,10 +12,6 @@ end
def file_remote_url=(url)
- unless self[:file_remote_url] == url
- self.file = URI.parse(url)
- end
-
- self[:file_remote_url] = url
+ self.file = URI.parse(url)
end
end
|
Fix for media attachments remote URL download
|
diff --git a/config/initializers/rails_config.rb b/config/initializers/rails_config.rb
index abc1234..def5678 100644
--- a/config/initializers/rails_config.rb
+++ b/config/initializers/rails_config.rb
@@ -3,7 +3,7 @@ end
ActiveSupport.on_load(:before_initialize) do
# Add other global settings files
- other_files = ["institutions", "sfx_databases", "solr", "sunspot", "capistrano", "authpds", "#{Rails.env}"]
+ other_files = ["institutions", "sfx_databases", "solr", "sunspot", "capistrano", "authpds", "newrelic", "#{Rails.env}"]
RailsConfig.load_and_set_settings(
Rails.root.join("config", "settings.yml").to_s,
*other_files.collect { |setting| Rails.root.join("config", "settings", "#{setting}.yml").to_s },
|
Add newrelic.yml to load order
|
diff --git a/spec/lib/from_yaml_spec.rb b/spec/lib/from_yaml_spec.rb
index abc1234..def5678 100644
--- a/spec/lib/from_yaml_spec.rb
+++ b/spec/lib/from_yaml_spec.rb
@@ -8,7 +8,8 @@ FromYaml.load(path_to_yaml: "#{Rails.root}/spec/support/bad_yaml_file.yml",
cache_key: 'test')
end
- it 'raises an error if a loaded file is misformatted' do
+ it 'outputs the filename when loading a misformatted file causes an error' do
+ expect(STDOUT).to receive(:puts).with(/.*bad_yaml_file.*/)
expect { subject }.to raise_error(NoMethodError)
end
end
|
Test the intended error handling of FromYaml more precisely
|
diff --git a/spec/support/connect_db.rb b/spec/support/connect_db.rb
index abc1234..def5678 100644
--- a/spec/support/connect_db.rb
+++ b/spec/support/connect_db.rb
@@ -3,6 +3,10 @@ DB = Sequel.connect(ENV['DATABASE_URL'] || 'postgres:///prelay-test')
DB.extension :pg_json
+
+# Check that we don't request the same column multiple times.
+DB.extension :duplicate_columns_handler
+DB.opts[:on_duplicate_columns] = :raise
# Simple way to spec what queries are being run.
logger = Object.new
|
Raise if the specs accidentally request the same column twice.
|
diff --git a/app/uploaders/base_uploader.rb b/app/uploaders/base_uploader.rb
index abc1234..def5678 100644
--- a/app/uploaders/base_uploader.rb
+++ b/app/uploaders/base_uploader.rb
@@ -34,9 +34,4 @@ def extension_white_list
%w(jpg jpeg png)
end
-
- # Override the filename of the uploaded files
- def filename
- "file.png" if original_filename
- end
end
|
Remove useless default filename definition.
|
diff --git a/app/values/renalware/gender.rb b/app/values/renalware/gender.rb
index abc1234..def5678 100644
--- a/app/values/renalware/gender.rb
+++ b/app/values/renalware/gender.rb
@@ -13,7 +13,7 @@ SALUTATIONS = {
"NK" => "",
"M" => "Mr",
- "F" => "Mme",
+ "F" => "Ms",
"NS" => ""
}.freeze
|
Use Ms for default F salutation
|
diff --git a/lib/dry/view/part.rb b/lib/dry/view/part.rb
index abc1234..def5678 100644
--- a/lib/dry/view/part.rb
+++ b/lib/dry/view/part.rb
@@ -3,18 +3,18 @@ module Dry
module View
class Part
- include Dry::Equalizer(:_object, :_renderer, :_context, :_locals)
+ include Dry::Equalizer(:_object, :_locals, :_context, :_renderer)
attr_reader :_object
+ attr_reader :_locals
+ attr_reader :_context
attr_reader :_renderer
- attr_reader :_context
- attr_reader :_locals
def initialize(object = nil, renderer:, context: nil, locals: {})
@_object = object
+ @_locals = locals
+ @_context = context
@_renderer = renderer
- @_context = context
- @_locals = locals
end
def __render(partial_name, object = _object, **locals, &block)
|
Tidy order of attrs in Part
|
diff --git a/lib/labor/helpers.rb b/lib/labor/helpers.rb
index abc1234..def5678 100644
--- a/lib/labor/helpers.rb
+++ b/lib/labor/helpers.rb
@@ -1,7 +1,7 @@ module Labor
module Helpers
- def classify(dashed_word)
- dashed_word.split('-').each { |part| part[0] = part[0].chr.upcase }.join
+ def classify(word)
+ word.split(/-_/).each { |part| part[0] = part[0].chr.upcase }.join
end
def constantize(camel_cased_word)
|
Split on hyphen and underscores for job names
|
diff --git a/lib/resume/output.rb b/lib/resume/output.rb
index abc1234..def5678 100644
--- a/lib/resume/output.rb
+++ b/lib/resume/output.rb
@@ -5,7 +5,7 @@ extend Colours
def self.messages(messages)
- messages.each { |type, key| public_send(key, type) }
+ messages.each { |type, key| public_send(type, key) }
end
def self.error(key)
@@ -32,8 +32,8 @@ puts I18n.t(*key)
end
- def self.raw(key)
- puts key # aka the message
+ def self.raw(message)
+ puts message
end
end
end
|
Fix bug with parameters in the wrong order
|
diff --git a/lib/shopify_theme.rb b/lib/shopify_theme.rb
index abc1234..def5678 100644
--- a/lib/shopify_theme.rb
+++ b/lib/shopify_theme.rb
@@ -2,15 +2,19 @@ module ShopifyTheme
include HTTParty
+ NOOPParser = Proc.new {|data, format| {} }
+
def self.asset_list
- response = shopify.get("/admin/assets.json")
+ # HTTParty parser chokes on assest listing, have it noop
+ # and then use a rel JSON parser.
+ response = shopify.get("/admin/assets.json", :parser => NOOPParser)
assets = JSON.parse(response.body)["assets"].collect {|a| a['key'] }
# Remove any .css files if a .css.liquid file exists
assets.reject{|a| assets.include?("#{a}.liquid") }
end
def self.get_asset(asset)
- response = shopify.get("/admin/assets.json", :query =>{:asset => {:key => asset}})
+ response = shopify.get("/admin/assets.json", :query =>{:asset => {:key => asset}}, :parser => NOOPParser)
# HTTParty json parsing is broken?
JSON.parse(response.body)["asset"]
end
|
Fix HTTParty json parsing choking in 1.9
|
diff --git a/lib/tasks/morph.rake b/lib/tasks/morph.rake
index abc1234..def5678 100644
--- a/lib/tasks/morph.rake
+++ b/lib/tasks/morph.rake
@@ -6,6 +6,20 @@ url = "https://api.morph.io/equivalentideas/westconnex_contracts/data.json?key=#{ENV['MORPH_SECRET_KEY']}&query=select%20*%20from%20'contractors'"
contractors = JSON.parse(open(url).read)
- p "Found #{contractors.count} contractors"
+ current_count = Contractor.count
+ contractors.each do |c|
+ Contractor.create(
+ abn: c["abn"],
+ name: c["name"],
+ acn: c["acn"],
+ street_adress: c["street_address"],
+ city: c["city"],
+ state: c["state"],
+ postcode: c["postcode"],
+ country: c["country"]
+ )
+ end
+
+ p "Created #{Contractor.count - current_count} new contractors"
end
end
|
Load in the new contractors
|
diff --git a/lib/sastrawi/morphology/disambiguator/disambiguator_prefix_rule32.rb b/lib/sastrawi/morphology/disambiguator/disambiguator_prefix_rule32.rb
index abc1234..def5678 100644
--- a/lib/sastrawi/morphology/disambiguator/disambiguator_prefix_rule32.rb
+++ b/lib/sastrawi/morphology/disambiguator/disambiguator_prefix_rule32.rb
@@ -0,0 +1,19 @@+module Sastrawi
+ module Morphology
+ module Disambiguator
+ class DisambiguatorPrefixRule32
+ def disambiguate(word)
+ return 'ajar' if word == 'pelajar'
+
+ contains = /^pe(l[aiueo])(.*)$/.match(word)
+
+ if contains
+ matches = contains.captures
+
+ return matches[0] << matches[1]
+ end
+ end
+ end
+ end
+ end
+end
|
Add implementation of thirtieth-second rule of disambiguator prefix
|
diff --git a/db/migrate/20170106112835_add_funding_request_amount_to_funding_request.rb b/db/migrate/20170106112835_add_funding_request_amount_to_funding_request.rb
index abc1234..def5678 100644
--- a/db/migrate/20170106112835_add_funding_request_amount_to_funding_request.rb
+++ b/db/migrate/20170106112835_add_funding_request_amount_to_funding_request.rb
@@ -0,0 +1,7 @@+class AddFundingRequestAmountToFundingRequest < ActiveRecord::Migration
+ def change
+ unless column_exists? :funding_requests, :funding_request_amount
+ add_column :funding_requests, :funding_request_amount, :integer, :null => false
+ end
+ end
+end
|
Migrate for Fixing up the javascript to populate the amounts & percents properly when a bucket is selected or if the Funding Line Item's line amount changes.
|
diff --git a/pen_and_paper/binary_search.rb b/pen_and_paper/binary_search.rb
index abc1234..def5678 100644
--- a/pen_and_paper/binary_search.rb
+++ b/pen_and_paper/binary_search.rb
@@ -4,18 +4,22 @@ def bin_search(a, k)
offset = 0
length = a.size
- while length > 0 && offset < a.size
+ c = 0
+ while length > 0
+ c += 1
half = length / 2
index = offset + half
- puts "#{k} #{index}"
case
when a[index] == k
+ puts "#{a.size} #{c}"
return index
when a[index] < k
offset = index
end
length = half
end
+
+ puts "#{a.size} #{c}"
return -1
end
|
Improve binary search by actually paying attention to the invariant
|
diff --git a/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb b/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb
index abc1234..def5678 100644
--- a/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb
+++ b/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb
@@ -15,11 +15,7 @@ result = SystemCommand.run("/usr/bin/curl", args: ["--compressed", "--location", "--user-agent", URL::FAKE_USER_AGENT, @uri], print_stderr: false)
checkpoint = if result.success?
- processed_appcast_text = result.stdout.gsub(%r{<pubDate>[^<]*</pubDate>}, "")
-
- # This step is necessary to replicate running `sed` from the command line
- processed_appcast_text << "\n" unless processed_appcast_text.end_with?("\n")
-
+ processed_appcast_text = result.stdout.gsub(%r{<pubDate>[^<]*</pubDate>}m, "")
Digest::SHA2.hexdigest(processed_appcast_text)
end
|
Change regex to catch multi-line `pubDate` tags.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.