diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index abc1234..def5678 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,3 +1,9 @@ # Be sure to restart your server when you modify this file. -Rails.application.config.session_store :cookie_store, key: "_#{Rails.application.config.project_slug}_session" +if Rails.env.production? && !ENV.key?('SECRET_KEY_BASE') + raise "Please run `rake secret` and configure ENV['SECRET_KEY_BASE'] "\ + "on production, or else session cookies will not be encrypted." +end + +Rails.application.config.session_store :cookie_store, + key: "_#{Rails.application.config.project_slug}_session"
Add message to initializer to enforce encrypted cookies on production
diff --git a/lib/kochiku/build_strategies/build_all_strategy.rb b/lib/kochiku/build_strategies/build_all_strategy.rb index abc1234..def5678 100644 --- a/lib/kochiku/build_strategies/build_all_strategy.rb +++ b/lib/kochiku/build_strategies/build_all_strategy.rb @@ -1,18 +1,21 @@ module BuildStrategy class BuildAllStrategy def execute_build(build_kind, test_files) - execute_with_timeout "env -i HOME=$HOME"+ - " PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"+ - " TEST_RUNNER=#{build_kind}"+ - " RUN_LIST=#{test_files.join(',')}"+ - " bash --noprofile --norc -c 'ruby -v ; source ~/.rvm/scripts/rvm ; source .rvmrc ; mkdir log ; script/ci worker 2>log/stderr.log 1>log/stdout.log'" + execute_with_timeout( + "env -i HOME=$HOME"+ + " PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"+ + " TEST_RUNNER=#{build_kind}"+ + " RUN_LIST=#{test_files.join(',')}"+ + " bash --noprofile --norc -c 'ruby -v ; source ~/.rvm/scripts/rvm ; source .rvmrc ; mkdir log ; script/ci worker 2>log/stderr.log 1>log/stdout.log'", + 60 * 60 # 1 hour + ) end def artifacts_glob ['log/*log', 'spec/reports/*.xml', 'features/reports/*.xml'] end - def execute_with_timeout(command, timeout = 60 * 60) + def execute_with_timeout(command, timeout) pid = Process.spawn(command) begin Timeout.timeout(timeout) do
Remove default timeout from execute_with_timeout
diff --git a/app/models/doc.rb b/app/models/doc.rb index abc1234..def5678 100644 --- a/app/models/doc.rb +++ b/app/models/doc.rb @@ -1,7 +1,8 @@ class Doc include Mongoid::Document - field :name, type: String - field :desc, type: String + field :name + field :desc + field :expires, type: DateTime end
Add expires field to Doc model
diff --git a/lib/mozart/value.rb b/lib/mozart/value.rb index abc1234..def5678 100644 --- a/lib/mozart/value.rb +++ b/lib/mozart/value.rb @@ -4,11 +4,11 @@ define_method(:initialize) do |params={}| raise ArgumentError unless params.keys == field_names - self.data = {} + self.__data__ = {} - params.each { |k,v| data[k] = v.freeze } + params.each { |k,v| __data__[k] = v.freeze } - data.freeze + __data__.freeze end def ==(other) @@ -18,16 +18,16 @@ alias_method :eql?, :== def hash - data.hash + __data__.hash end field_names.each do |name| - define_method(name) { data[name] } + define_method(name) { __data__[name] } end protected - attr_accessor :data + attr_accessor :__data__ end end end
Use a less clashy name
diff --git a/app/controllers/api/discovery_entities_controller.rb b/app/controllers/api/discovery_entities_controller.rb index abc1234..def5678 100644 --- a/app/controllers/api/discovery_entities_controller.rb +++ b/app/controllers/api/discovery_entities_controller.rb @@ -11,7 +11,7 @@ private SP_EAGER_FETCH = { - entity_id: {}, + entity_id: [], sp_sso_descriptors: { ui_info: %i(logos descriptions display_names information_urls privacy_statement_urls), @@ -21,7 +21,7 @@ } IDP_EAGER_FETCH = { - entity_id: {}, + entity_id: [], idp_sso_descriptors: { ui_info: %i(logos descriptions display_names), disco_hints: %i(geolocation_hints domain_hints),
Change empty hash to empty list for consistency
diff --git a/Library/Formula/berkeley-db.rb b/Library/Formula/berkeley-db.rb index abc1234..def5678 100644 --- a/Library/Formula/berkeley-db.rb +++ b/Library/Formula/berkeley-db.rb @@ -21,6 +21,10 @@ "--enable-java" system "make install" + + # use the standard docs location + doc.parent.mkpath + mv prefix+'docs', doc end end end
Install bdb docs to correct location
diff --git a/app/decorators/atmosphere/migration_job_decorator.rb b/app/decorators/atmosphere/migration_job_decorator.rb index abc1234..def5678 100644 --- a/app/decorators/atmosphere/migration_job_decorator.rb +++ b/app/decorators/atmosphere/migration_job_decorator.rb @@ -2,50 +2,32 @@ delegate_all def appliance_type_name - if object.appliance_type - object.appliance_type.name - else - 'unknown' - end + at = object.appliance_type + at ? at.name : 'unknown' end def virtual_machine_template_name - if object.virtual_machine_template - object.virtual_machine_template.name - else - 'unknown' - end + vmt = object.virtual_machine_template + vmt ? vmt.name : 'unknown' end def virtual_machine_template_id_at_site - if object.virtual_machine_template - object.virtual_machine_template.id_at_site - else - 'unknown' - end + vmt = object.virtual_machine_template + vmt ? vmt.id_at_site : 'unknown' end def compute_site_source_name - if object.compute_site_source - object.compute_site_source.name - else - 'unknown' - end + css = object.compute_site_source + css ? css.name : 'unknown' end def compute_site_destination_name - if object.compute_site_destination - object.compute_site_destination.name - else - 'unknown' - end + csd = object.compute_site_destination + csd ? csd.name : 'unknown' end def status_last_line - if object.status - object.status.lines.last - else - 'unknown' - end + s = object.status + s ? s.lines.last : 'unknown' end end
Fix due to comments, use ?: elvis operator
diff --git a/lib/rtasklib.rb b/lib/rtasklib.rb index abc1234..def5678 100644 --- a/lib/rtasklib.rb +++ b/lib/rtasklib.rb @@ -10,19 +10,33 @@ module Rtasklib class TaskWarrior - attr_reader :taskrc, :version + attr_reader :taskrc, :version, :rc_location, :data_location def initialize rc="#{Dir.home}/.taskrc" + @rc_location = rc + # TODO: use taskrc + @data_location = rc.chomp('rc') + # Check TW version, and throw warning - raw_version = Open3.capture2("task _version") - @version = Gem::Version.new(raw_version[0].chomp) - # @version = Gem::Version.new(`task _version`.chomp) - - if @version < Gem::Version.new('2.4.0') - warn "#{@version} is untested" + begin + @version = check_version + rescue + warn "Couldn't find the task version" end # @taskrc = end + + private + def check_version + raw_version = Open3.capture2( + "task rc.data.location=#{@data_location} _version") + gem_version = Gem::Version.new(raw_version[0].chomp) + + if gem_version < Gem::Version.new('2.4.0') + warn "#{@version} is untested" + end + gem_version + end end end
Add some error catching logic to the version checking call
diff --git a/asciimath.gemspec b/asciimath.gemspec index abc1234..def5678 100644 --- a/asciimath.gemspec +++ b/asciimath.gemspec @@ -3,7 +3,6 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'asciimath/version' -require 'rake/file_list' Gem::Specification.new do |spec| spec.name = "asciimath" @@ -15,8 +14,7 @@ spec.homepage = "" spec.license = "MIT" - spec.files = Rake::FileList['**/*'].exclude(*File.read('.gitignore').split) - .exclude('dump_symbol_table.rb') + 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.require_paths = ["lib"]
Remove usage of Rake classes in gemspec
diff --git a/rails_event_store/spec/middleware_integration_spec.rb b/rails_event_store/spec/middleware_integration_spec.rb index abc1234..def5678 100644 --- a/rails_event_store/spec/middleware_integration_spec.rb +++ b/rails_event_store/spec/middleware_integration_spec.rb @@ -10,7 +10,7 @@ specify 'works without event store instance' do event_store = Client.new - request = ::Rack::MockRequest.new(Middleware.new(app)) + request = ::Rack::MockRequest.new(middleware) request.get('/') event_store.read_all_streams_forward.map(&:metadata).each do |metadata| @@ -25,13 +25,17 @@ ) app.config.event_store = event_store - request = ::Rack::MockRequest.new(Middleware.new(app)) + request = ::Rack::MockRequest.new(middleware) request.get('/') event_store.read_all_streams_forward.map(&:metadata).each do |metadata| expect(metadata[:server_name]).to eq('example.org') expect(metadata[:timestamp]).to be_a(Time) end + end + + def middleware + ::Rack::Lint.new(Middleware.new(app)) end def app
Bring back Rack spec check for middleware. While performing integration test, check if we don't any Rack rules and conform to middleware specification. This brings (accidentally removed) linter back.
diff --git a/lib/rack-lesscss.rb b/lib/rack-lesscss.rb index abc1234..def5678 100644 --- a/lib/rack-lesscss.rb +++ b/lib/rack-lesscss.rb @@ -2,13 +2,13 @@ module Rack class LessCss - + def initialize(app, opts) @app = app @less_path = opts[:less_path] or raise ArgumentError, "You must specify :less_path option (path to directory containing .less files)" css_route = opts[:css_route] || "/stylesheets" css_route = css_route[0..-2] if css_route[-1] == "/" - @css_route_regexp = /#{Regexp.escape(css_route)}\/([^\.]+)\.css/ + @css_route_regexp = /#{Regexp.escape(css_route)}\/(.+)\.css/ end def call(env) @@ -25,7 +25,7 @@ end @app.call(env) end - + private def get_source(stylesheet) ::File.read(::File.join(@less_path, stylesheet + ".less"))
Fix handling filenames with more than one period
diff --git a/config.ru b/config.ru index abc1234..def5678 100644 --- a/config.ru +++ b/config.ru @@ -1,6 +1,7 @@ # This file is used by Rack-based servers to start the application. unless defined?(PhusionPassenger) + require 'unicorn' # Unicorn self-process killer require 'unicorn/worker_killer'
Fix 'uninitialized constant Unicorn' error
diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb index abc1234..def5678 100644 --- a/app/controllers/errors_controller.rb +++ b/app/controllers/errors_controller.rb @@ -0,0 +1,14 @@+class ErrorsController < ApplicationController + def not_found + render status: 404 + end + + def unacceptable + render status: 422 + end + + def internal_error + render status: 500 + end + +end
Create error controller for custom status code templates
diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index abc1234..def5678 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -44,6 +44,6 @@ end def ics - send_data @event.icalendar(root_url), filename: "#{@event.name}.ics", type: 'text/calendar' + send_data @event.icalendar(root_url), filename: "#{@event.name}.ics", type: 'text/calendar', x_sendfile: true end end
Add send file header to iCalendar downloads
diff --git a/rails_event_store-rspec/rails_event_store-rspec.gemspec b/rails_event_store-rspec/rails_event_store-rspec.gemspec index abc1234..def5678 100644 --- a/rails_event_store-rspec/rails_event_store-rspec.gemspec +++ b/rails_event_store-rspec/rails_event_store-rspec.gemspec @@ -6,6 +6,7 @@ Gem::Specification.new do |spec| spec.name = "rails_event_store-rspec" spec.version = RailsEventStore::RSpec::VERSION + spec.licenses = ["MIT"] spec.authors = ["Arkency"] spec.email = ["dev@arkency.com"]
Add license information to gemspec
diff --git a/app/controllers/scores_controller.rb b/app/controllers/scores_controller.rb index abc1234..def5678 100644 --- a/app/controllers/scores_controller.rb +++ b/app/controllers/scores_controller.rb @@ -13,7 +13,7 @@ end def map - return unless Score.where(map: params[:map].downcase).exists? + return unless Score.exists?(map: params[:map].downcase) scores = Score.map_scores params total_scores = scores.length
Use exists?(…) instead of where(…).exists?
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index abc1234..def5678 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -1,16 +1,8 @@ class SearchController < ApplicationController def index - if jump = jump_target - redirect_to jump - else - @keyword = params[:keyword] - @results = Search.for(params[:keyword]) - end + @keyword = params[:keyword] + @results = Search.for(params[:keyword]) end - - private - def jump_target - Museum.find_by(name: params[:keyword]) - end + end
Change search bar for added simplicity
diff --git a/lib/specter/file.rb b/lib/specter/file.rb index abc1234..def5678 100644 --- a/lib/specter/file.rb +++ b/lib/specter/file.rb @@ -27,7 +27,6 @@ def run fork do begin - Specter.current.store :file, self Specter.now.file = self filename = name @@ -40,7 +39,6 @@ fail exception ensure - Specter.current.delete :file Specter.now.file = nil exit 1 if failed?
Remove calls to old current context.
diff --git a/lib/tasks/cron.rake b/lib/tasks/cron.rake index abc1234..def5678 100644 --- a/lib/tasks/cron.rake +++ b/lib/tasks/cron.rake @@ -5,7 +5,6 @@ invoke 'crowd:cluster:free_calais_blacklist' invoke 'db:backup' invoke 'db:vacuum_analyze' - invoke 'db:optimize_solr' invoke 'mail:csv' end
Disable solr for the moment.
diff --git a/files/default/tests/minitest/hadoop_hdfs_datanode_test.rb b/files/default/tests/minitest/hadoop_hdfs_datanode_test.rb index abc1234..def5678 100644 --- a/files/default/tests/minitest/hadoop_hdfs_datanode_test.rb +++ b/files/default/tests/minitest/hadoop_hdfs_datanode_test.rb @@ -4,8 +4,13 @@ include Helpers::Hadoop - # Example spec tests can be found at http://git.io/Fahwsw - it 'runs no tests by default' do + it 'ensures HDFS data dirs exist' do + node['hadoop']['hdfs_site']['dfs.data.dir'].each do |dir| + directory(dir) + .must_exist + .with(:owner, 'hdfs') + .and(:group, 'hdfs') + .and(:mode, node['hadoop']['hdfs_site']['dfs.datanode.data.dir.perm']) end end
Add test on HDFS data dir
diff --git a/app/controllers/dataset_file_schemas_controller.rb b/app/controllers/dataset_file_schemas_controller.rb index abc1234..def5678 100644 --- a/app/controllers/dataset_file_schemas_controller.rb +++ b/app/controllers/dataset_file_schemas_controller.rb @@ -1,7 +1,7 @@ class DatasetFileSchemasController < ApplicationController def index - @dataset_file_schemas = DatasetFileSchema.where(user: current_user)#.paginate(page: params[:page], per_page: 7).order(name: :asc) + @dataset_file_schemas = DatasetFileSchema.where(user: current_user).order(created_at: :desc) end def new
Tidy commented out stuff and add ordering
diff --git a/lib/adiwg/mdtranslator/writers/html/sections/html_resourceType.rb b/lib/adiwg/mdtranslator/writers/html/sections/html_resourceType.rb index abc1234..def5678 100644 --- a/lib/adiwg/mdtranslator/writers/html/sections/html_resourceType.rb +++ b/lib/adiwg/mdtranslator/writers/html/sections/html_resourceType.rb @@ -2,6 +2,7 @@ # resource type # History: +# Stan Smith 2017-05-24 Fixed problem with nil name # Stan Smith 2015-03-25 original script module ADIWG @@ -19,7 +20,11 @@ # resource type @html.em('Resource Type: ') - @html.text!(hType[:type] + ' - ' + hType[:name]) + @html.text!(hType[:type]) + unless hType[:name].nil? + @html.em(' Name: ') + @html.text!(hType[:name]) + end @html.br end # writeHtml
Fix handling of nil 'resourceType.name' in html writer
diff --git a/lib/activeadmin_addons/support/custom_builder.rb b/lib/activeadmin_addons/support/custom_builder.rb index abc1234..def5678 100644 --- a/lib/activeadmin_addons/support/custom_builder.rb +++ b/lib/activeadmin_addons/support/custom_builder.rb @@ -23,11 +23,15 @@ end def options - @options ||= args.last.is_a?(Hash) ? args.last : {} + @options ||= has_opts? ? args.last : {} end def attribute - @attribute ||= args[1] || args[0] + @attribute ||= has_opts? ? args[0] : args[1] + end + + def has_opts? + args[1] && args[1].is_a?(Hash) end end
Fix passing options to addons Helpers were only working with args if used with a block [Closes #20]
diff --git a/app/models/pull_request.rb b/app/models/pull_request.rb index abc1234..def5678 100644 --- a/app/models/pull_request.rb +++ b/app/models/pull_request.rb @@ -1,6 +1,8 @@+# frozen_string_literal: true + class PullRequest - OPEN_ACTION = "opened".freeze - SYNC_ACTION = "synchronize".freeze + OPEN_ACTION = "opened" + SYNC_ACTION = "synchronize" def initialize(github_payload) self.github_payload = github_payload
Update frozen strings in PullRequest frozen_string_literal is more efficient and a step towards immutable strings in future versions of Ruby.
diff --git a/app/models/user_session.rb b/app/models/user_session.rb index abc1234..def5678 100644 --- a/app/models/user_session.rb +++ b/app/models/user_session.rb @@ -3,7 +3,7 @@ pds_url Settings.pds.login_url redirect_logout_url Settings.pds.logout_url aleph_url Exlibris::Aleph::Config.base_url - calling_system "umlaut" + calling_system "getit" institution_param_key "umlaut.institution" # (Re-)Set verification and Aleph permissions to user attributes
Use getit name for PDS :sunflower:
diff --git a/spec/lib/amarok-stats-common/config_spec.rb b/spec/lib/amarok-stats-common/config_spec.rb index abc1234..def5678 100644 --- a/spec/lib/amarok-stats-common/config_spec.rb +++ b/spec/lib/amarok-stats-common/config_spec.rb @@ -10,7 +10,7 @@ end describe '.load' do - context "file doesn't exist" do + context "when file doesn't exist" do before :each do allow(File).to receive(:exists?).with(described_class.filename).and_return(false) end @@ -21,7 +21,7 @@ end # todo: need clear way to load valid/not-valid data from real files in `spec/` - context 'file exists' do + context 'when file exists' do before :each do allow(described_class).to receive(:filename).and_return(filename) end
Add word 'when' to specs
diff --git a/Library/Formula/gambit-scheme.rb b/Library/Formula/gambit-scheme.rb index abc1234..def5678 100644 --- a/Library/Formula/gambit-scheme.rb +++ b/Library/Formula/gambit-scheme.rb @@ -16,9 +16,8 @@ # Gambit Scheme currently fails to build with llvm-gcc # (ld crashes during the build process) ENV.gcc_4_2 - # Gambit Scheme will not build with heavy optimizations. Disable all - # optimizations until safe values can be figured out. - ENV.no_optimization + # Gambit Scheme doesn't like full optimizations + ENV.O2 configure_args = [ "--prefix=#{prefix}",
Enable O2 optimizations for Gambit Scheme
diff --git a/www/make_www.rb b/www/make_www.rb index abc1234..def5678 100644 --- a/www/make_www.rb +++ b/www/make_www.rb @@ -10,10 +10,10 @@ } Dir.chdir(File.dirname(__FILE__)) -erb = ERB.new(File.read('layout.erb'), nil) +erb = ERB.new(File.read('layout.erb')) Dir['pages/*.erb'].each do |page| public_loc = "#{page.gsub(/\Apages\//, 'public/').sub('.erb', '.html')}" - content = content = ERB.new(File.read(page), nil).result(binding) + content = content = ERB.new(File.read(page)).result(binding) current_page = File.basename(page.sub('.erb', '')) description = description = descriptions[current_page.to_sym] File.open(public_loc, 'wb'){|f| f.write(erb.result(binding))}
Remove deprecated second argument to ERB.new when building website
diff --git a/lita-genius.gemspec b/lita-genius.gemspec index abc1234..def5678 100644 --- a/lita-genius.gemspec +++ b/lita-genius.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |spec| spec.name = "lita-genius" - spec.version = "0.1.1" + spec.version = "0.1.2" spec.authors = ["Tristan Chong"] spec.email = ["ong@tristaneuan.ch"] spec.description = "A Lita handler that returns requested songs from (Rap) Genius." @@ -15,7 +15,6 @@ spec.require_paths = ["lib"] spec.add_runtime_dependency "lita", ">= 4.3" - spec.add_runtime_dependency "rapgenius", "1.0.5" spec.add_development_dependency "bundler", "~> 1.3" spec.add_development_dependency "pry-byebug"
gemspec: Remove rapgenius gem dependency, increment version to 0.1.2
diff --git a/app/jobs/import_sheets_from_excel.rb b/app/jobs/import_sheets_from_excel.rb index abc1234..def5678 100644 --- a/app/jobs/import_sheets_from_excel.rb +++ b/app/jobs/import_sheets_from_excel.rb @@ -5,11 +5,11 @@ queue_as :import_sheets_from_excel after_perform do |job| - #if Pusher + if Pusher Pusher.trigger('import_sheets_from_excel', 'after_perform', { message: "Finished importing #{File.basename(job.arguments.first)}" }) - #end + end end def perform(path)
Add optional Pusher notification support
diff --git a/app/models/track_changes/snapshot.rb b/app/models/track_changes/snapshot.rb index abc1234..def5678 100644 --- a/app/models/track_changes/snapshot.rb +++ b/app/models/track_changes/snapshot.rb @@ -21,8 +21,8 @@ to[key] = record_state[key] end end - - record.diffs.create!(diff_attributes.reverse_merge(:from => from, :to => to)) unless from.empty? && to.empty? + diff_attributes = diff_attributes.reverse_merge(:from => from, :to => to) + record.diffs.create!(diff_attributes) unless diff_attributes[:from].empty? && diff_attributes[:to].empty? end # Updates the snapshot to the current record state
Check for :from and :to hash in the diff_attributes, not just the internally calculated ones
diff --git a/app/models/spree/store_decorator.rb b/app/models/spree/store_decorator.rb index abc1234..def5678 100644 --- a/app/models/spree/store_decorator.rb +++ b/app/models/spree/store_decorator.rb @@ -1,5 +1,5 @@ Spree::Store.class_eval do - has_one :braintree_configuration, class_name: "SolidusPaypalBraintree::Configuration" + has_one :braintree_configuration, class_name: "SolidusPaypalBraintree::Configuration", dependent: :destroy before_create :build_default_configuration
Add dependent :destroy to configuration association Since configurations are tied to the store, it doesn't make sense to keep them around if the store is deleted.
diff --git a/generate-coverage-report-index.rb b/generate-coverage-report-index.rb index abc1234..def5678 100644 --- a/generate-coverage-report-index.rb +++ b/generate-coverage-report-index.rb @@ -14,7 +14,11 @@ File.open(file, 'wb') { |f| f.write(content) } end -OUTPUT_FILE = ARGV.shift or raise 'Missing argument: OUTPUT_FILE' +unless ARGV.length == 1 + puts "Usage: #{$0} OUTPUT_FILE" + exit 1 +end +OUTPUT_FILE = ARGV.shift module_list_items = Dir.glob('*/target/pit-reports/*/index.html').sort. map { |module_index| module_list_item(module_index) }.
Print usage on wrong parameters
diff --git a/repoman.rb b/repoman.rb index abc1234..def5678 100644 --- a/repoman.rb +++ b/repoman.rb @@ -6,8 +6,15 @@ end def add path - if File.directory? path - puts path + if File.directory? path and has_git? path + puts "repo: I found a git repo at #{path}" + else + STDERR.puts "repo: Not a git repository -- #{path}" + exit 1 end end + + def has_git? path + File.directory? "#{path}/.git" + end end
Check for git repo works
diff --git a/test/lib/examples/galena/tissue/migration/frozen_test.rb b/test/lib/examples/galena/tissue/migration/frozen_test.rb index abc1234..def5678 100644 --- a/test/lib/examples/galena/tissue/migration/frozen_test.rb +++ b/test/lib/examples/galena/tissue/migration/frozen_test.rb @@ -24,7 +24,7 @@ def test_save # rename the target box - box = CaTissue::StorageContainer.new(:name => 'GTB Box 7') + box = CaTissue::StorageContainer.new(:name => 'Galena Box 7') if box.find then box.name = box.name.uniquify box.save
Change GTB to Galena in name.
diff --git a/lib/foreigner/connection_adapters/postgresql_adapter.rb b/lib/foreigner/connection_adapters/postgresql_adapter.rb index abc1234..def5678 100644 --- a/lib/foreigner/connection_adapters/postgresql_adapter.rb +++ b/lib/foreigner/connection_adapters/postgresql_adapter.rb @@ -6,7 +6,40 @@ include Foreigner::ConnectionAdapters::Sql2003 def foreign_keys(table_name) + foreign_keys = [] + + fk_info = select_all %{ + select tc.constraint_name as name + ,ccu.table_name as to_table + ,kcu.column_name as column + ,rc.delete_rule as dependency + from information_schema.table_constraints tc + join information_schema.key_column_usage kcu + on tc.constraint_catalog = kcu.constraint_catalog + and tc.constraint_schema = kcu.constraint_schema + and tc.constraint_name = kcu.constraint_name + join information_schema.referential_constraints rc + on tc.constraint_catalog = rc.constraint_catalog + and tc.constraint_schema = rc.constraint_schema + and tc.constraint_name = rc.constraint_name + join information_schema.constraint_column_usage ccu + on tc.constraint_catalog = ccu.constraint_catalog + and tc.constraint_schema = ccu.constraint_schema + and tc.constraint_name = ccu.constraint_name + where tc.constraint_type = 'FOREIGN KEY' + and tc.constraint_catalog = '#{@config[:database]}' + and tc.table_name = '#{table_name}' + } + fk_info.inject([]) do |foreign_keys, row| + options = {:column => row['column'], :name => row['name']} + if row['dependency'] == 'CASCADE' + options[:dependent] = :delete + elsif row['dependency'] == 'SET NULL' + options[:dependent] = :nullify + end + foreign_keys << ForeignKeyDefinition.new(table_name, row['to_table'], options) + end end end end
Add schema.rb support to the post gres adapter
diff --git a/spec/controllers/api/task_lists_controller_spec.rb b/spec/controllers/api/task_lists_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/api/task_lists_controller_spec.rb +++ b/spec/controllers/api/task_lists_controller_spec.rb @@ -10,16 +10,14 @@ it "should return json of array of those task lists" do get :index - tasks = JSON.parse(response.body) - tasks.should == [{'id' => user.task_list.id}] + json_response.should == [{'id' => user.task_list.id}] end end it "should return error json with 401 HTTP status when not authenticated" do get :index, format: :json response.status.should == 401 - tasks = JSON.parse(response.body) - tasks.should == {'error' => 'You need to sign in or sign up before continuing.'} + json_response.should == {'error' => 'You need to sign in or sign up before continuing.'} end end end
Use json_response in place of JSON.parse.
diff --git a/lib/generators/rails/templates/searcher.rb b/lib/generators/rails/templates/searcher.rb index abc1234..def5678 100644 --- a/lib/generators/rails/templates/searcher.rb +++ b/lib/generators/rails/templates/searcher.rb @@ -24,5 +24,8 @@ # Delegation to searchers (uncomment and fill with your keys from class above) # delegate :only_sale, :opt_in, :cat_in, to: :base + + # Alias to Ransack params + # alias_to_ransack :in_titles, :title_or_subtitle_or_category_title_cont end <% end -%>
Add aliases example to generator
diff --git a/lib/rvm/capistrano/install_rvm.rb b/lib/rvm/capistrano/install_rvm.rb index abc1234..def5678 100644 --- a/lib/rvm/capistrano/install_rvm.rb +++ b/lib/rvm/capistrano/install_rvm.rb @@ -8,6 +8,9 @@ # Let users set the install type of their choice. _cset(:rvm_install_type, :stable) + + # Let users override the installation url + _cset(:rvm_install_url, "get.rvm.io") # By default system installations add deploying user to rvm group. also try :all _cset(:rvm_add_to_group, fetch(:user,"$USER")) @@ -27,7 +30,7 @@ set :rvm_install_shell, :zsh EOF rvm_task :install_rvm do - command_fetch = "curl -L get.rvm.io" + command_fetch = "curl -L #{rvm_install_url}" command_install = rvm_if_sudo(:subject_class => :rvm) command_install << "#{rvm_install_shell} -s #{rvm_install_type} --path #{rvm_path}" case rvm_type
Allow overriding the install url. I am behind a proxy that for some reason does not guess that 'get.rvm.io' should be redirected to 'https://get.rvm.io'. With this solution I can explicitely declare the https url. Another solution would be to hard code the protocol "https://" within the variable command_fetch.
diff --git a/lib/yard-gobject-introspection.rb b/lib/yard-gobject-introspection.rb index abc1234..def5678 100644 --- a/lib/yard-gobject-introspection.rb +++ b/lib/yard-gobject-introspection.rb @@ -1,23 +1,39 @@ require "yard" -require "gobject-introspection" +require "rexml/document" +include REXML class GObjectIntropsectionHandler < YARD::Handlers::Ruby::Base handles :module def process - base = File.join(File.dirname(File.expand_path(statement.file))) - $LOAD_PATH.unshift(base) + gir_path = "/usr/share/gir-1.0" - puts "-- Load module info" + module_name = statement[0].source + girs_files = Dir.glob("#{gir_path}/#{module_name}-?.*gir") + gir_file = girs_files.last + file = File.new(gir_file) + doc = Document.new file - require File.expand_path(statement.file) - module_name = statement[0].source - puts module_name - current_module = Object.const_get("#{module_name}") - current_module.init if current_module.respond_to?(:init) + module_yo = register ModuleObject.new(namespace, module_name) + doc.elements.each("repository/namespace/class") do |klass| + klass_name = klass.attributes["name"] + klass_yo = ClassObject.new(module_yo, klass_name) + documentation = klass.elements["doc"] + klass_yo.docstring = documentation ? documentation.text : "" - current_module.constants.each do |c| - puts "#{c} #{current_module.const_get(c).class}" + klass.elements.each("constructor") do |c| + m = MethodObject.new(klass_yo, c.attributes["name"]) + documentation = c.elements["doc"] + m.docstring = documentation ? documentation.text : "" + end + + klass.elements.each("method") do |c| + m = MethodObject.new(klass_yo, c.attributes["name"]) + documentation = c.elements["doc"] + m.docstring = documentation ? documentation.text : "" + end end + end end +
Create a gir file loader
diff --git a/spec/rubocop/cop/rspec/instance_variable_spec.rb b/spec/rubocop/cop/rspec/instance_variable_spec.rb index abc1234..def5678 100644 --- a/spec/rubocop/cop/rspec/instance_variable_spec.rb +++ b/spec/rubocop/cop/rspec/instance_variable_spec.rb @@ -14,6 +14,19 @@ expect(cop.offenses.size).to eq(1) expect(cop.offenses.map(&:line).sort).to eq([3]) expect(cop.messages).to eq(['Use `let` instead of an instance variable']) + end + + it 'ignores non-spec blocks' do + inspect_source( + cop, + [ + 'not_rspec do', + ' before { @foo = [] }', + ' it { expect(@foo).to be_empty }', + 'end' + ] + ) + expect(cop.offenses).to be_empty end it 'finds an instance variable inside a shared example' do
Add test for non-rspec blocks
diff --git a/app/controllers/carto/builder/public/embeds_controller.rb b/app/controllers/carto/builder/public/embeds_controller.rb index abc1234..def5678 100644 --- a/app/controllers/carto/builder/public/embeds_controller.rb +++ b/app/controllers/carto/builder/public/embeds_controller.rb @@ -45,8 +45,11 @@ end def ensure_viewable - return(render 'admin/visualizations/embed_map_error', status: 403) if @visualization.private? - return(render 'show_protected', status: 403) if @visualization.password_protected? + if @visualization.private? && !@visualization.has_read_permission?(current_viewer) + return(render 'admin/visualizations/embed_map_error', status: 403) + elsif @visualization.password_protected? + return(render 'show_protected', status: 403) + end end end end
Check for permissions for visualization embed
diff --git a/spec/controllers/genres_controller_controller_spec.rb b/spec/controllers/genres_controller_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/genres_controller_controller_spec.rb +++ b/spec/controllers/genres_controller_controller_spec.rb @@ -3,12 +3,12 @@ RSpec.describe GenresController, type: :controller do describe "GET #index" do - it 'assigns all genres as @genre' do + xit 'assigns all genres as @genre' do get :index expect(assigns(:genres)).to eq(Genre.all) end - it 'renders the genres#index page' do + xit 'renders the genres#index page' do get :index expect(response).to render(:index) end
Add pending to tests that are not passing
diff --git a/db/migrate/20110705145807_add_name_index_to_stop_areas.rb b/db/migrate/20110705145807_add_name_index_to_stop_areas.rb index abc1234..def5678 100644 --- a/db/migrate/20110705145807_add_name_index_to_stop_areas.rb +++ b/db/migrate/20110705145807_add_name_index_to_stop_areas.rb @@ -0,0 +1,9 @@+class AddNameIndexToStopAreas < ActiveRecord::Migration + def self.up + execute "CREATE INDEX index_stop_areas_on_name_lower ON stop_areas ((lower(name)));" + end + + def self.down + remove_index :stop_areas, 'name_lower' + end +end
Add index on name, some easy loading to admin for stop areas.
diff --git a/gir_ffi-cairo.gemspec b/gir_ffi-cairo.gemspec index abc1234..def5678 100644 --- a/gir_ffi-cairo.gemspec +++ b/gir_ffi-cairo.gemspec @@ -17,7 +17,7 @@ s.files = Dir['{lib,test}/**/*.rb', 'README.md', 'Rakefile', 'COPYING.LIB'] s.test_files = Dir['test/**/*.rb'] - s.add_runtime_dependency('gir_ffi', ['~> 0.13.0']) + s.add_runtime_dependency('gir_ffi', ['~> 0.14.0']) s.add_development_dependency('minitest', ['~> 5.0']) s.add_development_dependency('rake', ['~> 12.0'])
Update gir_ffi to version 0.14.0
diff --git a/core/app/views/activities/_added_fact_to_topic_activity.json.jbuilder b/core/app/views/activities/_added_fact_to_topic_activity.json.jbuilder index abc1234..def5678 100644 --- a/core/app/views/activities/_added_fact_to_topic_activity.json.jbuilder +++ b/core/app/views/activities/_added_fact_to_topic_activity.json.jbuilder @@ -1,7 +1,6 @@ channel = object -pavlov_options = {current_user: current_user, ability: current_ability} -topic = Pavlov.interactor :'topics/get', channel.slug_title, pavlov_options +topic = query :'user_topics/by_slug_title', channel.slug_title json.fact_displaystring truncate(subject.data.displaystring.to_s, length: 48) json.fact_url friendly_fact_path(subject)
Use new query in the add_fact_to_topic_activity
diff --git a/activesupport-db-cache.gemspec b/activesupport-db-cache.gemspec index abc1234..def5678 100644 --- a/activesupport-db-cache.gemspec +++ b/activesupport-db-cache.gemspec @@ -1,6 +1,6 @@ # -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) -require File.expand_path('../lib/activesupport-db-cache', __FILE__) +require 'activesupport-db-cache' Gem::Specification.new do |gem| gem.authors = ["Sergei O. Udalov"]
Correct the require not to use relative path
diff --git a/app/views/api/v1/users/base.rabl b/app/views/api/v1/users/base.rabl index abc1234..def5678 100644 --- a/app/views/api/v1/users/base.rabl +++ b/app/views/api/v1/users/base.rabl @@ -2,7 +2,7 @@ node(:id) { |user| user._id.to_s } -attributes :name, :time_zone, :member_since, :suspended_until, :reason_for_suspension, :skype_name +attributes :name, :time_zone, :member_since, :suspended_until, :reason_for_suspension, :skype_name, :also_known_as node(:avatar) { |user| user.avatar_versions }
Return also known as in user rabl.
diff --git a/db/data/20150311125212_make_sentences_to_axioms.rb b/db/data/20150311125212_make_sentences_to_axioms.rb index abc1234..def5678 100644 --- a/db/data/20150311125212_make_sentences_to_axioms.rb +++ b/db/data/20150311125212_make_sentences_to_axioms.rb @@ -0,0 +1,15 @@+class MakeSentencesToAxioms < ActiveRecord::Migration + def self.up + Sentence.unscoped.where(type: nil).find_each do |sentence| + sentence.type = 'Axiom' + sentence.save! + end + end + + def self.down + Sentence.unscoped.where(type: 'Axiom').find_each do |sentence| + sentence.type = nil + sentence.save! + end + end +end
Add data migration on Axiom introduction.
diff --git a/config/software/openstack-project.rb b/config/software/openstack-project.rb index abc1234..def5678 100644 --- a/config/software/openstack-project.rb +++ b/config/software/openstack-project.rb @@ -31,6 +31,6 @@ "-p #{install_dir}/embedded/bin/python", "#{install_dir}/#{name}", "--system-site-packages"].join(" "), :env => env + command "rsync -avz --exclude '.git' . #{install_dir}/#{name}" command "#{install_dir}/#{name}/bin/python setup.py install", :env => env - command "if [ -d ./etc ]; then cp -R ./etc #{install_dir}/#{name}/etc; fi" end
Include all of the source in openstack projects This is not really ideal, but it shouldnt blow the sizes of the packages up too, too significantly. Having the source is useful for a number of reasons.
diff --git a/ordinalize_full.gemspec b/ordinalize_full.gemspec index abc1234..def5678 100644 --- a/ordinalize_full.gemspec +++ b/ordinalize_full.gemspec @@ -17,7 +17,7 @@ spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] - spec.add_dependency "i18n", ">= 0.5" + spec.add_dependency "i18n", ">= 0.6.6" spec.add_development_dependency "bundler", ">= 1.5" spec.add_development_dependency "rake"
Make sure we don't use an unsafe version of i18n https://hakiri.io/issues/cve-2013-4492
diff --git a/lib/filterrific/engine.rb b/lib/filterrific/engine.rb index abc1234..def5678 100644 --- a/lib/filterrific/engine.rb +++ b/lib/filterrific/engine.rb @@ -28,8 +28,12 @@ extend Filterrific::ActiveRecordExtension end - initializer "filterrific" do |app| - app.config.assets.precompile += %w(filterrific-spinner.gif) + # sprockets-rails 3 tracks down the calls to `font_path` and `image_path` + # and automatically precompiles the referenced assets. + unless Rails::VERSION::MAJOR < 5 + initializer "filterrific.assets.precompile" do |app| + app.config.assets.precompile += %w(filterrific/filterrific-spinner.gif) + end end end
Add to assets.precompile only prior to Rails 5
diff --git a/cookbooks/chef/attributes/default.rb b/cookbooks/chef/attributes/default.rb index abc1234..def5678 100644 --- a/cookbooks/chef/attributes/default.rb +++ b/cookbooks/chef/attributes/default.rb @@ -5,4 +5,4 @@ default[:chef][:server][:version] = "12.17.33" # Set the default client version -default[:chef][:client][:version] = "16.6.14" +default[:chef][:client][:version] = "16.8.14"
Update chef client to 16.8.14
diff --git a/lib/librarian/resolver.rb b/lib/librarian/resolver.rb index abc1234..def5678 100644 --- a/lib/librarian/resolver.rb +++ b/lib/librarian/resolver.rb @@ -4,6 +4,14 @@ module Librarian class Resolver + + class GraphHash < Hash + include TSort + alias tsort_each_node each_key + def tsort_each_child(node, &block) + self[node].each(&block) + end + end attr_reader :root_module, :source @@ -29,21 +37,9 @@ manifests[dependency.name] = manifest end end - manifest_pairs = Hash[manifests.map{|k, m| [k, m.dependencies.map{|d| d.name}]}] - manifest_names = tsort(manifest_pairs) + manifest_pairs = GraphHash[manifests.map{|k, m| [k, m.dependencies.map{|d| d.name}]}] + manifest_names = manifest_pairs.tsort manifest_names.map{|n| manifests[n]} - end - - def tsort(graph) - graph = graph.dup - class << graph - include TSort - alias tsort_each_node each_key - def tsort_each_child(node, &block) - self[node].each(&block) - end - end - graph.tsort end private
Clean up. In order to tsort a graph hash using the tsort stdlib, we were fiddling with the graph hash object's singleton class. It's clearer to have a specific class representing a graph hash.
diff --git a/NSLogger.podspec b/NSLogger.podspec index abc1234..def5678 100644 --- a/NSLogger.podspec +++ b/NSLogger.podspec @@ -5,7 +5,7 @@ s.summary = 'A modern, flexible logging tool.' s.homepage = 'https://github.com/fpillet/NSLogger' s.author = { 'Florent Pillet' => 'fpillet@gmail.com' } - s.source = { :git => 'https://github.com/fpillet/NSLogger.git', :commit => '3253608026' } + s.source = { :git => 'https://github.com/fpillet/NSLogger.git', :tag => 'v1.1' } s.description = 'NSLogger is a high perfomance logging utility which displays traces emitted by ' \ 'client applications running on Mac OS X or iOS (iPhone OS). It replaces your ' \
Update podspec to tag name. This has also been pushed to cocoapods/specs as a pull request
diff --git a/lib/protobuf/lifecycle.rb b/lib/protobuf/lifecycle.rb index abc1234..def5678 100644 --- a/lib/protobuf/lifecycle.rb +++ b/lib/protobuf/lifecycle.rb @@ -8,7 +8,7 @@ event_name = normalized_event_name( event_name ) log_warn { - message = "Lifecycle events have been deprecated. Use ::ActiveSupport::Notifications.subscribe('#{event_name}')" + message = "[DEPRECATED] Lifecycle events have been deprecated. Use ::ActiveSupport::Notifications.subscribe('#{event_name}')" sign_message(message) } @@ -19,7 +19,7 @@ def self.trigger( event_name, *args ) log_warn { - message = "Lifecycle events have been deprecated. Use ::ActiveSupport::Notifications.instrument(...)" + message = "[DEPRECATED] Lifecycle events have been deprecated. Use ::ActiveSupport::Notifications.instrument(...)" sign_message(message) }
Make deprecation warnings more visible
diff --git a/lib/pwdcalc/formtastic.rb b/lib/pwdcalc/formtastic.rb index abc1234..def5678 100644 --- a/lib/pwdcalc/formtastic.rb +++ b/lib/pwdcalc/formtastic.rb @@ -9,11 +9,11 @@ input_wrapping do label_html << builder.password_field(method, input_html_options) << - password_strength_meter(builder, method) + password_strength_meter end end - def password_strength_meter(builder, method) + def password_strength_meter template.content_tag(:p, "", :'data-field' => input_html_options[:id], :class => "password-strength-meter pwdcalc") end end
Remove unnecessary arguments from password_strength_meter method
diff --git a/lib/smart_answer/money.rb b/lib/smart_answer/money.rb index abc1234..def5678 100644 --- a/lib/smart_answer/money.rb +++ b/lib/smart_answer/money.rb @@ -10,7 +10,7 @@ def initialize(raw_input) input = self.class.parse(raw_input) - self.class.validate(input) + self.class.validate!(input) @value = BigDecimal.new(input.to_s) end @@ -30,7 +30,7 @@ raw_input.is_a?(Numeric) ? raw_input : raw_input.to_s.delete(',').gsub(/\s/, '') end - def self.validate(input) + def self.validate!(input) unless input.is_a?(Numeric) || input.is_a?(Money) || input =~ /\A *[0-9]+(\.[0-9]{1,2})? *\z/ raise InvalidResponse, "Sorry, that number is not valid. Please try again.", caller end
Add an exclamation mark on validate method Adding an exclamation mark to the `Money` class validate method, because it raises an exception if it fails. It is just a small style change.
diff --git a/lib/srtshifter/options.rb b/lib/srtshifter/options.rb index abc1234..def5678 100644 --- a/lib/srtshifter/options.rb +++ b/lib/srtshifter/options.rb @@ -22,7 +22,7 @@ opts.separator "Common Options:" opts.on("-o","--operation (ADD|SUB)", String, "Type ADD to increase time or SUB to decrease time.") do |o| - @options[:operation] = o + @options[:operation] = o.upcase end opts.on("-t","--time (VALUE)", Float, "Time in milliseconds.") do |n| @@ -42,7 +42,7 @@ begin raise "Operation option is missing" if @options[:operation].nil? - raise "Unknown operation: #{@options[:operation]}" unless @operations.include? @options[:operation].upcase + raise "Unknown operation: #{@options[:operation]}" unless @operations.include? @options[:operation] raise "Time option is missing" if @options[:time].nil?
Store the operation arg in upcase
diff --git a/lib/strategy/blacklist.rb b/lib/strategy/blacklist.rb index abc1234..def5678 100644 --- a/lib/strategy/blacklist.rb +++ b/lib/strategy/blacklist.rb @@ -3,15 +3,16 @@ class Blacklist < DataAnon::Strategy::Base def process_record index, record + updates = {} @fields.each do |field, strategy| database_field_name = record.attributes.select { |k,v| k == field }.keys[0] field_value = record.attributes[database_field_name] unless field_value.nil? || is_primary_key?(database_field_name) field = DataAnon::Core::Field.new(database_field_name, field_value, index, record, @name) - record[database_field_name] = strategy.anonymize(field) + updates[database_field_name] = strategy.anonymize(field) end end - record.save! + record.update_columns(updates) if updates.any? end end
Use update_columns instead of save! for performance
diff --git a/lib/tasks/sitemapper.rake b/lib/tasks/sitemapper.rake index abc1234..def5678 100644 --- a/lib/tasks/sitemapper.rake +++ b/lib/tasks/sitemapper.rake @@ -1,4 +1,8 @@+# encoding: utf-8 namespace :sitemapper do + + desc "Rebuilds all sitemaps" + task :rebuild => [:environment, :build_from_config, :build_kml] desc "Notifies search-engines about the index-sitemap" task :ping => :environment do @@ -8,11 +12,56 @@ end desc "Rebuild everything from config/sitemapper.yml" - task :rebuild => :environment do + task :build_from_config => :environment do + include Rails.application.routes.url_helpers + config = AegisNet::Sitemapper::Loader.load_config + default_url_options[:host] = config["default_host"] + ActiveRecord::Migration.say_with_time "Rebuilding sitemaps from config/sitemapper.yml" do AegisNet::Sitemapper::Urlset.build_all! AegisNet::Sitemapper::Index.create! end end + desc "Build KML file" + task :build_kml => :environment do + include Rails.application.routes.url_helpers + config = AegisNet::Sitemapper::Loader.load_config + default_url_options[:host] = config["default_host"] + + ActiveRecord::Migration.say_with_time "Rebuilding KML sitemap" do + options = { + :file => File.join(config["local_path"], "sitemap_geo.kml"), + :xmlns => "http://www.opengis.net/kml/2.2" + } + + AegisNet::Sitemapper::Generator.create( ServiceProvider.find(:all, :include => [:category, :geo_location]), options ) do |entry, xml| + xml.Placemark do + if entry.title.present? + xml.name entry.title + else + xml.name entry.name + end + xml.description "<p>Branchenbuch bei KAUPERTS Berlin</p>" + xml.ExtendedData do + xml.Data "name" => "Link" do + xml.displayName "Link" + xml.value service_provider_url(entry) + end + xml.Data "name" => "Kategorie" do + xml.displayName "Kategorie" + xml.value entry.category.plural_name + end + end + xml.Point do + xml.coordinates entry.geo_location.lng.to_s + "," + entry.geo_location.lat.to_s + ",0" + end + end + end + + `zip #{options[:file].gsub(/kml$/, 'kmz')} #{options[:file]} > /dev/null` + + end + end + end
Update rake task from @kaupertmedia
diff --git a/liquid-autoescape.gemspec b/liquid-autoescape.gemspec index abc1234..def5678 100644 --- a/liquid-autoescape.gemspec +++ b/liquid-autoescape.gemspec @@ -20,7 +20,7 @@ s.files += Dir.glob("spec/**/*") s.test_files = Dir.glob("spec/**/*") - s.add_dependency "liquid", ">= 2.0" + s.add_dependency "liquid", ">= 2.3" s.add_development_dependency "appraisal", "~> 2.0" s.add_development_dependency "rake", "~> 12.0"
Enforce the minimum supported Liquid version via the gemspec
diff --git a/glow.gemspec b/glow.gemspec index abc1234..def5678 100644 --- a/glow.gemspec +++ b/glow.gemspec @@ -16,8 +16,10 @@ Handles Flash messages in Javascript for Rails xhr-responses. Fires a dom event when flash messages are present. DESC - s.files = Dir["{app,config,db,lib,vendor}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.md"] - s.test_files = Dir["test/**/*"] + 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.rdoc_options = ['--main', 'README.md', '--charset=UTF-8'] s.extra_rdoc_files = ['README.md', 'MIT-LICENSE']
Use git ls-files in gemspec
diff --git a/app/helpers/crud_helper.rb b/app/helpers/crud_helper.rb index abc1234..def5678 100644 --- a/app/helpers/crud_helper.rb +++ b/app/helpers/crud_helper.rb @@ -13,28 +13,6 @@ url = options[:url] || send("new_admin_#{name}_path") text = options[:text] || "+ New #{name.humanize}" big_link(text, url) - end - - def td_delete(resource, options = {}) - url = options[:url] || [:admin, resource] - - if options[:disabled] - link = '' - else - anchor = raw('<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>') - link = link_to anchor, url, method: :delete, - data: { confirm: 'Are you sure?' } - end - - raw('<td class="delete">' + link + '</td>') - end - - def td_edit(resource, options = {}) - name = resource.class.table_name.singularize - url = options[:url] || send("edit_admin_#{name}_path", resource) - link = link_to 'Edit', url - raw('<td class="edit">' + link + '</td>') - end def back_link(text, url)
Remove unneeded td_edit and td_delete methods These are replaced with long form html version inside the index template.
diff --git a/app/mailers/test_mailer.rb b/app/mailers/test_mailer.rb index abc1234..def5678 100644 --- a/app/mailers/test_mailer.rb +++ b/app/mailers/test_mailer.rb @@ -3,13 +3,16 @@ @text = params[:text] e = mail(from: params[:from], to: params[:to], cc: params[:cc], subject: params[:subject]) e.delivery_method :smtp, { + # We're connecting to localhost so that on local vm we don't need + # to put anything in /etc/hosts for the name to resolve. This has some consequences + # for the SSL connection (see below) address: "localhost", port: Rails.configuration.cuttlefish_smtp_port, user_name: app.smtp_username, password: app.smtp_password, - # We're currently using a self-signed certificate on the smtp server. So, - # to keep everyone happy we have to use openssl verify mode none. - #openssl_verify_mode: "none", + # So that we don't get a certificate name and host mismatch we're just + # disabling the check. + openssl_verify_mode: "none", authentication: :plain } e
Disable ssl verify because we're connecting to localhost in test mailer
diff --git a/app/models/stream_token.rb b/app/models/stream_token.rb index abc1234..def5678 100644 --- a/app/models/stream_token.rb +++ b/app/models/stream_token.rb @@ -4,9 +4,14 @@ attr_accessible :token, :target, :expires def self.find_or_create_session_token(session, target) + self.purge_expired! result = self.find_or_create_by_token_and_target(session[:session_id], target) result.renew! result.token + end + + def self.purge_expired! + self.where("expires <= :now", :now => Time.now).each &:delete end def self.validate_token(value)
Purge expired StreamTokens on refresh
diff --git a/test/controllers/cms_partials_controller_test.rb b/test/controllers/cms_partials_controller_test.rb index abc1234..def5678 100644 --- a/test/controllers/cms_partials_controller_test.rb +++ b/test/controllers/cms_partials_controller_test.rb @@ -28,12 +28,7 @@ assert_redirected_to cms_partials_url end - - test 'should show cms_partial' do - get cms_partial_url(cms_partial) - assert_response :success - end - + test 'should get edit' do get edit_cms_partial_url(cms_partial) assert_response :success
Remove autogenerated test for nonexistent action
diff --git a/fluent-plugin-conditional_filter.gemspec b/fluent-plugin-conditional_filter.gemspec index abc1234..def5678 100644 --- a/fluent-plugin-conditional_filter.gemspec +++ b/fluent-plugin-conditional_filter.gemspec @@ -22,5 +22,5 @@ spec.add_development_dependency 'bundler' spec.add_development_dependency 'rake' spec.add_development_dependency 'rspec' + spec.add_development_dependency 'test-unit' end -
Add a missing test-unit development dependency
diff --git a/config/initializers/08-rack-cors.rb b/config/initializers/08-rack-cors.rb index abc1234..def5678 100644 --- a/config/initializers/08-rack-cors.rb +++ b/config/initializers/08-rack-cors.rb @@ -15,6 +15,7 @@ end headers['Access-Control-Allow-Origin'] = origin || @origins[0] + headers['Access-Control-Allow-Credentials'] = "true" [status,headers,body] end end
Add Access-Control-Allow-Credentials to the CORS headers.
diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index abc1234..def5678 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -4,5 +4,4 @@ # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. -Donationparty::Application.config.secret_token = 'a387d096b2919868f239f865596fcf0559ea093f9aea9992a41f266c8a86409457d901b77bef84a7a72717eb24dfa641a8d24ad940542094585de0fcf3ae95af' -Donationparty::Application.config.secret_key_base = 'lkjhsdahkjsdghiuweiuyewrhjksdjksdfhjkdfshjfdshjkdf' +Donationparty::Application.config.secret_key_base = ENV['SECRET_KEY_BASE']
Remove Rails 3 SECRET_TOKEN and use SECRET_KEY_BASE from environment
diff --git a/ucb_ldap.gemspec b/ucb_ldap.gemspec index abc1234..def5678 100644 --- a/ucb_ldap.gemspec +++ b/ucb_ldap.gemspec @@ -21,5 +21,5 @@ spec.add_development_dependency "rake" spec.add_development_dependency "rspec" - spec.add_runtime_dependency "net-ldap", "0.2.2" + spec.add_runtime_dependency "net-ldap", "0.16.1" end
Upgrade to latest net-ldap gem
diff --git a/src/config/initializers/mustache_template_handler.rb b/src/config/initializers/mustache_template_handler.rb index abc1234..def5678 100644 --- a/src/config/initializers/mustache_template_handler.rb +++ b/src/config/initializers/mustache_template_handler.rb @@ -18,7 +18,13 @@ end def render - renderer = @view_context.instance_variable_get('@renderer') if @view_context.instance_variable_names.include?('@renderer') + renderer = + if Rails.version >= '3.1' + @view_context.instance_variable_get('@view_renderer').instance_variable_get('@_partial_renderer') + else + @view_context.instance_variable_get('@renderer') if @view_context.instance_variable_names.include?('@renderer') + end + options = renderer.instance_variable_get("@options") if renderer if options && options.include?(:mustache)
Fix mustache template handler to work with Rails 3.1 and above Signed-off-by: Jason Guiditta <7fefa4e188e7870a3ee150310ebd55305fae98c8@redhat.com>
diff --git a/import_vm.rb b/import_vm.rb index abc1234..def5678 100644 --- a/import_vm.rb +++ b/import_vm.rb @@ -0,0 +1,39 @@+# TODO: Initial script for importing a vbox vm. Need to refactor. + +appliance_filename = 'Ubuntuserver1204-Test.ova' + +puts "\nImporting VM...\n\n" +`VBoxManage import #{appliance_filename}` +puts "\nDone importing VM.\n\n" + +puts "Modifying VM configuration:" + +vms = `VBoxManage list vms`.split("\n") +vm_name = /\"(.*)\"/.match(vms.last)[1] +vm_info_stdout = IO.popen(%Q(VBoxManage showvminfo "#{vm_name}")) + +vm_info_stdout.readlines.each do |l| + key, value = l.split(':', 2).map(&:strip) + + if !value.nil? + + # Remove existing port forwarding rules on Network Adapter 1 + if /NIC 1 Rule\(\d\)/.match(key) + rule_name = /^name = (.+?),/.match(value) + `VBoxManage modifyvm "#{vm_name}" --natpf1 delete "#{rule_name[1]}"` if !rule_name.nil? && rule_name.size > 1 + + # Remove network adapters 3 & 4 to avoid conflict with NAT and Bridged Adapter + elsif other_adapters = /^NIC (3|4)$/.match(key) && value != 'disabled' + `VBoxManage modifyvm "#{vm_name}" --nic#{other_adapters[1]}` + end + end +end +vm_info_stdout.close + +puts "Creating NAT on Network Adapter 1 and adding port forwarding..." +`VBoxManage modifyvm "#{vm_name}" --nic1 nat --cableconnected1 on --natpf1 "guestssh,tcp,,2222,,22"` + +puts "Creating Bridged Adapter on Network Adapter 2..." +`VBoxManage modifyvm "#{vm_name}" --nic2 bridged --bridgeadapter1 eth0` + +puts "\nDone modifying VM.\n\n"
Test script for importing a vbox vm.
diff --git a/unschema.gemspec b/unschema.gemspec index abc1234..def5678 100644 --- a/unschema.gemspec +++ b/unschema.gemspec @@ -18,5 +18,5 @@ gem.require_paths = ["lib"] gem.add_development_dependency 'rake' - gem.add_development_dependency 'minitest', '~> 5.3.5' + gem.add_development_dependency 'minitest', '~> 5.5' end
Tweak minitest dependency to ~> 5.5
diff --git a/spec/features/home_spec.rb b/spec/features/home_spec.rb index abc1234..def5678 100644 --- a/spec/features/home_spec.rb +++ b/spec/features/home_spec.rb @@ -10,7 +10,7 @@ expect(page).to have_link('Browse') expect(page).to have_link('Docs') - expect(page).to have_link('Start Recording') + expect(page).to have_button('Start Recording') expect(page).to have_content(/Featured asciicasts/i) expect(page).to have_content(/Latest asciicasts/i) expect(page).to have_link("the title")
Fix homepage test - "Start Recording" is a button now
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb index abc1234..def5678 100644 --- a/spec/models/commit_spec.rb +++ b/spec/models/commit_spec.rb @@ -0,0 +1,17 @@+require 'rails_helper' + +RSpec.describe Commit, type: :model do + before { @commit = Commit.new( + repo_full_name: 'minamijoyo/commit-m', + sha: 'ad029c9d6d79ad6e1b2ca4ff33e998c23c471675', + message: 'Initial commit') } + + subject { @commit } + + it { should respond_to(:repo_full_name) } + it { should respond_to(:sha) } + it { should respond_to(:message) } + + it { should be_valid } + +end
Add test for commit model
diff --git a/spec/models/player_spec.rb b/spec/models/player_spec.rb index abc1234..def5678 100644 --- a/spec/models/player_spec.rb +++ b/spec/models/player_spec.rb @@ -1,10 +1,5 @@ require 'rails_helper' require_relative 'shared_examples' - -RSpec.shared_examples "an invalid Player" do - let(:model) { player } - include_examples "an invalid ActiveRecord" -end RSpec.describe Player, type: :model do let(:user) { User.create!(nickname: "flipper") }
Tidy up unused test helpers in player spec
diff --git a/chef-provisioning-docker.gemspec b/chef-provisioning-docker.gemspec index abc1234..def5678 100644 --- a/chef-provisioning-docker.gemspec +++ b/chef-provisioning-docker.gemspec @@ -25,5 +25,6 @@ s.executables = %w( ) s.require_path = 'lib' - s.files = %w(Gemfile Rakefile LICENSE README.md) + Dir.glob("{distro,lib,tasks,spec}/**/*", File::FNM_DOTMATCH).reject {|f| File.directory?(f) } + s.files = %w(Gemfile Rakefile LICENSE README.md) + Dir.glob("*.gemspec") + + Dir.glob("{distro,lib,tasks,spec}/**/*", File::FNM_DOTMATCH).reject {|f| File.directory?(f) } end
Add gemspec files to allow bundler to run from the gem
diff --git a/week-5/gps2_2.rb b/week-5/gps2_2.rb index abc1234..def5678 100644 --- a/week-5/gps2_2.rb +++ b/week-5/gps2_2.rb @@ -0,0 +1,82 @@+# Input: A hash +# Output: A hash +# Define a method to create a new list +# Accepts a hash + # Returns hash + +# Input: Key and value +# Output: The updated hash +# Define a method that adds item with quantity +# Accepts a key and a value + # Push key and value onto hash + # Return hash + +# Input: Key +# Output: Updated hash +# Define a method that deletes an item + # Iterate through hash + # Delete the requested item + # Return hash + +# Input: Key and new value +# Output: Updated hash +# Define a method to update quantity + # Access key + # Change value + # Return hash + +# Input: Command +# Output: Formatted hash +# Define a method to print the list +# Iterate through hash +# Print friendly string that lists item and quantity + +def grocery_list(new_list) + puts new_list +end + +def add_list(item, qty, hash) + hash[item] = qty + puts hash +end + +def delete_item(item, hash) + hash.delete_if{|x, qty| x==item} + puts hash +end + +def update_qty(item, qty, hash) + hash.each do |key, value| + if key==item + hash[key]=qty + puts hash + end + end +end + +def print_list(hash) + hash.each do |key, value| + puts "You need " + value.to_s + " " + key.to_s + "." + end +end + +=begin +What did you learn about pseudocode from working on this challenge? +I did learn that pseudocode is not an exact science, and it is most important that it is readable to you. + +What are the tradeoffs of using Arrays and Hashes for this challenge? +It never occurred to me to use anything other than hashes for this challenge. A has lets you pair each item to its associate quantity, though it is also more complicated to use. + +What does a method return? +A method returns what you tell it to return. + +What kind of things can you pass into methods as arguments? +You can pass Integers, Floats, Strings, Arrays, and Hashes to a method. + +How can you pass information between methods? +You can have one method call on another method. + +What concepts were solidified in this challenge, and what concepts are still confusing? +Hashes remain a bit confusing, but I am a bit more certian as to how to use them. + +=end
Add code for gps challenge
diff --git a/test/test_mpeg_file.rb b/test/test_mpeg_file.rb index abc1234..def5678 100644 --- a/test/test_mpeg_file.rb +++ b/test/test_mpeg_file.rb @@ -39,7 +39,7 @@ end should "contain information" do - assert_true @xing_header.valid? + assert @xing_header.valid? assert_equal 88, @xing_header.total_frames assert_equal 45140, @xing_header.total_size end
Use assert instead of assert_true
diff --git a/knife-vsphere.gemspec b/knife-vsphere.gemspec index abc1234..def5678 100644 --- a/knife-vsphere.gemspec +++ b/knife-vsphere.gemspec @@ -15,7 +15,7 @@ s.homepage = "https://github.com/chef/knife-vsphere" s.license = "Apache-2.0" s.add_dependency "netaddr", ["~> 1.5"] - s.add_dependency "rbvmomi", [">= 1.8", "< 3.0"] + s.add_dependency "rbvmomi", ">= 1.8", "< 4.0" s.add_dependency "filesize", ">= 0.1.1", "< 0.3.0" s.add_dependency "chef-vault", [">= 2.6.0"] s.add_dependency "chef", ">= 15.1"
Update rbvmomi requirement from >= 1.8, < 3.0 to >= 1.8, < 4.0 Updates the requirements on [rbvmomi](https://github.com/vmware/rbvmomi) to permit the latest version. - [Release notes](https://github.com/vmware/rbvmomi/releases) - [Commits](https://github.com/vmware/rbvmomi/compare/v1.8.2.pre...v3.0.0) Signed-off-by: dependabot-preview[bot] <5bdcd3c0d4d24ae3e71b3b452a024c6324c7e4bb@dependabot.com>
diff --git a/test/dummy/app/controllers/common_controller_actions.rb b/test/dummy/app/controllers/common_controller_actions.rb index abc1234..def5678 100644 --- a/test/dummy/app/controllers/common_controller_actions.rb +++ b/test/dummy/app/controllers/common_controller_actions.rb @@ -32,7 +32,7 @@ end def sign_in_as_admin! - sign_in(:admin, Admin.first) unless Admin.all.empty? + sign_in(:admin, Admin.where(role: 'Super').first) unless Admin.where(role: 'Super').empty? end end
Make sure admin auto-login signs in as a Super admin
diff --git a/recipes/container.rb b/recipes/container.rb index abc1234..def5678 100644 --- a/recipes/container.rb +++ b/recipes/container.rb @@ -2,7 +2,7 @@ docker_image 'drone' do repo 'drone/drone' - tag '0.4' + tag node['drone']['version'] action :pull end
Fix taking version from attributes
diff --git a/vmdb/app/models/configuration_manager_foreman.rb b/vmdb/app/models/configuration_manager_foreman.rb index abc1234..def5678 100644 --- a/vmdb/app/models/configuration_manager_foreman.rb +++ b/vmdb/app/models/configuration_manager_foreman.rb @@ -34,8 +34,4 @@ def self.unknown_task_exception(options) raise "Unknown task, #{options[:task]}" unless instance_methods.collect(&:to_s).include?(options[:task]) end - - def self.refresh_ems(provider_ids) - EmsRefresh.queue_refresh(Array.wrap(provider_ids).collect { |id| [base_class, id] }) - end end
Use underlying refresh_ems impl for foreman https://bugzilla.redhat.com/show_bug.cgi?id=1211693
diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index abc1234..def5678 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -7,7 +7,8 @@ flash[:success] = "Welcome, #{@user.name}!" if is_navigational_format? else session["devise.facebook_data"] = request.env["omniauth.auth"] - redirect_to new_user_registration_url + flash[:danger] = "We're sorry, but we couldn't log you in." + redirect_to root_path end end
Fix redirect issue if FB login fails
diff --git a/app/controllers/spina/admin/articles_controller.rb b/app/controllers/spina/admin/articles_controller.rb index abc1234..def5678 100644 --- a/app/controllers/spina/admin/articles_controller.rb +++ b/app/controllers/spina/admin/articles_controller.rb @@ -7,7 +7,7 @@ layout "spina/admin/admin" def index - @articles = Spina::Article.all + @articles = Spina::Article.order(:title).all end def new @@ -23,6 +23,10 @@ else render :new end + end + + def edit + add_breadcrumb @article.title end def update @@ -42,7 +46,7 @@ private def set_article - @article = Article.find(params[:id]) + @article = Spina::Article.find(params[:id]) end def set_breadcrumb
Order by title in admin
diff --git a/app/controllers/spree/user_passwords_controller.rb b/app/controllers/spree/user_passwords_controller.rb index abc1234..def5678 100644 --- a/app/controllers/spree/user_passwords_controller.rb +++ b/app/controllers/spree/user_passwords_controller.rb @@ -3,12 +3,6 @@ helper 'spree/users', 'spree/base' ssl_required - - after_filter :associate_user - - def new - super - end # Temporary Override until next Devise release (i.e after v1.3.4) # line: @@ -29,12 +23,4 @@ end end - def edit - super - end - - def update - super - end - end
Remove associate_user call from UserPasswordsController + cleanup
diff --git a/lib/elocal_capistrano/delayed_job.rb b/lib/elocal_capistrano/delayed_job.rb index abc1234..def5678 100644 --- a/lib/elocal_capistrano/delayed_job.rb +++ b/lib/elocal_capistrano/delayed_job.rb @@ -2,12 +2,18 @@ set(:delayed_job_application_name) { "#{application}_delayed_job" } namespace :delayed_job do namespace :upstart do - %w(restart start stop status).each do |t| + %w(start stop status).each do |t| desc "Perform #{t} of the delayed_job service" task t, roles: :app, except: { no_release: true } do sudo "#{t} #{delayed_job_application_name}" end end + desc 'Perform a restart of the application puma service' + task :restart, roles: :app, except: { no_release: true } do + run <<-CMD.strip + pid=`status #{delayed_job_application_name} | grep -o -E '[0-9]+'`; if [ -z $pid ]; then sudo start #{delayed_job_application_name}; else sudo restart #{delayed_job_application_name}; fi + CMD + end end end end
Call start if not started
diff --git a/Casks/mou.rb b/Casks/mou.rb index abc1234..def5678 100644 --- a/Casks/mou.rb +++ b/Casks/mou.rb @@ -2,5 +2,5 @@ url 'http://mouapp.com/download/Mou.zip' version 'latest' homepage 'http://mouapp.com/' - sha1 'e69bc2bbdadea6a2929032506085b6e9501a7fb9' + no_checksum end
Use `no_checksum` instead of a sha1 when getting `latest` version.
diff --git a/lib/file_extractors/sf2_extractor.rb b/lib/file_extractors/sf2_extractor.rb index abc1234..def5678 100644 --- a/lib/file_extractors/sf2_extractor.rb +++ b/lib/file_extractors/sf2_extractor.rb @@ -10,14 +10,16 @@ list = [] begin + escape_characters = /([\/])/ content = IO.popen("sf2text \"#{@file}\"").read # Search for the pattern for a sounfont preset, like this: # (0 "Acoustic Bass" (preset 0) (bank 0) - matches = content.scan(/\(([0-9]+) "?([^"]*)"? \(preset [0-9]+\) \(bank [0-9]+\)/) + matches = content.scan(/\([0-9]+ "?([^"]*)"? \(preset ([0-9]+)\) \(bank [0-9]+\)/) matches.each do |preset| - list << "#{preset[0]} - #{preset[1]}" + preset_name = "#{sprintf "%03d", preset[1]} - #{preset[0].gsub(escape_characters, "\\\1")}" + list.unshift(preset_name) end if content.blank? # probably sf2text is not present @@ -25,7 +27,7 @@ end end - list + list.sort end def get_data
Correct sf2 preset numbering when extracting metadata
diff --git a/app/models/node.rb b/app/models/node.rb index abc1234..def5678 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -19,15 +19,7 @@ unless node node = Node.create!( :key => key, :content => content ) end - node - end - - def initialize( params = nil ) - if params.nil? or params.keys.map( &:to_s ).sort == %w[ content key ] - super( params ) - else - raise "Unexpected params passed to Node.new: #{params.inspect} -- you may want Node.custom_find_or_create(...), or Node.new()" - end + node end def to_param
Remove safeguard against Node.create!( 'content' ), blows up in rails 3
diff --git a/app/models/post.rb b/app/models/post.rb index abc1234..def5678 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -9,7 +9,7 @@ def author_date_subject # slugs are created before created_at is set - time = created_at || Time.now + time = created_at || Time.zone.now "#{author.login_name} #{time.strftime("%Y%m%d")} #{subject}" end
Fix intermittent build failure due to timezones Because our default timezone for the app is UTC, at certain times, some tests could fail outside of UTC. This commit fixes that by changing a single call to Time.now to Time.zone.now.
diff --git a/awesome_nested_set.gemspec b/awesome_nested_set.gemspec index abc1234..def5678 100644 --- a/awesome_nested_set.gemspec +++ b/awesome_nested_set.gemspec @@ -1,7 +1,5 @@ # -*- encoding: utf-8 -*- -lib = File.expand_path('../lib/', __FILE__) -$:.unshift lib unless $:.include?(lib) -require 'awesome_nested_set/version' +require File.expand_path('../lib/awesome_nested_set/version', __FILE__) Gem::Specification.new do |s| s.name = %q{awesome_nested_set}
Stop messing with the load path.
diff --git a/lib/jekyll/minibundle/asset_stamp.rb b/lib/jekyll/minibundle/asset_stamp.rb index abc1234..def5678 100644 --- a/lib/jekyll/minibundle/asset_stamp.rb +++ b/lib/jekyll/minibundle/asset_stamp.rb @@ -3,7 +3,7 @@ module Jekyll::Minibundle module AssetStamp def self.from_file(path) - Digest::MD5.hexdigest(File.read(path)) + Digest::MD5.file(path).hexdigest end end end
Create asset stamp by reading file in chunks Because an asset file can be really big, we should avoid reading it into memory as a whole. We conserve memory by reading it in chunks.
diff --git a/parse_assets.rb b/parse_assets.rb index abc1234..def5678 100644 --- a/parse_assets.rb +++ b/parse_assets.rb @@ -1,20 +1,89 @@ #!/usr/bin/env ruby require 'simple-spreadsheet' +require 'pp' +require 'yaml' -s = SimpleSpreadsheet::Workbook.read('./asset-toolbox.ods') +def get_header_line_num(ods) + line_num = -1 + for rowi in 0..ods.size do + line_num += 1 + row = ods[rowi] + if row[0] == "Asset" then + return line_num + end + end + return -1 +end -s.selected_sheet = s.sheets.first +def devices_raw_get(ods, offset) + hdr_line_num = get_header_line_num(ods) + row = ods[hdr_line_num] + return row[offset..-1] +end -table_row = 0 -saw_table_header = false -s.first_row.upto(s.last_row) do |line| - data = s.cell(line, 1) - if data == "Asset" then - saw_table_header = true - next +# read all the junk from .ods +def ods_read(file_name) + s = SimpleSpreadsheet::Workbook.read(file_name) + s.selected_sheet = s.sheets.first + + rows = [] + s.first_row.upto(s.last_row) do |cell_line| + one_row = [] + for coli in 1..20 do + col_data = s.cell(cell_line, coli) + if col_data == nil then + col_data = "" + end + one_row.push(col_data) + end + rows.push(one_row) end - next unless saw_table_header - name = s.cell(line, 2) - print name + "\n" + return rows end + +def nicefy(ods) + nice_data = Hash.new + nice_data["devices"] = [] + + # get device names + dev_offset = 2 + devs = devices_raw_get(ods, dev_offset) + + # figure out where's the header + hdr_line_num = get_header_line_num(ods) + + # for all actual data lines get name first, and device names + # and pick resolutions from the table and generate the assets + devs.each_with_index do |dev, devi| + if dev.length == 0 then + next + end + device = Hash.new + device["devname"] = dev + device["assets"] = [] + ods[hdr_line_num + 1..-1].each_with_index do |row, rowi| + desc = row[0] + name = row[1] + resolution = row[2 + devi] + + asset = Hash.new + asset["name"] = name + asset["resolution"] = resolution + + device["assets"].push(asset) + + #print "#{name} #{dev} #{resolution}\n" + end + nice_data["devices"].push(device) + end + return nice_data +end + +def main + data = ods_read("./asset-toolbox.ods") + data_nice = nicefy(data) + print data_nice.to_yaml +end + +main
Bring .ods -> .yaml conversion tool.
diff --git a/lib/minitest/documentation_plugin.rb b/lib/minitest/documentation_plugin.rb index abc1234..def5678 100644 --- a/lib/minitest/documentation_plugin.rb +++ b/lib/minitest/documentation_plugin.rb @@ -9,7 +9,7 @@ def self.plugin_documentation_init options if Documentation.documentation? - io = options.delete(:io) || $stdout + io = options.fetch(:io, $stdout) self.reporter.reporters.reject! {|o| o.is_a? ProgressReporter } self.reporter.reporters << Documentation.new(io, options) end
Make minitest-documentation play nice with others. Plugins are not provided with unique copies of the `options` Hash, so when you delete `:io` from that, you prevent any other outputter from working. This fixes that. (It’s arguable whether you should be removing any `ProgressReporter` as well, but that didn’t cause failure on output.)
diff --git a/lib/seek/research_objects/acts_as_snapshottable.rb b/lib/seek/research_objects/acts_as_snapshottable.rb index abc1234..def5678 100644 --- a/lib/seek/research_objects/acts_as_snapshottable.rb +++ b/lib/seek/research_objects/acts_as_snapshottable.rb @@ -33,12 +33,12 @@ def create_snapshot ro_file = Seek::ResearchObjects::Generator.instance.generate(self) # This only works for investigations + snapshot = snapshots.create blob = ContentBlob.new({ tmp_io_object: ro_file, content_type: Mime::Type.lookup_by_extension("ro").to_s, - original_filename: self.research_object_filename + original_filename: "#{self.class.name.underscore}-#{self.id}-#{snapshot.snapshot_number}.ro.zip" }) - snapshot = snapshots.create blob.asset = snapshot blob.save snapshot
Add snapshot number to RO filename
diff --git a/lib/unboxed/capistrano/recipes/deploy/passenger.rb b/lib/unboxed/capistrano/recipes/deploy/passenger.rb index abc1234..def5678 100644 --- a/lib/unboxed/capistrano/recipes/deploy/passenger.rb +++ b/lib/unboxed/capistrano/recipes/deploy/passenger.rb @@ -0,0 +1,10 @@+Unboxed::Capistrano::Recipes::Configuration.load do + namespace :deploy do + task :start do ; end + task :stop do ; end + task :restart, :roles => :app, :except => { :no_release => true } do + run "touch #{File.join(current_path, 'tmp' ,'restart.txt')}" + end + end +end +
Add a Passenger version of deploy:start, deploy:stop and deploy:restart
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,16 +2,17 @@ belongs_to :district has_many :candidates - has_many :observers, :class_name => "Watching", :foreign_key => "observer_id" - has_many :subjects, :class_name => "Watching", :foreign_key => "subject_id" + has_many :observers, :class_name => "Watching", :foreign_key => "subject_id" + has_many :subjects, :class_name => "Watching", :foreign_key => "observer_id" - has_many :endorsers, :class_name => "Endorsement", :foreign_key => "endorser_id" - has_many :endorsees, :class_name => "Endorsement", :foreign_key => "endorsee_id" + has_many :endorsers, :class_name => "Endorsement", :foreign_key => "endorsee_id" + has_many :endorsees, :class_name => "Endorsement", :foreign_key => "endorser_id" - # Refractor later, and User can watch other user multiple time, need to fix + def add_watch (user) Watching.create(observer: self, subject: user) end + end
Fix foreign key references to subj and endorsees
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 @@ -9,15 +9,15 @@ validates :title, :presence => true, if: :venture_officer? def long_name - "#{self.name} (#{self.email})".strip! + "#{self.name} (#{self.email})" end def formal_name - "#{self.title} #{self.name}".strip! + "#{self.title} #{self.name}" end def formal_name_with_stars - "#{self.title} #{self.name} #{self.show_stars}".strip! - end + "#{self.title} #{self.name} #{self.show_stars}" + en STAR = "\u272F" @@ -28,7 +28,7 @@ (1..self.gm_stars.to_i).each do stars = "#{stars}#{star}" end - stars.strip! + stars end def <=> (user)
Rollback - removed all strips