Sha256: afd8c0754389d3952153b96d4fdb6b6b226197263f5937a48b9c0f664610c79c

Contents?: true

Size: 1.12 KB

Versions: 8

Compression:

Stored size: 1.12 KB

Contents

require 'digest/sha1'

class DragonflyAppGenerator < Rails::Generator::NamedBase
 
  def manifest
    app_name = plural_name
    metal_name = plural_name.camelize
    path_prefix = plural_name
    single_name = singular_name.singularize
    
    record do |m|
      # The initializer
      initializer_path = File.join(Rails.root, 'config', 'initializers', 'dragonfly.rb')
      already_initialized_code = File.read(initializer_path) if File.exists?(initializer_path)
      m.template(
        'initializer.erb',
        'config/initializers/dragonfly.rb',
        :assigns => {
          :app_name => app_name,
          :accessor_prefix => single_name,
          :already_initialized_code => already_initialized_code
        },
        :collision => :force
      )
      
      # The metal file
      m.directory('app/metal')
      m.template(
        'metal_file.erb',
        "app/metal/#{plural_name}.rb",
        :assigns => {
          :app_name => app_name,
          :metal_name => metal_name,
          :path_prefix => path_prefix,
          :random_secret => Digest::SHA1.hexdigest(Time.now.to_s)
        }
      )
      
    end
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
dragonfly-0.3.7 generators/dragonfly_app/dragonfly_app_generator.rb
dragonfly-0.3.6 generators/dragonfly_app/dragonfly_app_generator.rb
dragonfly-0.3.5 generators/dragonfly_app/dragonfly_app_generator.rb
dragonfly-0.3.4 generators/dragonfly_app/dragonfly_app_generator.rb
dragonfly-0.3.3 generators/dragonfly_app/dragonfly_app_generator.rb
dragonfly-0.3.2 generators/dragonfly_app/dragonfly_app_generator.rb
dragonfly-0.3.0 generators/dragonfly_app/dragonfly_app_generator.rb
dragonfly-0.2.1 generators/dragonfly_app/dragonfly_app_generator.rb