Skip to content

Commit

Permalink
issue #31 replace Gemfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Onur Özgür ÖZKAN committed May 9, 2013
1 parent 29ddfb9 commit 593304f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 14 deletions.
21 changes: 15 additions & 6 deletions lib/cybele/app_builder.rb
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
module Cybele #:nodoc:#

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

# Internal: Add readme.md file
def add_readme_md
# Internal: Overwrite super class readme
def readme
template 'README.md.erb', 'README.md', :force => true
end

# Internal: Overwrite superclass gemfile
def gemfile
template 'Gemfile_new', 'Gemfile', :force => true
end

# Remove: Remove public index file
def remove_public_index
say 'public'
remove_file 'public/index.html'
end

# Internal: remove rdoc.md file
# Internal: Remove README.rdoc file
def remove_readme_rdoc
say 'readme'
remove_file 'README.rdoc'
end

# Internal: Replace gemfile
def replace_gemfile
remove_file 'Gemfile_new'
copy_file 'Gemfile_new', 'Gemfile_new'
end

end
end
26 changes: 18 additions & 8 deletions lib/cybele/generators/app_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
module Cybele #:nodoc:#

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

Expand All @@ -19,27 +19,37 @@ class AppGenerator < Rails::Generators::AppGenerator
# Internal: Finish template
def finish_template
invoke :customization
invoke :customize_gemfile
super
end

# Internal: Customization template
def customization
invoke :add_readme_md
invoke :remove_files_we_dont_need
end

# Internal: Add Readme.md file
def add_readme_md
say 'Add README.md'
build :readme
end

# Internal: Remove files don't need
def remove_files_we_dont_need
say 'Remove files we don\'t need'
build :remove_public_index
build :remove_readme_rdoc
end

# Internal: Customize gemfile
def customize_gemfile
build :replace_gemfile
bundle_command 'install --binstubs=bin/stubs'
end

# Internal: Let's not: We'll bundle manually at the right spot.
def run_bundle
end

protected

# Internal: We need get_builder class
def get_builder_class
Cybele::AppBuilder
end
end
end
13 changes: 13 additions & 0 deletions templates/Gemfile_new
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
source 'https://rubygems.org'

gem 'rails', '~> 4.0.0.rc1'
gem 'pg'
gem 'sass-rails', '~> 4.0.0.rc1'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'

group :doc do
gem 'sdoc', require: false
end

0 comments on commit 593304f

Please sign in to comment.