rails-embryo 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e3f4ad3fec63bed5cd7163c4e0324cdf91ff68a5
4
+ data.tar.gz: f84aec31ccfaa312d3e3a11224770863e757c9dc
5
+ SHA512:
6
+ metadata.gz: e035eb9df84d3977804a7a9bacc5263bd4978bc234c0b87678a2ff80930332104adb5ef3e0497f7f3317200885637c4092d7df22e4e5c55f20bbb511f46e0768
7
+ data.tar.gz: 10e4aa4adef14787d8c83983e84c1b0b177fac2bc9167a836ffed6c721859e713e925ff2338ab894ad80179bb8b0075f04ba4ac8925a2c336f3831a7f0bd40d7
data/History.md CHANGED
@@ -1,3 +1,10 @@
1
+ ### Version 0.3.0
2
+ 2014-09-14
3
+
4
+ * Remove standalone executable in favor of running the 'embryo' generator
5
+ * Configure Postgres automatically
6
+ * Generate a working JavaScript-enabled spec
7
+
1
8
  ### Version 0.2.1
2
9
  2014-08-05
3
10
 
data/README.md CHANGED
@@ -15,52 +15,43 @@ configurable in the future.
15
15
  ### Requirements
16
16
 
17
17
  * Ruby 1.9.3 or newer
18
- * Rails 4.1.4 or newer
18
+ * Rails 4.1.6 or newer
19
19
 
20
- ### Generating a New Application
20
+ ### Getting Started
21
21
 
22
- To generate a new Rails application with all Rails Embryo features
23
- added, first make sure the gem is installed in your current
24
- environment (this will also install Rails 4.1.4 if it's not already
25
- present).
22
+ The rails-embryo gem provides an `embryo` generator that is designed to enhance a
23
+ newly-generated Rails application. This guide assumes you've created a new Rails application
24
+ using the `rails new` command, and that you've changed into the application directory.
26
25
 
27
- gem install rails-embryo
26
+ Add "rails-embryo" to the new application's Gemfile and install it via Bundler:
28
27
 
29
- Once rails-embryo is installed, you can run "rails-embryo new" the
30
- same way you would normally run "rails new".
28
+ echo "gem 'rails-embryo'" >> Gemfile
29
+ bundle install
31
30
 
32
- rails-embryo new my_project
31
+ Now you're ready to generate the rails-embryo enhancements. It's recommended to provide the
32
+ `--force` option to the generator, since some of the files from your newly-generated Rails
33
+ application will need to be overwritten.
33
34
 
34
- This will create a new application called "My Project" in a directory
35
- called my_project. It's the same skeleton Rails app you would get from
36
- "rails new", but with additional rails-embryo-specific enhancements
37
- (described below).
35
+ rails generate embryo --force
38
36
 
39
- The enhancements include .ruby-version and .ruby-gemset files, so if
40
- your system is configured with a Ruby version manager that looks for
41
- those files, you should be able to change into the project directory
42
- and then run Bundler to configure the gems for your new application.
37
+ To verify that the rails-embryo enhancements have been installed, you'll need to update your
38
+ installed Gems again, and then initialize the database. You may want to look at the generated
39
+ `config/database.yml`, which assumes a local Postgres server is available, and make any
40
+ necessary changes to that file first.
43
41
 
44
- cd my_project
45
42
  bundle install
43
+ rake db:create
46
44
 
47
- Your new application will have a working test suite, and you can run
48
- it by invoking RSpec (or Rake, but RSpec is faster).
45
+ Now you can run the generated RSpec suite by invoking RSpec (or Rake, but RSpec is faster).
49
46
 
50
47
  rspec
51
48
 
52
- It's also ready to run with the Rails server, so fire up the server
53
- and visit localhost:3000 to see your application's
54
- Bootstrap-enhanced landing page.
49
+ You can also see your application's new Bootstrap-enhanced landing page by running a
50
+ development server and visiting `http://localhost:3000/`.
55
51
 
56
52
  rails server
57
53
 
58
- ### Generators Available in the Application
59
-
60
- You can also install the Rails Embryo enhancements by adding the gem
61
- to an existing Rails application and running the "embryo" generator:
62
-
63
- rails generate embryo
54
+ ### Other Generators
64
55
 
65
56
  Once Rails Embryo has has been initialized in an application, more
66
57
  generators are available to add features to the app.
@@ -133,15 +124,22 @@ feature "Customer searches for widgets" do
133
124
 
134
125
  #### Other Enhancements
135
126
 
136
- A .ruby-version file is created that specifies Ruby 2.1.2, and a
137
- .ruby-gemset file is created with a gemset that has the same name as
138
- your application directory. These can be safely ignored on systems
139
- that aren't automatically configured to switch Ruby versions and/or
140
- gemsets based on these files.
141
-
142
127
  Some files that normally have lots of documentation comments added
143
128
  when they are first generated (e.g. Gemfile, routes.rb, and others)
144
129
  will have all comments removed by rails-futurizer. These comments may
145
130
  be helpful for new users, but they may be more of a distraction for
146
131
  experienced developers, and they tend to get out of date as Rails and
147
132
  other gems are updated.
133
+
134
+ #### For Existing Rails Applications
135
+
136
+ You can attempt to run the `embryo` generator on an existing application that has been
137
+ modified since it was first generated, but rails-embryo makes little attempt to coexist with
138
+ those modifications, so you may get undesirable results.
139
+
140
+ #### Using With Ruby Version Managers (rvm, rbenv, etc.)
141
+
142
+ The `embryo` generator does not create configuration for any Ruby version manager you might be
143
+ using. If you're using a Ruby version manager, configure your Ruby version and gemset as
144
+ desired for your application as a part of generating the application before running the
145
+ `embryo` generator.
@@ -1,34 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
- require "rake"
3
-
4
- task "embryo_new", :path do |task, args|
5
- verbose false
6
- path = args[:path]
7
- if File.exists?(path) && (Dir.entries(path) - [".", ".."]).any?
8
- puts "Rerunning Rails app generator in existing application..."
9
- sh "rails new #{path} --skip-bundle"
10
- puts "Reapplying Embryo extensions to existing application..."
11
- sh "cd #{path}; rails g embryo"
12
- else
13
- puts "Generating standard Rails application..."
14
- sh "rails new #{path} --skip-bundle"
15
- puts "Adding Embryo extensions to generated application..."
16
- sh "cd #{path}; rails g embryo --force"
17
- end
18
- end
19
-
20
- if ARGV[0] == "new"
21
- if ARGV[1]
22
- Rake.application["embryo_new"].invoke ARGV[1]
23
- else
24
- puts 'Missing required argument ("rails-embryo help" for info)'
25
- end
26
- else
27
- puts 'Usage: rails-embryo COMMAND [ARGS]
28
-
29
- Available commands:
30
- help Show this message
31
- new PATH Create a new Rails application in PATH with rails-embryo
32
- enhancements. "rails-embryo new my_app" creates a new
33
- application called MyApp in "./my_app"'
34
- end
2
+ puts
3
+ puts " NOTICE:"
4
+ puts
5
+ puts " The rails-embryo command is no longer used to initialize"
6
+ puts " new applications."
7
+ puts
8
+ puts " Instead, install the 'rails-embryo' gem in an existing"
9
+ puts " application (or one freshly created with 'rails-new'),"
10
+ puts " and then run 'rails generate embryo'."
11
+ puts
@@ -1,5 +1,4 @@
1
1
  require "rails/generators"
2
- require "generators/embryo/ruby_version"
3
2
  require "generators/embryo/default_view"
4
3
  require "generators/embryo/template_support"
5
4
  require "generators/embryo/rspec"
@@ -7,11 +6,11 @@ require "generators/embryo/factory_girl"
7
6
  require "generators/embryo/capybara"
8
7
  require "generators/embryo/poltergeist"
9
8
  require "generators/embryo/devise"
9
+ require "generators/embryo/application"
10
+ require "generators/embryo/postgres"
10
11
 
11
12
  class EmbryoGenerator < Rails::Generators::Base
12
13
  def install(force: false, bundle: false)
13
- add_embryo_gem
14
- invoke "embryo:ruby_version"
15
14
  invoke "embryo:rspec"
16
15
  invoke "embryo:factory_girl"
17
16
  invoke "embryo:capybara"
@@ -19,6 +18,8 @@ class EmbryoGenerator < Rails::Generators::Base
19
18
  invoke "embryo:template_support"
20
19
  invoke "embryo:default_view"
21
20
  invoke "embryo:devise"
21
+ invoke "embryo:application"
22
+ invoke "embryo:postgres"
22
23
  clean_files
23
24
  end
24
25
 
@@ -29,8 +30,4 @@ class EmbryoGenerator < Rails::Generators::Base
29
30
  gsub_file "Gemfile", /\n\n+/, "\n", verbose: false
30
31
  append_to_file "Gemfile", "\n\n"
31
32
  end
32
-
33
- def add_embryo_gem
34
- gem "rails-embryo", "~> #{Rails::Embryo::VERSION}", group: :development
35
- end
36
33
  end
@@ -0,0 +1,31 @@
1
+ require "rails-embryo"
2
+ require "securerandom"
3
+
4
+ module Embryo
5
+ class ApplicationGenerator < Rails::Generators::Base
6
+ include GeneratorHelpers::Hidden
7
+ include GeneratorHelpers::Files
8
+
9
+ def install
10
+ create_file "config/secrets.yml", secrets_yml_data
11
+ create_file "config/secrets.yml.example", secrets_yml_data
12
+ gitignore "config/secrets.yml"
13
+ duplicate_file "config/environments/staging.rb", "config/environments/production.rb"
14
+ end
15
+
16
+ private
17
+
18
+ def secrets_yml_data
19
+ @secrets_yml_data ||= "development:
20
+ secret_key_base: #{new_secret}
21
+
22
+ test:
23
+ secret_key_base: #{new_secret}
24
+ "
25
+ end
26
+
27
+ def new_secret
28
+ SecureRandom.hex 64
29
+ end
30
+ end
31
+ end
@@ -48,7 +48,7 @@ end
48
48
  'require "rails_helper.rb"
49
49
 
50
50
  feature "Dashboard" do
51
- scenario "index view" do
51
+ scenario "index view", :js do
52
52
  visit "/"
53
53
  expect(page).to have_content "Welcome"
54
54
  end
@@ -6,7 +6,9 @@ module Embryo
6
6
 
7
7
  def install
8
8
  gem "poltergeist", "~> 1.0", group: :test
9
+ gem "database_cleaner", group: :test
9
10
  create_file "spec/support/poltergeist.rb", poltergeist_helper_data
11
+ create_file "spec/support/database_cleaner.rb", cleaner_helper_data
10
12
  end
11
13
 
12
14
  private
@@ -14,6 +16,28 @@ module Embryo
14
16
  def poltergeist_helper_data
15
17
  'require "capybara/poltergeist"
16
18
  Capybara.javascript_driver = :poltergeist
19
+ '
20
+ end
21
+
22
+ def cleaner_helper_data
23
+ 'require "database_cleaner"
24
+
25
+ RSpec.configure do |config|
26
+ config.use_transactional_fixtures = false
27
+
28
+ config.before :suite do
29
+ DatabaseCleaner.clean_with :truncation
30
+ end
31
+
32
+ config.before :example do |example|
33
+ DatabaseCleaner.strategy = example.metadata[:js] ? :truncation : :transaction
34
+ DatabaseCleaner.start
35
+ end
36
+
37
+ config.after :example do
38
+ DatabaseCleaner.clean
39
+ end
40
+ end
17
41
  '
18
42
  end
19
43
  end
@@ -0,0 +1,32 @@
1
+ require "rails-embryo"
2
+
3
+ module Embryo
4
+ class PostgresGenerator < Rails::Generators::Base
5
+ include GeneratorHelpers::Hidden
6
+ include GeneratorHelpers::Files
7
+
8
+ def install
9
+ gem "pg"
10
+ create_file "config/database.yml", database_yml_data
11
+ create_file "config/database.yml.example", database_yml_data
12
+ gitignore "config/database.yml"
13
+ end
14
+
15
+ private
16
+
17
+ def database_yml_data
18
+ "default: &default
19
+ adapter: postgresql
20
+ template: template0
21
+
22
+ test:
23
+ <<: *default
24
+ database: #{application_name}_test
25
+
26
+ development:
27
+ <<: *default
28
+ database: #{application_name}_development
29
+ "
30
+ end
31
+ end
32
+ end
@@ -34,7 +34,6 @@ Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
34
34
  ActiveRecord::Migration.maintain_test_schema!
35
35
 
36
36
  RSpec.configure do |config|
37
- config.use_transactional_fixtures = true
38
37
  config.infer_spec_type_from_file_location!
39
38
  end
40
39
  '
@@ -1,5 +1,6 @@
1
1
  require "rails-embryo/version"
2
2
  require "rails-embryo/generator_helpers/hidden"
3
+ require "rails-embryo/generator_helpers/files"
3
4
  require "generators/embryo"
4
5
  require "generators/embryo/model"
5
6
  require "generators/embryo/model/authenticated"
