rails_apps_composer 1.5.4 → 1.5.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -98,18 +98,22 @@ module RailsWizard
98
98
  else
99
99
  file = Tempfile.new('template')
100
100
  end
101
- template = RailsWizard::Template.new(recipes, defaults)
102
- file.write template.compile
103
- file.close
104
- if name
105
- system "rails new #{name} -m #{file.path} #{template.args.join(' ')}"
106
- else
107
- puts "install with the command:"
108
- puts
109
- puts "rails new <APP_NAME> -m #{file.path} #{template.args.join(' ')}"
101
+ begin
102
+ template = RailsWizard::Template.new(recipes, defaults)
103
+ file.write template.compile
104
+ file.close
105
+ if name
106
+ system "rails new #{name} -m #{file.path} #{template.args.join(' ')}"
107
+ else
108
+ puts "install with the command:"
109
+ puts
110
+ puts "rails new <APP_NAME> -m #{file.path} #{template.args.join(' ')}"
111
+ end
112
+ rescue RailsWizard::UnknownRecipeError
113
+ raise Thor::Error.new("> #{red}#{$!.message}.#{clear}")
114
+ ensure
115
+ file.unlink unless file_name
110
116
  end
111
- ensure
112
- file.unlink unless file_name
113
117
  end
114
118
  end
115
119
  end
@@ -7,7 +7,7 @@ require 'erb'
7
7
  module RailsWizard
8
8
  class Recipe
9
9
  extend Comparable
10
-
10
+
11
11
  def self.<=>(another)
12
12
  return -1 if another.run_after.include?(self.key) || self.run_before.include?(another.key)
13
13
  return 1 if another.run_before.include?(self.key) || self.run_after.include?(another.key)
@@ -37,8 +37,8 @@ module RailsWizard
37
37
  else
38
38
  template = template_or_file
39
39
  end
40
-
41
- recipe_class = Class.new(RailsWizard::Recipe)
40
+
41
+ recipe_class = Class.new(RailsWizard::Recipe)
42
42
  recipe_class.attributes = attributes
43
43
  recipe_class.template = template
44
44
  recipe_class.key = key
@@ -95,12 +95,20 @@ module RailsWizard
95
95
  end
96
96
 
97
97
  def self.from_mongo(key)
98
- return key if key.respond_to?(:superclass) && key.superclass == RailsWizard::Recipe
99
- RailsWizard::Recipes[key]
98
+ return key if (key.respond_to?(:superclass) && key.superclass == RailsWizard::Recipe)
99
+ return RailsWizard::Recipes[key] if RailsWizard::Recipes[key]
100
+ raise(RailsWizard::UnknownRecipeError.new(key))
100
101
  end
101
102
 
102
103
  def self.get_binding
103
104
  binding
104
105
  end
105
106
  end
107
+
108
+ class UnknownRecipeError < StandardError
109
+ def initialize(key)
110
+ message = "No recipe found with name '#{key}'"
111
+ super(message)
112
+ end
113
+ end
106
114
  end
data/recipes/add_user.rb CHANGED
@@ -43,14 +43,18 @@ RUBY
43
43
 
44
44
  # Add a 'name' attribute to the User model
45
45
  if recipes.include? 'mongoid'
46
+ # include timestamps to avoid special casing views for Mongoid
47
+ gsub_file 'app/models/user.rb',
48
+ /include Mongoid::Document$/,
49
+ "\\0\n include Mongoid::Timestamps\n"
46
50
  # for mongoid
47
51
  gsub_file 'app/models/user.rb', /\bend\s*\Z/ do
48
52
  <<-RUBY
49
53
  # run 'rake db:mongoid:create_indexes' to create indexes
50
- index :email, :unique => true
51
- field :name
54
+ index({ email: 1 }, { unique: true, background: true })
55
+ field :name, :type => String
52
56
  validates_presence_of :name
53
- attr_accessible :name, :email, :password, :password_confirmation, :remember_me
57
+ attr_accessible :name, :email, :password, :password_confirmation, :remember_me, :created_at, :updated_at
54
58
  end
55
59
  RUBY
56
60
  end
data/recipes/html5.rb CHANGED
@@ -5,7 +5,7 @@ case config['css_option']
5
5
 
6
6
  when 'foundation'
7
7
  # https://github.com/zurb/foundation-rails
8
- gem 'zurb-foundation', '>= 3.0.2'
8
+ gem 'zurb-foundation', '>= 3.0.5'
9
9
 
10
10
  when 'bootstrap_less'
11
11
  # https://github.com/seyhunak/twitter-bootstrap-rails
@@ -124,7 +124,6 @@ RUBY
124
124
  get 'https://raw.github.com/dhgamache/Skeleton/master/stylesheets/base.css', 'app/assets/stylesheets/base.css.scss'
125
125
  get 'https://raw.github.com/dhgamache/Skeleton/master/stylesheets/layout.css', 'app/assets/stylesheets/layout.css.scss'
126
126
  get 'https://raw.github.com/dhgamache/Skeleton/master/stylesheets/skeleton.css', 'app/assets/stylesheets/skeleton.css.scss'
127
- get 'https://raw.github.com/dhgamache/Skeleton/master/javascripts/tabs.js', 'app/assets/javascripts/tabs.js'
128
127
 
129
128
  when 'normalize'
130
129
  say_wizard 'normalizing CSS for consistent styling'
data/recipes/mongoid.rb CHANGED
@@ -4,8 +4,7 @@
4
4
  if config['mongoid']
5
5
  say_wizard "REMINDER: When creating a Rails app using Mongoid..."
6
6
  say_wizard "you should add the '-O' flag to 'rails new'"
7
- gem 'bson_ext', '>= 1.6.4'
8
- gem 'mongoid', '>= 2.4.11'
7
+ gem 'mongoid', '>= 3.0.1'
9
8
  else
10
9
  recipes.delete('mongoid')
11
10
  end
data/recipes/omniauth.rb CHANGED
@@ -13,8 +13,8 @@ if config['omniauth']
13
13
  gem 'omniauth-github'
14
14
  when 'linkedin'
15
15
  gem 'omniauth-linkedin'
16
- when 'google'
17
- gem 'omniauth-google'
16
+ when 'google-oauth2'
17
+ gem 'omniauth-google-oauth2'
18
18
  when 'tumblr'
19
19
  gem 'omniauth-tumblr'
20
20
  end
@@ -48,6 +48,8 @@ RUBY
48
48
  gsub_file 'app/models/user.rb', /\bend\s*\Z/ do
49
49
  <<-RUBY
50
50
  attr_accessible :provider, :uid, :name, :email
51
+ # run 'rake db:mongoid:create_indexes' to create indexes
52
+ index({ email: 1 }, { unique: true, background: true })
51
53
  end
52
54
  RUBY
53
55
  end
@@ -189,4 +191,4 @@ config:
189
191
  - provider:
190
192
  type: multiple_choice
191
193
  prompt: "Which service provider will you use?"
192
- choices: [["Twitter", twitter], ["Facebook", facebook], ["GitHub", github], ["LinkedIn", linkedin], ["Google", google], ["Tumblr", tumblr]]
194
+ choices: [["Twitter", twitter], ["Facebook", facebook], ["GitHub", github], ["LinkedIn", linkedin], ["Google-Oauth-2",google-oauth2], ["Tumblr", tumblr]]
@@ -18,7 +18,7 @@ gem 'haml-rails', '>= 0.3.4', :group => :development
18
18
 
19
19
  # >---------------------------------[ RSpec ]---------------------------------<
20
20
 
21
- gem 'rspec-rails', '>= 2.10.1', :group => [:development, :test]
21
+ gem 'rspec-rails', '>= 2.11.0', :group => [:development, :test]
22
22
  gem 'factory_girl_rails', '>= 3.5.0', :group => [:development, :test]
23
23
  # add a collection of RSpec matchers and Cucumber steps to make testing email easy
24
24
  gem 'email_spec', '>= 1.2.1', :group => :test
data/recipes/rspec.rb CHANGED
@@ -2,12 +2,12 @@
2
2
  # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rspec.rb
3
3
 
4
4
  if config['rspec']
5
- gem 'rspec-rails', '>= 2.10.1', :group => [:development, :test]
5
+ gem 'rspec-rails', '>= 2.11.0', :group => [:development, :test]
6
6
  if recipes.include? 'mongoid'
7
7
  # use the database_cleaner gem to reset the test database
8
8
  gem 'database_cleaner', '>= 0.8.0', :group => :test
9
- # include RSpec matchers from the mongoid-rspec gem, 1.4.6 requires mongoid 3.0.0.rc making it impossible to resolve dependencies
10
- gem 'mongoid-rspec', '1.4.5', :group => :test
9
+ # include RSpec matchers from the mongoid-rspec gem
10
+ gem 'mongoid-rspec', '1.4.6', :group => :test
11
11
  end
12
12
  case config['fixtures']
13
13
  when 'machinist'
@@ -3,13 +3,6 @@
3
3
 
4
4
  after_bundler do
5
5
  say_wizard "SeedDatabase recipe running 'after bundler'"
6
- if recipes.include? 'mongoid'
7
- append_file 'db/seeds.rb' do <<-FILE
8
- puts 'EMPTY THE MONGODB DATABASE'
9
- Mongoid.master.collections.reject { |c| c.name =~ /^system/}.each(&:drop)
10
- FILE
11
- end
12
- end
13
6
  if recipes.include? 'devise'
14
7
  if recipes.include? 'devise-confirmable'
15
8
  append_file 'db/seeds.rb' do <<-FILE
data/recipes/turnip.rb ADDED
@@ -0,0 +1,18 @@
1
+ gem 'turnip', :group => [:test]
2
+
3
+ after_bundler do
4
+ append_to_file '.rspec', '-r turnip/rspec'
5
+ create_file 'spec/acceptance/steps/.gitkeep'
6
+ end
7
+
8
+ __END__
9
+
10
+ name: Turnip
11
+ description: "Gherkin extension for RSpec"
12
+ author: listrophy,mathias
13
+
14
+ requires: [rspec]
15
+ run_after: [rspec]
16
+ exclusive: acceptance_testing
17
+ category: testing
18
+ tags: [acceptance]
@@ -41,7 +41,7 @@ name: This is an Example
41
41
  description: You know it's an exmaple.
42
42
  RUBY
43
43
  recipe = RailsWizard::Recipe.generate('just_a_test', file)
44
- recipe.template.should == '# this is an example'
44
+ recipe.template.should == '# this is an example'
45
45
  recipe.category.should == 'example'
46
46
  recipe.name.should == 'This is an Example'
47
47
  end
@@ -69,11 +69,37 @@ RUBY
69
69
 
70
70
  it 'should set default attributes' do
71
71
  recipe = RailsWizard::Recipe.generate('abc','# test')
72
-
72
+
73
73
  RailsWizard::Recipe::DEFAULT_ATTRIBUTES.each_pair do |k,v|
74
74
  recipe.send(k).should == v
75
75
  end
76
76
  end
77
+
78
+ describe ".from_mongo" do
79
+ context "when asked for a known recipe" do
80
+ let(:recipe_key) {'recipe_example'}
81
+ let(:recipe) { RailsWizard::Recipe.generate(recipe_key, "# this is a test", :category => 'example', :name => "RailsWizard Example") }
82
+ let(:recipe_klass) { Kernel.const_get("RailsWizard").const_get("Recipes").const_get("RecipeExample") }
83
+ before :all do
84
+ RailsWizard::Recipes.add(recipe)
85
+ end
86
+ context "by key" do
87
+ it "returns the recipe" do
88
+ RailsWizard::Recipe.from_mongo(recipe_key).should == recipe_klass
89
+ end
90
+ end
91
+ context "by class" do
92
+ it "returns the recipe" do
93
+ RailsWizard::Recipe.from_mongo(recipe_klass).should == recipe_klass
94
+ end
95
+ end
96
+ end
97
+ context "when asked for an unknown recipe" do
98
+ it "raises an UnknownRecipeError" do
99
+ expect { RailsWizard::Recipe.from_mongo("foo") }.to raise_error RailsWizard::UnknownRecipeError, "No recipe found with name 'foo'"
100
+ end
101
+ end
102
+ end
77
103
  end
78
104
 
79
105
  __END__
data/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RailsWizard
2
- VERSION = "1.5.4"
2
+ VERSION = "1.5.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_apps_composer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.4
4
+ version: 1.5.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-03 00:00:00.000000000 Z
12
+ date: 2012-07-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: i18n
@@ -197,6 +197,7 @@ files:
197
197
  - recipes/slim.rb
198
198
  - recipes/static_page.rb
199
199
  - recipes/subdomains.rb
200
+ - recipes/turnip.rb
200
201
  - recipes/unicorn.rb
201
202
  - recipes/users_page.rb
202
203
  - README.textile
@@ -227,7 +228,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
227
228
  version: '0'
228
229
  segments:
229
230
  - 0
230
- hash: -215979203623829965
231
+ hash: 584023313180931500
231
232
  required_rubygems_version: !ruby/object:Gem::Requirement
232
233
  none: false
233
234
  requirements:
@@ -236,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
236
237
  version: '0'
237
238
  segments:
238
239
  - 0
239
- hash: -215979203623829965
240
+ hash: 584023313180931500
240
241
  requirements: []
241
242
  rubyforge_project: rails_apps_composer
242
243
  rubygems_version: 1.8.24