Refactor annotate_routes (Reduced offenses).

Reduced the Cyclomatic complexity. #330 By default didn't annotate activeadmin models. This close #330
parent 3e441d14
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
.bundle .bundle
.gems .gems
.rbenv-version .rbenv-version
.ruby-*
/.idea/ /.idea/
/.rbx /.rbx
/.rvmrc /.rvmrc
......
inherit_from: ./.rubocop_todo.yml inherit_from: ./.rubocop_todo.yml
AllCops: AllCops:
Include:
- '**/Rakefile'
- '**/config.ru'
Exclude: Exclude:
- 'bin/**/*' - 'vendor/**/*'
- 'spec/fixtures/**/*'
- 'tmp/**/*'
...@@ -14,4 +14,3 @@ before_install: ...@@ -14,4 +14,3 @@ before_install:
- rvm @global do gem install bundler - rvm @global do gem install bundler
script: script:
- bundle exec rspec - bundle exec rspec
- bundle exec rubocop
...@@ -17,7 +17,7 @@ group :development, :test do ...@@ -17,7 +17,7 @@ group :development, :test do
gem 'terminal-notifier-guard', require: false gem 'terminal-notifier-guard', require: false
gem 'simplecov', require: false gem 'simplecov', require: false
gem 'rubocop', require: false unless RUBY_VERSION =~ /^1.8/ gem 'rubocop', require: false unless RUBY_VERSION =~ /^1.8/
gem 'coveralls' # gem 'coveralls'
gem 'codeclimate-test-reporter' gem 'codeclimate-test-reporter'
platforms :mri do platforms :mri do
......
...@@ -177,6 +177,7 @@ you can do so with a simple environment variable, instead of editing the ...@@ -177,6 +177,7 @@ you can do so with a simple environment variable, instead of editing the
--wo, --wrapper-open STR Annotation wrapper opening. --wo, --wrapper-open STR Annotation wrapper opening.
--wc, --wrapper-close STR Annotation wrapper closing --wc, --wrapper-close STR Annotation wrapper closing
-r, --routes Annotate routes.rb with the output of 'rake routes' -r, --routes Annotate routes.rb with the output of 'rake routes'
-aa, --active-admin Annotate all activeadmin models
-v, --version Show the current version of this gem -v, --version Show the current version of this gem
-m, --show-migration Include the migration version number in the annotation -m, --show-migration Include the migration version number in the annotation
-i, --show-indexes List the table's database indexes in the annotation -i, --show-indexes List the table's database indexes in the annotation
......
...@@ -26,40 +26,40 @@ include Rake::DSL if using_dsl ...@@ -26,40 +26,40 @@ include Rake::DSL if using_dsl
require './lib/annotate' require './lib/annotate'
require 'mg' require 'mg'
begin begin
MG.new("annotate.gemspec") MG.new('annotate.gemspec')
rescue Exception rescue Exception
STDERR.puts("WARNING: Couldn't read gemspec. As such, a number of tasks may be unavailable to you until you run 'rake gem:gemspec' to correct the issue.") STDERR.puts("WARNING: Couldn't read gemspec. As such, a number of tasks may be unavailable to you until you run 'rake gem:gemspec' to correct the issue.")
# Gemspec is probably in a broken state, so let's give ourselves a chance to # Gemspec is probably in a broken state, so let's give ourselves a chance to
# build a new one... # build a new one...
end end
DEVELOPMENT_GROUPS=[:development, :test] DEVELOPMENT_GROUPS = [:development, :test].freeze
RUNTIME_GROUPS=Bundler.definition.groups - DEVELOPMENT_GROUPS RUNTIME_GROUPS = Bundler.definition.groups - DEVELOPMENT_GROUPS
namespace :gem do namespace :gem do
task :gemspec do task :gemspec do
spec = Gem::Specification.new do |gem| spec = Gem::Specification.new do |gem|
# See http://docs.rubygems.org/read/chapter/20 # See http://docs.rubygems.org/read/chapter/20
# for more options. # for more options.
gem.version = Annotate.version gem.version = Annotate.version
gem.name = "annotate" gem.name = 'annotate'
gem.homepage = "http://github.com/ctran/annotate_models" gem.homepage = 'http://github.com/ctran/annotate_models'
gem.rubyforge_project = "annotate" gem.rubyforge_project = 'annotate'
gem.license = "Ruby" gem.license = 'Ruby'
gem.summary = %q{Annotates Rails Models, routes, fixtures, and others based on the database schema.} gem.summary = 'Annotates Rails Models, routes, fixtures, and others based on the database schema.'
gem.description = %q{Annotates Rails/ActiveRecord Models, routes, fixtures, and others based on the database schema.} gem.description = 'Annotates Rails/ActiveRecord Models, routes, fixtures, and others based on the database schema.'
gem.email = ["alex@stinky.com", "cuong@gmail.com", "x@nofxx.com", "turadg@aleahmad.net", "jon@cloudability.com"] gem.email = ['alex@stinky.com', 'cuong@gmail.com', 'x@nofxx.com', 'turadg@aleahmad.net', 'jon@cloudability.com']
gem.authors = ["Alex Chaffee", "Cuong Tran", "Marcos Piccinini", "Turadg Aleahmad", "Jon Frisby"] gem.authors = ['Alex Chaffee', 'Cuong Tran', 'Marcos Piccinini', 'Turadg Aleahmad', 'Jon Frisby']
gem.require_paths = ["lib"] gem.require_paths = ['lib']
# gem.rdoc_options = ["--charset=UTF-8"] # gem.rdoc_options = ["--charset=UTF-8"]
# gem.required_ruby_version = "> 1.9.2" # gem.required_ruby_version = "> 1.9.2"
Bundler.load.dependencies_for(*RUNTIME_GROUPS).each do |dep| Bundler.load.dependencies_for(*RUNTIME_GROUPS).each do |dep|
runtime_resolved = Bundler.definition.specs_for(RUNTIME_GROUPS).select { |spec| spec.name == dep.name }.first runtime_resolved = Bundler.definition.specs_for(RUNTIME_GROUPS).find { |spec| spec.name == dep.name }
if(!runtime_resolved.nil?) unless runtime_resolved.nil?
gem.add_dependency(dep.name, dep.requirement) gem.add_dependency(dep.name, dep.requirement)
end end
end end
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
gem.extra_rdoc_files = ['README.rdoc', 'CHANGELOG.rdoc', 'TODO.rdoc'] gem.extra_rdoc_files = ['README.rdoc', 'CHANGELOG.rdoc', 'TODO.rdoc']
gem.files = `git ls-files -- .`.split("\n").reject do |fn| gem.files = `git ls-files -- .`.split("\n").reject do |fn|
...@@ -76,7 +76,7 @@ namespace :gem do ...@@ -76,7 +76,7 @@ namespace :gem do
fn =~ /^vendor\/cache/ fn =~ /^vendor\/cache/
end.sort end.sort
end end
File.open("annotate.gemspec", "wb") do |fh| File.open('annotate.gemspec', 'wb') do |fh|
fh.write("# This file is auto-generated!\n") fh.write("# This file is auto-generated!\n")
fh.write("# DO NOT EDIT THIS FILE DIRECTLY!\n") fh.write("# DO NOT EDIT THIS FILE DIRECTLY!\n")
fh.write("# Instead, edit the Rakefile and run 'rake gems:gemspec'.") fh.write("# Instead, edit the Rakefile and run 'rake gems:gemspec'.")
...@@ -87,12 +87,12 @@ end ...@@ -87,12 +87,12 @@ end
namespace :jeweler do namespace :jeweler do
task :clobber do task :clobber do
FileUtils.rm_f("pkg") FileUtils.rm_f('pkg')
end end
end end
task clobber: :'jeweler:clobber' task clobber: :'jeweler:clobber'
require "rspec/core/rake_task" # RSpec 2.0 require 'rspec/core/rake_task' # RSpec 2.0
RSpec::Core::RakeTask.new(:spec) do |t| RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = ['spec/*_spec.rb', 'spec/**/*_spec.rb'] t.pattern = ['spec/*_spec.rb', 'spec/**/*_spec.rb']
t.rspec_opts = ['--backtrace', '--format d'] t.rspec_opts = ['--backtrace', '--format d']
...@@ -107,8 +107,8 @@ end ...@@ -107,8 +107,8 @@ end
namespace :gemsets do namespace :gemsets do
desc "Completely empty any gemsets used by scenarios, so they'll be perfectly clean on the next run." desc "Completely empty any gemsets used by scenarios, so they'll be perfectly clean on the next run."
task :empty => [:integration_environment] do task empty: [:integration_environment] do
Annotate::Integration::SCENARIOS.each do |test_rig, base_dir, test_name| Annotate::Integration::SCENARIOS.each do |test_rig, _base_dir, _test_name|
Annotate::Integration.empty_gemset(test_rig) Annotate::Integration.empty_gemset(test_rig)
end end
end end
...@@ -117,11 +117,11 @@ task clobber: :'gemsets:empty' ...@@ -117,11 +117,11 @@ task clobber: :'gemsets:empty'
namespace :integration do namespace :integration do
desc "Remove any cruft generated by manual debugging runs which is .gitignore'd." desc "Remove any cruft generated by manual debugging runs which is .gitignore'd."
task :clean => :integration_environment do task clean: :integration_environment do
Annotate::Integration.nuke_all_cruft Annotate::Integration.nuke_all_cruft
end end
desc "Reset any changed files, and remove any untracked files in spec/integration/*/, plus run integration:clean." desc 'Reset any changed files, and remove any untracked files in spec/integration/*/, plus run integration:clean.'
task clobber: [:integration_environment, :'integration:clean'] do task clobber: [:integration_environment, :'integration:clean'] do
Annotate::Integration.reset_dirty_files Annotate::Integration.reset_dirty_files
Annotate::Integration.clear_untracked_files Annotate::Integration.clear_untracked_files
...@@ -132,16 +132,16 @@ namespace :integration do ...@@ -132,16 +132,16 @@ namespace :integration do
integration_dir = File.expand_path(File.join(File.dirname(__FILE__), 'spec', 'integration')) integration_dir = File.expand_path(File.join(File.dirname(__FILE__), 'spec', 'integration'))
# fixture_dir = File.expand_path(File.join(File.dirname(__FILE__), 'spec', 'fixtures')) # fixture_dir = File.expand_path(File.join(File.dirname(__FILE__), 'spec', 'fixtures'))
target_dir = File.expand_path(ENV['TARGET']) if(ENV['TARGET']) target_dir = File.expand_path(ENV['TARGET']) if ENV['TARGET']
raise "Must specify TARGET=x, where x is an integration test scenario!" unless target_dir && Dir.exist?(target_dir) fail 'Must specify TARGET=x, where x is an integration test scenario!' unless target_dir && Dir.exist?(target_dir)
raise "TARGET directory must be within spec/integration/!" unless target_dir.start_with?(integration_dir) fail 'TARGET directory must be within spec/integration/!' unless target_dir.start_with?(integration_dir)
candidates = {} candidates = {}
FileList[ FileList[
"#{target_dir}/.rvmrc", "#{target_dir}/.rvmrc",
"#{target_dir}/**/*" "#{target_dir}/**/*"
].select { |fname| !(File.symlink?(fname) || File.directory?(fname)) }. ].select { |fname| !(File.symlink?(fname) || File.directory?(fname)) }
map { |fname| fname.sub(integration_dir, '') }. .map { |fname| fname.sub(integration_dir, '') }
reject do |fname| .reject do |fname|
fname =~ /\/\.gitkeep$/ || fname =~ /\/\.gitkeep$/ ||
fname =~ /\/app\/models\// || fname =~ /\/app\/models\// ||
fname =~ /\/routes\.rb$/ || fname =~ /\/routes\.rb$/ ||
...@@ -150,9 +150,9 @@ namespace :integration do ...@@ -150,9 +150,9 @@ namespace :integration do
fname =~ /\.sqlite3$/ || fname =~ /\.sqlite3$/ ||
(fname =~ /\/test\// && fname !~ /_helper\.rb$/) || (fname =~ /\/test\// && fname !~ /_helper\.rb$/) ||
(fname =~ /\/spec\// && fname !~ /_helper\.rb$/) (fname =~ /\/spec\// && fname !~ /_helper\.rb$/)
end. end
map { |fname| "#{integration_dir}#{fname}"}. .map { |fname| "#{integration_dir}#{fname}" }
each do |fname| .each do |fname|
digest = Digest::MD5.hexdigest(File.read(fname)) digest = Digest::MD5.hexdigest(File.read(fname))
candidates[digest] ||= [] candidates[digest] ||= []
candidates[digest] << fname candidates[digest] << fname
...@@ -163,22 +163,20 @@ namespace :integration do ...@@ -163,22 +163,20 @@ namespace :integration do
end end
candidates.keys.each do |digest| candidates.keys.each do |digest|
if(fixtures.has_key?(digest)) next unless fixtures.key?(digest)
candidates[digest].each do |fname| candidates[digest].each do |fname|
# Double-check contents in case of hash collision... # Double-check contents in case of hash collision...
if(FileUtils.identical?(fname, fixtures[digest])) next unless FileUtils.identical?(fname, fixtures[digest])
destination_dir = Pathname.new(File.dirname(fname)) destination_dir = Pathname.new(File.dirname(fname))
relative_target = Pathname.new(fixtures[digest]).relative_path_from(destination_dir) relative_target = Pathname.new(fixtures[digest]).relative_path_from(destination_dir)
Dir.chdir(destination_dir) do Dir.chdir(destination_dir) do
sh("ln", "-sfn", relative_target.to_s, File.basename(fname)) sh('ln', '-sfn', relative_target.to_s, File.basename(fname))
end
end
end end
end end
end end
end end
end end
task :clobber => :'integration:clobber' task clobber: :'integration:clobber'
require 'yard' require 'yard'
YARD::Rake::YardocTask.new do |t| YARD::Rake::YardocTask.new do |t|
...@@ -188,16 +186,16 @@ end ...@@ -188,16 +186,16 @@ end
namespace :yard do namespace :yard do
task :clobber do task :clobber do
FileUtils.rm_f(".yardoc") FileUtils.rm_f('.yardoc')
FileUtils.rm_f("doc") FileUtils.rm_f('doc')
end end
end end
task clobber: :'yard:clobber' task clobber: :'yard:clobber'
namespace :rubinius do namespace :rubinius do
task :clobber do task :clobber do
FileList["**/*.rbc"].each { |fname| FileUtils.rm_f(fname) } FileList['**/*.rbc'].each { |fname| FileUtils.rm_f(fname) }
FileList[".rbx/**/*"].each { |fname| FileUtils.rm_f(fname) } FileList['.rbx/**/*'].each { |fname| FileUtils.rm_f(fname) }
end end
end end
task clobber: :'rubinius:clobber' task clobber: :'rubinius:clobber'
......
...@@ -8,7 +8,7 @@ require 'rubygems' ...@@ -8,7 +8,7 @@ require 'rubygems'
begin begin
require 'bundler' require 'bundler'
Bundler.setup Bundler.setup
rescue Exception => e rescue Exception
end end
here = File.expand_path(File.dirname __FILE__) here = File.expand_path(File.dirname __FILE__)
...@@ -33,7 +33,7 @@ OptionParser.new do |opts| ...@@ -33,7 +33,7 @@ OptionParser.new do |opts|
'Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory/route/serializer file(s)') do |p| 'Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory/route/serializer file(s)') do |p|
ENV['position'] = p ENV['position'] = p
%w(position_in_class position_in_factory position_in_fixture position_in_test position_in_routes position_in_serializer).each do |key| %w(position_in_class position_in_factory position_in_fixture position_in_test position_in_routes position_in_serializer).each do |key|
ENV[key] = p unless(has_set_position[key]) ENV[key] = p unless (has_set_position[key])
end end
end end
...@@ -90,6 +90,10 @@ OptionParser.new do |opts| ...@@ -90,6 +90,10 @@ OptionParser.new do |opts|
ENV['routes'] = 'true' ENV['routes'] = 'true'
end end
opts.on('-aa', '--active-admin', 'Annotate active_admin models') do |p|
ENV['active_admin'] = p
end
opts.on('-v', '--version', opts.on('-v', '--version',
'Show the current version of this gem') do 'Show the current version of this gem') do
puts "annotate v#{Annotate.version}"; exit puts "annotate v#{Annotate.version}"; exit
...@@ -169,25 +173,25 @@ OptionParser.new do |opts| ...@@ -169,25 +173,25 @@ OptionParser.new do |opts|
ENV['trace'] = 'yes' ENV['trace'] = 'yes'
end end
opts.on('-I', '--ignore-columns REGEX', "don't annotate columns that match a given REGEX (i.e., `annotate -I '^(id|updated_at|created_at)'`" ) do |regex| opts.on('-I', '--ignore-columns REGEX', "don't annotate columns that match a given REGEX (i.e., `annotate -I '^(id|updated_at|created_at)'`") do |regex|
ENV['ignore_columns'] = regex ENV['ignore_columns'] = regex
end end
opts.on('--ignore-routes REGEX', "don't annotate routes that match a given REGEX (i.e., `annotate -I '(mobile|resque|pghero)'`" ) do |regex| opts.on('--ignore-routes REGEX', "don't annotate routes that match a given REGEX (i.e., `annotate -I '(mobile|resque|pghero)'`") do |regex|
ENV['ignore_routes'] = regex ENV['ignore_routes'] = regex
end end
opts.on('--hide-limit-column-types VALUES', "don't show limit for given column types, separated by comas (i.e., `integer,boolean,text`)" ) do |values| opts.on('--hide-limit-column-types VALUES', "don't show limit for given column types, separated by comas (i.e., `integer,boolean,text`)") do |values|
ENV['hide_limit_column_types'] = "#{values}" ENV['hide_limit_column_types'] = "#{values}"
end end
opts.on('--ignore-unknown-models', "don't display warnings for bad model files" ) do |_values| opts.on('--ignore-unknown-models', "don't display warnings for bad model files") do |values|
ENV['ignore_unknown_models'] = 'true' ENV['ignore_unknown_models'] = 'true'
end end
end.parse! end.parse!
options = Annotate.setup_options({ :is_rake => ENV['is_rake'] && !ENV['is_rake'].empty? }) options = Annotate.setup_options({is_rake: ENV['is_rake'] && !ENV['is_rake'].empty?})
Annotate.eager_load(options) Annotate.eager_load(options)
AnnotateModels.send(target_action, options) if Annotate.include_models? AnnotateModels.send(target_action, options) if Annotate.include_models?
......
$:.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.dirname(__FILE__))
require 'annotate/version' require 'annotate/version'
require 'annotate/annotate_models' require 'annotate/annotate_models'
require 'annotate/annotate_routes' require 'annotate/annotate_routes'
...@@ -19,45 +19,45 @@ module Annotate ...@@ -19,45 +19,45 @@ module Annotate
## ##
# The set of available options to customize the behavior of Annotate. # The set of available options to customize the behavior of Annotate.
# #
POSITION_OPTIONS=[ POSITION_OPTIONS = [
:position_in_routes, :position_in_class, :position_in_test, :position_in_routes, :position_in_class, :position_in_test,
:position_in_fixture, :position_in_factory, :position, :position_in_fixture, :position_in_factory, :position,
:position_in_serializer :position_in_serializer
] ].freeze
FLAG_OPTIONS=[ FLAG_OPTIONS = [
:show_indexes, :simple_indexes, :include_version, :exclude_tests, :show_indexes, :simple_indexes, :include_version, :exclude_tests,
:exclude_fixtures, :exclude_factories, :ignore_model_sub_dir, :exclude_fixtures, :exclude_factories, :ignore_model_sub_dir,
:format_bare, :format_rdoc, :format_markdown, :sort, :force, :trace, :format_bare, :format_rdoc, :format_markdown, :sort, :force, :trace,
:timestamp, :exclude_serializers, :classified_sort, :show_foreign_keys, :timestamp, :exclude_serializers, :classified_sort, :show_foreign_keys,
:exclude_scaffolds, :exclude_controllers, :exclude_helpers, :ignore_unknown_models, :exclude_scaffolds, :exclude_controllers, :exclude_helpers, :ignore_unknown_models
] ].freeze
OTHER_OPTIONS=[ OTHER_OPTIONS = [
:ignore_columns, :skip_on_db_migrate, :wrapper_open, :wrapper_close, :wrapper, :routes, :ignore_columns, :skip_on_db_migrate, :wrapper_open, :wrapper_close, :wrapper, :routes,
:hide_limit_column_types, :ignore_routes :hide_limit_column_types, :ignore_routes, :active_admin
] ].freeze
PATH_OPTIONS=[ PATH_OPTIONS = [
:require, :model_dir, :root_dir :require, :model_dir, :root_dir
] ].freeze
## ##
# Set default values that can be overridden via environment variables. # Set default values that can be overridden via environment variables.
# #
def self.set_defaults(options = {}) def self.set_defaults(options = {})
return if(@has_set_defaults) return if @has_set_defaults
@has_set_defaults = true @has_set_defaults = true
options = HashWithIndifferentAccess.new(options) options = HashWithIndifferentAccess.new(options)
[POSITION_OPTIONS, FLAG_OPTIONS, PATH_OPTIONS, OTHER_OPTIONS].flatten.each do |key| [POSITION_OPTIONS, FLAG_OPTIONS, PATH_OPTIONS, OTHER_OPTIONS].flatten.each do |key|
if options.has_key?(key) if options.key?(key)
default_value = if options[key].is_a?(Array) default_value = if options[key].is_a?(Array)
options[key].join(",") options[key].join(',')
else else
options[key] options[key]
end end
end end
default_value = ENV[key.to_s] if !ENV[key.to_s].blank? default_value = ENV[key.to_s] unless ENV[key.to_s].blank?
ENV[key.to_s] = default_value.nil? ? nil : default_value.to_s ENV[key.to_s] = default_value.nil? ? nil : default_value.to_s
end end
end end
...@@ -73,19 +73,14 @@ module Annotate ...@@ -73,19 +73,14 @@ module Annotate
options[key] = true?(ENV[key.to_s]) options[key] = true?(ENV[key.to_s])
end end
OTHER_OPTIONS.each do |key| OTHER_OPTIONS.each do |key|
options[key] = (!ENV[key.to_s].blank?) ? ENV[key.to_s] : nil options[key] = !ENV[key.to_s].blank? ? ENV[key.to_s] : nil
end end
PATH_OPTIONS.each do |key| PATH_OPTIONS.each do |key|
options[key] = (!ENV[key.to_s].blank?) ? ENV[key.to_s].split(',') : [] options[key] = !ENV[key.to_s].blank? ? ENV[key.to_s].split(',') : []
end end
if(options[:model_dir].empty?) options[:model_dir] = ['app/models'] if options[:model_dir].empty?
options[:model_dir] = ['app/models'] options[:root_dir] = [''] if options[:root_dir].empty?
end
if(options[:root_dir].empty?)
options[:root_dir] = ['']
end
options[:wrapper_open] ||= options[:wrapper] options[:wrapper_open] ||= options[:wrapper]
options[:wrapper_close] ||= options[:wrapper] options[:wrapper_close] ||= options[:wrapper]
...@@ -95,7 +90,7 @@ module Annotate ...@@ -95,7 +90,7 @@ module Annotate
options[:exclude_controllers] = Annotate.true?(ENV.fetch('exclude_controllers', 'true')) options[:exclude_controllers] = Annotate.true?(ENV.fetch('exclude_controllers', 'true'))
options[:exclude_helpers] = Annotate.true?(ENV.fetch('exclude_helpers', 'true')) options[:exclude_helpers] = Annotate.true?(ENV.fetch('exclude_helpers', 'true'))
return options options
end end
def self.reset_options def self.reset_options
...@@ -116,11 +111,16 @@ module Annotate ...@@ -116,11 +111,16 @@ module Annotate
true true
end end
def self.loaded_tasks=(val); @loaded_tasks = val; end def self.loaded_tasks=(val)
def self.loaded_tasks; return @loaded_tasks; end @loaded_tasks = val
end
def self.loaded_tasks
@loaded_tasks
end
def self.load_tasks def self.load_tasks
return if(self.loaded_tasks) return if loaded_tasks
self.loaded_tasks = true self.loaded_tasks = true
Dir[File.join(File.dirname(__FILE__), 'tasks', '**/*.rake')].each { |rake| load rake } Dir[File.join(File.dirname(__FILE__), 'tasks', '**/*.rake')].each { |rake| load rake }
...@@ -131,11 +131,11 @@ module Annotate ...@@ -131,11 +131,11 @@ module Annotate
end end
def self.eager_load(options) def self.eager_load(options)
self.load_requires(options) load_requires(options)
require "annotate/active_record_patch" require 'annotate/active_record_patch'
if(defined?(Rails)) if defined?(Rails)
if(Rails.version.split('.').first.to_i < 3) if Rails.version.split('.').first.to_i < 3
Rails.configuration.eager_load_paths.each do |load_path| Rails.configuration.eager_load_paths.each do |load_path|
matcher = /\A#{Regexp.escape(load_path)}(.*)\.rb\Z/ matcher = /\A#{Regexp.escape(load_path)}(.*)\.rb\Z/
Dir.glob("#{load_path}/**/*.rb").sort.each do |file| Dir.glob("#{load_path}/**/*.rb").sort.each do |file|
...@@ -166,7 +166,11 @@ module Annotate ...@@ -166,7 +166,11 @@ module Annotate
require 'rake' require 'rake'
load './Rakefile' if File.exist?('./Rakefile') load './Rakefile' if File.exist?('./Rakefile')
Rake::Task[:environment].invoke rescue nil begin
Rake::Task[:environment].invoke
rescue
nil
end
unless defined?(Rails) unless defined?(Rails)
# Not in a Rails project, so time to load up the parts of # Not in a Rails project, so time to load up the parts of
# ActiveSupport we need. # ActiveSupport we need.
...@@ -175,17 +179,17 @@ module Annotate ...@@ -175,17 +179,17 @@ module Annotate
require 'active_support/core_ext/string/inflections' require 'active_support/core_ext/string/inflections'
end end
self.load_tasks load_tasks
Rake::Task[:set_annotation_options].invoke Rake::Task[:set_annotation_options].invoke
end end
def self.fallback(*args) def self.fallback(*args)
return args.detect { |arg| !arg.blank? } args.detect { |arg| !arg.blank? }
end end
def self.true?(val) def self.true?(val)
return false if(val.blank?) return false if val.blank?
return false unless(val =~ TRUE_RE) return false unless val =~ TRUE_RE
return true true
end end
end end
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
module ::ActiveRecord module ::ActiveRecord
class Base class Base
def self.method_missing(name, *args) def self.method_missing(_name, *_args)
# ignore this, so unknown/unloaded macros won't cause parsing to fail # ignore this, so unknown/unloaded macros won't cause parsing to fail
end end
end end
......
...@@ -21,72 +21,51 @@ module AnnotateRoutes ...@@ -21,72 +21,51 @@ module AnnotateRoutes
PREFIX = '# == Route Map' PREFIX = '# == Route Map'
def self.do_annotations(options={}) def self.do_annotations(options={})
return unless(routes_exists?) return unless routes_exists?
position_after = ! %w(before top).include?(options[:position_in_routes]) routes_map = AnnotateRoutes.app_routes_map(options)
routes_map = `rake routes`.split(/\n/, -1)
# In old versions of Rake, the first line of output was the cwd. Not so
# much in newer ones. We ditch that line if it exists, and if not, we
# keep the line around.
routes_map.shift if(routes_map.first =~ /^\(in \//)
# Skip routes which match given regex
# Note: it matches the complete line (route_name, path, controller/action)
routes_map.reject!{|line| line.match(/#{options[:ignore_routes]}/)} if options[:ignore_routes]
header = [ header = [
"#{PREFIX}" + (options[:timestamp] ? " (Updated #{Time.now.strftime('%Y-%m-%d %H:%M')})" : ''), "#{PREFIX}" + (options[:timestamp] ? " (Updated #{Time.now.strftime('%Y-%m-%d %H:%M')})" : ''), '#'
'#'
] + routes_map.map { |line| "# #{line}".rstrip } ] + routes_map.map { |line| "# #{line}".rstrip }
existing_text = File.read(routes_file) existing_text = File.read(routes_file)
(content, where_header_found) = strip_annotations(existing_text)
changed = where_header_found != 0 # This will either be :before, :after, or
# a number. If the number is > 0, the
# annotation was found somewhere in the
# middle of the file. If the number is
# zero, no annotation was found.
if position_after if write_contents(existing_text, header, options)
# Ensure we have adequate trailing newlines at the end of the file to
# ensure a blank line separating the content from the annotation.
content << '' if(content.last != '')
# We're moving something from the top of the file to the bottom, so ditch
# the spacer we put in the first time around.
if(changed && where_header_found == :before)
content.shift if(content.first == '')
end
else
header = header << '' if(content.first != '' || changed)
end
content = position_after ? (content + header) : header + content
if write_contents(existing_text, content)
puts "#{routes_file} annotated." puts "#{routes_file} annotated."
else
puts "#{routes_file} unchanged."
end end
end end
def self.remove_annotations(options={}) def self.remove_annotations(options={})
return unless(routes_exists?) return unless routes_exists?
existing_text = File.read(routes_file) existing_text = File.read(routes_file)
(content, where_header_found) = strip_annotations(existing_text) content, where_header_found = strip_annotations(existing_text)
content = strip_on_removal(content, where_header_found) content = strip_on_removal(content, where_header_found)
if write_contents(existing_text, content) if write_contents(existing_text, content, options)
puts "Removed annotations from #{routes_file}." puts "Removed annotations from #{routes_file}."
else
puts "#{routes_file} unchanged."
end end
end end
protected private
def self.app_routes_map(options)
routes_map = `rake routes`.split(/\n/, -1)
# In old versions of Rake, the first line of output was the cwd. Not so
# much in newer ones. We ditch that line if it exists, and if not, we
# keep the line around.
routes_map.shift if routes_map.first =~ /^\(in \//
# Skip routes which match given regex
# Note: it matches the complete line (route_name, path, controller/action)
if options[:ignore_routes]
routes_map.reject! { |line| line =~ /#{options[:ignore_routes]}/ }
end
routes_map
end
def self.routes_file def self.routes_file
@routes_rb ||= File.join('config', 'routes.rb') @routes_rb ||= File.join('config', 'routes.rb')
...@@ -94,67 +73,96 @@ protected ...@@ -94,67 +73,96 @@ protected
def self.routes_exists? def self.routes_exists?
routes_exists = File.exists?(routes_file) routes_exists = File.exists?(routes_file)
puts "Can't find routes.rb" if(!routes_exists) puts "Can't find routes.rb" unless routes_exists
return routes_exists
routes_exists
end end
def self.write_contents(existing_text, new_content) def self.write_contents(existing_text, header, options = {})
content, where_header_found = strip_annotations(existing_text)
new_content = annotate_routes(header, content, where_header_found, options)
# Make sure we end on a trailing newline. # Make sure we end on a trailing newline.
new_content << '' unless(new_content.last == '') new_content << '' unless new_content.last == ''
new_text = new_content.join("\n") new_text = new_content.join("\n")
return false if existing_text == new_text if existing_text == new_text
puts "#{routes_file} unchanged."
false
else
File.open(routes_file, 'wb') { |f| f.puts(new_text) } File.open(routes_file, 'wb') { |f| f.puts(new_text) }
return true true
end
end
def self.annotate_routes(header, content, where_header_found, options = {})
if %w(before top).include?(options[:position_in_routes])
header = header << '' if content.first != ''
new_content = header + content
else
# Ensure we have adequate trailing newlines at the end of the file to
# ensure a blank line separating the content from the annotation.
content << '' unless content.last == ''
# We're moving something from the top of the file to the bottom, so ditch
# the spacer we put in the first time around.
content.shift if where_header_found == :before && content.first == ''
new_content = content + header
end
new_content
end end
# TODO: write the method doc using ruby rdoc formats
# where_header_found => This will either be :before, :after, or
# a number. If the number is > 0, the
# annotation was found somewhere in the
# middle of the file. If the number is
# zero, no annotation was found.
def self.strip_annotations(content) def self.strip_annotations(content)
real_content = [] real_content = []
mode = :content mode = :content
line_number = 0
header_found_at = 0 header_found_at = 0
content.split(/\n/, -1).each do |line|
line_number += 1 content.split(/\n/, -1).each_with_index do |line, line_number|
begin if mode == :header && line !~ /\s*#/
if mode == :header
if line !~ /\s*#/
mode = :content mode = :content
raise unless (line == '') next unless line == ''
end
elsif mode == :content elsif mode == :content
if line =~ /^\s*#\s*== Route.*$/ if line =~ /^\s*#\s*== Route.*$/
header_found_at = line_number header_found_at = line_number + 1 # index start's at 0
mode = :header mode = :header
else else
real_content << line real_content << line
end end
end end
rescue
retry
end end
where_header_found(real_content, header_found_at)
end end
content_lines = real_content.count
def self.where_header_found(real_content, header_found_at)
# By default assume the annotation was found in the middle of the file... # By default assume the annotation was found in the middle of the file...
where_header_found = header_found_at if header_found_at == 1 # ... unless we have evidence it was at the beginning ...
# ... unless we have evidence it was at the beginning ... return real_content, :before
where_header_found = :before if(header_found_at == 1) elsif header_found_at >= real_content.count # ... or that it was at the end.
# ... or that it was at the end. return real_content, :after
where_header_found = :after if(header_found_at >= content_lines) end
return real_content, where_header_found return real_content, header_found_at
end end
def self.strip_on_removal(content, where_header_found) def self.strip_on_removal(content, where_header_found)
if where_header_found == :before if where_header_found == :before
content.shift while(content.first == '') content.shift while content.first == ''
elsif where_header_found == :after elsif where_header_found == :after
content.pop while(content.last == '') content.pop while content.last == ''
end end
# TODO: If the user buried it in the middle, we should probably see about # TODO: If the user buried it in the middle, we should probably see about
# TODO: preserving a single line of space between the content above and # TODO: preserving a single line of space between the content above and
# TODO: below... # TODO: below...
return content content
end end
end end
module FilePatterns
class << self
def test_files(root_directory)
[
File.join(root_directory, UNIT_TEST_DIR, '%MODEL_NAME%_test.rb'),
File.join(root_directory, MODEL_TEST_DIR, '%MODEL_NAME%_test.rb'),
File.join(root_directory, SPEC_MODEL_DIR, '%MODEL_NAME%_spec.rb'),
]
end
def fixture_files(root_directory)
[
File.join(root_directory, FIXTURE_TEST_DIR, '%TABLE_NAME%.yml'),
File.join(root_directory, FIXTURE_SPEC_DIR, '%TABLE_NAME%.yml'),
File.join(root_directory, FIXTURE_TEST_DIR, '%PLURALIZED_MODEL_NAME%.yml'),
File.join(root_directory, FIXTURE_SPEC_DIR, '%PLURALIZED_MODEL_NAME%.yml'),
]
end
def scaffold_files(root_directory)
[
File.join(root_directory, CONTROLLER_TEST_DIR, '%PLURALIZED_MODEL_NAME%_controller_test.rb'),
File.join(root_directory, CONTROLLER_SPEC_DIR, '%PLURALIZED_MODEL_NAME%_controller_spec.rb'),
File.join(root_directory, REQUEST_SPEC_DIR, '%PLURALIZED_MODEL_NAME%_spec.rb'),
File.join(root_directory, ROUTING_SPEC_DIR, '%PLURALIZED_MODEL_NAME%_routing_spec.rb'),
]
end
def factory_files(root_directory)
[
File.join(root_directory, EXEMPLARS_TEST_DIR, '%MODEL_NAME%_exemplar.rb'),
File.join(root_directory, EXEMPLARS_SPEC_DIR, '%MODEL_NAME%_exemplar.rb'),
File.join(root_directory, BLUEPRINTS_TEST_DIR, '%MODEL_NAME%_blueprint.rb'),
File.join(root_directory, BLUEPRINTS_SPEC_DIR, '%MODEL_NAME%_blueprint.rb'),
File.join(root_directory, FACTORY_GIRL_TEST_DIR, '%MODEL_NAME%_factory.rb'), # (old style)
File.join(root_directory, FACTORY_GIRL_SPEC_DIR, '%MODEL_NAME%_factory.rb'), # (old style)
File.join(root_directory, FACTORY_GIRL_TEST_DIR, '%TABLE_NAME%.rb'), # (new style)
File.join(root_directory, FACTORY_GIRL_SPEC_DIR, '%TABLE_NAME%.rb'), # (new style)
File.join(root_directory, FABRICATORS_TEST_DIR, '%MODEL_NAME%_fabricator.rb'),
File.join(root_directory, FABRICATORS_SPEC_DIR, '%MODEL_NAME%_fabricator.rb'),
]
end
def serialize_files(root_directory)
[
File.join(root_directory, SERIALIZERS_DIR, '%MODEL_NAME%_serializer.rb'),
File.join(root_directory, SERIALIZERS_TEST_DIR, '%MODEL_NAME%_serializer_spec.rb'),
File.join(root_directory, SERIALIZERS_SPEC_DIR, '%MODEL_NAME%_serializer_spec.rb')
]
end
def files_by_pattern(root_directory, pattern_type)
case pattern_type
when 'test' then test_files(root_directory)
when 'fixture' then fixture_files(root_directory)
when 'scaffold' then scaffold_files(root_directory)
when 'factory' then factory_files(root_directory)
when 'serializer' then serialize_files(root_directory)
when 'controller'
[File.join(root_directory, CONTROLLER_DIR, '%PLURALIZED_MODEL_NAME%_controller.rb')]
when 'admin'
[File.join(root_directory, ACTIVEADMIN_DIR, '%MODEL_NAME%.rb')]
when 'helper'
[File.join(root_directory, HELPER_DIR, '%PLURALIZED_MODEL_NAME%_helper.rb')]
else
[]
end
end
end
end
module Annotate module Annotate
module Generators module Generators
class InstallGenerator < Rails::Generators::Base class InstallGenerator < Rails::Generators::Base
desc "Copy annotate_models rakefiles for automatic annotation" desc 'Copy annotate_models rakefiles for automatic annotation'
source_root File.expand_path('../templates', __FILE__) source_root File.expand_path('../templates', __FILE__)
# copy rake tasks # copy rake tasks
def copy_tasks def copy_tasks
template "auto_annotate_models.rake", "lib/tasks/auto_annotate_models.rake" template 'auto_annotate_models.rake', 'lib/tasks/auto_annotate_models.rake'
end end
end end
end end
end end
...@@ -31,7 +31,7 @@ if Rails.env.development? ...@@ -31,7 +31,7 @@ if Rails.env.development?
'ignore_columns' => nil, 'ignore_columns' => nil,
'ignore_routes' => nil, 'ignore_routes' => nil,
'ignore_unknown_models' => 'false', 'ignore_unknown_models' => 'false',
'hide_limit_column_types' => '<%= AnnotateModels::NO_LIMIT_COL_TYPES.join(',') %>', 'hide_limit_column_types' => '<%= AnnotateModels::NO_LIMIT_COL_TYPES.join(",") %>',
'skip_on_db_migrate' => 'false', 'skip_on_db_migrate' => 'false',
'format_bare' => 'true', 'format_bare' => 'true',
'format_rdoc' => 'false', 'format_rdoc' => 'false',
...@@ -40,7 +40,7 @@ if Rails.env.development? ...@@ -40,7 +40,7 @@ if Rails.env.development?
'force' => 'false', 'force' => 'false',
'trace' => 'false', 'trace' => 'false',
'wrapper_open' => nil, 'wrapper_open' => nil,
'wrapper_close' => nil, 'wrapper_close' => nil
) )
end end
......
annotate_lib = File.expand_path(File.dirname(File.dirname(__FILE__))) annotate_lib = File.expand_path(File.dirname(File.dirname(__FILE__)))
if !ENV['is_cli'] unless ENV['is_cli']
task :set_annotation_options task :set_annotation_options
task :annotate_models => :set_annotation_options task annotate_models: :set_annotation_options
end end
desc "Add schema information (as comments) to model and fixture files" desc 'Add schema information (as comments) to model and fixture files'
task :annotate_models => :environment do task annotate_models: :environment do
require "#{annotate_lib}/annotate/annotate_models" require "#{annotate_lib}/annotate/annotate_models"
require "#{annotate_lib}/annotate/active_record_patch" require "#{annotate_lib}/annotate/active_record_patch"
options={ :is_rake => true } options={is_rake: true}
ENV['position'] = options[:position] = Annotate.fallback(ENV['position'], 'before') ENV['position'] = options[:position] = Annotate.fallback(ENV['position'], 'before')
options[:position_in_class] = Annotate.fallback(ENV['position_in_class'], ENV['position']) options[:position_in_class] = Annotate.fallback(ENV['position_in_class'], ENV['position'])
options[:position_in_fixture] = Annotate.fallback(ENV['position_in_fixture'], ENV['position']) options[:position_in_fixture] = Annotate.fallback(ENV['position_in_fixture'], ENV['position'])
...@@ -48,12 +48,12 @@ task :annotate_models => :environment do ...@@ -48,12 +48,12 @@ task :annotate_models => :environment do
AnnotateModels.do_annotations(options) AnnotateModels.do_annotations(options)
end end
desc "Remove schema information from model and fixture files" desc 'Remove schema information from model and fixture files'
task :remove_annotation => :environment do task remove_annotation: :environment do
require "#{annotate_lib}/annotate/annotate_models" require "#{annotate_lib}/annotate/annotate_models"
require "#{annotate_lib}/annotate/active_record_patch" require "#{annotate_lib}/annotate/active_record_patch"
options={ :is_rake => true } options={is_rake: true}
options[:model_dir] = ENV['model_dir'] options[:model_dir] = ENV['model_dir']
options[:root_dir] = ENV['root_dir'] options[:root_dir] = ENV['root_dir']
options[:require] = ENV['require'] ? ENV['require'].split(',') : [] options[:require] = ENV['require'] ? ENV['require'].split(',') : []
......
...@@ -47,7 +47,8 @@ describe AnnotateModels do ...@@ -47,7 +47,8 @@ describe AnnotateModels do
stubs = default_options.dup stubs = default_options.dup
stubs.merge!(options) stubs.merge!(options)
stubs.merge!(:name => name, :type => type) stubs[:name] = name
stubs[:type] = type
double("Column", stubs) double("Column", stubs)
end end
...@@ -274,7 +275,7 @@ EOS ...@@ -274,7 +275,7 @@ EOS
module ::ActiveRecord module ::ActiveRecord
class Base class Base
def self.has_many name def self.has_many _name
end end
end end
end end
......
...@@ -38,11 +38,9 @@ describe AnnotateRoutes do ...@@ -38,11 +38,9 @@ describe AnnotateRoutes do
AnnotateRoutes.do_annotations AnnotateRoutes.do_annotations
end end
end end
describe 'When adding with older Rake versions' do describe 'When adding with older Rake versions' do
before(:each) do before(:each) do
expect(File).to receive(:exists?).with(ROUTE_FILE).and_return(true) expect(File).to receive(:exists?).with(ROUTE_FILE).and_return(true)
expect(AnnotateRoutes).to receive(:`).with('rake routes').and_return("(in /bad/line)\ngood line") expect(AnnotateRoutes).to receive(:`).with('rake routes').and_return("(in /bad/line)\ngood line")
...@@ -61,11 +59,9 @@ describe AnnotateRoutes do ...@@ -61,11 +59,9 @@ describe AnnotateRoutes do
expect(@mock_file).to receive(:puts).with(/ActionController::Routing...\nfoo\n\n# == Route Map\n#\n# good line\n/) expect(@mock_file).to receive(:puts).with(/ActionController::Routing...\nfoo\n\n# == Route Map\n#\n# good line\n/)
AnnotateRoutes.do_annotations AnnotateRoutes.do_annotations
end end
end end
describe 'When adding with newer Rake versions' do describe 'When adding with newer Rake versions' do
before(:each) do before(:each) do
expect(File).to receive(:exists?).with(ROUTE_FILE).and_return(true) expect(File).to receive(:exists?).with(ROUTE_FILE).and_return(true)
expect(AnnotateRoutes).to receive(:`).with("rake routes").and_return("another good line\ngood line") expect(AnnotateRoutes).to receive(:`).with("rake routes").and_return("another good line\ngood line")
...@@ -73,7 +69,6 @@ describe AnnotateRoutes do ...@@ -73,7 +69,6 @@ describe AnnotateRoutes do
expect(AnnotateRoutes).to receive(:puts).with(ANNOTATION_ADDED) expect(AnnotateRoutes).to receive(:puts).with(ANNOTATION_ADDED)
end end
it 'should annotate and add a newline!' do it 'should annotate and add a newline!' do
expect(File).to receive(:read).with(ROUTE_FILE).and_return("ActionController::Routing...\nfoo") expect(File).to receive(:read).with(ROUTE_FILE).and_return("ActionController::Routing...\nfoo")
expect(@mock_file).to receive(:puts).with(/ActionController::Routing...\nfoo\n\n# == Route Map\n#\n# another good line\n# good line\n/) expect(@mock_file).to receive(:puts).with(/ActionController::Routing...\nfoo\n\n# == Route Map\n#\n# another good line\n# good line\n/)
...@@ -91,11 +86,9 @@ describe AnnotateRoutes do ...@@ -91,11 +86,9 @@ describe AnnotateRoutes do
expect(@mock_file).to receive(:puts).with(/ActionController::Routing...\nfoo\n\n# == Route Map \(Updated \d{4}-\d{2}-\d{2} \d{2}:\d{2}\)\n#\n# another good line\n# good line\n/) expect(@mock_file).to receive(:puts).with(/ActionController::Routing...\nfoo\n\n# == Route Map \(Updated \d{4}-\d{2}-\d{2} \d{2}:\d{2}\)\n#\n# another good line\n# good line\n/)
AnnotateRoutes.do_annotations :timestamp => true AnnotateRoutes.do_annotations :timestamp => true
end end
end end
describe 'When removing' do describe 'When removing' do
before(:each) do before(:each) do
expect(File).to receive(:exists?).with(ROUTE_FILE).and_return(true) expect(File).to receive(:exists?).with(ROUTE_FILE).and_return(true)
expect(File).to receive(:open).with(ROUTE_FILE, 'wb').and_yield(mock_file) expect(File).to receive(:open).with(ROUTE_FILE, 'wb').and_yield(mock_file)
...@@ -113,7 +106,5 @@ describe AnnotateRoutes do ...@@ -113,7 +106,5 @@ describe AnnotateRoutes do
expect(@mock_file).to receive(:puts).with(/ActionController::Routing...\nfoo\n\n\n\n\n\n\n\n\n\n\n/) expect(@mock_file).to receive(:puts).with(/ActionController::Routing...\nfoo\n\n\n\n\n\n\n\n\n\n\n/)
AnnotateRoutes.remove_annotations AnnotateRoutes.remove_annotations
end end
end end
end end
...@@ -54,7 +54,7 @@ describe "annotate inside Rails, using #{CURRENT_RUBY}" do ...@@ -54,7 +54,7 @@ describe "annotate inside Rails, using #{CURRENT_RUBY}" do
ENV['rvm_ruby_string']=CURRENT_RUBY ENV['rvm_ruby_string']=CURRENT_RUBY
require "#{base_dir}" # Will get "#{base_dir}.rb"... require "#{base_dir}" # Will get "#{base_dir}.rb"...
klass = "Annotate::Validations::#{base_dir.gsub('.', '_').classify}".constantize klass = "Annotate::Validations::#{base_dir.tr('.', '_').classify}".constantize
Dir.chdir(temp_dir) do Dir.chdir(temp_dir) do
# bash is required by rvm # bash is required by rvm
......
require 'coveralls' # require 'coveralls'
require 'codeclimate-test-reporter' require 'codeclimate-test-reporter'
require 'simplecov' require 'simplecov'
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
Coveralls::SimpleCov::Formatter, # Coveralls::SimpleCov::Formatter,
SimpleCov::Formatter::HTMLFormatter, SimpleCov::Formatter::HTMLFormatter,
CodeClimate::TestReporter::Formatter CodeClimate::TestReporter::Formatter
] ]
...@@ -14,6 +14,7 @@ require 'rubygems' ...@@ -14,6 +14,7 @@ require 'rubygems'
require 'bundler' require 'bundler'
Bundler.setup Bundler.setup
require 'rake'
require 'rspec' require 'rspec'
require 'wrong/adapters/rspec' require 'wrong/adapters/rspec'
...@@ -26,6 +27,10 @@ require 'active_support/core_ext/class/subclasses' ...@@ -26,6 +27,10 @@ require 'active_support/core_ext/class/subclasses'
require 'active_support/core_ext/string/inflections' require 'active_support/core_ext/string/inflections'
require 'annotate' require 'annotate'
require 'rubocop/rake_task'
RuboCop::RakeTask.new
Rake::Task['rubocop'].invoke
module Annotate module Annotate
module Integration module Integration
ABSOLUTE_GEM_ROOT=File.expand_path('../../', __FILE__) ABSOLUTE_GEM_ROOT=File.expand_path('../../', __FILE__)
...@@ -49,7 +54,7 @@ module Annotate ...@@ -49,7 +54,7 @@ module Annotate
end end
def self.nuke_all_cruft def self.nuke_all_cruft
SCENARIOS.each do |test_rig, base_dir, test_name| SCENARIOS.each do |test_rig, _base_dir, _test_name|
nuke_cruft(test_rig) nuke_cruft(test_rig)
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment