diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/0_code_wars/memoized_fibonacci.rb b/0_code_wars/memoized_fibonacci.rb index abc1234..def5678 100644 --- a/0_code_wars/memoized_fibonacci.rb +++ b/0_code_wars/memoized_fibonacci.rb @@ -0,0 +1,14 @@+# http://www.codewars.com/kata/529adbf7533b761c560004e5/ +# --- iteration 1 --- +def fibonacci(n) + a, b = 1, 1 + (n - 1).times do |i| + a, b = b, a + b + end + a +end + +# --- iteration 2 --- +def fibonacci(n, cache = [0,1]) + cache[n] ||= fibonacci(n-1, cache) + fibonacci(n-2, cache) +end
Add code wars (5) - memoized fibonacci
diff --git a/spec/h_spec.rb b/spec/h_spec.rb index abc1234..def5678 100644 --- a/spec/h_spec.rb +++ b/spec/h_spec.rb @@ -3,7 +3,7 @@ describe "h plugin" do it "adds h method for html escaping" do app(:h) do |r| - r.on do |id| + r.on do h("<form>") + h(:form) end end
Fix minor nit in h plugin spec
diff --git a/src/bxs.rb b/src/bxs.rb index abc1234..def5678 100644 --- a/src/bxs.rb +++ b/src/bxs.rb @@ -14,6 +14,7 @@ .collect(&:strip) .drop_while { |l| l != 'Failed examples:' } \ [2..-2] + lines = lines && lines .collect { |l| l.gsub(/\x1b\[\d+(;\d+)?m/, '') } .collect { |l| l.match(/\Arspec ([^ ]+)/)[1] } #require 'pp'; pp lines
Fix issue when .rspec.out green
diff --git a/lib/notifiable/notification_status.rb b/lib/notifiable/notification_status.rb index abc1234..def5678 100644 --- a/lib/notifiable/notification_status.rb +++ b/lib/notifiable/notification_status.rb @@ -3,6 +3,7 @@ belongs_to :notification, :class_name => 'Notifiable::Notification' belongs_to :device_token, :class_name => 'Notifiable::DeviceToken' + self.table_name = 'notifiable_statuses' def opened! update_attributes({:status => -1, :uuid => nil}) end
Set table name for NotificationStatus
diff --git a/app/controllers/position_applications_controller.rb b/app/controllers/position_applications_controller.rb index abc1234..def5678 100644 --- a/app/controllers/position_applications_controller.rb +++ b/app/controllers/position_applications_controller.rb @@ -34,7 +34,7 @@ def update position_application = PositionApplication.find params[:id] position_params = params[:position_application] - position_application.set_position! position_params + position_application.update_attributes! position_params respond_to do |format| format.json { render :json => position_application } end
Use update_attributes (and the internal set_position handling) for position application also
diff --git a/test/test_usage.rb b/test/test_usage.rb index abc1234..def5678 100644 --- a/test/test_usage.rb +++ b/test/test_usage.rb @@ -19,7 +19,7 @@ # ensures that it uses next token and what not def test_select_usage_logging - SimpleRecord.log_usage(:select=>{:filename=>"/mnt/selects.csv", :format=>:csv, :lines_between_flushes=>2}) + SimpleRecord.log_usage(:select=>{:filename=>"/tmp/selects.csv", :format=>:csv, :lines_between_flushes=>2}) num_made = 10 num_made.times do |i|
Move the test log to /tmp as most won't have permission for /mnt
diff --git a/test/test_fulltext.rb b/test/test_fulltext.rb index abc1234..def5678 100644 --- a/test/test_fulltext.rb +++ b/test/test_fulltext.rb @@ -1,7 +1,7 @@ require 'helper' describe Arel do - before :all do + before do @table = Arel::Table.new(:people) @attr = @table[:name] @conn = FakeRecord::Base.new
Fix on minitest to support 1.9.3
diff --git a/MockInject.podspec b/MockInject.podspec index abc1234..def5678 100644 --- a/MockInject.podspec +++ b/MockInject.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| s.name = "MockInject" - s.version = "0.1.1" + s.version = "1.0.0" s.summary = "A library that allows developers to globally mock any ObjectiveC class' initialization method when testing with Kiwi." s.homepage = "https://github.com/gantaa/MockInject" s.license = { :type => 'MIT', :file => 'MIT-LICENSE.txt' } s.author = { "Matt Ganski" => "[email protected]" } - s.source = { :git => "https://github.com/gantaa/MockInject.git", :tag => "0.1.1" } + s.source = { :git => "https://github.com/gantaa/MockInject.git", :tag => "#{s.version}" } s.platform = :ios, '6.0' s.source_files = 'MockInject', 'MockInject/**/*.{h,m}' s.public_header_files = 'MockInject/**/*.h'
Update Podspec for 1.0.0 version
diff --git a/test/register_test.rb b/test/register_test.rb index abc1234..def5678 100644 --- a/test/register_test.rb +++ b/test/register_test.rb @@ -21,4 +21,21 @@ assert_equal [["del", "widget:foo"]], breadcrumb.tracked_keys end + + it 'can register member of set keys for a specific object' do + class MemberOfSetBreadcrumb < Redis::Breadcrumb + tracked_in 'widget:<id>:tracking' + + member_of_set "<id>" => :a_set_of_things + end + + obj = Object.new + class << obj + def id; "foo"; end + end + + breadcrumb = MemberOfSetBreadcrumb.register(obj) + + assert_equal [["srem", "a_set_of_things", "foo"]], breadcrumb.tracked_keys + end end
Add test 'can register member of set keys for a specific object'
diff --git a/amakanize.gemspec b/amakanize.gemspec index abc1234..def5678 100644 --- a/amakanize.gemspec +++ b/amakanize.gemspec @@ -16,7 +16,7 @@ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_development_dependency "bundler", "~> 1.12" + spec.add_development_dependency "bundler" spec.add_development_dependency "rake", "~> 10.0" spec.add_development_dependency "rspec", "3.5.0" end
Allow any version bundler for Travis CI
diff --git a/spec/page_spec.rb b/spec/page_spec.rb index abc1234..def5678 100644 --- a/spec/page_spec.rb +++ b/spec/page_spec.rb @@ -0,0 +1,36 @@+describe 'Page' do + let(:site) { double } + + describe '#initialize' do + context 'when a path is provided' do + let(:page) { Dimples::Page.new(site, './pages/about.erb') } + + before do + page_data = <<PAGE_DATA +--- +title: About +layout: default +--- + +Hello. +PAGE_DATA + + allow(File).to receive(:read).with('./pages/about.erb').and_return(page_data) + end + + it 'parses the metadata and contents' do + expect(page.contents).to eq('Hello.') + expect(page.metadata).to eq({ title: 'About', layout: 'default' }) + end + end + + context 'when no path is provided' do + let(:page) { Dimples::Page.new(site) } + + it 'sets the default metadata and contents' do + expect(page.contents).to eq('') + expect(page.metadata).to eq({}) + end + end + end +end
Add the initial Page tests
diff --git a/Casks/dump-truck.rb b/Casks/dump-truck.rb index abc1234..def5678 100644 --- a/Casks/dump-truck.rb +++ b/Casks/dump-truck.rb @@ -4,7 +4,7 @@ url 'https://www.goldenfrog.com/downloads/dumptruck/dumptruck.dmg' name 'Dump Truck' - homepage 'http://www.goldenfrog.com/dumptruck' + homepage 'https://www.goldenfrog.com/dumptruck' license :unknown # todo: change license and remove this comment; ':unknown' is a machine-generated placeholder app 'Dump Truck.app'
Fix homepage to use SSL in Dump Truck Cask The HTTP URL is already getting redirected to HTTPS. Using the HTTPS URL directly makes it more secure and saves a HTTP round-trip.
diff --git a/lib/hanami/assets/cache.rb b/lib/hanami/assets/cache.rb index abc1234..def5678 100644 --- a/lib/hanami/assets/cache.rb +++ b/lib/hanami/assets/cache.rb @@ -4,7 +4,7 @@ module Assets # Store assets references when compile mode is on. # - # This is expecially useful in development mode, where we want to compile + # This is especially useful in development mode, where we want to compile # only the assets that were changed from last browser refresh. # # @since 0.1.0
Fix typo in documentation comment [skip ci]
diff --git a/ZamzamKit.podspec b/ZamzamKit.podspec index abc1234..def5678 100644 --- a/ZamzamKit.podspec +++ b/ZamzamKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "ZamzamKit" - s.version = "0.9.1" + s.version = "0.9.2" s.summary = "A Swift framework for rapidly developing Apple mobile apps." s.description = <<-DESC ZamzamKit is a Swift framework for Apple devices to allow @@ -23,8 +23,8 @@ s.requires_arc = true - s.ios.frameworks = 'AVFoundation' - s.watchos.frameworks = 'ClockKit' + s.ios.framework = 'AVFoundation' + s.watchos.framework = 'ClockKit' s.source_files = "Sources/**/*.{h,swift}" end
Fix pod spec framework linking.
diff --git a/lib/rubocop_delayed_job.rb b/lib/rubocop_delayed_job.rb index abc1234..def5678 100644 --- a/lib/rubocop_delayed_job.rb +++ b/lib/rubocop_delayed_job.rb @@ -5,9 +5,11 @@ module Cop module Lint class DelayedJob < Cop + MSG = "Don't use the %s method to create jobs. Instead, create a custom job class in app/jobs and enqueue it with Delayed::Job.enqueue MyJob.new" def on_send(node) - return unless node.to_a[1] == :delay - msg = "Don't call the delay method to create jobs. Instead, create a custom job class in app/jobs" + method_name = node.to_a[1] + return unless [:handle_asynchronously, :delay].include?(method_name) + msg = MSG % method_name add_offense(node, :expression, msg) end end
Update to forbid handle_asynchronously as well
diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index abc1234..def5678 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -1,9 +1,8 @@ class CommentsController < ApplicationController def create - comment = params[:comment] - comment[:post_id] = params[:post_id] @new_comment = Comment.new(comment_params) + @new_comment.post_id = params[:post_id] if @new_comment.save render json: @new_comment end
Change add new comment structure
diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index abc1234..def5678 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -29,7 +29,7 @@ def new @message = Message.new - @message.receiver = User.find_by_username! params[:receiver] + @message.receiver = User.find_by_username params[:receiver] @reply = Message.find params[:reply] if params[:reply] if @reply
Fix receiver on new message
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index abc1234..def5678 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -20,4 +20,10 @@ end end + def delete + session.delete(:student_id) + session.delete(:professor_id) + redirect_to login + end + end
Write the controller for a logout route
diff --git a/app/models/shipwire/order_decorator.rb b/app/models/shipwire/order_decorator.rb index abc1234..def5678 100644 --- a/app/models/shipwire/order_decorator.rb +++ b/app/models/shipwire/order_decorator.rb @@ -0,0 +1,10 @@+# Fix for retrieve order from Shipwire gem +module SolidusShipwire + module FixFindOrder + def find(id, params = {}) + request(:get, "orders/#{id}", params: params) + end + end +end + +Shipwire::Orders.prepend SolidusShipwire::FixFindOrder
Fix for retrieve order from Shipwire gem Shipwire::Orders.new.find must return order information instead trackings
diff --git a/lib/static_sync/storage.rb b/lib/static_sync/storage.rb index abc1234..def5678 100644 --- a/lib/static_sync/storage.rb +++ b/lib/static_sync/storage.rb @@ -49,6 +49,7 @@ :region => @config.remote['region'], :aws_access_key_id => @config.remote['username'], :aws_secret_access_key => @config.remote['password'], + :aws_session_token => @config.remote['session_token'], :path_style => @config.remote['path_style'] }) end
Add support for AWS STS tokens
diff --git a/lib/tasks/api_clients.rake b/lib/tasks/api_clients.rake index abc1234..def5678 100644 --- a/lib/tasks/api_clients.rake +++ b/lib/tasks/api_clients.rake @@ -1,4 +1,18 @@ namespace :api_clients do + # Used to register an API client (API clients are just a type of user), + # grant them a given named permission in a named application, + # authorize them and create an appropriate token for use as a Bearer + # token. + # + # Parameters: + # name - A friendly name for the "user" + # (eg. "frontend application") + # email - An email address for contact about that app + # (eg. [email protected]) + # application_name - The *name* used for the app within signonotron + # (eg. 'Panopticon') + # permission - The *name* of the default permission to be granted + # (eg. 'signin') desc "Create an API client for a registered application" task :create, [:name, :email, :application_name, :permission] => :environment do |t, args| # make sure we have all the pieces
Add helpful comment to describe parameters to rake task
diff --git a/mtransform.gemspec b/mtransform.gemspec index abc1234..def5678 100644 --- a/mtransform.gemspec +++ b/mtransform.gemspec @@ -13,9 +13,9 @@ spec.homepage = "" spec.license = "MIT" - spec.files = `git ls-files -z`.split("\x0") - spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } - spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) + spec.files = Dir['Rakefile', 'README.md', 'LICENSE.txt', 'lib/**/*'] + spec.executables = Dir['bin/*'] + spec.test_files = Dir['spec/**/*'] spec.require_paths = ["lib"] spec.add_development_dependency "bundler", "~> 1.5"
Remove git dependency from gemspec.
diff --git a/netuitived.gemspec b/netuitived.gemspec index abc1234..def5678 100644 --- a/netuitived.gemspec +++ b/netuitived.gemspec @@ -10,7 +10,7 @@ s.files = files s.homepage = 'http://rubygems.org/gems/netuitived' - s.license = 'Apache v2.0' + s.license = 'Apache-2.0' s.required_ruby_version = '>= 1.9.0' s.executables << 'netuitived' end
Update Gemspec to use a valid license
diff --git a/active_git.gemspec b/active_git.gemspec index abc1234..def5678 100644 --- a/active_git.gemspec +++ b/active_git.gemspec @@ -23,6 +23,10 @@ s.add_development_dependency "bundler", "~> 1.3" s.add_development_dependency "rake" s.add_development_dependency 'rspec' - s.add_development_dependency 'sqlite3' s.add_development_dependency "simplecov" + if RUBY_ENGINE == 'jruby' + s.add_development_dependency 'activerecord-jdbcsqlite3-adapter' + else + s.add_development_dependency 'sqlite3' + end end
Support for test with jruby
diff --git a/lib/blog/engine.rb b/lib/blog/engine.rb index abc1234..def5678 100644 --- a/lib/blog/engine.rb +++ b/lib/blog/engine.rb @@ -7,5 +7,9 @@ FactoryGirl.definition_file_paths << File.expand_path('../../../spec/factories', __FILE__) end end + + config.generators do |g| + g.test_framework :rspec, :view_specs => false + end end end
Set rspec as test framework for generators
diff --git a/actiontext.gemspec b/actiontext.gemspec index abc1234..def5678 100644 --- a/actiontext.gemspec +++ b/actiontext.gemspec @@ -7,15 +7,15 @@ Gem::Specification.new do |s| s.name = "actiontext" s.version = ActionText::VERSION - s.authors = ["Javan Makhmali", "Sam Stephenson"] - s.email = ["[email protected]", "[email protected]"] + s.authors = ["Javan Makhmali", "Sam Stephenson", "David Heinemeier Hansson"] + s.email = ["[email protected]", "[email protected]", "[email protected]"] s.summary = "Edit and display rich text in Rails applications" - s.homepage = "https://github.com/basecamp/activetext" + s.homepage = "https://github.com/basecamp/actiontext" s.license = "MIT" s.required_ruby_version = ">= 2.2.2" - s.add_dependency "rails", ">= 5.2.0.rc1" + s.add_dependency "rails", ">= 5.2.0" s.add_dependency "nokogiri" s.add_development_dependency "bundler", "~> 1.15"
Update gemspec links and Rails dependency and humbly add myself as a coauthor
diff --git a/fql.gemspec b/fql.gemspec index abc1234..def5678 100644 --- a/fql.gemspec +++ b/fql.gemspec @@ -27,6 +27,7 @@ s.add_development_dependency "rails", "~> 3.2.6" s.add_development_dependency "sqlite3", ">= 1.3.6" s.add_development_dependency "fakeweb", "~> 1.3.0" + s.add_development_dependency "vcr" s.add_development_dependency "rb-fsevent" s.add_development_dependency "guard-test" end
Add vcr to development dependencies
diff --git a/vk.gemspec b/vk.gemspec index abc1234..def5678 100644 --- a/vk.gemspec +++ b/vk.gemspec @@ -19,7 +19,7 @@ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.require_paths = %w(lib) - s.add_dependency('activesupport', '>= 3.2.22') + s.add_dependency('activesupport', '>= 4.2.2') s.add_dependency('oauth2') s.add_development_dependency('rake')
Raise activesupport dep to one without security issues
diff --git a/lib/readline-ng.rb b/lib/readline-ng.rb index abc1234..def5678 100644 --- a/lib/readline-ng.rb +++ b/lib/readline-ng.rb @@ -60,6 +60,14 @@ nil end + def line + @lines.shift + end + + def each_line + yield @lines.shift while @lines.any? + end + end end
Add wrappers for popping lines off the stack
diff --git a/app/models/user.rb b/app/models/user.rb index abc1234..def5678 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,10 +2,11 @@ has_secure_password validates :username, :email, presence: true validates :email, uniqueness: true + validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i, :on => :create has_many :questions has_many :answers has_many :votes has_many :comments - + end
Add validation to put a format constraint on email attribute in User class
diff --git a/app/models/user.rb b/app/models/user.rb index abc1234..def5678 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,9 +1,42 @@ class User < ActiveRecord::Base has_secure_password has_many :dogs, foreign_key: :owner - has_many :bookings + has_many :requested_bookings, foreign_key: :requester_id, class_name: "Booking" + has_many :booking_requests, foreign_key: :sitter_id, class_name: "Booking" + + validates :first_name, presence: true + validates :last_name, presence: true + validates :email, presence: true, uniqueness: true + validates :username, presence: true, uniqueness: true + validates :password, presence: true, allow_nil: true, length: {minimum: 8, maximum: 25} + validates :birthday, presence: true + validates :price, numericality: {greater_than_or_equal_to: 0} + validates :xp_years, numericality: {only_integer: true, greater_than_or_equal_to: 0} + validates :housing_type, presence: true + validates :bio, presence: true, length: {maximum: 750} + validates :sitter, presence: true + validates :city, presence: true + validates :state, presence: true + validates :country, presence: true + validates :zip_code, presence: true + + validates_format_of :email, with: /\A([\w+\-]\.?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i + + validate birthday_cant_be_in_the_future, person_is_at_least_17 def age (Date.today - birthday).to_i / 365 end + + def birthday_cant_be_in_the_future + if birthday.present? && birthday > Date.today + errors.add(:birthday, "Birthday can't be in the future") + end + end + + def person_is_at_least_17 + if birthday.present? && birthday < 17.years.ago + errors.add(:birthday, "Must be older than 17") + end + end end
Add validations and fix associations
diff --git a/app/admin/queue.rb b/app/admin/queue.rb index abc1234..def5678 100644 --- a/app/admin/queue.rb +++ b/app/admin/queue.rb @@ -1,6 +1,5 @@ ActiveAdmin.register_page 'Queue' do content do - # Get runs that have a background worker workers = Sidekiq::Workers.new active_runs = workers.collect do |process_id, thread_id, work| if work["queue"] == "scraper"
Remove unhelpful comment from copy pasta
diff --git a/app/models/user.rb b/app/models/user.rb index abc1234..def5678 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -28,11 +28,11 @@ end def projects - Project.where('employee_id=? AND status!=?', id, Constants.get_status_id(:deleted)).order(:priority) + Project.where('employee_id=? AND status>=?', id, Constants.get_status_id(:deleted)).order(:priority) end def recent_projects - query = 'employee_id=? AND status!=? AND updated_at>=?' + query = 'employee_id=? AND status>=? AND updated_at>=?' Project.where(query, id, Constants.get_status_id(:deleted),
Use '>=' for integer comparison
diff --git a/app/models/user.rb b/app/models/user.rb index abc1234..def5678 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,2 +1,11 @@ class User < ActiveRecord::Base + VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i + + validates :name, presence: true, + uniqueness: { case_sensitive: false }, + length: { minimum: 3, maximum: 16 } + validates :email, presence: true, + length: { maximum: 255 }, + uniqueness: { case_sensitive: false }, + format: { with: VALID_EMAIL_REGEX } end
Add validations to the User model
diff --git a/ci_environment/hhvm/recipes/package.rb b/ci_environment/hhvm/recipes/package.rb index abc1234..def5678 100644 --- a/ci_environment/hhvm/recipes/package.rb +++ b/ci_environment/hhvm/recipes/package.rb @@ -1,12 +1,11 @@-if node["lsb"]["codename"] == 'precise' - apt_repository "boost-backports" do - uri "http://ppa.launchpad.net/mapnik/boost/ubuntu" - distribution node["lsb"]["codename"] - components ["main"] - keyserver "keyserver.ubuntu.com" - key "5D50B6BA" - action :add - end +apt_repository "boost-backports" do + uri "http://ppa.launchpad.net/mapnik/boost/ubuntu" + distribution node["lsb"]["codename"] + components ["main"] + keyserver "keyserver.ubuntu.com" + key "5D50B6BA" + action :add + only_if { node["lsb"]["codename"] == 'precise' } end apt_repository "hhvm-repository" do
Use chef conditional instead of ruby conditional
diff --git a/app/models/user.rb b/app/models/user.rb index abc1234..def5678 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -4,10 +4,9 @@ has_many :votes has_secure_password - before_validation :set_full_name - validates :full_name, :email, presence: true - validates :email, uniqueness: true + validate :validate_full_name + validates :email, presence: true, uniqueness: true def set_full_name if !self.full_name @@ -15,7 +14,19 @@ end end + def validate_full_name + if first_name == "" && last_name == "" + errors.add(:full_name, "must include first and last name") + elsif first_name == "" + errors.add(:full_name, "must include first name") + elsif last_name == "" + errors.add(:full_name, "must include last name") + end + end + def spotify_user_hash eval(self.spotify_credentials) end + + end
Create custom method to display actionable errors
diff --git a/app/models/user.rb b/app/models/user.rb index abc1234..def5678 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -10,6 +10,7 @@ field :admin, :type => Boolean, :default => false field :github_access_token field :signup_channel, :default => "unknown" + field :signup_referer, :default => "unknown" # validates_presence_of :email, :contact, :name # validates_uniqueness_of :email, :case_sensitive => false
Store the http-referers of signups.
diff --git a/app/models/vote.rb b/app/models/vote.rb index abc1234..def5678 100644 --- a/app/models/vote.rb +++ b/app/models/vote.rb @@ -4,5 +4,6 @@ validates :voter_id, presence: true validates :votable_type, presence: true validates :value, presence: true + validates :votable_id, presence: true end
Add presence validation for votable_id in Vote class
diff --git a/possessify.gemspec b/possessify.gemspec index abc1234..def5678 100644 --- a/possessify.gemspec +++ b/possessify.gemspec @@ -5,6 +5,7 @@ Gem::Specification.new do |s| s.name = "possessify" s.version = Possessify::VERSION + s.licenses = ['MIT'] s.platform = Gem::Platform::RUBY s.authors = ["David Busse"] s.email = ["[email protected]"] @@ -12,11 +13,10 @@ s.summary = %q{Possessify extends the Ruby String class adding functionality to make strings possessive and non-possessive.} s.description = %q{Possessify extends the Ruby String class adding functionality to make strings possessive and non-possessive. Methods include possessive, non_possessive, and possessive?} - s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.require_paths = ["lib"] - s.add_development_dependency 'minitest', '~> 5.4.2' + s.add_development_dependency 'minitest', '~> 5.4' end
Add license to gemspec and loosen version requirement for minitest
diff --git a/tchart.gemspec b/tchart.gemspec index abc1234..def5678 100644 --- a/tchart.gemspec +++ b/tchart.gemspec @@ -1,19 +1,20 @@ require './lib/tchart/version' Gem::Specification.new do |s| - s.name = "tchart" - s.summary = "Generate TeX/TikZ charts." - s.description = "Generate TikZ code to draw a chart of date-based data." - s.license = "MIT" - s.requirements = [ "none" ] - s.version = "#{TChart::Version}" - s.author = "Michael Lewandowski" - s.email = "[email protected]" - s.homepage = "https://github.com/milewgit/tchart" - s.platform = Gem::Platform::RUBY - s.required_ruby_version = ">=1.9" - s.files = Dir[ "lib/**/**", "LICENSE.txt", "README.md" ] - s.executables = [ "tchart" ] - s.test_files = Dir[ "test/*_test.rb" ] - s.has_rdoc = false + s.name = "tchart" + s.summary = "Generate TikZ code to draw a chart of date-based data." + s.description = s.summary + s.license = "MIT" + s.requirements = [ "none" ] + s.version = "#{TChart::Version}" + s.author = "Michael Lewandowski" + s.email = "[email protected]" + s.homepage = "https://github.com/milewgit/tchart" + s.platform = Gem::Platform::RUBY + s.required_ruby_version = ">=2.0" + s.files = Dir[ "lib/**/**", "LICENSE.txt", "README.md" ] + s.executables = [ "tchart" ] + s.test_files = Dir[ "test/*_test.rb" ] + s.has_rdoc = false + s.add_development_dependency "mocha", [ ">= 0.14.0" ] end
Add development dependency, adjust summary text.
diff --git a/spec/lonelyplanet_spec.rb b/spec/lonelyplanet_spec.rb index abc1234..def5678 100644 --- a/spec/lonelyplanet_spec.rb +++ b/spec/lonelyplanet_spec.rb @@ -15,7 +15,7 @@ obj = LonelyPlanetScrape::LonelyPlanetTours.new tours_found = JSON.parse(obj.tours) if !obj.tours.nil? - describe 'Check for difference between returned results and actual data and possibly HTML structure changes' do + describe 'Validate structure of result' do it 'check if the number of taiwan tours has changed' do tours_found.size.must_equal tours_from_file.size @@ -23,15 +23,15 @@ 0.upto(tours_from_file.length - 1) do |index| it 'check for price changes' do - tours_from_file[index]['price'].must_equal tours_found[index]['price'] + refute_empty tours_found[index]['price'], "Expect Price value for Object #{index}" end it 'check for title changes' do - tours_from_file[index]['title'].must_equal tours_found[index]['title'] + tours_found[index]['title'] end it 'check for description changes' do - tours_from_file[index]['content'].must_equal tours_found[index]['content'] + tours_found[index]['content'] end end end
Fix spec structure for pice
diff --git a/app.rb b/app.rb index abc1234..def5678 100644 --- a/app.rb +++ b/app.rb @@ -23,11 +23,12 @@ headcount = redis.scard('people') subject = if headcount < 2 - logger.info "personal subject" redis.srandmember('people') + elsif headcount < 3 + redis.srandmember('people', 2).join(' and ') else logger.info "cardinal subject" - headcount.to_s + "people" + "#{headcount} people" end text = "#{subject} would like coffee!"
Support personal output for 2 people Now, when there are two people, you get a response like 'Bob and Alice' instead of '2 people'. It'd be nice to know who you're going with if you're a pair, so 3 is the limit for cardinal output.
diff --git a/app.rb b/app.rb index abc1234..def5678 100644 --- a/app.rb +++ b/app.rb @@ -1,10 +1,13 @@ #encoding : utf-8 + +#Подключаем гемы require 'rubygems' require 'sinatra' require 'sinatra/reloader' require 'sqlite3' def init_db + #процедура инициализации БД db = SQLite3::Database.new 'leprosorium.db' db.results_as_hash = true return db @@ -37,7 +40,11 @@ post '/new' do content = params[:content] + if content.size < 1 + @error = 'Enter text of your post' + return erb :new + end - erb "#{content}" + erb "Other" end
Add validation of post text
diff --git a/cookbooks/nagios/attributes/default.rb b/cookbooks/nagios/attributes/default.rb index abc1234..def5678 100644 --- a/cookbooks/nagios/attributes/default.rb +++ b/cookbooks/nagios/attributes/default.rb @@ -26,9 +26,13 @@ case node['platform_family'] when 'debian' -default['nagios']['plugin_dir'] = '/usr/lib/nagios/plugins' +default['nagios']['plugin_dir'] = '/usr/lib/nagios/plugins' when 'rhel','fedora' - default['nagios']['plugin_dir'] = '/usr/lib64/nagios/plugins' + if node['kernel']['machine'] == "i686" + default['nagios']['plugin_dir'] = '/usr/lib/nagios/plugins' + else + default['nagios']['plugin_dir'] = '/usr/lib64/nagios/plugins' + end else - default['nagios']['plugin_dir'] = '/usr/lib/nagios/plugins' + default['nagios']['plugin_dir'] = '/usr/lib/nagios/plugins' end
Add 32bit RHEL support for the nagios plugins directory Former-commit-id: 73bc64ab57e2e2986ee985041d88b2940822a87a [formerly 4c6d5109c5c343f56ea43ac5b1b69969023b6a46] [formerly 2eb2a13bc4b9ec104dbb8c7b739851482f642e8e [formerly 48457e6f5fd0593a8257cfff2b84db3d7642f6a4]] Former-commit-id: d6ec4eefbd945dabe4dffa393a80d65ab7d921fa [formerly 5e0c0d02c26dd26661f2d1e3b801bb1c5948cfa0] Former-commit-id: 609fb277dff34efeabacfe73c96c58ecfb93a2ba
diff --git a/recipes/mod_ftp.rb b/recipes/mod_ftp.rb index abc1234..def5678 100644 --- a/recipes/mod_ftp.rb +++ b/recipes/mod_ftp.rb @@ -0,0 +1,33 @@+# +# Author:: Kevin Rivers (<[email protected]>) +# Cookbook Name:: iis +# Recipe:: mod_ftp +# +# Copyright 2014, Kevin Rivers +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +include_recipe "iis" + +if Opscode::IIS::Helper.older_than_windows2008r2? + features = %w{Web-Ftp-Server Web-Ftp-Service Web-Ftp-Ext} +else + features = %w{IIS-FTPServer IIS-FTPSvc IIS-FTPExtensibility} +end + +features.each do |f| + windows_feature f do + action :install + end +end
Add iis ftp feature installation
diff --git a/backburner.gemspec b/backburner.gemspec index abc1234..def5678 100644 --- a/backburner.gemspec +++ b/backburner.gemspec @@ -17,7 +17,7 @@ s.license = 'MIT' s.add_runtime_dependency 'beaneater', '~> 0.3.1' - s.add_runtime_dependency 'dante', '~> 0.1.5' + s.add_runtime_dependency 'dante', '> 0.1.5' s.add_development_dependency 'rake' s.add_development_dependency 'minitest', '3.2.0'
Change Dante dependency to allow v0.2.0 and play nice with Stripe Mocks
diff --git a/Casks/inform.rb b/Casks/inform.rb index abc1234..def5678 100644 --- a/Casks/inform.rb +++ b/Casks/inform.rb @@ -1,6 +1,6 @@ cask 'inform' do version '6M62' - sha256 '6fd0442a4b64a66ee27f0d09caf27bcc117737bd997653b94e8404ef7795f963' + sha256 'e3c9cbbd7fd3933e7585a0a89596c0c736e89d8bb5a9f297edfd6ad7d0f97c8c' url "http://inform7.com/download/content/#{version}/I7-#{version}-OSX.dmg" name 'Inform'
Fix checksum in Inform Cask
diff --git a/Casks/reeder.rb b/Casks/reeder.rb index abc1234..def5678 100644 --- a/Casks/reeder.rb +++ b/Casks/reeder.rb @@ -1,7 +1,7 @@ class Reeder < Cask - url 'http://reederapp.com/beta-reeder-for-mac/Reeder2.0b2.zip' + url 'http://reederapp.com/beta-reeder-for-mac/Reeder2.0b5.zip' homepage 'http://reederapp.com/mac/' - version '2.0b2' - sha256 '67491dcfa999e753c1f220a4f1216f15e14bea32af7e5a9c31499ccf082a1e66' + version '2.0b5' + sha256 '3841689b9642bcd94268964d6afa43d364eb1795ba1292f4816e21b343eb499c' link 'Reeder.app' end
Update Reeder to beta 5
diff --git a/Casks/skitch.rb b/Casks/skitch.rb index abc1234..def5678 100644 --- a/Casks/skitch.rb +++ b/Casks/skitch.rb @@ -4,7 +4,7 @@ url "http://cdn1.evernote.com/skitch/mac/release/Skitch-#{version}.zip" name 'Skitch' - homepage 'http://evernote.com/skitch/' + homepage 'https://evernote.com/skitch/' license :unknown # todo: change license and remove this comment; ':unknown' is a machine-generated placeholder app 'Skitch.app'
Fix homepage to use SSL in Skitch Cask The HTTP URL is already getting redirected to HTTPS. Using the HTTPS URL directly makes it more secure and saves a HTTP round-trip.
diff --git a/spec/lib/nfedobrasil_spec.rb b/spec/lib/nfedobrasil_spec.rb index abc1234..def5678 100644 --- a/spec/lib/nfedobrasil_spec.rb +++ b/spec/lib/nfedobrasil_spec.rb @@ -18,7 +18,7 @@ subject { NfedoBrasil.client({ssl_plcs_file: File.dirname(__FILE__) + '/../support/certificate.p12', ssl_plcs_password: 'nughee1O'}, true) } it 'handles dev mode properly' do - expect(subject.globals[:wsdl]).to match(/https:\/\/dev.sistema/) + expect(subject.globals[:wsdl]).to match(/https:\/\/nfeplacehl.e-datacenter/) end end end
Update dev mode url on nfedobrasil spec
diff --git a/spec/models/bus_stop_spec.rb b/spec/models/bus_stop_spec.rb index abc1234..def5678 100644 --- a/spec/models/bus_stop_spec.rb +++ b/spec/models/bus_stop_spec.rb @@ -30,4 +30,13 @@ end end end + + describe 'completed scope' do + end + + describe 'not_started scope' do + end + + describe 'pending scope' do + end end
Make sure to test these models
diff --git a/gittake.gemspec b/gittake.gemspec index abc1234..def5678 100644 --- a/gittake.gemspec +++ b/gittake.gemspec @@ -22,4 +22,5 @@ spec.add_development_dependency "bundler", "~> 1.3" spec.add_development_dependency "rake" + spec.add_development_dependency "pry" end
Add pry as dev dependency
diff --git a/lib/dpla.rb b/lib/dpla.rb index abc1234..def5678 100644 --- a/lib/dpla.rb +++ b/lib/dpla.rb @@ -2,10 +2,10 @@ require 'linked_vocabs' module DPLA - require 'dpla/source_resource' - require 'dpla/collection' - require 'dpla/place' - require 'dpla/time_span' - require 'dpla/aggregation' - require 'dpla/web_resource' + autoload :SourceResource, 'dpla/source_resource' + autoload :Collection, 'dpla/collection' + autoload :Place, 'dpla/place' + autoload :TimeSpan, 'dpla/time_span' + autoload :Aggregation, 'dpla/aggregation' + autoload :WebResource, 'dpla/web_resource' end
Use autoload for Resource classes
diff --git a/lib/services.rb b/lib/services.rb index abc1234..def5678 100644 --- a/lib/services.rb +++ b/lib/services.rb @@ -4,19 +4,11 @@ module Services def self.publishing_api - @publishing_api ||= GdsApi::PublishingApiV2.new( - Plek.find("publishing-api"), - bearer_token: ENV.fetch("PUBLISHING_API_BEARER_TOKEN", "example"), - timeout: 20, - ) + @publishing_api ||= publishing_api_client_with_timeout(20) end def self.publishing_api_with_low_timeout - @publishing_api_with_low_timeout ||= begin - publishing_api.dup.tap do |client| - client.options[:timeout] = 1 - end - end + @publishing_api_with_low_timeout ||= publishing_api_client_with_timeout(1) end def self.asset_manager @@ -32,4 +24,12 @@ bearer_token: ENV.fetch("EMAIL_ALERT_API_BEARER_TOKEN", "gazorpazorp") ) end + + def self.publishing_api_client_with_timeout(timeout) + GdsApi::PublishingApiV2.new( + Plek.find("publishing-api"), + bearer_token: ENV.fetch("PUBLISHING_API_BEARER_TOKEN", "example"), + timeout: timeout, + ) + end end
Fix changing the timeout for the Publishing API client Calling the publishing_api_with_low_timeout function would cause the Publishing API client timeout to be set to 1, which would break parts of Whitehall that talk to the Publishing API, casuing it to "hang up" after a second. Rather than using `.dup`, just make it a parameter to a new function, and call that in both places.
diff --git a/init.rb b/init.rb index abc1234..def5678 100644 --- a/init.rb +++ b/init.rb @@ -3,9 +3,7 @@ major, minor, _ = Heroku::VERSION.split(/\./).map(&:to_i) if (major > 3) || (major == 3 && minor >= 4) require File.expand_path('lib/heroku/client/heroku_postgresql', File.dirname(__FILE__)) - require File.expand_path('lib/heroku/client/heroku_postgresql_backups', File.dirname(__FILE__)) require File.expand_path('lib/heroku/command/pg', File.dirname(__FILE__)) - require File.expand_path('lib/heroku/command/pg_backups', File.dirname(__FILE__)) else $stderr.puts(Heroku::Helpers.format_with_bang(<<-EOM)) The heroku-pg-extras plugin was not loaded.
Remove migrated commands from imports
diff --git a/lib/too_dead.rb b/lib/too_dead.rb index abc1234..def5678 100644 --- a/lib/too_dead.rb +++ b/lib/too_dead.rb @@ -11,6 +11,7 @@ module TooDead class Menu - include Vedeu + # include Vedeu + end end
Remove vedeu from Menu class.
diff --git a/lib/ule_page.rb b/lib/ule_page.rb index abc1234..def5678 100644 --- a/lib/ule_page.rb +++ b/lib/ule_page.rb @@ -27,6 +27,11 @@ @@map_initialized = false def self.setup + UlePage::Page.send(:include, Rails.application.routes.url_helpers) if defined? Rails + UlePage::Page.send(:include, ActionView::Helpers::NumberHelper) if defined? ActionView + + self.add_models + yield self end @@ -38,3 +43,5 @@ end end end + +
Include rails router and action number helper module to page base model
diff --git a/spec/classes/astrill_spec.rb b/spec/classes/astrill_spec.rb index abc1234..def5678 100644 --- a/spec/classes/astrill_spec.rb +++ b/spec/classes/astrill_spec.rb @@ -4,6 +4,6 @@ it { should contain_class('astrill') } it { should contain_package('Astrill').with_provider('appdmg') } - it { should contain_package('Adium').with_source('https://www.astrill.com/downloads/astrill-setup-mac.dmg?mirror=usa') } + it { should contain_package('Astrill').with_source('https://www.astrill.com/downloads/astrill-setup-mac.dmg?mirror=usa') } end
Fix naming error produced from a copy and paste
diff --git a/spec/lib/api/helpers_spec.rb b/spec/lib/api/helpers_spec.rb index abc1234..def5678 100644 --- a/spec/lib/api/helpers_spec.rb +++ b/spec/lib/api/helpers_spec.rb @@ -0,0 +1,109 @@+require 'spec_helper' + +describe API::Helpers do + subject { Class.new.include(described_class).new } + + describe '#find_namespace' do + let(:namespace) { create(:namespace) } + + shared_examples 'namespace finder' do + context 'when namespace exists' do + it 'returns requested namespace' do + expect(subject.find_namespace(existing_id)).to eq(namespace) + end + end + + context "when namespace doesn't exists" do + it 'returns nil' do + expect(subject.find_namespace(non_existing_id)).to be_nil + end + end + end + + context 'when ID is used as an argument' do + let(:existing_id) { namespace.id } + let(:non_existing_id) { 9999 } + + it_behaves_like 'namespace finder' + end + + context 'when PATH is used as an argument' do + let(:existing_id) { namespace.path } + let(:non_existing_id) { 'non-existing-path' } + + it_behaves_like 'namespace finder' + end + end + + shared_examples 'user namespace finder' do + let(:user1) { create(:user) } + + before do + allow(subject).to receive(:current_user).and_return(user1) + allow(subject).to receive(:header).and_return(nil) + allow(subject).to receive(:not_found!).and_raise('404 Namespace not found') + end + + context 'when namespace is group' do + let(:namespace) { create(:group) } + + context 'when user has access to group' do + before do + namespace.add_guest(user1) + namespace.save! + end + + it 'returns requested namespace' do + expect(namespace_finder).to eq(namespace) + end + end + + context "when user doesn't have access to group" do + it 'raises not found error' do + expect { namespace_finder }.to raise_error(RuntimeError, '404 Namespace not found') + end + end + end + + context "when namespace is user's personal namespace" do + let(:namespace) { create(:namespace) } + + context 'when user owns the namespace' do + before do + namespace.owner = user1 + namespace.save! + end + + it 'returns requested namespace' do + expect(namespace_finder).to eq(namespace) + end + end + + context "when user doesn't own the namespace" do + it 'raises not found error' do + expect { namespace_finder }.to raise_error(RuntimeError, '404 Namespace not found') + end + end + end + end + + describe '#find_namespace!' do + let(:namespace_finder) do + subject.find_namespace!(namespace.id) + end + + it_behaves_like 'user namespace finder' + end + + describe '#user_namespace' do + let(:namespace_finder) do + subject.user_namespace + end + + before do + allow(subject).to receive(:params).and_return({ id: namespace.id }) + end + + it_behaves_like 'user namespace finder' + end +end
Add some unit tests for lib/api/helpers.rb
diff --git a/spec/scoring/entropy_spec.rb b/spec/scoring/entropy_spec.rb index abc1234..def5678 100644 --- a/spec/scoring/entropy_spec.rb +++ b/spec/scoring/entropy_spec.rb @@ -12,13 +12,13 @@ describe '#digits_entropy' do it 'returns a base 2 log of 10 to the power of the token length' do match = Zxcvbn::Match.new(:token => '12345678') - entropy.digits_entropy(match).should eq lg(10 ** match.token.length) + entropy.digits_entropy(match).should eq 26.5754247590989 end end describe '#year_entropy' do it 'returns a base 2 log of the number of possible years' do - entropy.year_entropy(nil).should eq lg(Zxcvbn::Scoring::Entropy::NUM_YEARS) + entropy.year_entropy(nil).should eq 6.894817763307944 end end end
Use fixed values rather than repeat the calculation in specs
diff --git a/test/integration/homepage_test.rb b/test/integration/homepage_test.rb index abc1234..def5678 100644 --- a/test/integration/homepage_test.rb +++ b/test/integration/homepage_test.rb @@ -34,8 +34,7 @@ should "use the English locale after visiting the Welsh content" do visit @payload[:base_path] visit "/" - assert page.has_content?(I18n.t("homepage.index.services_and_information", locale: :en)) - assert_not page.has_content?(I18n.t("homepage.index.services_and_information", locale: :cy)) + assert page.has_content?(I18n.t("homepage.index.government_activity_description", locale: :en)) end end end
Make homepage / Welsh test less coupled to Welsh locale file The previous iteration of this test checked that 1) English text appeared, and 2) Welsh text did not appear. Whilst that fulfilled the needs of the test, 2) is a bit redundant, given that we don't render a Welsh homepage at all. It means having to maintain a set of Welsh locales for a homepage, which never ends up getting used. It should be sufficient to just check that the English text displays. I've chosen a more substanial English locale property than just "Topics", which is the current value of `services_and_information` and could risk being part of 'normal' page furniture (as not everything on a Welsh page is translated).
diff --git a/test/unit/certificate_log_test.rb b/test/unit/certificate_log_test.rb index abc1234..def5678 100644 --- a/test/unit/certificate_log_test.rb +++ b/test/unit/certificate_log_test.rb @@ -0,0 +1,28 @@+require File.expand_path('../../test_helper', __FILE__) + +describe "CertificateDepot::Log" do + before do + @collector = Collector.new + @collector.stubs(:flock) + @log = CertificateDepot::Log.new(@collector) + end + + it "logs" do + @log.log(CertificateDepot::Log::DEBUG, "A message") + parts = @collector.written.join.split('|') + parts[0][0,7].should == "[#{Process.pid.to_s.rjust(5)}]" + parts[1].should == " A message\n" + end + + it "does not log under its loglevel" do + @log.level = CertificateDepot::Log::WARN + @log.debug("Info") + @collector.written.should == [] + end + + it "logs above its loglevel" do + @log.level = CertificateDepot::Log::WARN + @log.fatal("Info") + @collector.written.should.not.be.empty + end +end
Add tests for the logger. git-svn-id: 0b34dac3a39d255f46ac888f3fd4ecac3c863f70@93 b2217739-5cbd-4580-87d5-f689c6e5027b
diff --git a/app/models/tagging_spreadsheet.rb b/app/models/tagging_spreadsheet.rb index abc1234..def5678 100644 --- a/app/models/tagging_spreadsheet.rb +++ b/app/models/tagging_spreadsheet.rb @@ -1,7 +1,10 @@ class TaggingSpreadsheet < ActiveRecord::Base validates :url, presence: true - validates_presence_of :state - validates_inclusion_of :state, in: %w(uploaded errored ready_to_import imported) + validates( + :state, + presence: true, + inclusion: { in: %w(uploaded errored ready_to_import imported) } + ) validates_with GoogleUrlValidator has_many :tag_mappings, dependent: :delete_all
Rewrite tagging spreadsheet validations in consistent style
diff --git a/metadata.rb b/metadata.rb index abc1234..def5678 100644 --- a/metadata.rb +++ b/metadata.rb @@ -8,7 +8,7 @@ issues_url 'https://github.com/cvent/octopus-deploy-cookbook/issues' version '0.3.0' -depends 'windows', '~> 1' +depends 'windows', '~> 1.38' supports 'windows' provides 'octopus_deploy_server[OctopusServer]'
Fix issue with cookbook dependency version constraint
diff --git a/omnisend.rb b/omnisend.rb index abc1234..def5678 100644 --- a/omnisend.rb +++ b/omnisend.rb @@ -1,8 +1,10 @@ require 'amqp' require 'mq' -exit(1) unless ARGV.size == 1 -data = Marshal.dump(ARGV[0]) +exit(1) if ARGV.empty? +message = ARGV.join(' ') +puts "Sending message #{message}" +data = Marshal.dump(message) Signal.trap('INT') { AMQP.stop{ EM.stop } }
Send all command line parameters
diff --git a/vendor/sinatra-hacks/lib/hacks.rb b/vendor/sinatra-hacks/lib/hacks.rb index abc1234..def5678 100644 --- a/vendor/sinatra-hacks/lib/hacks.rb +++ b/vendor/sinatra-hacks/lib/hacks.rb @@ -0,0 +1,49 @@+module Sinatra + class EventContext + def params + @params ||= ParamsParser.new(@route_params.merge(@request.params)).to_hash + end + + private + + class ParamsParser + attr_reader :hash + + def initialize(hash) + @hash = nested(hash) + end + + alias :to_hash :hash + + protected + + def nested(hash) + hash.inject(indifferent_hash) do |par, (key,val)| + if key =~ /([^\[]+)\[([^\]]+)\](.*)/ # a[b] || a[b][c] ($1 == a, $2 == b, $3 == [c]) + par[$1] ||= indifferent_hash + par[$1].merge_recursive nested("#{$2}#{$3}" => val) + else + par[key] = val + end + par + end + end + + def indifferent_hash + Hash.new {|h,k| h[k.to_s] if Symbol === k} + end + end + end +end + +class Hash + def merge_recursive(other) + update(other) do |key, old_value, new_value| + if Hash === old_value && Hash === new_value + old_value.merge_recursive(new_value) + else + new_value + end + end + end +end
Add nested parameter support to Sinatra. Gets the job done till redux is out
diff --git a/recipes/_plugin_manager.rb b/recipes/_plugin_manager.rb index abc1234..def5678 100644 --- a/recipes/_plugin_manager.rb +++ b/recipes/_plugin_manager.rb @@ -1,3 +1,8 @@ add_vim_git_plugin({ "vundle" => "https://github.com/gmarik/vundle.git", "unbundle" => "https://github.com/sunaku/vim-unbundle.git", "pathogen" => "https://github.com/tpope/vim-pathogen.git" }[node[:vim_config][:plugin_manager].to_s]) + +case node[:vim_config][:plugin_manager] + when "pathogen" + node.override[:vim_config][:vimrc][:config][:system_wide] = node[:vim_config][:vimrc][:config][:system_wide].dup << "" << "source /etc/vim/bundle/vim-pathogen/autoload/pathogen.vim" << "execute pathogen#infect('/etc/vim/bundle/{}', 'bundle/{}')" +end
Configure pathogen for autoload system-wide bundles
diff --git a/pivnet_api.gemspec b/pivnet_api.gemspec index abc1234..def5678 100644 --- a/pivnet_api.gemspec +++ b/pivnet_api.gemspec @@ -19,7 +19,6 @@ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_development_dependency "oven" spec.add_development_dependency "bundler", "~> 1.13" spec.add_development_dependency "rake", "~> 10.0" spec.add_development_dependency "minitest", "~> 5.0"
Remove oven from development dependency
diff --git a/parse.rb b/parse.rb index abc1234..def5678 100644 --- a/parse.rb +++ b/parse.rb @@ -0,0 +1,103 @@+class KprobeOutput + attr_reader :fn, :src_ip, :dst_ip, :type + + FN_TO_NAME = { + 1 => 'netif_receive_skb', + 2 => 'ip_rcv', + 3 => 'ip_forward', + 4 => 'ip_output', + 5 => 'ip_finish_output', + 6 => 'ip_finish_output2', + 7 => 'icmp_send', + } + + def initialize(fn, src_ip, dst_ip, type) + @fn = fn + @src_ip = src_ip + @dst_ip = dst_ip + @type = type == 0 ? :syn : :syn_ack + end + + def fn_name + FN_TO_NAME[fn] + end + +end + +class OutputSequence + attr_reader :outputs + + def initialize(outputs) + if !outputs.map(&:type).all? + raise ArgumentError, 'kprobe outputs have mixed syn and syn-ack types' + end + + @outputs = outputs + end + + def type + outputs.first.type + end + + def src_ip + outputs.first.src_ip + end + + def dst_ip + outputs.first.dst_ip + end + + def has_drops? + !(seq_one? || seq_two?) + end + + def last_fn + outputs.last.fn_name + end + + SEQUENCE_ONE = [4, 5, 6, 1, 2, 3, 4, 5, 6] + SEQUENCE_TWO = [2, 3, 4, 5, 6, 2] + # A full sequence may be repeated multiple times within a single ack or + # syn-ack transmission. + # Additionally, it appears full syn and syn-ack messages can follow either + # function sequence. + def seq_one? + fns == SEQUENCE_ONE * (fns.length / SEQUENCE_ONE.length) + end + + def seq_two? + fns == SEQUENCE_TWO * (fns.length / SEQUENCE_TWO.length) + end + + def fns + outputs.map(&:fn) + end +end + +output = File.readlines('output.txt').map do |line| + s = line.split + KprobeOutput.new(s[0].to_i, s[1], s[2], s[3].to_i) +end + +grouped = output.group_by {|k| "#{k.src_ip} #{k.dst_ip}" } + +output_sequences = grouped.each.map do |_,v| + OutputSequence.new(v) +end + +drop_sequences = output_sequences.select(&:has_drops?) + +drop_length = drop_sequences.length + +if drop_length == 0 + puts "no drops" +end + +drop_percent = (drop_length.to_f / output_sequences.length * 100).round(2) + +puts "total packets: #{output_sequences.length}" +puts "total drops: #{drop_length} (#{drop_percent}%)" + +drop_sequences.each do |seq| + puts "drop #{seq.src_ip} #{seq.dst_ip} #{seq.fns} #{seq.type}" +end
Print out packets that dont match fairly narrow expectations
diff --git a/Casks/lighttable.rb b/Casks/lighttable.rb index abc1234..def5678 100644 --- a/Casks/lighttable.rb +++ b/Casks/lighttable.rb @@ -1,7 +1,7 @@ class Lighttable < Cask - url 'http://d35ac8ww5dfjyg.cloudfront.net/playground/bins/0.6.4/LightTableMac.zip' + url 'http://d35ac8ww5dfjyg.cloudfront.net/playground/bins/0.6.5/LightTableMac.zip' homepage 'http://www.lighttable.com/' - version '0.6.4' - sha256 'b6a925c50cb2dfe8de9b215456763145d8d7c6432cb013e39e0fb6432fb8dda7' + version '0.6.5' + sha256 '05b816605b901e63c47e5add543a21b59c811ac424b00fc3f3bcc3145180be77' link 'LightTable/LightTable.app' end
Update Light Table to 0.6.5
diff --git a/Casks/vienna-rss.rb b/Casks/vienna-rss.rb index abc1234..def5678 100644 --- a/Casks/vienna-rss.rb +++ b/Casks/vienna-rss.rb @@ -0,0 +1,6 @@+class ViennaRss < Cask + url 'http://downloads.sourceforge.net/vienna-rss/Vienna3.0.0_beta11.tgz' + homepage 'http://www.vienna-rss.org' + version '3.0.0_beta11' + sha1 'c1530387fb471331ed3947994e2071151e8d471b' +end
Add cask for Vienna RSS reader
diff --git a/rb/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb b/rb/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb index abc1234..def5678 100644 --- a/rb/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +++ b/rb/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb @@ -19,7 +19,10 @@ # Example: # # driver = Selenium::WebDriver.for :remote - # driver.file_detector = lambda { |str| str if File.exist?(str) } + # driver.file_detector = lambda do |args| + # # args => ["/path/to/file"] + # str if File.exist?(args.first.to_s) + # end # # driver.find_element(:id => "upload").send_keys "/path/to/file" #
JariBakken: Update file detector Ruby example. r14082
diff --git a/spec/googlefight_spec.rb b/spec/googlefight_spec.rb index abc1234..def5678 100644 --- a/spec/googlefight_spec.rb +++ b/spec/googlefight_spec.rb @@ -7,5 +7,6 @@ describe Lita::Handlers::Googlefight, lita_handler: true do it { is_expected.to route_command("!googlefight this;that").to(:googlefight) } + it { is_expected.to route_command("!gf 'another this';'another that'").to(:googlefight) } end
Add test for the short variant
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index abc1234..def5678 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,9 +1,4 @@ require 'rails_helper' - -# RSpec.describe User, type: :model do -# pending "add some examples to (or delete) #{__FILE__}" -# end - describe User do before { @user = FactoryGirl.build(:user) } @@ -15,4 +10,9 @@ it { should respond_to(:password_confirmation) } it { should be_valid } + + it { should validate_presence_of(:email) } + it { should validate_uniqueness_of(:email) } + it { should validate_confirmation_of(:password) } + it { should allow_value('[email protected]').for(:email) } end
Use shoulda matchers for spec refactors
diff --git a/lib/patterns.rb b/lib/patterns.rb index abc1234..def5678 100644 --- a/lib/patterns.rb +++ b/lib/patterns.rb @@ -30,6 +30,7 @@ mruby ruby rubygems + update_rubygems install uninstall sidekiq-pro
Add update_rubygems to reserve list
diff --git a/tematica.gemspec b/tematica.gemspec index abc1234..def5678 100644 --- a/tematica.gemspec +++ b/tematica.gemspec @@ -18,7 +18,7 @@ s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.markdown"] s.test_files = Dir["test/**/*"] - s.add_dependency 'rails', '~> 4.1.4' + s.add_dependency 'rails', '~> 4.1.5' s.add_dependency 'inherited_resources' s.add_dependency 'haml' s.add_dependency 'simple_form'
Update rails version to 4.1.5
diff --git a/lib/gitlab/markdown/sanitization_filter.rb b/lib/gitlab/markdown/sanitization_filter.rb index abc1234..def5678 100644 --- a/lib/gitlab/markdown/sanitization_filter.rb +++ b/lib/gitlab/markdown/sanitization_filter.rb @@ -8,27 +8,32 @@ # Extends HTML::Pipeline::SanitizationFilter with a custom whitelist. class SanitizationFilter < HTML::Pipeline::SanitizationFilter def whitelist - whitelist = HTML::Pipeline::SanitizationFilter::WHITELIST + whitelist = super - # Allow code highlighting - whitelist[:attributes]['pre'] = %w(class) - whitelist[:attributes]['span'] = %w(class) + # Only push these customizations once + unless customized?(whitelist[:transformers]) + # Allow code highlighting + whitelist[:attributes]['pre'] = %w(class) + whitelist[:attributes]['span'] = %w(class) - # Allow table alignment - whitelist[:attributes]['th'] = %w(style) - whitelist[:attributes]['td'] = %w(style) + # Allow table alignment + whitelist[:attributes]['th'] = %w(style) + whitelist[:attributes]['td'] = %w(style) - # Allow span elements - whitelist[:elements].push('span') + # Allow span elements + whitelist[:elements].push('span') - # Remove `rel` attribute from `a` elements - whitelist[:transformers].push(remove_rel) + # Remove `rel` attribute from `a` elements + whitelist[:transformers].push(remove_rel) - # Remove `class` attribute from non-highlight spans - whitelist[:transformers].push(clean_spans) + # Remove `class` attribute from non-highlight spans + whitelist[:transformers].push(clean_spans) + end whitelist end + + private def remove_rel lambda do |env| @@ -48,6 +53,10 @@ end end end + + def customized?(transformers) + transformers.last.source_location[0] == __FILE__ + end end end end
Customize the sanitization whitelist only once Fixes #1651
diff --git a/lib/mailer_previews/role_mailer_preview.rb b/lib/mailer_previews/role_mailer_preview.rb index abc1234..def5678 100644 --- a/lib/mailer_previews/role_mailer_preview.rb +++ b/lib/mailer_previews/role_mailer_preview.rb @@ -1,3 +1,4 @@+# Preview all emails at http://localhost:3000/rails/mailers/role_mailer class RoleMailerPreview < ActionMailer::Preview def user_added_to_team RoleMailer.user_added_to_team(Role.first) @@ -6,4 +7,9 @@ def coach_added_to_team RoleMailer.user_added_to_team(Role.where(name: 'coach').first) end + + def supervisor_added_to_team + role = Role.where(name: 'supervisor').first + RoleMailer.user_added_to_team role + end end
Add preview for new supervisor role mail notification
diff --git a/lib/rubocop/cop/style/colon_method_call.rb b/lib/rubocop/cop/style/colon_method_call.rb index abc1234..def5678 100644 --- a/lib/rubocop/cop/style/colon_method_call.rb +++ b/lib/rubocop/cop/style/colon_method_call.rb @@ -9,11 +9,11 @@ MSG = 'Do not use `::` for method calls.' def on_send(node) - receiver, _method_name, *_args = *node + receiver, method_name, *_args = *node # discard methods with nil receivers and op methods(like []) return unless receiver && node.loc.dot && node.loc.dot.is?('::') - return if allowed_name(_method_name.to_s) + return if allowed_name(method_name.to_s) add_offense(node, :dot) end
Fix an offense reported by UnderscorePrefixedVariableName
diff --git a/resources/mount.rb b/resources/mount.rb index abc1234..def5678 100644 --- a/resources/mount.rb +++ b/resources/mount.rb @@ -20,7 +20,7 @@ actions :mount, :umount, :enable, :disable default_action :mount -attribute :name, :kind_of => String, :name_attribute => true -attribute :server, :kind_of => String, :default => nil, :required => true -attribute :backup_server, :kind_of => [String, Array], :default => nil -attribute :mount_point, :kind_of => String, :default => nil, :required => true +attribute :name, kind_of: String, name_attribute: true +attribute :server, kind_of: String, default: nil, required: true +attribute :backup_server, kind_of: [String, Array], default: nil +attribute :mount_point, kind_of: String, default: nil, required: true
Switch to Ruby 1.9 hash syntax
diff --git a/recipes/nexi.rb b/recipes/nexi.rb index abc1234..def5678 100644 --- a/recipes/nexi.rb +++ b/recipes/nexi.rb @@ -1,10 +1,10 @@ -deb_name = 'VidyoDesktopInstaller-ubuntu64-TAG_VD_3_5_4_010.deb' +deb_name = 'VidyoDesktopInstaller-ubuntu64-TAG_VD_3_6_3_017.deb' deb_path = "#{Chef::Config[:file_cache_path]}/#{deb_name}" remote_file deb_path do source "https://demo.vidyo.com/upload/#{deb_name}" - checksum '9c5ab8293b6888336bc8d7a6d8b6d097f40efd201966c18cfd983f8adf58627c' + checksum '9d2455dc29bfa7db5cf3ec535ffd2a8c86c5a71f78d7d89c40dbd744b2c15707' end package 'libqt4-gui'
Update Vidyo client to newest package
diff --git a/comfy_blog.gemspec b/comfy_blog.gemspec index abc1234..def5678 100644 --- a/comfy_blog.gemspec +++ b/comfy_blog.gemspec @@ -16,7 +16,7 @@ s.platform = Gem::Platform::RUBY s.require_paths = ['lib'] - s.add_dependency 'comfortable_mexican_loveseat', '0.0.20' + s.add_dependency 'comfortable_mexican_loveseat', '0.0.22' s.add_dependency 'paperclip', '~> 4.3' s.add_dependency 'mini_magick', '4.3.6' end
Update gemspec to use the latest version of loveseat
diff --git a/lib/helpers/find_or_create_students.rb b/lib/helpers/find_or_create_students.rb index abc1234..def5678 100644 --- a/lib/helpers/find_or_create_students.rb +++ b/lib/helpers/find_or_create_students.rb @@ -6,12 +6,12 @@ using_cache = !@user_cache.nil? if !using_cache || !@user_cache.key?(username) profile = { - first_name: Faker::Name.first_name, - last_name: Faker::Name.last_name, - nickname: username, - role_id: Role.student_id, - email: "#{username}@doubtfire.com", - username: username + first_name: Faker::Name.first_name, + last_name: Faker::Name.last_name, + nickname: username, + role_id: Role.student_id, + email: "#{username}@doubtfire.com", + username: username } if !AuthenticationHelpers.aaf_auth? profile[:password] = 'password'
QUALITY: Use two space indentation for hash
diff --git a/lib/noosfero/core_ext/action_mailer.rb b/lib/noosfero/core_ext/action_mailer.rb index abc1234..def5678 100644 --- a/lib/noosfero/core_ext/action_mailer.rb +++ b/lib/noosfero/core_ext/action_mailer.rb @@ -1,27 +1,6 @@ class ActionMailer::Base attr_accessor :environment - - # Monkey patch to: - # 1) Allow multiple render calls, by keeping the body assigns into an instance variable - # 2) Don't render layout for partials - def render opts={} - @assigns ||= opts.delete(:body) - if opts[:file] && (opts[:file] !~ /\// && !opts[:file].respond_to?(:render)) - opts[:file] = "#{mailer_name}/#{opts[:file]}" - end - - begin - old_template, @template = @template, initialize_template_class(@assigns || {}) - unless opts[:partial] - layout = respond_to?(:pick_layout, true) ? pick_layout(opts) : false - opts.merge! :layout => layout - end - @template.render opts - ensure - @template = old_template - end - end # Set default host automatically if environment is set def url_for options = {}
Remove monkey patches on render
diff --git a/lib/temple/coffee_script/generators.rb b/lib/temple/coffee_script/generators.rb index abc1234..def5678 100644 --- a/lib/temple/coffee_script/generators.rb +++ b/lib/temple/coffee_script/generators.rb @@ -7,7 +7,7 @@ def call(exp) @indent = options[:indent] - compile [:multi, [:code, "#{buffer} = ''"], exp] + compile [:multi, [:code, "#{buffer} = ''"], exp, [:code, "#{buffer}"]] end def on_multi(*exp)
Return buffer from generator function.
diff --git a/test/user_test.rb b/test/user_test.rb index abc1234..def5678 100644 --- a/test/user_test.rb +++ b/test/user_test.rb @@ -4,14 +4,18 @@ require 'user' class UserTest < Test::Unit::TestCase + attr_reader :user + + def setup + @user = User.new '[email protected]' + end + def test_initialize - user = User.new '[email protected]' assert_equal '[email protected]', user.jid assert_equal [], user.paths end def test_add - user = User.new '[email protected]' # Should return itself assert_equal user, user << '/project' # Should have added to paths @@ -19,7 +23,6 @@ end def test_delete - user = User.new '[email protected]' user.paths = %w( /foo /bar ) user.delete '/bar' assert_equal ['/foo'], user.paths
Move user creation into setup.
diff --git a/soa-demo-client.rb b/soa-demo-client.rb index abc1234..def5678 100644 --- a/soa-demo-client.rb +++ b/soa-demo-client.rb @@ -1,5 +1,9 @@ require "bunny" require "json" + +name = "Bob" +address = "123 main" +orderId = "12345" puts "I want some pizza" @@ -14,7 +18,7 @@ puts session.exchange_exists?("pizzarequested.v1") exchange = ch.exchange("pizzarequested.v1", :passive => true) -exchange.publish("{name: 'Bob', address: '123 main', toppings: ['pepperoni'], orderId: '12345'}") +exchange.publish({:name => name, :address => address, :toppings => ['pepperoni'], :orderId => orderId}.to_json) puts "Pizz ordered!" couponqueue.subscribe(:block => true) do |delivery_info, properties, body| @@ -23,7 +27,7 @@ response = JSON.parse(body) if response["correlationId"] == "12345" puts "The free pizza coupon is for me!" - exchange.publish("{name: 'Bob', address: '123 main', toppings: ['sausage', 'pepperoni'], coupon: '#{response["coupon"]}'}") + exchange.publish({:name => name, :address => address, :toppings => ['pepperoni', 'sausage'], :orderId => orderId, :coupon => response["coupon"]}.to_json) puts "Free pizza ordered!" exit end
Use serialized hashes instead of hand rolled JSON
diff --git a/lib/mikoshi/plan.rb b/lib/mikoshi/plan.rb index abc1234..def5678 100644 --- a/lib/mikoshi/plan.rb +++ b/lib/mikoshi/plan.rb @@ -9,6 +9,7 @@ def initialize(yaml_path: nil, client: nil) raise ArgumentError, 'Yaml file path is required.' if yaml_path.nil? + raise ArgumentError, 'client is required.' if client.nil? @data = YAML.safe_load(ERB.new(File.new(yaml_path).read).result).symbolize_keys @client = client
Raise error when client is nil
diff --git a/mdspell.gemspec b/mdspell.gemspec index abc1234..def5678 100644 --- a/mdspell.gemspec +++ b/mdspell.gemspec @@ -14,8 +14,7 @@ s.extra_rdoc_files = %w(README.md LICENSE) # Manifest - s.files = Dir.glob('lib/**/*') - s.files += Dir.glob('bin/**/*') + s.files = Dir.glob('{lib,bin}/**/*') s.test_files = Dir.glob('{spec}/**/*') s.require_paths = ['lib']
Fix files definition in gemspec.
diff --git a/que.gemspec b/que.gemspec index abc1234..def5678 100644 --- a/que.gemspec +++ b/que.gemspec @@ -8,8 +8,8 @@ spec.version = Que::Version spec.authors = ["Chris Hanks"] spec.email = ['[email protected]'] - spec.description = %q{Durable job queueing with PostgreSQL.} - spec.summary = %q{Durable, efficient job queueing with PostgreSQL.} + spec.description = %q{A job queue that uses PostgreSQL's advisory locks for speed and reliability.} + spec.summary = %q{A PostgreSQL-based Job Queue} spec.homepage = 'https://github.com/chanks/que' spec.license = 'MIT'
Tweak gem's description and summary.
diff --git a/config/schedule.rb b/config/schedule.rb index abc1234..def5678 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -0,0 +1,29 @@+# Use this file to easily define all of your cron jobs. +# +# It's helpful, but not entirely necessary to understand cron before proceeding. +# http://en.wikipedia.org/wiki/Cron + +set :output, { error: 'log/cron.error.log', standard: 'log/cron.log' } + +bundler_prefix = ENV.fetch('BUNDLER_PREFIX', '/usr/local/bin/govuk_setenv finder-frontend') +job_type :rake, "cd :path && #{bundler_prefix} bundle exec rake :task :output" + +every 1.hours do + rake "registries:cache_refresh" +end + +# Example: +# +# set :output, "/path/to/my/cron_log.log" +# +# every 2.hours do +# command "/usr/bin/some_great_command" +# runner "MyModel.some_method" +# rake "some:great:rake:task" +# end +# +# every 4.days do +# runner "AnotherModel.prune_old_records" +# end + +# Learn more: http://github.com/javan/whenever
Add cron job to refresh cache I went for 1 hour as that is the current refresh rate for caches. https://trello.com/c/knffA0Fb/786-import-the-new-topic-registry-on-a-schedule-s
diff --git a/config/schedule.rb b/config/schedule.rb index abc1234..def5678 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -27,4 +27,7 @@ every 1.hour do runner 'DigestBuilder.send_daily_email' -end+end + +every :minute { command "whoami" } +every :minute { command "which ruby" }
Add crons to check env
diff --git a/config/schedule.rb b/config/schedule.rb index abc1234..def5678 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -19,6 +19,6 @@ rake "export:redirector_mappings" end -every :day, at: ['2am'], roles: [:backend] do +every :day, at: ['1:30am'], roles: [:backend] do rake "rummager:index:closed_consultation" end
Move rake task to 1:30am So not to conflic with export:redirector_mappings which is a heavy task
diff --git a/spec/requests/groups/profiles_spec.rb b/spec/requests/groups/profiles_spec.rb index abc1234..def5678 100644 --- a/spec/requests/groups/profiles_spec.rb +++ b/spec/requests/groups/profiles_spec.rb @@ -1,6 +1,25 @@ require "spec_helper" describe "Group profiles" do + context "as a public user" do + + describe "viewing the group profile" do + let(:group) { FactoryGirl.create(:group) } + + before do + # fixme Work around - hard to get group + group_profile via factories + group.profile.description = "This is a group of people." + group.profile.location = "POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))" + group.profile.save! + end + + it "should show you the profile" do + visit group_profile_path(group) + page.should have_content(group.profile.description) + end + end + end + context "as a group member" do include_context "signed in as a group member"
Test that the group profile page is working.
diff --git a/app/models/customer.rb b/app/models/customer.rb index abc1234..def5678 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -7,6 +7,8 @@ validates_length_of :name, :maximum=>200 validates_presence_of :name + validates_uniqueness_of :name, :scope => 'company_id' + validates_presence_of :company_id after_destroy { |r|
Make sure client names are unique within a company
diff --git a/test.rb b/test.rb index abc1234..def5678 100644 --- a/test.rb +++ b/test.rb @@ -6,16 +6,31 @@ ffi_lib "gtk-x11-2.0" attach_function :gtk_init, [:pointer, :pointer], :void attach_function :gtk_main, [], :void + attach_function :gtk_main_quit, [], :void - def self.init - gtk_init nil, nil - end + def self.init; gtk_init nil, nil; end + def self.main; gtk_main; end + def self.main_quit; gtk_main_quit; end class Widget extend FFI::Library attach_function :gtk_widget_show, [:pointer], :pointer + + callback :GCallback, [], :void + enum :GConnectFlags, [:AFTER, (1<<0), :SWAPPED, (1<<1)] + attach_function :g_signal_connect_data, [:pointer, :string, :GCallback, + :pointer, :pointer, :GConnectFlags], :ulong + + @@callbacks = [] + def show gtk_widget_show(@gobj) + end + + def signal_connect signal, data, &block + prc = block.to_proc + @@callbacks << prc + g_signal_connect_data @gobj, signal, prc, data, nil, 0 end private def initialize @@ -36,4 +51,5 @@ Gtk.init win = Gtk::Window.new(:GTK_WINDOW_TOPLEVEL) win.show -Gtk.gtk_main +win.signal_connect("destroy", nil) { Gtk.main_quit } +Gtk.main
Connect signal for destroy event.
diff --git a/api/v1.rb b/api/v1.rb index abc1234..def5678 100644 --- a/api/v1.rb +++ b/api/v1.rb @@ -10,6 +10,10 @@ register Sinatra::Pebblebed set :config, Tiramisu.config + + before do + cache_control :private, :no_cache, :no_store, :must_revalidate + end helpers do
Add no-cache header to prevent Safari on IOS6 from caching POST requests (sic!)
diff --git a/bdd_settings.rb b/bdd_settings.rb index abc1234..def5678 100644 --- a/bdd_settings.rb +++ b/bdd_settings.rb @@ -13,9 +13,7 @@ require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' require 'authlogic/test_case' -require 'login_module' include Authlogic::TestCase -include LoginModule # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories.
Remove the login_module requirement from rspec helper
diff --git a/src/shared/args.rb b/src/shared/args.rb index abc1234..def5678 100644 --- a/src/shared/args.rb +++ b/src/shared/args.rb @@ -5,6 +5,7 @@ while args.count > 0 arg = args.shift.strip next if arg.empty? + flag = nil if arg.start_with? '--' if flag.nil? if arg.start_with? '--' flag = arg[2..-1].tr('-', '_').to_sym
Fix flags without arguments (`--with-cov --dump post`)
diff --git a/lib/blocktrain/aggregations/histogram_aggregation.rb b/lib/blocktrain/aggregations/histogram_aggregation.rb index abc1234..def5678 100644 --- a/lib/blocktrain/aggregations/histogram_aggregation.rb +++ b/lib/blocktrain/aggregations/histogram_aggregation.rb @@ -8,7 +8,6 @@ date_histogram: { field: 'timeStamp', interval: @interval, - time_zone: '+01:00', min_doc_count: 1, extended_bounds: { min: @from,
Stop changing the times of results