Class: Jabysoft::Generators::SetupGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/jabysoft/setup/setup_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_gemfileObject



48
49
50
51
52
53
# File 'lib/generators/jabysoft/setup/setup_generator.rb', line 48

def create_gemfile
  remove_file "Gemfile"
  remove_file "Gemfile.lock"
  copy_file "Gemfile", "Gemfile"
  run('bundle install')
end

#create_layoutObject



10
11
12
13
14
# File 'lib/generators/jabysoft/setup/setup_generator.rb', line 10

def create_layout
  remove_file "app/views/layouts/application.html.erb"
  template "layouts/application.html.haml", "app/views/layouts/application.html.haml"
  template "layouts/admin.html.haml", "app/views/layouts/admin.html.haml"
end

#create_spec_rails_helperObject



20
21
22
23
24
# File 'lib/generators/jabysoft/setup/setup_generator.rb', line 20

def create_spec_rails_helper
  copy_file "spec/rails_helper.rb", "spec/rails_helper.rb"
  copy_file "spec/spec_helper.rb", "spec/spec_helper.rb"
  copy_file ".rspec", ".rspec"
end

#create_stylesheetsObject



16
17
18
# File 'lib/generators/jabysoft/setup/setup_generator.rb', line 16

def create_stylesheets
  copy_file "assets/stylesheets/bootstrap-variables.scss", "app/assets/stylesheets/bootstrap-variables.scss"
end

#inject_backboneObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/generators/jabysoft/setup/setup_generator.rb', line 26

def inject_backbone
  application_js_path = 'app/assets/javascripts/application.js'
  application_sass_path = 'app/assets/stylesheets/application.scss'

  if ::File.exists?('app/assets/stylesheets/application.css')
    css_file = ::File.open('app/assets/stylesheets/application.css')
    FileUtils.mv css_file, "#{File.dirname(css_file)}/#{File.basename(css_file,'.*')}.scss"
  end

  if ::File.exists?(::File.join(destination_root, application_js_path))
    inject_into_file application_js_path, before: '//= require_tree' do
      "//= require jabysoft\n"
    end
  end

  if ::File.exists?(::File.join(destination_root, application_sass_path))
    inject_into_file application_sass_path, after: ' */' do
      "\n\n@import 'jabysoft'\n"
    end
  end
end