Module: Wagons

Defined in:
lib/wagons.rb,
lib/wagons/wagon.rb,
lib/wagons/railtie.rb,
lib/wagons/version.rb,
lib/wagons/installer.rb,
lib/wagons/view_helper.rb

Overview

Utility class to find single wagons and provide additional information about the main application.

Defined Under Namespace

Modules: ViewHelper, Wagon Classes: Installer, Railtie

Constant Summary collapse

VERSION =
'0.7.0'

Class Method Summary collapse

Class Method Details

.allObject

All wagons installed in the current Rails application.



18
19
20
21
22
# File 'lib/wagons.rb', line 18

def self.all
  enumerable = Rails.application.railties
  enumerable = enumerable.all if enumerable.respond_to?(:all)
  enumerable.select { |r| r.is_a?(Wagon) }
end

.app_nameObject

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,



33
34
35
# File 'lib/wagons.rb', line 33

def self.app_name
  @app_name ||= Rails.application.class.name.split('::').first.underscore
end

.app_name=(name) ⇒ Object

Set the application name. Should be lowercase with underscores. Do this in an initializer.



39
40
41
# File 'lib/wagons.rb', line 39

def self.app_name=(name)
  @app_name = name
end

.app_versionObject

The version of the main application.



44
45
46
# File 'lib/wagons.rb', line 44

def self.app_version
  @app_version ||= Gem::Version.new('0')
end

.app_version=(version) ⇒ Object

Set the version of the main application. Do this in an initializer.



50
51
52
# File 'lib/wagons.rb', line 50

def self.app_version=(version)
  @app_version = version.is_a?(Gem::Version) ? version : Gem::Version.new(version)
end

.current_wagonObject

Returns the wagon that is currently executing a rake task or tests.



55
56
57
# File 'lib/wagons.rb', line 55

def self.current_wagon
  @current_wagon ||= find_wagon(ENV['BUNDLE_GEMFILE'])
end

.find(name) ⇒ Object

Find a wagon by its name.



25
26
27
28
# File 'lib/wagons.rb', line 25

def self.find(name)
  name = name.to_s
  all.find { |wagon| wagon.wagon_name == name || wagon.gem_name == name }
end