Skip to content

Commit 593304f

Browse files
author
Onur Özgür ÖZKAN
committed
issue #31 replace Gemfile
1 parent 29ddfb9 commit 593304f

File tree

3 files changed

+46
-14
lines changed

3 files changed

+46
-14
lines changed

lib/cybele/app_builder.rb

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
11
module Cybele #:nodoc:#
22

33
# Public: This allows you to override entire operations, like the creation of the
4-
# Gemfile, README, or JavaScript files, without needing to know exactly
4+
# Gemfile_new, README, or JavaScript files, without needing to know exactly
55
# what those operations do so you can create another template action.
66
class AppBuilder < Rails::AppBuilder
77

8-
# Internal: Add readme.md file
9-
def add_readme_md
8+
# Internal: Overwrite super class readme
9+
def readme
1010
template 'README.md.erb', 'README.md', :force => true
1111
end
1212

13+
# Internal: Overwrite superclass gemfile
14+
def gemfile
15+
template 'Gemfile_new', 'Gemfile', :force => true
16+
end
17+
1318
# Remove: Remove public index file
1419
def remove_public_index
15-
say 'public'
1620
remove_file 'public/index.html'
1721
end
1822

19-
# Internal: remove rdoc.md file
23+
# Internal: Remove README.rdoc file
2024
def remove_readme_rdoc
21-
say 'readme'
2225
remove_file 'README.rdoc'
2326
end
2427

28+
# Internal: Replace gemfile
29+
def replace_gemfile
30+
remove_file 'Gemfile_new'
31+
copy_file 'Gemfile_new', 'Gemfile_new'
32+
end
33+
2534
end
2635
end

lib/cybele/generators/app_generator.rb

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
module Cybele #:nodoc:#
55

66
# Public: This allows you to override entire operations, like the creation of the
7-
# Gemfile, README, or JavaScript files, without needing to know exactly
7+
# Gemfile_new, README, or JavaScript files, without needing to know exactly
88
# what those operations do so you can create another template action.
99
class AppGenerator < Rails::Generators::AppGenerator
1010

@@ -19,27 +19,37 @@ class AppGenerator < Rails::Generators::AppGenerator
1919
# Internal: Finish template
2020
def finish_template
2121
invoke :customization
22+
invoke :customize_gemfile
2223
super
2324
end
2425

2526
# Internal: Customization template
2627
def customization
27-
invoke :add_readme_md
2828
invoke :remove_files_we_dont_need
2929
end
3030

31-
# Internal: Add Readme.md file
32-
def add_readme_md
33-
say 'Add README.md'
34-
build :readme
35-
end
36-
3731
# Internal: Remove files don't need
3832
def remove_files_we_dont_need
3933
say 'Remove files we don\'t need'
4034
build :remove_public_index
4135
build :remove_readme_rdoc
4236
end
4337

38+
# Internal: Customize gemfile
39+
def customize_gemfile
40+
build :replace_gemfile
41+
bundle_command 'install --binstubs=bin/stubs'
42+
end
43+
44+
# Internal: Let's not: We'll bundle manually at the right spot.
45+
def run_bundle
46+
end
47+
48+
protected
49+
50+
# Internal: We need get_builder class
51+
def get_builder_class
52+
Cybele::AppBuilder
53+
end
4454
end
4555
end

templates/Gemfile_new

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
source 'https://rubygems.org'
2+
3+
gem 'rails', '~> 4.0.0.rc1'
4+
gem 'pg'
5+
gem 'sass-rails', '~> 4.0.0.rc1'
6+
gem 'uglifier', '>= 1.3.0'
7+
gem 'coffee-rails', '~> 4.0.0'
8+
gem 'jquery-rails'
9+
gem 'turbolinks'
10+
11+
group :doc do
12+
gem 'sdoc', require: false
13+
end

0 commit comments

Comments
 (0)