Class: CoffeeGrounds::Grinder
- Inherits:
-
Object
- Object
- CoffeeGrounds::Grinder
- Defined in:
- lib/coffee-grounds/grinder.rb
Instance Method Summary collapse
- #grind ⇒ Object
-
#initialize(rails_app, options = {}) ⇒ Grinder
constructor
A new instance of Grinder.
Constructor Details
#initialize(rails_app, options = {}) ⇒ Grinder
Returns a new instance of Grinder.
3 4 5 6 7 |
# File 'lib/coffee-grounds/grinder.rb', line 3 def initialize( rails_app, = {} ) @rails = rails_app config = @rails.application.config @target_dir = ( [:output_dir] ) ? [:output_dir] : File.join(@rails.root, "app/assets/javascripts") end |
Instance Method Details
#grind ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/coffee-grounds/grinder.rb', line 9 def grind if !Dir.exists?( @target_dir ) Dir.mkdir( @target_dir ) end route_hash = Hash.new @rails.application.routes.routes.to_a.each do |route| if route.name && !route.name.empty? route_hash[ route.name.to_s] = route.path.spec.to_s end end save_routes_to_js( @target_dir, route_hash ) end |