@@ -0,0 +1,25 @@
1
+ module Embryo
2
+ module GeneratorHelpers
3
+ module Files
4
+ def duplicate_file(source, destination)
5
+ create_file source, File.read(destination) if File.exist? destination
6
+ end
7
+
8
+ def append_file(path, *args)
9
+ File.exist?(path) ? super : create_file(path, *args)
10
+ end
11
+
12
+ def gitignore(path)
13
+ append_file ".gitignore", "/#{path}\n"
14
+ end
15
+
16
+ def application_name
17
+ if Rails.respond_to? :application
18
+ Rails.application.class.parent_name.underscore
19
+ else
20
+ "unknown"
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,5 +1,5 @@
1
1
  module Rails
2
2
  module Embryo
3
- VERSION = "0.2.1"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,52 +1,46 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-embryo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
5
- prerelease:
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Brian Auton
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-08-05 00:00:00.000000000 Z
11
+ date: 2014-09-14 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: 4.1.4
19
+ version: 4.1.6
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: 4.1.4
26
+ version: 4.1.6
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - "~>"
36
32
  - !ruby/object:Gem::Version
37
- version: 3.0.0
33
+ version: 3.1.0
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - "~>"
44
39
  - !ruby/object:Gem::Version
45
- version: 3.0.0
40
+ version: 3.1.0
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rake
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - "~>"
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - "~>"
60
53
  - !ruby/object:Gem::Version
@@ -67,47 +60,48 @@ executables:
67
60
  extensions: []
68
61
  extra_rdoc_files: []
69
62
  files:
70
- - lib/rails-embryo/generator_helpers/hidden.rb
71
- - lib/rails-embryo/version.rb
72
- - lib/rails-embryo.rb
73
- - lib/generators/embryo/model/authenticated.rb
74
- - lib/generators/embryo/factory_girl.rb
63
+ - History.md
64
+ - License.txt
65
+ - README.md
66
+ - bin/rails-embryo
67
+ - lib/generators/embryo.rb
68
+ - lib/generators/embryo/application.rb
75
69
  - lib/generators/embryo/capybara.rb
76
70
  - lib/generators/embryo/default_view.rb
77
- - lib/generators/embryo/model.rb
78
- - lib/generators/embryo/template_support.rb
79
71
  - lib/generators/embryo/devise.rb
72
+ - lib/generators/embryo/factory_girl.rb
73
+ - lib/generators/embryo/model.rb
74
+ - lib/generators/embryo/model/authenticated.rb
80
75
  - lib/generators/embryo/poltergeist.rb
76
+ - lib/generators/embryo/postgres.rb
81
77
  - lib/generators/embryo/rspec.rb
82
- - lib/generators/embryo/ruby_version.rb
83
- - lib/generators/embryo.rb
84
- - README.md
85
- - History.md
86
- - License.txt
87
- - bin/rails-embryo
78
+ - lib/generators/embryo/template_support.rb
79
+ - lib/rails-embryo.rb
80
+ - lib/rails-embryo/generator_helpers/files.rb
81
+ - lib/rails-embryo/generator_helpers/hidden.rb
82
+ - lib/rails-embryo/version.rb
88
83
  homepage: http://github.com/brianauton/rails-embryo
89
84
  licenses:
90
85
  - MIT
86
+ metadata: {}
91
87
  post_install_message:
92
88
  rdoc_options: []
93
89
  require_paths:
94
90
  - lib
95
91
  required_ruby_version: !ruby/object:Gem::Requirement
96
- none: false
97
92
  requirements:
98
93
  - - ">="
99
94
  - !ruby/object:Gem::Version
100
95
  version: '0'
101
96
  required_rubygems_version: !ruby/object:Gem::Requirement
102
- none: false
103
97
  requirements:
104
98
  - - ">="
105
99
  - !ruby/object:Gem::Version
106
100
  version: 1.3.6
107
101
  requirements: []
108
102
  rubyforge_project:
109
- rubygems_version: 1.8.29
103
+ rubygems_version: 2.2.2
110
104
  signing_key:
111
- specification_version: 3
105
+ specification_version: 4
112
106
  summary: Generators for quick setup of advanced Rails practices
113
107
  test_files: []
@@ -1,12 +0,0 @@
1
- require "rails-embryo"
2
-
3
- module Embryo
4
- class RubyVersionGenerator < Rails::Generators::Base
5
- include GeneratorHelpers::Hidden
6
-
7
- def install
8
- create_file ".ruby-version", "2.1.2\n"
9
- create_file ".ruby-gemset", "#{File.basename Dir.getwd}\n"
10
- end
11
- end
12
- end