Class: ManifoldMock::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/manifold_mock/install_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



15
16
17
# File 'lib/generators/manifold_mock/install_generator.rb', line 15

def self.source_root
  @source_root ||= File.join(File.dirname(__FILE__), 'templates')
end

Instance Method Details

#installObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/generators/manifold_mock/install_generator.rb', line 19

def install
  say "Hello, Manifold Mock will help you set up your template"
  installed_gems = Gem::Specification.map { |g| g.name }
  if options[:framework] == "bootstrap"
    unless installed_gems.include?("twitter-bootstrap-rails")
      say "Adding bootstrap-rails gem to your Gemfile:"
      append_file "Gemfile", "\n", :force => true
      gem 'therubyracer' unless installed_gems.include?("therubyracer")
      gem 'less-rails' unless installed_gems.include?("less-rails")
      gem 'twitter-bootstrap-rails', git: 'git://github.com/seyhunak/twitter-bootstrap-rails.git'
      begin
        Bundler.with_clean_env do
          run "bundle install"
          run "rails g bootstrap:install"
        end
      rescue RuntimeError => e
        raise "There was an error occurred", e.message
      end
    end
    say "Installing Bootstrap..."
  elsif options[:framework] == "foundation"
    unless installed_gems.include?("zurb-foundation")
      say "Adding foundation-rails gem to your Gemfile:"
      append_file "Gemfile", "\n", :force => true
      gem 'zurb-foundation'
      say "Installing Foundation..."
      begin
        Bundler.with_clean_env do
          run "bundle install"
          run "rails g foundation:install"
        end
      rescue RuntimeError => e
        raise "There was an error occurred", e.message
      end
    end
  else
    say "Framework not found. Please choose froom either 'foundation' or 'bootstrap'"
  end
  create_layout
end