diff stringlengths 65 26.7k | message stringlengths 7 9.92k |
|---|---|
diff --git a/lib/gir_ffi/zero_terminated.rb b/lib/gir_ffi/zero_terminated.rb
index abc1234..def5678 100644
--- a/lib/gir_ffi/zero_terminated.rb
+++ b/lib/gir_ffi/zero_terminated.rb
@@ -7,7 +7,6 @@
def initialize elm_t, ptr
@element_type = elm_t
- @ffi_type = TypeMap.map_basic_type_or_string elm_t
@ptr = ptr
end
@@ -27,7 +26,10 @@ return if @ptr.null?
offset = 0
while val = read_value(offset)
- offset += FFI.type_size(@ffi_type)
+ offset += FFI.type_size(ffi_type)
+ if complex_element_type?
+ val = element_class.wrap val
+ end
yield val
end
end
@@ -36,11 +38,37 @@
def read_value offset
val = @ptr.send("get_#{ffi_type}", offset)
- return val unless val == 0
+ return val unless is_null_value(val)
end
def ffi_type
- @ffi_type ||= TypeMap.map_basic_type_or_string element_type
+ @ffi_type ||= TypeMap.map_basic_type_or_string basic_element_type
+ end
+
+ def complex_element_type?
+ Array === element_type
+ end
+
+ def basic_element_type
+ if complex_element_type?
+ element_type.first
+ else
+ element_type
+ end
+ end
+
+ def is_null_value value
+ if basic_element_type == :pointer
+ value.null?
+ else
+ value == 0
+ end
+ end
+
+ def element_class
+ if complex_element_type?
+ element_type.last
+ end
end
end
end
| Make ZeroTerminated work for arrays of pointers to objects
|
diff --git a/examples/custom_coercion_spec.rb b/examples/custom_coercion_spec.rb
index abc1234..def5678 100644
--- a/examples/custom_coercion_spec.rb
+++ b/examples/custom_coercion_spec.rb
@@ -0,0 +1,50 @@+require './spec/spec_helper'
+
+class MD5 < Virtus::Attribute::Object
+ primitive String
+ coercion_method :to_md5
+end
+
+module Virtus
+ class Coercion
+ class String < Virtus::Coercion::Object
+ def self.to_md5(value)
+ Digest::MD5.hexdigest(value)
+ end
+ end
+ end
+end
+
+class User
+ include Virtus
+
+ attribute :name, String
+ attribute :password, MD5
+end
+
+describe User do
+ it { should respond_to(:name) }
+ it { should respond_to(:name=) }
+ it { should respond_to(:password) }
+ it { should respond_to(:password=) }
+
+ describe '#name=' do
+ let(:value) { 'Piotr' }
+
+ before do
+ subject.name = value
+ end
+
+ its(:name) { should == value }
+ end
+
+ describe '#password=' do
+ let(:value) { 'foobar' }
+
+ before do
+ subject.password = value
+ end
+
+ its(:password) { should == Virtus::Coercion::String.to_md5(value) }
+ end
+end
| Add specs for examples in README
|
diff --git a/breezy_rails/lib/breezy/render.rb b/breezy_rails/lib/breezy/render.rb
index abc1234..def5678 100644
--- a/breezy_rails/lib/breezy/render.rb
+++ b/breezy_rails/lib/breezy/render.rb
@@ -1,5 +1,11 @@ module Breezy
module Render
+ DEFAULT_ACTIONS_FOR_VERBS = {
+ :post => 'new',
+ :patch => 'edit',
+ :put => 'edit'
+ }
+
def default_render(*args)
if @_use_breezy_html
render(*args)
@@ -21,7 +27,8 @@ end
if breezy
- view_parts = _prefixes.reverse.push(action_name)[1..-1]
+ action = render_options[action] || DEFAULT_ACTIONS_FOR_VERBS[request.request_method_symbol] || action_name
+ view_parts = _prefixes.reverse.push(action)[1..-1]
view_name = view_parts.map(&:camelize).join.gsub('::', '')
breezy[:screen] ||= view_name
| Add default screen names for post patch and put
|
diff --git a/lib/octokit/client/licenses.rb b/lib/octokit/client/licenses.rb
index abc1234..def5678 100644
--- a/lib/octokit/client/licenses.rb
+++ b/lib/octokit/client/licenses.rb
@@ -12,7 +12,7 @@ # @example
# Octokit.licenses
def licenses(options = {})
- options = ensure_license_api_media_type(options)
+ options = ensure_api_media_type(:licenses, options)
paginate "licenses", options
end
| Change one last reference to ensure_license_api_media_type
|
diff --git a/lib/palletjack/tool-support.rb b/lib/palletjack/tool-support.rb
index abc1234..def5678 100644
--- a/lib/palletjack/tool-support.rb
+++ b/lib/palletjack/tool-support.rb
@@ -0,0 +1,35 @@+# Support functions used by the Pallet Jack tools
+
+require 'rugged'
+
+# Return a string stating the Git provenance of a warehouse directory,
+# suitable for inclusion at the top of a generated configuration file,
+# with each line prefixed by +comment_char+.
+#
+# If +warehouse_path+ points within a Git repository, return a string
+# stating its absolute path, active branch and commit ID.
+#
+# If Git information cannot be found for +warehouse_path+, return a
+# string stating its path and print an error message on stderr.
+
+def git_header(tool_name, warehouse_path, comment_char = '#')
+ repo = Rugged::Repository.discover(warehouse_path)
+ workdir = repo.workdir
+ branch = repo.head.name
+ commit = repo.head.target_id
+ return "#{comment_char}#{comment_char}
+#{comment_char}#{comment_char} Automatically generated by #{tool_name} from
+#{comment_char}#{comment_char} Repository: #{workdir}
+#{comment_char}#{comment_char} Branch: #{branch}
+#{comment_char}#{comment_char} Commit ID: #{commit}
+#{comment_char}#{comment_char}
+
+"
+rescue
+ STDERR.puts "Error finding Git sourcing information: #{$!}"
+ return "#{comment_char}#{comment_char}
+#{comment_char}#{comment_char} Automatically generated by #{tool_name} from #{warehouse_path}
+#{comment_char}#{comment_char}
+
+"
+end
| Move function for writing Git provenance header into a support module
All tools will want to use this function, so move it out of the tool itself to
a common file.
|
diff --git a/lib/travis/api/app/endpoint.rb b/lib/travis/api/app/endpoint.rb
index abc1234..def5678 100644
--- a/lib/travis/api/app/endpoint.rb
+++ b/lib/travis/api/app/endpoint.rb
@@ -14,7 +14,7 @@
# TODO hmmm?
before { flash.clear }
- before { content_type :json }
+ after { content_type :json unless content_type }
error(ActiveRecord::RecordNotFound, Sinatra::NotFound) { not_found }
not_found { content_type =~ /json/ ? { 'file' => 'not found' } : 'file not found' }
| Set json content type only when content type is not set
|
diff --git a/lib/tumblargh/resource/blog.rb b/lib/tumblargh/resource/blog.rb
index abc1234..def5678 100644
--- a/lib/tumblargh/resource/blog.rb
+++ b/lib/tumblargh/resource/blog.rb
@@ -31,7 +31,7 @@ end
def fetch!
- attributes = fetch
+ self.attributes = fetch
end
def posts
| Make the linter happy :)
|
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
@@ -3,7 +3,7 @@ # In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
-config.cache_classes = false
+config.cache_classes = true
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
| Secure fix for gravatar images
|
diff --git a/capistrano-resque-pool.gemspec b/capistrano-resque-pool.gemspec
index abc1234..def5678 100644
--- a/capistrano-resque-pool.gemspec
+++ b/capistrano-resque-pool.gemspec
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
# Maintain your gem's version:
-require 'capistrano/resque/pool/version'
+require 'capistrano-resque-pool/version'
Gem::Specification.new do |spec|
spec.name = "capistrano-resque-pool"
| Change path to gem version
|
diff --git a/app/s3_uploader.rb b/app/s3_uploader.rb
index abc1234..def5678 100644
--- a/app/s3_uploader.rb
+++ b/app/s3_uploader.rb
@@ -6,18 +6,26 @@ # http://docs.aws.amazon.com/sdkforruby/api/index.html
class S3Uploader
+ DEFAULT_PUT_OPTIONS = {
+ acl: 'public-read',
+ server_side_encryption: 'AES256',
+ storage_class: 'REDUCED_REDUNDANCY', # accepts STANDARD, REDUCED_REDUNDANCY, LT
+ }
+
def initialize(bucket_name = nil)
@s3 = Aws::S3::Resource.new
bkt = bucket_name || ENV['AWS_S3_BUCKET'] || (raise ArgumentError, 'S3 Bucket name is missing')
@bucket = @s3.bucket(bkt)
end
- def put(key, file)
+ def put(key, file, opts ={})
obj = @bucket.object(key)
- obj.put(body: file)
+ put_opts = DEFAULT_PUT_OPTIONS.merge(opts).merge({ body: file })
+
+ obj.put(put_opts)
end
- def self.put(key, file, bucket: nil)
- new(bucket).put(key, file)
+ def self.put(key, file, opts = {})
+ new(opts[:bucket]).put(key, file, opts)
end
end
| Use AES256 server-side encryption and reduced_redundancy storage class
|
diff --git a/test/serializer_support_test.rb b/test/serializer_support_test.rb
index abc1234..def5678 100644
--- a/test/serializer_support_test.rb
+++ b/test/serializer_support_test.rb
@@ -2,6 +2,13 @@
class RandomModel
include ActiveModel::SerializerSupport
+end
+
+class OtherRandomModel
+ include ActiveModel::SerializerSupport
+end
+
+class OtherRandomModelSerializer
end
class RandomModelCollection
@@ -18,6 +25,10 @@ assert_equal nil, RandomModel.new.active_model_serializer
end
+ test "it returns a deducted serializer if it exists exists" do
+ assert_equal OtherRandomModelSerializer, OtherRandomModel.new.active_model_serializer
+ end
+
test "it returns ArraySerializer for a collection" do
assert_equal ActiveModel::ArraySerializer, RandomModelCollection.new.active_model_serializer
end
| Test : use a deducted serializer on non-ActiveRecord models
|
diff --git a/color_schema_validator.gemspec b/color_schema_validator.gemspec
index abc1234..def5678 100644
--- a/color_schema_validator.gemspec
+++ b/color_schema_validator.gemspec
@@ -9,9 +9,9 @@ spec.authors = ["ka"]
spec.email = ["ka.kaosf@gmail.com"]
- spec.summary = %q{TODO: Write a short summary, because Rubygems requires one.}
- spec.description = %q{TODO: Write a longer description or delete this line.}
- spec.homepage = "TODO: Put your gem's website or public repo URL here."
+ spec.summary = %q{Color schema validator for Rails.}
+ spec.description = %q{Color schema validator for Rails.}
+ spec.homepage = "https://github.com/kaosf/color_schema_validator"
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.bindir = "exe"
| Fix placeholders in gemspec file
|
diff --git a/test/tc_historical_date.rb b/test/tc_historical_date.rb
index abc1234..def5678 100644
--- a/test/tc_historical_date.rb
+++ b/test/tc_historical_date.rb
@@ -0,0 +1,27 @@+#!/usr/bin/env ruby -w
+
+$:.unshift File.join( File.dirname( __FILE__ ), '..', 'lib' )
+
+require 'test/unit'
+require 'historical_date'
+
+class HistoricalDateTest < Test::Unit::TestCase
+
+ def test_dates
+ hd = HistoricalDate.parse_date( '2010-04-05' )
+ assert_equal( hd[ :fixed ], '2010-04-05' )
+ assert_equal( hd[ :month_name ], 'April' )
+ assert_equal( hd[ :circa ], false )
+ assert_equal( hd[ :month ], 4 )
+ assert_nil( hd[ :errors ] )
+ assert_equal( hd[ :day ], 5 )
+ assert_equal( hd[ :year ], 2010 )
+ assert_equal( hd[ :full ], 'Monday, April 5, 2010 AD' )
+ assert_equal( hd[ :short ], '4/5/2010 AD' )
+ assert_equal( hd[ :era ], 'AD' )
+ assert_equal( hd[ :long ], 'April 5, 2010 AD' )
+ assert_equal( hd[ :original ], '2010-04-05' )
+ end
+
+end
+
| Add test dir, tc_date.rb file, and first test.
|
diff --git a/app/controllers/api/v1/helpers.rb b/app/controllers/api/v1/helpers.rb
index abc1234..def5678 100644
--- a/app/controllers/api/v1/helpers.rb
+++ b/app/controllers/api/v1/helpers.rb
@@ -46,7 +46,7 @@ end
def declared_params
- declared(params, include_missing: false).to_hash
+ declared(params, include_missing: false).to_hash.with_indifferent_access
end
def permitted_params(*args)
| Allow access to declared_params with key as symbol
|
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index abc1234..def5678 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -29,11 +29,11 @@ def thumbnail_url(obj)
thumbnail = (obj.has_attribute?(:thumbnail) ?
obj.thumbnail : obj.logo)
- request.protocol + request.host_with_port + thumbnail.opengraph.url
+ thumbnail.opengraph.url
end
def opengraph_thumb_url
- request.protocol + request.host_with_port + path_to_image("opengraph_default_thumbnail.png")
+ path_to_image("opengraph_default_thumbnail.png")
end
def text_field_datetime(datetime)
| Fix opengraph image urls again
|
diff --git a/app/helpers/surveys_url_helper.rb b/app/helpers/surveys_url_helper.rb
index abc1234..def5678 100644
--- a/app/helpers/surveys_url_helper.rb
+++ b/app/helpers/surveys_url_helper.rb
@@ -2,6 +2,6 @@
module SurveysUrlHelper
def course_survey_url(notification)
- "#{survey_url(notification.survey)}?course_slug=#{notification.course.slug}"
+ "#{survey_url(notification.survey)}?course_slug=#{notification.course.slug.gsub('&', '%26')}"
end
end
| Replace ampersand in course slug for survey links
We disallow "&" in a course title on the frontend, but that validation wasn't preventing submission for several months. We now have 11 courses, most of them recent (and a few much older) that have this character. It's fine except in cases where the slug is passed as a URL param, in which case it gets treated as a separated instead of being automatically encoded in by the browser. This should fix survey links that are going out to Fall 2019 courses.
|
diff --git a/test/unit/donation_test.rb b/test/unit/donation_test.rb
index abc1234..def5678 100644
--- a/test/unit/donation_test.rb
+++ b/test/unit/donation_test.rb
@@ -19,4 +19,18 @@
assert_equal Rails.application.config.gravatar_url % "aa99b351245441b8ca95d54a52d2998c", @d.gravatar_url
end
+
+ test "donation has randomly generated secret" do
+ @donation = Donation.create
+ @donation2 = Donation.new
+
+ assert_match /^[[:xdigit:]]{32}$/, @donation.secret
+ assert_match /^[[:xdigit:]]{32}$/, @donation2.secret
+
+ assert_not_equal @donation.secret, @donation2.secret
+
+ @donation3 = Donation.find(@donation.id)
+
+ assert_equal @donation.secret, @donation3.secret
+ end
end
| Test Donation has random secret
|
diff --git a/lib/rfd.rb b/lib/rfd.rb
index abc1234..def5678 100644
--- a/lib/rfd.rb
+++ b/lib/rfd.rb
@@ -3,6 +3,7 @@
class Window
def draw(contents)
+ @win.setpos 0, 0
@win.addstr contents
@win.refresh
end
| Set position before each draw
|
diff --git a/lib/tty.rb b/lib/tty.rb
index abc1234..def5678 100644
--- a/lib/tty.rb
+++ b/lib/tty.rb
@@ -41,6 +41,9 @@ # Raised when the argument validation fails
class ArgumentValidation < ArgumentError; end
+ # Raised when the argument is not expected
+ class InvalidArgument < ArgumentError; end
+
# Raised when the passed in validation argument is of wrong type
class ValidationCoercion < TypeError; end
| Add invalid argument error type.
|
diff --git a/postman.rb b/postman.rb
index abc1234..def5678 100644
--- a/postman.rb
+++ b/postman.rb
@@ -28,18 +28,18 @@ @@normal_sleep += 1
@@low_sleep += 1
- if(@@normal_sleep == 12)
+ if(@@normal_sleep == Postman.settings['normal_sleep'])
mails.concat Postman.find_mails(MailNormal, Postman.settings['normal_quota'])
@@normal_sleep = 0
end
- if(@@low_sleep == 54)
+ if(@@low_sleep == Postman.settings['low_sleep'])
mails.concat Postman.find_mails(MailLow, Postman.settings['low_quota'])
@@low_sleep = 0
end
Postman.send_mails(mails)
- sleep 5
+ sleep Postman.settings['sleep']
end
end
end
| Move sleep variables into settings file
|
diff --git a/config/subscribers/customer.rb b/config/subscribers/customer.rb
index abc1234..def5678 100644
--- a/config/subscribers/customer.rb
+++ b/config/subscribers/customer.rb
@@ -8,7 +8,7 @@ :deleted_at,
:bill_to_location_id,
:ship_to_location_id,
- :is_tax_excempt,
+ :is_tax_exempt,
:is_active,
:uuid
end
| Remove incorrect c from is_tax_exempt
|
diff --git a/app/models/hyrax/uploaded_file.rb b/app/models/hyrax/uploaded_file.rb
index abc1234..def5678 100644
--- a/app/models/hyrax/uploaded_file.rb
+++ b/app/models/hyrax/uploaded_file.rb
@@ -10,7 +10,5 @@ class_name: 'JobIoWrapper',
dependent: :destroy
belongs_to :user, class_name: '::User'
-
- before_destroy :remove_file!
end
end
| Remove unnecessary callback
Carrierwave installs an after_commit callback to run delete_file!
|
diff --git a/EnumeratorKit.podspec b/EnumeratorKit.podspec
index abc1234..def5678 100644
--- a/EnumeratorKit.podspec
+++ b/EnumeratorKit.podspec
@@ -16,7 +16,6 @@ collection classes.
EOS
- s.ios.deployment_target = '5.1.1'
s.requires_arc = true
s.homepage = 'https://github.com/sharplet/EnumeratorKit'
| Remove explicit iOS deployment target from podspec
|
diff --git a/GDPerformanceView.podspec b/GDPerformanceView.podspec
index abc1234..def5678 100644
--- a/GDPerformanceView.podspec
+++ b/GDPerformanceView.podspec
@@ -7,8 +7,8 @@ s.author = { "Gavrilov Daniil" => "daniilmbox@gmail.com" }
s.platform = :ios, "8.0"
s.ios.deployment_target = "8.0"
- s.source = { :git => "https://github.com/dani-gavrilov/GDPerformanceView.git", :tag => "1.0.0" }
+ s.source = { :git => "https://github.com/dani-gavrilov/GDPerformanceView.git", :tag => "1.0.1" }
s.source_files = "GDPerformanceView/GDPerformanceMonitoring/*"
- s.frameworks = "UIKit", "Foundation", "QuartzCore", "mach"
+ s.frameworks = "UIKit", "Foundation", "QuartzCore"
s.requires_arc = true
end
| Fix pod spec frameworks list
Remove ‘mach’ from list, because it is not a framework
|
diff --git a/yaks-html/lib/yaks-html.rb b/yaks-html/lib/yaks-html.rb
index abc1234..def5678 100644
--- a/yaks-html/lib/yaks-html.rb
+++ b/yaks-html/lib/yaks-html.rb
@@ -3,6 +3,6 @@ require 'yaks/format/html'
-> do
- unparser = Hexp::Unparser.new({})
+ unparser = Hexp::Unparser.new({no_escape: [:script, :style]})
Yaks::Serializer.register(:html, ->(data, env) { unparser.call(data) })
end.call
| Stop Hexp from escaping `<style>` stuff
This will be fixed in Hexp as well, but this way people aren't forced to
upgrade.
|
diff --git a/.delivery/build/metadata.rb b/.delivery/build/metadata.rb
index abc1234..def5678 100644
--- a/.delivery/build/metadata.rb
+++ b/.delivery/build/metadata.rb
@@ -10,3 +10,4 @@ depends 's3_file'
depends 'delivery-red-pill'
depends 'delivery-sugar-extras'
+depends 'fancy_execute'
| Use fancy_execute in the pipeline
We would like to be able to see what the commands that ran successsfully
displays to the STDOUT. By depending in `fancy_execute` that overrides
the `execute` resource in chef we will be able to do it.
|
diff --git a/test/unit/resources/global_spec.rb b/test/unit/resources/global_spec.rb
index abc1234..def5678 100644
--- a/test/unit/resources/global_spec.rb
+++ b/test/unit/resources/global_spec.rb
@@ -0,0 +1,49 @@+require "chef/resource/lwrp_base"
+
+unless Chef::Resource.const_defined?("RbenvGlobal")
+ Chef::Resource::LWRPBase.build_from_file(
+ "rbenv",
+ File.join(File.dirname(__FILE__), %w{.. .. .. resources global.rb}),
+ nil
+ )
+end
+
+describe Chef::Resource::RbenvGlobal do
+
+ let(:resource) { described_class.new("antruby") }
+
+ it "sets the default attribute to rbenv_version" do
+ expect(resource.rbenv_version).to eq("antruby")
+ end
+
+ it "attribute user defaults to nil" do
+ expect(resource.user).to be_nil
+ end
+
+ it "attribute user takes a String value" do
+ resource.user("casper")
+ expect(resource.user).to eq("casper")
+ end
+
+ it "attribute root_path defaults to nil" do
+ expect(resource.root_path).to be_nil
+ end
+
+ it "attribute root_path takes a String value" do
+ resource.root_path("C:\\wintowne")
+ expect(resource.root_path).to eq("C:\\wintowne")
+ end
+
+ it "action defaults to :create" do
+ expect(resource.action).to eq(:create)
+ end
+
+ it "#to_s includes user if provided" do
+ resource.user("molly")
+ expect(resource.to_s).to eq("rbenv_global[antruby] (molly)")
+ end
+
+ it "#to_s includes system label if user is not provided" do
+ expect(resource.to_s).to eq("rbenv_global[antruby] (system)")
+ end
+end
| Add spec coverage for rbenv_global resource.
|
diff --git a/app/models/answer.rb b/app/models/answer.rb
index abc1234..def5678 100644
--- a/app/models/answer.rb
+++ b/app/models/answer.rb
@@ -1,6 +1,4 @@ class Answer < ActiveRecord::Base
belongs_to :question
belongs_to :user
-
- attr_accessible :body, :question_id, :user_id
end | Remove attr_accessible calls for Rails4
|
diff --git a/lib/hightops.rb b/lib/hightops.rb
index abc1234..def5678 100644
--- a/lib/hightops.rb
+++ b/lib/hightops.rb
@@ -20,12 +20,19 @@ if block_given?
yield config
+ serverengine_config = {
+ supervisor: true,
+ daemon_process_name: "hightops-supervisor-#{config.project_name}-#{config.service_name}",
+ worker_process_name: "hightops-worker-#{config.project_name}-#{config.service_name}",
+ server_process_name: "hightops-server-#{config.project_name}-#{config.service_name}"
+ }
+
# We ignore env configuration for Sneakers as it is too tied to its
# internals.
#
# Note: Sneakers 0.1.0 has an additional configuration option to ignore
# environment variable with Sneakers.not_environmental!
- Sneakers.configure env: nil, amqp: config.amqp
+ Sneakers.configure serverengine_config.merge(env: nil, log: config.log, amqp: config.amqp)
end
end
end
| Add customization options for serverengine
|
diff --git a/lib/hubstats.rb b/lib/hubstats.rb
index abc1234..def5678 100644
--- a/lib/hubstats.rb
+++ b/lib/hubstats.rb
@@ -6,4 +6,7 @@ require "hubstats/config"
module Hubstats
+ def self.config
+ @@config ||= Hubstats::Config.parse
+ end
end
| Add back in the config method on Hubstats
|
diff --git a/lib/jukeberx.rb b/lib/jukeberx.rb
index abc1234..def5678 100644
--- a/lib/jukeberx.rb
+++ b/lib/jukeberx.rb
@@ -1,5 +1,56 @@ require "jukeberx/version"
+require "jukeberx/song"
+require "jukeberx/searcher"
+
+require "sinatra/base"
+require "json"
+require "pry"
+
+MUSIC_DIR = "/Users/brit/Music/downloads"
module Jukeberx
# Your code goes here...
+ class App < Sinatra::Base
+ set :logging, true
+ set :library, Searcher.new(MUSIC_DIR)
+
+ get "/api/search" do
+ if params["artist"]
+ results = settings.library.match_artists(params["artist"])
+ elsif params["album"]
+ results = settings.library.match_albums(params["album"])
+ elsif params["title"]
+ results = settings.library.match_titles(params["title"])
+ else
+ results = { message: "You must supply an artist, album, or title." }
+ status 204
+ end
+ content_type "application/json"
+ results.to_json
+ end
+
+ post "/api/play/:id" do
+ if @pid
+ Process.kill(:SIGINT, @pid) unless Process.waitpid(@pid, Process::WNOHANG)
+ end
+
+ content_type "application/json"
+ @song = settings.library.get_song(params["id"].to_i)
+ if @song
+ @pid = @song.play
+ status 201
+ { message: "Now playing: #{@song.artist} - #{@song.title}" }.to_json
+ else
+ status 404
+ { message: "No song found with id: #{params["id"]}" }.to_json
+ end
+ end
+
+ delete "/api/stop" do
+ spawn("killall afplay")
+ status 204
+ end
+
+ run! if app_file == $0
+ end
end
| Add a basic API for song playback.
|
diff --git a/lib/sem_info.rb b/lib/sem_info.rb
index abc1234..def5678 100644
--- a/lib/sem_info.rb
+++ b/lib/sem_info.rb
@@ -3,7 +3,11 @@ def SemInfo.tag(args)
subcommand = args.shift
if subcommand == "latest"
- ::SemInfo::Tag.latest.to_version_string
+ if latest = ::SemInfo::Tag.latest
+ latest.to_version_string
+ else
+ nil
+ end
elsif subcommand == "next"
::SemInfo::Tag.next(args).to_version_string
else
| Fix NPE when there are no git tags
|
diff --git a/tasks.rb b/tasks.rb
index abc1234..def5678 100644
--- a/tasks.rb
+++ b/tasks.rb
@@ -12,6 +12,7 @@ end
end
sh "./codegen.py spec #{spec} lib/amqp/protocol.rb"
+ sh "ruby -c lib/amqp/protocol.rb"
end
end
| Check syntax of the generated Ruby file.
|
diff --git a/pco_api.gemspec b/pco_api.gemspec
index abc1234..def5678 100644
--- a/pco_api.gemspec
+++ b/pco_api.gemspec
@@ -6,7 +6,7 @@ s.homepage = "https://github.com/planningcenter/pco_api_ruby"
s.summary = "Ruby wrapper for api.planningcenteronline.com"
s.description = "Ruby wrapper for api.planningcenteronline.com"
- s.author = ["Planning Center Online"]
+ s.author = "Planning Center Online"
s.files = Dir["lib/**/*", "README.md"]
s.test_files = Dir["spec/**/*"]
| Fix author setting in gemspec
|
diff --git a/lib/condition/condition_format.rb b/lib/condition/condition_format.rb
index abc1234..def5678 100644
--- a/lib/condition/condition_format.rb
+++ b/lib/condition/condition_format.rb
@@ -8,7 +8,18 @@
def search(db)
@format = Format[@format_name].new(db.resolve_time(@time))
- db.cards.values.select do |card|
+ # This is just performance hack - Standard/Modern can use this hack
+ # Legacy/Vintage/Commander/etc. don't want it
+ if @format.format_sets.size < 100
+ cards_probably_in_format = @format.format_sets.flat_map do |set_code|
+ # This will only be nil in subset of db, so really only in tests
+ set = db.sets[set_code]
+ set ? set.printings.map(&:card) : []
+ end.to_set
+ else
+ cards_probably_in_format = db.cards.values
+ end
+ cards_probably_in_format.select do |card|
legality_ok?(@format.legality(card))
end.flat_map(&:printings).to_set
end
| Speed up ConditionFormat for small formats |
diff --git a/lib/middleman-s3_sync/commands.rb b/lib/middleman-s3_sync/commands.rb
index abc1234..def5678 100644
--- a/lib/middleman-s3_sync/commands.rb
+++ b/lib/middleman-s3_sync/commands.rb
@@ -24,9 +24,9 @@
def s3_sync
shared_inst = ::Middleman::Application.server.inst
- bucket = shared_inst.s3_sync_options.bucket
- if (!bucket)
- raise Thor::Error.new "You need to activate this extension."
+ bucket = shared_inst.s3_sync_options.bucket rescue nil
+ unless bucket
+ raise Thor::Error.new "You need to activate the s3_sync extension."
end
# Override options based on what was passed on the command line...
| Return nil if the extension isn't loaded, update the error message.
|
diff --git a/lib/diaclone/result.rb b/lib/diaclone/result.rb
index abc1234..def5678 100644
--- a/lib/diaclone/result.rb
+++ b/lib/diaclone/result.rb
@@ -0,0 +1,78 @@+# Parse result that's passed around in the stack and eventually returned
+# at the end of parsing. Includes a `lines` array for holding each line
+# of the message, a `body` string for holding the entire raw message
+# data, and a `hash` that is eventually read into the `ActiveRecord` object
+# for storage in the database and dissemination to eLocal.com.
+#
+# A result must start with a body, but this can be an empty string so
+# long as the other ^fields are filled out. These fields, like `lines`
+# and `hash`, can be populated here as well, so one can "preload"
+# the result with test data or begin at a specific point in the stack.
+#
+# Example:
+#
+# Diaclone::Result.new "Message: body."
+# Diaclone::Result.new "", hash: { message: "body." }
+
+module Diaclone
+ class Result
+ attr_accessor :body, :lines, :hash
+
+ def initialize(body, options={})
+ @body, @lines, @hash, @extras = body, [], {}, nil
+
+ unless options.empty?
+ options.each do |property, value|
+ send :"#{property}=", value
+ end
+ end
+ end
+
+ # Make an exact duplicate of this Result, allowing experimentation
+ # or modulation without touching the original object (or perhaps
+ # creating an entirely new object to pass around).
+ def dup
+ pr = Result.new(body)
+ pr.lines = lines.nil? ? nil : lines.dup
+ pr.hash = hash.nil? ? nil : hash.dup
+ pr.extras = extras.nil? ? nil : extras.dup
+ pr
+ end
+
+ # Access the Hash if a symbol is passed in as the key, otherwise
+ # access the `lines` array.
+ def [] key
+ if key.is_a? Symbol
+ self.hash[key]
+ else
+ self.lines[key]
+ end
+ end
+
+ # Mutate the Hash if a symbol is passed in as the key, otherwise
+ # mutate the `lines` array.
+ def []= key, value
+ self.hash[key] = value
+ end
+
+ # Print the parsed Hash as a String.
+ def to_s
+ self.hash.reduce("") { |a,(k,v)| a << "#{k}: #{v}" }
+ end
+
+ # Print the raw body as a String.
+ def raw
+ self.body
+ end
+
+ # Delete a key from the Hash.
+ def delete key
+ self.hash.delete key
+ end
+
+ # An Array of all attributes in the Hash.
+ def keys
+ self.hash.keys
+ end
+ end
+end
| Add Diaclone::Result, the object that transformers pass around
|
diff --git a/lib/dimples/archive.rb b/lib/dimples/archive.rb
index abc1234..def5678 100644
--- a/lib/dimples/archive.rb
+++ b/lib/dimples/archive.rb
@@ -0,0 +1,64 @@+# frozen_string_literal: true
+
+module Dimples
+ # A collection of posts, organised by date.
+ class Archive
+ def initialize
+ @years = {}
+ end
+
+ def add_post(post)
+ year(post.year)[:posts] << post
+ month(post.year, post.month)[:posts] << post
+ day(post.year, post.month, post.day)[:posts] << post
+ end
+
+ def years
+ @years.keys
+ end
+
+ def months(year)
+ year(year)[:months].keys
+ end
+
+ def days(year, month)
+ month(year, month)[:days].keys
+ end
+
+ def posts_for_date(year, month = nil, day = nil)
+ if day
+ day_posts(year, month, day)
+ elsif month
+ month_posts(year, month)
+ else
+ year_posts(year)
+ end
+ end
+
+ def year_posts(year)
+ year(year)[:posts]
+ end
+
+ def month_posts(year, month)
+ month(year, month)[:posts]
+ end
+
+ def day_posts(year, month, day)
+ day(year, month, day)[:posts]
+ end
+
+ private
+
+ def year(year)
+ @years[year.to_s] ||= { months: {}, posts: [] }
+ end
+
+ def month(year, month)
+ year(year)[:months][month.to_s] ||= { days: {}, posts: [] }
+ end
+
+ def day(year, month, day)
+ month(year, month)[:days][day.to_s] ||= { posts: [] }
+ end
+ end
+end
| Add the new Archive class
|
diff --git a/plugin.rb b/plugin.rb
index abc1234..def5678 100644
--- a/plugin.rb
+++ b/plugin.rb
@@ -13,11 +13,11 @@
enabled_site_setting :rocketchatsso_enabled
+load Rails.root.join( 'plugins', 'rocketchat-sso', 'lib', 'engine.rb' ).to_s
+
def rocketchatsso_require( path )
require Rails.root.join( 'plugins', 'rocketchat-sso', 'app', path ).to_s
end
-
-load Rails.root.join( 'plugins', 'rocketchat-sso', 'lib', 'engine.rb' ).to_s
after_initialize do
@@ -29,7 +29,7 @@ require 'rest-client'
rocketchatsso_require 'controllers/auth_controller.rb'
-# require File.expand_path( '../app/controllers/rocketchat-sso/users_controller.rb', __FILE__ )
- require File.expand_path( '../app/jobs/rocketchat-sso/send-busy-info.rb', __FILE__ )
+ rocketchatsso_require 'controllers/users_controller.rb'
+ rocketchatsso_require 'jobs/send-users-online.rb'
end
| Fix loading of controllers, jobs
|
diff --git a/lib/la_maquina/dependency_map/yaml_map.rb b/lib/la_maquina/dependency_map/yaml_map.rb
index abc1234..def5678 100644
--- a/lib/la_maquina/dependency_map/yaml_map.rb
+++ b/lib/la_maquina/dependency_map/yaml_map.rb
@@ -5,6 +5,7 @@ submap = map
args.each do |key|
submap = submap[key]
+ break if submap.blank?
end
submap
end
| Allow for anything in the yaml find chain to be not found
|
diff --git a/lib/rails_autoscale_agent/registration.rb b/lib/rails_autoscale_agent/registration.rb
index abc1234..def5678 100644
--- a/lib/rails_autoscale_agent/registration.rb
+++ b/lib/rails_autoscale_agent/registration.rb
@@ -10,7 +10,7 @@ dyno: config.dyno,
pid: config.pid,
ruby_version: RUBY_VERSION,
- rails_version: Rails.version,
+ rails_version: defined?(Rails) && Rails.version,
gem_version: VERSION,
}
end
| Check for the presence of Rails before using it
|
diff --git a/lib/biased/client.rb b/lib/biased/client.rb
index abc1234..def5678 100644
--- a/lib/biased/client.rb
+++ b/lib/biased/client.rb
@@ -2,10 +2,12 @@ require "wikipedia"
module Biased
+ # The main class that a end user will use to interact with the application.
# @author Justin Harrison
# @since 0.0.1
# @attr_reader [String] parent The potentially biased website's parent
# organization.
+ # Biased::Client.new("huffingtonpost.com")
class Client
attr_reader(:parent)
| Include more documentation for Biased::Client
|
diff --git a/lib/emcee/railtie.rb b/lib/emcee/railtie.rb
index abc1234..def5678 100644
--- a/lib/emcee/railtie.rb
+++ b/lib/emcee/railtie.rb
@@ -7,6 +7,7 @@ module Emcee
class Railtie < Rails::Railtie
initializer :add_preprocessors do |app|
+ app.assets.register_mime_type "text/html", ".html"
app.assets.register_preprocessor "text/html", DirectiveProcessor
end
| Add back in mime type declaration
For html
|
diff --git a/lib/gitlab/ci/status/core.rb b/lib/gitlab/ci/status/core.rb
index abc1234..def5678 100644
--- a/lib/gitlab/ci/status/core.rb
+++ b/lib/gitlab/ci/status/core.rb
@@ -23,7 +23,7 @@ end
def group
- self.class.name.demodulize.downcase.underscore
+ self.class.name.demodulize.underscore
end
def has_details?
| Improve how we calculate detailed status group name
|
diff --git a/lib/openlogi/api/endpoint.rb b/lib/openlogi/api/endpoint.rb
index abc1234..def5678 100644
--- a/lib/openlogi/api/endpoint.rb
+++ b/lib/openlogi/api/endpoint.rb
@@ -5,26 +5,6 @@
def initialize(client)
@client = client
- end
-
- def find(id)
- raise NotImplementedError
- end
-
- def all
- raise NotImplementedError
- end
-
- def update(id, params)
- raise NotImplementedError
- end
-
- def create(params)
- raise NotImplementedError
- end
-
- def destroy(id)
- raise NotImplementedError
end
def resource_class
| Remove placeholder actions in Openlogi::Api::Endpoint
We don't really need these.
|
diff --git a/lib/roda/plugins/dry_view.rb b/lib/roda/plugins/dry_view.rb
index abc1234..def5678 100644
--- a/lib/roda/plugins/dry_view.rb
+++ b/lib/roda/plugins/dry_view.rb
@@ -13,12 +13,16 @@ def view_context_options
{}
end
+
+ def view_key(name)
+ "views.#{name}"
+ end
end
module RequestMethods
def view(name, options = {})
options = {context: scope.view_context}.merge(options)
- is to: "views.#{name}", call_with: [options]
+ is to: scope.view_key(name), call_with: [options]
end
end
end
| Add ability to define a custom view key resolver
|
diff --git a/lib/ruote/postgres/worker.rb b/lib/ruote/postgres/worker.rb
index abc1234..def5678 100644
--- a/lib/ruote/postgres/worker.rb
+++ b/lib/ruote/postgres/worker.rb
@@ -2,7 +2,7 @@
Ruote::Worker.class_eval do
def run
- @storage.wait_for_notify(6) do
+ @storage.wait_for_notify(60) do
step
end while @state != 'stopped'
end
| Update timeout to 60 seconds
|
diff --git a/library/fiber/resume_spec.rb b/library/fiber/resume_spec.rb
index abc1234..def5678 100644
--- a/library/fiber/resume_spec.rb
+++ b/library/fiber/resume_spec.rb
@@ -10,6 +10,12 @@ fiber2.resume
-> { fiber2.resume }.should raise_error(FiberError)
end
+
+ it "raises a FiberError if the Fiber attempts to resume a resuming fiber" do
+ root_fiber = Fiber.current
+ fiber1 = Fiber.new { root_fiber.resume }
+ -> { fiber1.resume }.should raise_error(FiberError, /double resume/)
+ end
end
ruby_version_is '3.0' do
@@ -19,5 +25,11 @@ fiber2.resume.should == 10
fiber2.resume.should == 20
end
+
+ it "raises a FiberError if the Fiber attempts to resume a resuming fiber" do
+ root_fiber = Fiber.current
+ fiber1 = Fiber.new { root_fiber.resume }
+ -> { fiber1.resume }.should raise_error(FiberError, /attempt to resume a resuming fiber/)
+ end
end
end
| Add spec to cover resume a resuming fiber error
|
diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb
index abc1234..def5678 100644
--- a/app/mailers/application_mailer.rb
+++ b/app/mailers/application_mailer.rb
@@ -1,4 +1,4 @@ class ApplicationMailer < ActionMailer::Base
- default from: Woodlock.site_name
+ default from: Woodlock.site_email
layout 'mailer'
end
| Fix default mailer <from> reference.
|
diff --git a/app/models/campus_activity_set.rb b/app/models/campus_activity_set.rb
index abc1234..def5678 100644
--- a/app/models/campus_activity_set.rb
+++ b/app/models/campus_activity_set.rb
@@ -1,2 +1,7 @@ class CampusActivitySet < ActiveRecord::Base
+ belongs_to :campus
+ belongs_to :unit_activity_set
+
+ validates :campus, presence: true
+ validates :unit_activity_set, presence: true
end
| ENHANCE: Validate the presence of campus and unit activity set
|
diff --git a/app/workers/music_graph_worker.rb b/app/workers/music_graph_worker.rb
index abc1234..def5678 100644
--- a/app/workers/music_graph_worker.rb
+++ b/app/workers/music_graph_worker.rb
@@ -1,18 +1,18 @@-
-class MusicGraphWorker
- include Sidekiq::Worker
-
- def perform
- # @word = "coffee"
- # url = "http://api.musicgraph.com/api/v2/track/search?api_key=" + ENV['MUSIC_GRAPH_API_KEY'] + "&lyrics_phrase=" + @word
- # uri = URI(url)
- # response = Net::HTTP.get(uri)
- # @tracks = JSON.parse(response)
-
- view = html = ActionView::Base.new(Rails.root.join('app/views'))
- view.class.include ApplicationHelper
- view.render(
- file: 'tracks/index.html.erb'
- )
- end
-end
+#
+# class MusicGraphWorker
+# # include Sidekiq::Worker
+#
+# def perform
+# # @word = "coffee"
+# # url = "http://api.musicgraph.com/api/v2/track/search?api_key=" + ENV['MUSIC_GRAPH_API_KEY'] + "&lyrics_phrase=" + @word
+# # uri = URI(url)
+# # response = Net::HTTP.get(uri)
+# # @tracks = JSON.parse(response)
+#
+# view = html = ActionView::Base.new(Rails.root.join('app/views'))
+# view.class.include ApplicationHelper
+# view.render(
+# file: 'tracks/index.html.erb'
+# )
+# end
+# end
| Comment out ununsed Sidekiq worker code
|
diff --git a/config/environments/production.rb b/config/environments/production.rb
index abc1234..def5678 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -1,4 +1,3 @@-require Rails.root.join("config/smtp")
Rails.application.configure do
config.cache_classes = true
config.eager_load = true
| Remove reference to old smtp (MailGun) config |
diff --git a/config/initializers/extensions.rb b/config/initializers/extensions.rb
index abc1234..def5678 100644
--- a/config/initializers/extensions.rb
+++ b/config/initializers/extensions.rb
@@ -1,4 +1,4 @@-Rails.application.config.after_initialize do
+Rails.application.config.before_initialize do
extensions_path = "#{Rails.root}/lib/extensions"
# Load the base Extensions module
| Load Extensions before rails initialize
|
diff --git a/core/spec/models/taxonomy_spec.rb b/core/spec/models/taxonomy_spec.rb
index abc1234..def5678 100644
--- a/core/spec/models/taxonomy_spec.rb
+++ b/core/spec/models/taxonomy_spec.rb
@@ -1,6 +1,6 @@ require 'spec_helper'
-describe Taxonomy do
+describe Spree::Taxonomy do
context "validation" do
it { should have_valid_factory(:taxonomy) }
| Correct reference in Taxonomy spec
|
diff --git a/lib/generators/rain/install/install_generator.rb b/lib/generators/rain/install/install_generator.rb
index abc1234..def5678 100644
--- a/lib/generators/rain/install/install_generator.rb
+++ b/lib/generators/rain/install/install_generator.rb
@@ -3,7 +3,7 @@ source_root File.expand_path('../templates', __FILE__)
def copy_config_file
- copy_file "config/versions.yml", "#{Rails.root}/config/versions.yml"
+ copy_file "versions.yml", "config/versions.yml"
end
def show_capistrano_instructions
| Fix source path in generator
|
diff --git a/lib/tasks/publishing_api/publish_api_prefix.rake b/lib/tasks/publishing_api/publish_api_prefix.rake
index abc1234..def5678 100644
--- a/lib/tasks/publishing_api/publish_api_prefix.rake
+++ b/lib/tasks/publishing_api/publish_api_prefix.rake
@@ -0,0 +1,33 @@+require 'logger'
+require 'gds_api/publishing_api'
+require 'gds_api/publishing_api/special_route_publisher'
+
+namespace :publishing_api do
+ desc "Publish /api route to publishing_api"
+ task publish_api_prefix: :environment do
+ puts "Content Tagger is claiming path /api"
+ endpoint = Services.publishing_api.options[:endpoint_url]
+ Services.publishing_api.put_json("#{endpoint}/paths/api", publishing_app: "content-tagger", override_existing: true)
+
+ publishing_api = GdsApi::PublishingApiV2.new(
+ Plek.new.find('publishing-api'),
+ bearer_token: ENV['PUBLISHING_API_BEARER_TOKEN'] || 'example'
+ )
+
+ special_route_publisher = GdsApi::PublishingApi::SpecialRoutePublisher.new(
+ logger: Logger.new(STDOUT),
+ publishing_api: publishing_api
+ )
+
+ puts "Publishing /api..."
+ special_route_publisher.publish(
+ title: 'Public content API',
+ description: '/api was used by Content API which has been retired. It is used by other applications such as search, whitehall, content-store and calendars.',
+ content_id: "363a1f3a-5e80-4ff7-8f6f-be1bec62821f",
+ base_path: '/api',
+ type: 'prefix',
+ publishing_app: 'content-tagger',
+ rendering_app: 'publicapi'
+ )
+ end
+end
| Bring back /api prefix by publishing it to publishing-api
This commit makes content-tagger the publishing-app of `/api` prefix,
this is because content-api has been retired.
This commit also aims to fix the unpublishing of the /api prefix which was
done
[here](https://github.com/alphagov/content-tagger/pull/369/commits/42a2bbcd98847a3b63a8ec77f7d89f4abb59e2ec)
The majority of the code was brough from https://github.com/gds-attic/govuk_content_api/blob/d292c2ce0059e7899a7f03dd8e8587a6116c802b/lib/tasks/publishing_api.rake
|
diff --git a/lib/aws/plugins/content_length.rb b/lib/aws/plugins/content_length.rb
index abc1234..def5678 100644
--- a/lib/aws/plugins/content_length.rb
+++ b/lib/aws/plugins/content_length.rb
@@ -16,7 +16,7 @@ module Aws
module Plugins
class ContentLength < Seahorse::Client::Plugin
- handle_request :Handler do |context|
+ handle_request(:Handler, step: :sign, priority: 0) do |context|
next if context.http_request.headers['Content-Length']
length = context.http_request.body.size
context.http_request.headers['Content-Length'] = length
| Set the content-length plugin to lowest priority.
|
diff --git a/lib/capistrano-info/capistrano.rb b/lib/capistrano-info/capistrano.rb
index abc1234..def5678 100644
--- a/lib/capistrano-info/capistrano.rb
+++ b/lib/capistrano-info/capistrano.rb
@@ -23,7 +23,11 @@ rel_date = Time.local(*rel.unpack("a4a2a2a2a2a2"))
version_file = "#{current_path}/VERSION"
- version = capture("test -r #{version_file} && cat #{version_file}").chomp
+ version = begin
+ capture("test -r #{version_file} && cat #{version_file}").chomp
+ rescue Capistrano::CommandError
+ ""
+ end
message = <<-EOT
| Handle "failed" reading of VERSION-file silently
|
diff --git a/lib/geocoder/results/nominatim.rb b/lib/geocoder/results/nominatim.rb
index abc1234..def5678 100644
--- a/lib/geocoder/results/nominatim.rb
+++ b/lib/geocoder/results/nominatim.rb
@@ -20,7 +20,7 @@ end
def village
- @data['address']['villiage']
+ @data['address']['village']
end
def town
| Fix a typo 'villiage' with village
|
diff --git a/MagicalRecord.podspec b/MagicalRecord.podspec
index abc1234..def5678 100644
--- a/MagicalRecord.podspec
+++ b/MagicalRecord.podspec
@@ -1,6 +1,5 @@ Pod::Spec.new do |s|
s.name = 'MagicalRecord'
- s.version = '1.8'
s.license = 'MIT'
s.summary = 'Effortless fetching, saving, and importing for Core Data.'
s.homepage = 'http://github.com/magicalpanda/MagicalRecord'
@@ -9,6 +8,7 @@ 'Alexsander Akers' => 'a2@pandamonia.us' }
s.source = { :git => 'http://github.com/zwaldowski/MagicalRecord.git' }
s.source_dirs = 'Source'
+ s.clean_paths = 'iOS App Unit Tests/', 'Mac App Unit Tests/', 'Magical Record.xcodeproj/', 'Unit Tests/', '.gitignore'
s.framework = 'CoreData'
s.requires_arc = true
| Prepare Pod Spec for ad-hoc usage.
Signed-off-by: Zachary Waldowski <f6cb034ae1bf314d2c0261a7a22e4684d1f74b57@gmail.com>
|
diff --git a/db/data_migration/20180802133114_update_html_attachment_slug.rb b/db/data_migration/20180802133114_update_html_attachment_slug.rb
index abc1234..def5678 100644
--- a/db/data_migration/20180802133114_update_html_attachment_slug.rb
+++ b/db/data_migration/20180802133114_update_html_attachment_slug.rb
@@ -0,0 +1,22 @@+edition = Edition.find(866063)
+html_attachment = HtmlAttachment.find(2844573)
+html_attachment.update(slug: "provisional-findings-of-the-call-for-evidence-into-UK-interest-in-existing-EU-trade-remedy-measures")
+Whitehall::SearchIndex.delete(edition)
+Whitehall::PublishingApi.republish_async(html_attachment)
+Whitehall::PublishingApi.republish_document_async(edition)
+Whitehall::SearchIndex.add(edition)
+
+base_path = "/government/consultations/call-for-evidence-to-identify-uk-interest-in-existing-eu-trade-remedy-measures/test"
+destination = "/government/consultations/call-for-evidence-to-identify-uk-interest-in-existing-eu-trade-remedy-measures/provisional-findings-of-the-call-for-evidence-into-UK-interest-in-existing-EU-trade-remedy-measures"
+redirects = [
+ { path: base_path, type: "exact", destination: destination }
+]
+redirect = Whitehall::PublishingApi::Redirect.new(base_path, redirects)
+content_id = SecureRandom.uuid
+
+puts "Redirecting: #{base_path} to #{destination} with a randomly generated content_id: #{content_id}"
+
+Services.publishing_api.put_content(content_id, redirect.as_json)
+
+puts "Publishing content_id: #{content_id} with redirect #{redirect.as_json}"
+Services.publishing_api.publish(content_id, nil, locale: "en")
| Update html attachment slug for Brexit document
|
diff --git a/db/migrate/20170714092132_add_engagement_to_entry_enclosures.rb b/db/migrate/20170714092132_add_engagement_to_entry_enclosures.rb
index abc1234..def5678 100644
--- a/db/migrate/20170714092132_add_engagement_to_entry_enclosures.rb
+++ b/db/migrate/20170714092132_add_engagement_to_entry_enclosures.rb
@@ -0,0 +1,5 @@+class AddEngagementToEntryEnclosures < ActiveRecord::Migration[5.0]
+ def change
+ add_column :entry_enclosures, :engagement, :integer, default: 0, null: false
+ end
+end
| Add migration: add engagment to entry_enclosures
|
diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/games_controller.rb
+++ b/app/controllers/games_controller.rb
@@ -3,7 +3,7 @@ @title = '301'
@scores = []
- 10.times do
+ 12.times do
@scores.push(0)
end
| Change row number to 12
|
diff --git a/app/controllers/rooms_controller.rb b/app/controllers/rooms_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/rooms_controller.rb
+++ b/app/controllers/rooms_controller.rb
@@ -2,7 +2,7 @@ before_action :authenticate, except: [:github]
def index
- @rooms = current_user.rooms
+ @rooms = current_user.rooms.order :id
end
def create
| Add order in room list
|
diff --git a/app/lib/activitypub/activity/add.rb b/app/lib/activitypub/activity/add.rb
index abc1234..def5678 100644
--- a/app/lib/activitypub/activity/add.rb
+++ b/app/lib/activitypub/activity/add.rb
@@ -7,7 +7,7 @@ status = status_from_uri(object_uri)
status ||= fetch_remote_original_status
- return unless !status.nil? && status.account_id == @account.id && !@account.pinned?(status)
+ return unless !status.nil? && status.account_id == @account.id && !@account.pinned?(status) && status.distributable?
StatusPin.create!(account: @account, status: status)
end
| Fix spurious errors when receiving an Add activity for a private post
|
diff --git a/lib/inline_svg/transform_pipeline/transformations/no_comment.rb b/lib/inline_svg/transform_pipeline/transformations/no_comment.rb
index abc1234..def5678 100644
--- a/lib/inline_svg/transform_pipeline/transformations/no_comment.rb
+++ b/lib/inline_svg/transform_pipeline/transformations/no_comment.rb
@@ -2,11 +2,11 @@ module Transformations
class NoComment < Transformation
def transform(doc)
- doc = Nokogiri::XML::Document.parse(doc.to_html)
- doc.xpath("//comment()").each do |comment|
- comment.remove
+ with_svg(doc) do |svg|
+ svg.xpath("//comment()").each do |comment|
+ comment.remove
+ end
end
- doc
end
end
end
| Handle documents without SVG root elements
|
diff --git a/init.rb b/init.rb
index abc1234..def5678 100644
--- a/init.rb
+++ b/init.rb
@@ -8,4 +8,4 @@ puts 'Equivalent of ActiveModel::Errors#messages'
puts password.errors.to_h
puts password.errors.to_a.inspect
-exit 1 unless password.errors.any?
+exit 1 if password.errors.any?
| Fix exit signal of executed script
|
diff --git a/init.rb b/init.rb
index abc1234..def5678 100644
--- a/init.rb
+++ b/init.rb
@@ -11,6 +11,7 @@
require 'rails_xss_helper'
require 'av_patch'
-rescue LoadError
+rescue LoadError => e
puts "Could not load all modules required by rails_xss. Please make sure erubis is installed an try again."
+ raise e
end unless $gems_rake_task
| Abort loading if there's a LoadError
|
diff --git a/lib/vSphere/action/vim_helpers.rb b/lib/vSphere/action/vim_helpers.rb
index abc1234..def5678 100644
--- a/lib/vSphere/action/vim_helpers.rb
+++ b/lib/vSphere/action/vim_helpers.rb
@@ -13,8 +13,8 @@ end
def get_resource_pool(connection, machine)
- cr = get_datacenter(connection, machine).find_compute_resource(machine.provider_config.compute_resource_name) or fail Errors::VSphereError, :message => I18n.t('erorrs.missing_compute_resource')
- cr.resourcePool.find(machine.provider_config.resource_pool_name) or fail Errors::VSphereError, :message => I18n.t('erorrs.missing_resource_pool')
+ cr = get_datacenter(connection, machine).find_compute_resource(machine.provider_config.compute_resource_name) or fail Errors::VSphereError, :message => I18n.t('errors.missing_compute_resource')
+ cr.resourcePool.find(machine.provider_config.resource_pool_name) or fail Errors::VSphereError, :message => I18n.t('errors.missing_resource_pool')
end
end
end
| Correct typo 'erorrs' -> 'errors'
|
diff --git a/app/mailers/spree/email_delivery_mailer.rb b/app/mailers/spree/email_delivery_mailer.rb
index abc1234..def5678 100644
--- a/app/mailers/spree/email_delivery_mailer.rb
+++ b/app/mailers/spree/email_delivery_mailer.rb
@@ -3,6 +3,4 @@ @inventory_units = shipment.inventory_units
mail :to => shipment.order.user.email
end
-
- handle_asynchronously :electronic_delivery_email
end
| Revert "Send license key email asynchronously."
This reverts commit 5c27d5745aa9df94bcf9071df197076599e144db.
We added this after we had issues with sendgrid that caused delayed jobs
to fail and re-send license keys, but the commit does not actually work:
it makes email_delivery_email asynchronous so it returns `nil`, and then
`deliver` is called on that and fails. Luckily we override this method
so it doesn't seem to have affected anything.
Closes #17.
|
diff --git a/lib/websocket/server_handshake.rb b/lib/websocket/server_handshake.rb
index abc1234..def5678 100644
--- a/lib/websocket/server_handshake.rb
+++ b/lib/websocket/server_handshake.rb
@@ -7,17 +7,20 @@ end
def render(out)
- response_header = "#{@version} #{@status} #{@reason}#{CRLF}"
+ out << to_data
+ end
+
+ def to_data
+ data = "#{@version} #{@status} #{@reason}#{CRLF}"
unless @headers.empty?
- response_header << @headers.map do |header, value|
+ data << @headers.map do |header, value|
"#{header}: #{value}"
end.join(CRLF) << CRLF
end
- response_header << CRLF
-
- out << response_header
+ data << CRLF
+ data
end
end
end | Split data generation and rendering in server handshake
|
diff --git a/delayed_job_active_record.gemspec b/delayed_job_active_record.gemspec
index abc1234..def5678 100644
--- a/delayed_job_active_record.gemspec
+++ b/delayed_job_active_record.gemspec
@@ -16,7 +16,7 @@ s.test_files = Dir.glob('spec/**/*')
s.add_runtime_dependency 'activerecord', '> 2.1.0'
- s.add_runtime_dependency 'delayed_job', '3.0.0.pre'
+ s.add_runtime_dependency 'delayed_job', '~> 3.0.0.pre'
s.add_development_dependency 'rspec', '~> 2.0'
s.add_development_dependency 'rake', '~> 0.8'
| Use pessimistic version constraint to allow latest pre-release delayed_job
http://docs.rubygems.org/read/chapter/16#page74
|
diff --git a/gir_ffi.gemspec b/gir_ffi.gemspec
index abc1234..def5678 100644
--- a/gir_ffi.gemspec
+++ b/gir_ffi.gemspec
@@ -4,7 +4,6 @@ Gem::Specification.new do |s|
s.name = "gir_ffi"
s.version = GirFFI::VERSION
- s.date = Date.today.to_s
s.summary = "FFI-based GObject binding using the GObject Introspection Repository"
| Remove superfluous date setting in gemspec. |
diff --git a/IKEventSource.podspec b/IKEventSource.podspec
index abc1234..def5678 100644
--- a/IKEventSource.podspec
+++ b/IKEventSource.podspec
@@ -12,5 +12,5 @@ s.tvos.deployment_target = '9.0'
s.osx.deployment_target = '10.10'
s.source = { :git => "https://github.com/inaka/EventSource.git" }
- s.source_files = "EventSource", "EventSource/**/*.{h,m}"
+ s.source_files = "Sources/*.swift"
end
| Update podspec source files path
|
diff --git a/cookbooks/rbenv/recipes/default.rb b/cookbooks/rbenv/recipes/default.rb
index abc1234..def5678 100644
--- a/cookbooks/rbenv/recipes/default.rb
+++ b/cookbooks/rbenv/recipes/default.rb
@@ -42,14 +42,3 @@ group "mzp"
mode 0644
end
-
-%w(2.1.0-rc1).each do|version|
- bash "install #{version}" do
- user "mzp"
- environment({ 'HOME' => '/home/mzp' })
- code <<-END
- source /home/mzp/profiles/rbenv.profile
- rbenv install #{version}
- END
- end
-end
| Revert "update recipe: install ruby 2.1.0-rc1"
This reverts commit 7eee16d7a76c806ada686605f9dd986dba97b2d9.
|
diff --git a/debug-extras.gemspec b/debug-extras.gemspec
index abc1234..def5678 100644
--- a/debug-extras.gemspec
+++ b/debug-extras.gemspec
@@ -1,7 +1,7 @@ # coding: utf-8
-lib = File.expand_path('../lib', __FILE__)
+lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
-require 'debug_extras/version'
+require "debug_extras/version"
Gem::Specification.new do |spec|
spec.name = "debug-extras"
@@ -9,24 +9,24 @@ spec.authors = ["Vladimir Avgustov"]
spec.email = ["vavgustov@gmail.com"]
- spec.summary = 'Extras for rails debugging.'
- spec.description = 'Provide debug helper methods for ActionController::Base and ActionView::Base.'
- spec.homepage = 'https://github.com/vavgustov/debug-extras'
- spec.license = 'MIT'
+ spec.summary = "Extras for rails debugging."
+ spec.description = "Provide debug helper methods for ActionController::Base and ActionView::Base."
+ spec.homepage = "https://github.com/vavgustov/debug-extras"
+ spec.license = "MIT"
- spec.required_ruby_version = '>= 2.1.0'
+ spec.required_ruby_version = ">= 2.1.0"
spec.files = `git ls-files -z`.split("\x0").reject do |f|
f.match(%r{^(test|spec|features)/})
end
- spec.require_paths = ['lib']
+ spec.require_paths = ["lib"]
- spec.add_development_dependency 'bundler', '~> 1.15'
- spec.add_development_dependency 'rake', '~> 10.0'
- spec.add_development_dependency 'rspec', '~> 3.0'
+ spec.add_development_dependency "bundler", "~> 1.15"
+ spec.add_development_dependency "rake", "~> 10.0"
+ spec.add_development_dependency "rspec", "~> 3.0"
- spec.add_runtime_dependency 'awesome_print', '~> 1.8'
- spec.add_runtime_dependency 'actionview', '> 4.0', '< 6'
- spec.add_runtime_dependency 'activesupport', '> 4.0', '< 6'
+ spec.add_runtime_dependency "awesome_print", "~> 1.8"
+ spec.add_runtime_dependency "actionview", "> 4.0", "< 6"
+ spec.add_runtime_dependency "activesupport", "> 4.0", "< 6"
end
| Move gemspec to double quotes.
|
diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb
index abc1234..def5678 100644
--- a/test/dummy/config/application.rb
+++ b/test/dummy/config/application.rb
@@ -26,6 +26,19 @@ # For long-polling 45 seconds timeout seems reasonable.
config.web_console.timeout = 45.seconds
end
+
+ config.web_console.colors =
+ if ENV['SOLARIZED_LIGHT']
+ 'solarized_light'
+ elsif ENV['SOLARIZED_DARK']
+ 'solarized_dark'
+ elsif ENV['TANGO']
+ 'tango'
+ elsif ENV['XTERM']
+ 'xterm'
+ else
+ 'light'
+ end
end
end
| Add color switching ENV vars to the dummy app
|
diff --git a/plugins/httpwatch.rb b/plugins/httpwatch.rb
index abc1234..def5678 100644
--- a/plugins/httpwatch.rb
+++ b/plugins/httpwatch.rb
@@ -0,0 +1,64 @@+require 'digest'
+require 'zmb/timer'
+
+class HttpWatch
+ attr_accessor :settings
+
+ def initialize(sender, s)
+ @delegate = sender
+ @settings = s
+ @settings['urls'] = Array.new unless @settings.has_key?('urls')
+ @settings['interval'] = 60*5 unless @settings.has_key?('interval')
+
+ @delegate.timer_add(Timer.new(self, :check, @settings['interval'], true))
+ end
+
+ def check
+ @settings['urls'].each do |url|
+ hash = Digest::SHA256.hexdigest(url['url'].get.body)
+
+ if hash != url['hash'] then
+ @delegate.instances[url['instance']].message(url['sender'], "#{url['url']} has been changed")
+ end
+
+ url['hash'] = hash
+ end
+ end
+
+ def commands
+ {
+ 'watch' => [:watch, 1, {}],
+ 'stop-watching' => :remove
+ }
+ end
+
+ def watch(e, url)
+ @settings['urls'] << {
+ 'instance' => e.delegate.instance,
+ 'sender' => e.sender,
+ 'url' => url,
+ 'hash' => Digest::SHA256.hexdigest(url.get.body)
+ }
+
+ "#{url} is now being watched"
+ end
+
+ def remove(e, url)
+ u = @settings['urls'].find do |u|
+ (u['url'] == url) and (u['instance'] == e.delegate.instance) and (u['sender'] == e.sender)
+ end
+
+ if u then
+ @settings['urls'].delete(u)
+ "#{url} is no longer being watched"
+ else
+ "No url match for this url on this irc server from user/channel"
+ end
+ end
+end
+
+Plugin.define do
+ name 'httpwatch'
+ description 'Watch a url for changes'
+ object HttpWatch
+end
| Add a plugin to watch a url for changes
|
diff --git a/plugins/ohai_solo.rb b/plugins/ohai_solo.rb
index abc1234..def5678 100644
--- a/plugins/ohai_solo.rb
+++ b/plugins/ohai_solo.rb
@@ -0,0 +1,10 @@+provides "ohai_solo"
+
+def parse_version(versionfile)
+ data = File.open(versionfile) {|f| f.readline}.strip
+ version = data.split(" ")[1]
+ return version
+end
+
+ohai_solo Mash.new
+ohai_solo[:version] = parse_version("/opt/ohai-solo/version-manifest.txt")
| Add plugin to report ohai-solo version
|
diff --git a/lib/mutant/mutator/node/named_value/variable_assignment.rb b/lib/mutant/mutator/node/named_value/variable_assignment.rb
index abc1234..def5678 100644
--- a/lib/mutant/mutator/node/named_value/variable_assignment.rb
+++ b/lib/mutant/mutator/node/named_value/variable_assignment.rb
@@ -39,7 +39,7 @@ def mutate_name
prefix = MAP.fetch(node.type)
Mutator::Util::Symbol.each(name, self) do |name|
- emit_name("#{prefix}#{name}")
+ emit_name(prefix + name.to_s)
end
end
| Change variable interpolation into simpler to read statement
|
diff --git a/did_you_mean.gemspec b/did_you_mean.gemspec
index abc1234..def5678 100644
--- a/did_you_mean.gemspec
+++ b/did_you_mean.gemspec
@@ -13,7 +13,7 @@ spec.homepage = "https://github.com/yuki24/did_you_mean"
spec.license = "MIT"
- spec.files = `git ls-files`.split($/)
+ spec.files = `git ls-files`.split($/).reject{|path| path.start_with?('evaluation/') }
spec.test_files = spec.files.grep(%r{^(test)/})
spec.require_paths = ["lib"]
| Exclude non-production code that has a non-commercial license
closes #105
|
diff --git a/app/models/authorization.rb b/app/models/authorization.rb
index abc1234..def5678 100644
--- a/app/models/authorization.rb
+++ b/app/models/authorization.rb
@@ -36,7 +36,7 @@
def token_auth_podcasts
if token.globally_authorized?('read-private')
- Podcast.all
+ Podcast.with_deleted.all
else
Podcast.where(prx_account_uri: token_auth_account_uris)
end
@@ -45,7 +45,7 @@ # avoid joining podcasts here, as it breaks a bunch of other queries
def token_auth_episodes
if token.globally_authorized?('read-private')
- Episode.all
+ Episode.with_deleted.all
else
Episode.where(podcast_id: token_auth_podcasts.pluck(:id))
end
| Include deleted only on wildcard requests
|
diff --git a/week-4/basic-math.rb b/week-4/basic-math.rb
index abc1234..def5678 100644
--- a/week-4/basic-math.rb
+++ b/week-4/basic-math.rb
@@ -0,0 +1,86 @@+# Solution Below
+
+num1 = 7
+num2 = 13
+sum = num1 + num2
+difference = num1 - num2
+quotient = num1.to_f/num2.to_f
+product = num1 * num2
+modulus = num1 % num2
+
+
+
+
+
+# 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 'num1' do
+ it "is defined as a local variable" do
+ expect(defined?(num1)).to eq 'local-variable'
+ end
+
+ it "is an integer" do
+ expect(num1).to be_a Fixnum
+ end
+end
+
+describe 'num2' do
+ it "is defined as a local variable" do
+ expect(defined?(num2)).to eq 'local-variable'
+ end
+
+ it "is an integer" do
+ expect(num2).to be_a Fixnum
+ end
+end
+
+describe 'sum' do
+ it "is defined as a local variable" do
+ expect(defined?(sum)).to eq 'local-variable'
+ end
+
+ it "is assigned the value of num1 + num2" do
+ expect(sum).to eq num1 + num2
+ end
+end
+
+describe 'difference' do
+ it "is defined as a local variable" do
+ expect(defined?(difference)).to eq 'local-variable'
+ end
+
+ it "is assigned the value of num1 - num2" do
+ expect(difference).to eq num1 - num2
+ end
+end
+
+describe 'product' do
+ it "is defined as a local variable" do
+ expect(defined?(product)).to eq 'local-variable'
+ end
+
+ it "is assigned the value of num1 * num2" do
+ expect(product).to eq num1 * num2
+ end
+end
+
+describe 'quotient' do
+ it "is defined as a local variable" do
+ expect(defined?(quotient)).to eq 'local-variable'
+ end
+
+ it "is assigned the value of num1 / num2" do
+ expect(quotient).to eq num1.to_f / num2.to_f
+ end
+end
+
+describe 'modulus' do
+ it "is defined as a local variable" do
+ expect(defined?(modulus)).to eq 'local-variable'
+ end
+
+ it "is assigned the value of num1 % num2" do
+ expect(modulus).to eq num1.to_f % num2.to_f
+ end
+end | Create basic math tests for basic integers
|
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -1,5 +1,7 @@ class UsersController < ApplicationController
include Orderable
+
+ respond_to :html, :json, :js, :atom
before_action :authenticate_user!, except: [:show]
@@ -11,8 +13,7 @@ def show
@pictures = @user.pictures.order_by_time.page(params[:page])
- respond_to do |format|
- format.all # show.html.erb
+ respond_with(@user) do |format|
format.js { render template: "pictures/index" }
end
end
@@ -21,15 +22,9 @@ end
def update
- respond_to do |format|
- if @user.update(user_params)
- format.html { redirect_to @user, notice: "Profile was successfully updated." }
- format.json { render :show, status: :ok, location: @user }
- else
- format.html { render :edit }
- format.json { render json: @user.errors, status: :unprocessable_entity }
- end
- end
+ @user.update(user_params)
+
+ respond_with(@user)
end
private
| Use responders in users controller
|
diff --git a/app/helpers/claim_reviews_helper.rb b/app/helpers/claim_reviews_helper.rb
index abc1234..def5678 100644
--- a/app/helpers/claim_reviews_helper.rb
+++ b/app/helpers/claim_reviews_helper.rb
@@ -6,10 +6,6 @@ message: t('.incomplete_claim_message')
}
end
- end
-
- def review_header
- I18n.t("#{current_step}.header")
end
def email_addresses
| Remove unused helper method in the claims reviews helper |
diff --git a/app/models/concerns/api_resource.rb b/app/models/concerns/api_resource.rb
index abc1234..def5678 100644
--- a/app/models/concerns/api_resource.rb
+++ b/app/models/concerns/api_resource.rb
@@ -2,9 +2,8 @@ extend ActiveSupport::Concern
included do
- cattr_accessor(:panoptes_attributes) do
- HashWithIndifferentAccess.new
- end
+ class_attribute :panoptes_attributes
+ self.panoptes_attributes = HashWithIndifferentAccess.new
end
module ClassMethods
| Use class_attribute instead of cattr_accessor |
diff --git a/queue/lib/flow/queue/transport.rb b/queue/lib/flow/queue/transport.rb
index abc1234..def5678 100644
--- a/queue/lib/flow/queue/transport.rb
+++ b/queue/lib/flow/queue/transport.rb
@@ -15,9 +15,13 @@
def transform(type, data)
queue = @router ? @router.call(data) : @queue
- queue = flow.queue_provider.new queue
- queue.push wrap(type, data)
- nil
+ if queue
+ queue = flow.queue_provider.new queue
+ queue.push wrap(type, data)
+ nil
+ else
+ data
+ end
end
private
| Support skipping queue (local mode)
|
diff --git a/omnibus/config/software/pushy-server-cookbooks.rb b/omnibus/config/software/pushy-server-cookbooks.rb
index abc1234..def5678 100644
--- a/omnibus/config/software/pushy-server-cookbooks.rb
+++ b/omnibus/config/software/pushy-server-cookbooks.rb
@@ -6,33 +6,30 @@
name "pushy-server-cookbooks"
+source path: "#{project.files_path}/pushy-server-cookbooks"
+
dependency 'berkshelf2'
-cookbook_name = "opscode-pushy-server"
-cookbook_dir = "#{install_dir}/embedded/cookbooks"
-
-source path: "#{project.files_path}/pushy-server-cookbooks"
-
build do
- mkdir "#{cookbook_dir}"
- command "cd #{cookbook_name} && #{install_dir}/embedded/bin/berks install" \
- " --path=#{cookbook_dir}"
+ env = with_standard_compiler_flags(with_embedded_path)
+ command "berks install" \
+ " --path=#{install_dir}/embedded/cookbooks", env: env, cwd: "#{project_dir}/opscode-pushy-server"
block do
- File.open("#{cookbook_dir}/dna.json", "w") do |f|
+ File.open("#{install_dir}/embedded/cookbooks/dna.json", "w") do |f|
f.write JSON.fast_generate(
run_list: [
'recipe[opscode-pushy-server::default]',
]
)
end
- File.open("#{cookbook_dir}/show-config.json", "w") do |f|
+ File.open("#{install_dir}/embedded/cookbooks/show-config.json", "w") do |f|
f.write JSON.fast_generate(
run_list: [
'recipe[opscode-pushy-server::show_config]',
]
)
end
- File.open("#{cookbook_dir}/solo.rb", "w") do |f|
+ File.open("#{install_dir}/embedded/cookbooks/solo.rb", "w") do |f|
f.write <<-EOH.gsub(/^ {8}/, '')
cookbook_path "#{install_dir}/embedded/cookbooks"
file_cache_path "#{install_dir}/embedded/cookbooks/cache"
| Make cookbooks software definition consistent with other projects.
|
diff --git a/spec/gc.rb b/spec/gc.rb
index abc1234..def5678 100644
--- a/spec/gc.rb
+++ b/spec/gc.rb
@@ -0,0 +1,103 @@+#!/usr/bin/env ruby
+
+require 'rubygems'
+require 'bacon'
+require "#{File.expand_path(File.dirname(__FILE__))}/../lib/bitcask"
+
+unless ARGV.first
+ puts "I need a bitcask directory."
+ exit 1
+end
+
+Bacon.summary_on_exit
+
+describe 'Bitcask GC' do
+ def count(k)
+ c = 0
+ ObjectSpace.each_object(k) do |x|
+ c += 1
+ end
+ c
+ end
+
+ def all(k)
+ os = []
+ ObjectSpace.each_object(k) do |x|
+ os << x
+ end
+ os
+ end
+
+ def fhs
+ `lsof -p #{Process.pid} 2>/dev/null`.split("\n").map do |line|
+ line.chomp.split("\s", 9).last
+ end.select do |e|
+ e[File.expand_path(ARGV.first)]
+ end.size
+ end
+
+ it 'test GC tests' do
+ class Foo; end
+ x = Foo.new
+ count(Foo).should == 1
+
+ x = nil
+ GC.start
+ count(Foo).should == 0
+ end
+
+ should 'GC an unloaded bitcask' do
+ x = Bitcask.new ARGV.first
+ count(Bitcask).should == 1
+ x = nil
+ GC.start
+ count(Bitcask).should == 0
+ end
+
+ should 'GC a bitcask and datafiles' do
+ x = Bitcask.new ARGV.first
+ x.data_files
+
+ count(Bitcask::DataFile).should > 0
+
+ x = nil
+ GC.start
+
+ count(Bitcask::DataFile).should == 0
+ count(Bitcask).should == 0
+ end
+
+ should 'close filehandles from an unloaded bitcask at GC' do
+ f1 = fhs
+
+ b = Bitcask.new ARGV.first
+ b.data_files
+
+ f2 = fhs
+ f2.should > f1
+
+ # When removed, the datafiles should be GCed.
+ b = nil
+ GC.start
+
+ f3 = fhs
+ f3.should < f2
+ f3.should == f1
+ end
+
+ should 'close filehandles from a loaded bitcask at GC' do
+ f1 = fhs
+ b = Bitcask.new ARGV.first
+ b.load
+
+ f2 = fhs
+ f2.should > f1
+
+ b = nil
+ GC.start
+
+ f3 = fhs
+ f3.should < f2
+ f3.should == f1
+ end
+end
| Add spec to verify filehandle closing on GC.
|
diff --git a/spec/lib/initializers/zz_patch_reconnect_spec.rb b/spec/lib/initializers/zz_patch_reconnect_spec.rb
index abc1234..def5678 100644
--- a/spec/lib/initializers/zz_patch_reconnect_spec.rb
+++ b/spec/lib/initializers/zz_patch_reconnect_spec.rb
@@ -0,0 +1,19 @@+# encoding: utf-8
+
+require_relative '../../spec_helper'
+
+describe ActiveRecord::ConnectionAdapters::PostgreSQLAdapter do
+ describe '#survive_failure' do
+
+ it 'Should survive a PostgreSQL disconnection' do
+ # We don't care about whether a visualization exists, we just want some activity
+ viz1 = Carto::Visualization.first
+ #break the AR connection on purpose
+ expect {
+ ActiveRecord::Base.connection.exec_query("SELECT pg_terminate_backend(pg_backend_pid())")
+ }.to raise_exception(ActiveRecord::StatementInvalid)
+ viz2 = Carto::Visualization.first
+ end
+ end
+
+end
| Add spec for AR reconnection monkeypatching
|
diff --git a/lib/capistrano/tasks/shared.rake b/lib/capistrano/tasks/shared.rake
index abc1234..def5678 100644
--- a/lib/capistrano/tasks/shared.rake
+++ b/lib/capistrano/tasks/shared.rake
@@ -1,3 +1,11 @@+#
+# Manage shared files
+#
+# Configuration:
+#
+# - `shared_rsync_options`: Allow to specify which options to be used to pull rsync (default: `-avz --no-owner --no-group -delete`)
+# - `shared_sync_pattern`: Allow to filter directories path using regular expression (default: `/^(web\/medias|app\/Resources)/`)
+#
namespace :shared do
desc "Pull locally shared files using rsync"
task :pull do
@@ -5,7 +13,7 @@ run_locally do
rsync_options = fetch(:shared_rsync_options, "-avz --no-owner --no-group -delete")
fetch(:linked_dirs).each do |dir|
- if dir =~ fetch(:shared_rsync_pattern, /^(web|app\/Resources)/)
+ if dir =~ fetch(:shared_rsync_pattern, /^(web\/medias|app\/Resources)/)
execute :rsync, rsync_options, "-e 'ssh -p #{fetch(:port, 22)}'", "#{server.user}@#{server.hostname}:#{shared_path}/#{dir}/*", "#{dir}"
end
end
| Add some documentation, update default filter
|
diff --git a/lib/github_cli/commands/users.rb b/lib/github_cli/commands/users.rb
index abc1234..def5678 100644
--- a/lib/github_cli/commands/users.rb
+++ b/lib/github_cli/commands/users.rb
@@ -5,17 +5,41 @@
namespace :user
+ desc 'list', 'List all users'
+ option :since, :type => :string, :banner => "<user>",
+ :desc => "The integer ID of the last User that you’ve seen."
+ def list
+ params = options[:params].dup
+ params['since'] = options[:since] if options[:since]
+ User.all params, options[:format]
+ end
+
desc 'get', 'Get the authenticated user'
- method_option :user, :type => :string, :aliases => ["-u"],
- :desc => 'Get a single unauthenticated <user>',
- :banner => '<user>'
+ option :user, :type => :string, :aliases => ["-u"],
+ :desc => 'Get a single unauthenticated <user>',
+ :banner => '<user>'
def get
User.get options[:user], options[:params], options[:format]
end
desc 'update', 'Update the authenticated user'
+ option :name, :type => :string
+ option :email, :type => :string
+ option :blog, :type => :string
+ option :company, :type => :string
+ option :location, :type => :string
+ option :hireable, :type => :string
+ option :bio, :type => :string
def update
- User.update options[:params], options[:format]
+ params = options[:params].dup
+ params['name'] = options[:name] if options[:name]
+ params['email'] = options[:email] if options[:email]
+ params['blog'] = options[:blog] if options[:blog]
+ params['company'] = options[:company] if options[:company]
+ params['location'] = options[:location] if options[:location]
+ params['hireable'] = options[:hireable] if options[:hireable]
+ params['bio'] = options[:bio] if options[:bio]
+ User.update params, options[:format]
end
end # Users
| Add user listing command and add options support.
|
diff --git a/lib/jmespath/nodes/projection.rb b/lib/jmespath/nodes/projection.rb
index abc1234..def5678 100644
--- a/lib/jmespath/nodes/projection.rb
+++ b/lib/jmespath/nodes/projection.rb
@@ -11,7 +11,8 @@ if (targets = extract_targets(@target.visit(value)))
list = []
targets.each do |v|
- if (vv = @projection.visit(v))
+ vv = @projection.visit(v)
+ unless vv.nil?
list << vv
end
end
| Fix a bug in Projection
It shouldn't skip false values, just nil values
|
diff --git a/lib/net/ptth/incoming_request.rb b/lib/net/ptth/incoming_request.rb
index abc1234..def5678 100644
--- a/lib/net/ptth/incoming_request.rb
+++ b/lib/net/ptth/incoming_request.rb
@@ -11,6 +11,8 @@ env["CONTENT_LENGTH"] = body.length unless body.nil?
env.merge!(headers) if headers
+
+ env
end
end
end
| Make sure env is always returned
If headers is nil here, the method previously returned nil.
|
diff --git a/lib/traitdb_import/downloader.rb b/lib/traitdb_import/downloader.rb
index abc1234..def5678 100644
--- a/lib/traitdb_import/downloader.rb
+++ b/lib/traitdb_import/downloader.rb
@@ -0,0 +1,27 @@+require 'net/http'
+require 'uri'
+
+# initialize with url
+# return path to downloaded file on local file system
+
+module TraitDB
+ class Downloader
+ def initialize(uri=nil)
+ puts uri
+ @file = nil
+ end
+
+ def file
+ if @file.nil?
+ download
+ end
+ return @file
+ end
+
+ private
+
+ def download
+ raise 'Not yet implemented'
+ end
+ end
+end | Add skeleton class for downloading files, not functional
|
diff --git a/app/models/application_record.rb b/app/models/application_record.rb
index abc1234..def5678 100644
--- a/app/models/application_record.rb
+++ b/app/models/application_record.rb
@@ -4,7 +4,7 @@ self.abstract_class = true
def self.raise_not_implemented_error
- raise NotImplementedError, "Subclass should override method '#{caller(1..1).first[/`.*'/][1..-2]}'"
+ raise NotImplementedError, "Subclass should override method '#{caller_locations(1, 1)[0].label}'"
end
private_class_method :raise_not_implemented_error
end
| Update method to get name of called method for Ruby 2.0+
|
diff --git a/app/models/quota_order_number.rb b/app/models/quota_order_number.rb
index abc1234..def5678 100644
--- a/app/models/quota_order_number.rb
+++ b/app/models/quota_order_number.rb
@@ -1,6 +1,6 @@ class QuotaOrderNumber < Sequel::Model
plugin :time_machine
- plugin :oplog, primary_key: :quota_definition_sid
+ plugin :oplog, primary_key: :quota_order_number_sid
plugin :conformance_validator
set_primary_key [:quota_order_number_sid]
| Fix QuotaOrderNumber pk for oplog plugin
|
diff --git a/test/centos_spec.rb b/test/centos_spec.rb
index abc1234..def5678 100644
--- a/test/centos_spec.rb
+++ b/test/centos_spec.rb
@@ -16,4 +16,12 @@ it 'should disable SELinux' do
expect(selinux).to be_disabled
end
+
+ vbox_string = command("dmesg | grep VirtualBox").stdout
+ has_vbox = vbox_string.include? 'VirtualBox'
+ it 'should have single-request-reopen on virtualbox', :if => has_vbox do
+ if file('/redhat/release').content.scan(/(release 5) | (release 6)/)
+ expect(file('/etc/resolv.conf').content).to match /single-request-reopen/
+ end
+ end
end
| Add test for slow DNS fix
|
diff --git a/test/test_helper.rb b/test/test_helper.rb
index abc1234..def5678 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -1,4 +1,13 @@ require 'rubygems'
+
+if ENV['CODECLIMATE_REPO_TOKEN']
+ require 'codeclimate-test-reporter'
+ CodeClimate::TestReporter.start
+else
+ require 'simplecov'
+ SimpleCov.start
+end
+
require 'test/unit'
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
@@ -11,4 +20,4 @@ def assert_all_equal(expected, *results)
results.each { |result| assert_equal expected, result }
end
-end+end
| Integrate code climate test coverage
|
diff --git a/test/test_octets.rb b/test/test_octets.rb
index abc1234..def5678 100644
--- a/test/test_octets.rb
+++ b/test/test_octets.rb
@@ -20,6 +20,15 @@ assert_equal(0x01020304, o.to_i)
end
+ def test_octets_single_octet
+ o = Octets.new
+ o.read("ABCD")
+ assert_equal(o.o1, 0x41)
+ assert_equal(o.o2, 0x42)
+ assert_equal(o.o3, 0x43)
+ assert_equal(o.o4, 0x44)
+ end
+
end
# vim: nowrap sw=2 sts=0 ts=2 ff=unix ft=ruby
| Add some single octet tests.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.