Skip to content

Commit

Permalink
autofix styles with rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
codez committed May 27, 2014
1 parent b3aa3fb commit abd2e8b
Show file tree
Hide file tree
Showing 45 changed files with 284 additions and 318 deletions.
10 changes: 4 additions & 6 deletions Rakefile
Expand Up @@ -21,7 +21,6 @@ RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_files.include('lib/**/*.rb')
end


Bundler::GemHelper.install_tasks

require 'rake/testtask'
Expand All @@ -33,14 +32,13 @@ end

task :test do
begin
Bundler.with_clean_env { sh "cd test/dummy && rails g wagon test_wagon" }
Bundler.with_clean_env { sh "cd test/dummy && bundle exec rake wagon:bundle:update" }
Bundler.with_clean_env { sh 'cd test/dummy && rails g wagon test_wagon' }
Bundler.with_clean_env { sh 'cd test/dummy && bundle exec rake wagon:bundle:update' }
Bundler.with_clean_env { sh "cd test/dummy && bundle exec rake db:migrate test #{'-t' if Rake.application.options.trace}" }
Bundler.with_clean_env { sh "cd test/dummy && bundle exec rake wagon:test #{'-t' if Rake.application.options.trace}" }
ensure
sh "rm -rf test/dummy/vendor/wagons/test_wagon"
sh 'rm -rf test/dummy/vendor/wagons/test_wagon'
end
end

task :default => :test

task default: :test
10 changes: 4 additions & 6 deletions lib/generators/wagon/wagon_generator.rb
@@ -1,5 +1,4 @@
class WagonGenerator < Rails::Generators::NamedBase #:nodoc:

attr_reader :wagon_name

source_root File.expand_path('../templates', __FILE__)
Expand Down Expand Up @@ -28,11 +27,10 @@ def copy_templates
private

def all_templates
source_paths.collect do |path|
Dir[File.join(path, "**", "{*,.[a-z]*}")].
select {|f| File.file?(f) }.
collect {|f| f.sub(path + File::SEPARATOR, '') }
source_paths.map do |path|
Dir[File.join(path, '**', '{*,.[a-z]*}')].
select { |f| File.file?(f) }.
map { |f| f.sub(path + File::SEPARATOR, '') }
end.flatten.uniq.sort
end

end
18 changes: 8 additions & 10 deletions lib/wagons.rb
Expand Up @@ -10,45 +10,43 @@
require 'wagons/extensions/require_optional'
require 'wagons/extensions/test_case'


# Utility class to find single wagons and provide additional information
# about the main application.
module Wagons
# All wagons installed in the current Rails application.
def self.all
enumerable = Rails.application.railties
enumerable = enumerable.all if enumerable.respond_to?(:all)
enumerable.select {|r| r.is_a?(Wagon) }
enumerable.select { |r| r.is_a?(Wagon) }
end

# Find a wagon by its name.
def self.find(name)
name = name.to_s
all.find {|wagon| wagon.wagon_name == name || wagon.gem_name == name }
all.find { |wagon| wagon.wagon_name == name || wagon.gem_name == name }
end

# The name of the main Rails application.
# By default, this is the underscored name of the application module.
# This name is directly used for the gem names,
def self.app_name
@app_name ||= Rails.application.class.name.split('::').first.underscore
end

# Set the application name. Should be lowercase with underscores.
# Do this in an initializer.
def self.app_name=(name)
@app_name = name
end

# The version of the main application.
def self.app_version
@app_version ||= Gem::Version.new("0")
@app_version ||= Gem::Version.new('0')
end

# Set the version of the main application.
# Do this in an initializer.
def self.app_version=(version)
@app_version = version.is_a?(Gem::Version) ? version : Gem::Version.new(version)
end
end

6 changes: 2 additions & 4 deletions lib/wagons/extensions/application.rb
@@ -1,6 +1,5 @@
module Rails
class Application < Engine

protected

# Append wagons at the end of all railties, even after the application.
Expand All @@ -11,8 +10,7 @@ def ordered_railties_with_wagons
end
end
end

alias_method_chain :ordered_railties, :wagons

end
end
end
4 changes: 2 additions & 2 deletions lib/wagons/extensions/require_optional.rb
Expand Up @@ -5,5 +5,5 @@ def require_optional(*args)
rescue LoadError
# that's fine, it's an optional require
end
alias optional_require require_optional
end
alias_method :optional_require, :require_optional
end
12 changes: 5 additions & 7 deletions lib/wagons/extensions/test_case.rb
@@ -1,13 +1,11 @@
module ActiveSupport #:nodoc:
class TestCase

# Resets the fixtures to the new path
def self.reset_fixture_path(path)
self.fixture_table_names = []
self.fixture_class_names = {}
self.fixture_path = path
self.fixtures :all
self.fixture_table_names = []
self.fixture_class_names = {}
self.fixture_path = path
fixtures :all
end

end
end
end

0 comments on commit abd2e8b

Please sign in to comment.