pah 0.0.20 → 0.0.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -0
  3. data/README.md +0 -7
  4. data/features/binstubs.feature +12 -0
  5. data/features/capybara.feature +0 -3
  6. data/features/commands.feature +1 -0
  7. data/features/rails_works.feature +2 -2
  8. data/features/rspec.feature +1 -4
  9. data/features/run_specs.feature +1 -1
  10. data/features/runner.feature +7 -7
  11. data/features/step_definitions/create_simple_app.rb +1 -1
  12. data/features/support/bin/heroku +5 -0
  13. data/features/support/env.rb +1 -0
  14. data/lib/pah/cli.rb +7 -1
  15. data/lib/pah/commands/app.rb +15 -3
  16. data/lib/pah/commands/base.rb +16 -0
  17. data/lib/pah/commands/help.rb +2 -1
  18. data/lib/pah/commands/version.rb +1 -1
  19. data/lib/pah/commands.rb +2 -0
  20. data/lib/pah/files/Gemfile +11 -10
  21. data/lib/pah/files/README.md +1 -1
  22. data/lib/pah/rails_template.rb +31 -37
  23. data/lib/pah/runner.rb +3 -4
  24. data/lib/pah/template.rb +2 -2
  25. data/lib/pah/templates/bin.rb +1 -1
  26. data/lib/pah/templates/bourbon.rb +1 -1
  27. data/lib/pah/templates/bullet.rb +0 -2
  28. data/lib/pah/templates/capybara.rb +0 -3
  29. data/lib/pah/templates/cleanup.rb +2 -2
  30. data/lib/pah/templates/config.rb +46 -17
  31. data/lib/pah/templates/gems.rb +21 -3
  32. data/lib/pah/templates/git.rb +1 -1
  33. data/lib/pah/templates/heroku.rb +12 -9
  34. data/lib/pah/templates/public.rb +0 -1
  35. data/lib/pah/templates/rollbar.rb +1 -1
  36. data/lib/pah/templates/rspec.rb +0 -3
  37. data/lib/pah/templates/simple_form.rb +1 -1
  38. data/lib/pah/version.rb +1 -1
  39. data/pah.gemspec +1 -0
  40. metadata +19 -9
  41. data/lib/pah/files/spec/acceptance/dummy_spec.rb +0 -8
  42. data/lib/pah/files/spec/support/README +0 -1
  43. data/lib/pah/files/spec/support/acceptance_helpers.rb +0 -28
  44. data/lib/pah/files/spec/support/acceptance_macros.rb +0 -15
  45. data/lib/pah/files/spec/support/http_basic_auth.rb +0 -26
  46. data/lib/pah/files/spec/support/matchers.rb +0 -5
  47. data/lib/pah/files/spec/support/uploaded_file.rb +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a9e2ca0f111a63544cf4ee0702de50a80a0486c3
4
- data.tar.gz: 64cb3b14530c5437c6fe3871b6348bdcbd967fe0
3
+ metadata.gz: 82af1b3c9d0fc895805fa986582e027916b4d5f8
4
+ data.tar.gz: 11b3142d89ee4a7487955083b1838f9327b6d2fb
5
5
  SHA512:
6
- metadata.gz: 039c174e96df2b05db280abcfb76efb2def4ae23a35445d39f57fd343a1607b7967bec9e7dbf43870874f04ea4c017d967452ae6484265b2c5e6e81e6aed75aa
7
- data.tar.gz: 589521a3a9b71326ce82db2b4db448dd11267763e962e1a27482c320d5aa52df750ef76120e4a9843949b5a2447d42310b8ab7ee1e7915787326533499fd5c39
6
+ metadata.gz: ac99987a1ed8a1726659b7ec300cf1b0d160c3ee81b2c616b2a2b60e345fffb99801f1bb136a5c5e4f2df538d122d115eb42adf22efb176fa9bb25e8df360f92
7
+ data.tar.gz: d1ff3acf5446c5c5c99cfb1dd471b01f08475decb032137bd507ecf29c9499e9c669c1f1e5faf56ced9718d980b8f5da600a8350f5242a7c237961b5e9f17142
data/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.0.22 (Unreleased)
4
+
5
+ ### features
6
+
7
+ ### improvements
8
+
9
+ ### bug fixes
10
+
11
+ ## 0.0.21 (March 19,2015)
12
+
13
+ ### features
14
+
15
+ - Add the spring-commands-rspec gem
16
+ - Make pah less verbose. To get all the outputs use the --verbose option
17
+
18
+ ### bug fixes
19
+
20
+ - Pg backups as a addon has been deprecated, update commands to reflect it
21
+
22
+ ### improvements
23
+
24
+ - Update the bitters and refills gems
25
+ - Remove old spec/support files
26
+ - Remove acceptance test example
27
+ - Break heroku config class in small methods
28
+
3
29
  ## 0.0.20 (January 16,2015)
4
30
 
5
31
  ### features
data/README.md CHANGED
@@ -64,13 +64,6 @@ Please see [CONTRIBUTING.md](https://github.com/Helabs/pah/blob/master/CONTRIBUT
64
64
  - [Mauro George](https://github.com/maurogeorge)
65
65
  - [Thiago Belem](https://github.com/TiuTalk)
66
66
 
67
- ## Roadmap
68
-
69
- - Improve the specs and test coverage
70
- - Make sure all the generated files are not beign overriden with older versions (like spec_helper, applications config & etc), don't copy files.. build them
71
- - Remove the old and unused spec/support files
72
- - Release version 1.0
73
-
74
67
  ## Release
75
68
 
76
69
  Follow this steps to release a new version of the gem.
@@ -0,0 +1,12 @@
1
+ @no-clobber
2
+ Feature: Binstubs
3
+ Background:
4
+ Given I have created the app "myapp" with pah
5
+
6
+ Scenario: Have correct files
7
+ Then I have a bin/bundle
8
+ Then I have a bin/rails
9
+ Then I have a bin/rake
10
+ Then I have a bin/rspec
11
+ Then I have a bin/spring
12
+
@@ -4,7 +4,4 @@ Feature: Capybara
4
4
  Given I have created the app "myapp" with pah
5
5
 
6
6
  Scenario: Have correct files
7
- Then I have a spec/support/acceptance_helpers.rb
8
- Then I have a spec/support/acceptance_macros.rb
9
7
  Then I have a spec/support/capybara.rb
10
- Then I have a spec/acceptance/dummy_spec.rb
@@ -22,4 +22,5 @@ Feature: Commands
22
22
  """
23
23
  Usage: pah <project_name> Creates a new rails application using project_name
24
24
  [--version|-v] Prompts the pah, rails and ruby version
25
+ [--verbose] Ouputs in verbose mode
25
26
  """
@@ -10,11 +10,11 @@ Feature: Rails works
10
10
  And I run `ruby -e "Bundler.with_clean_env { system 'bundle exec rails g controller welcome index' }"`
11
11
  And I run `ruby -e "Bundler.with_clean_env { system 'bundle exec rails s' }"` interactively
12
12
  And I run `ruby -e "Bundler.with_clean_env { system 'sleep 15' }"`
13
- And I run `curl http://0.0.0.0:3000/welcome/index`
13
+ And I run `curl http://localhost:3000/welcome/index`
14
14
  And I run `ruby -e 'pid = %x(cat tmp/pids/server.pid); %x(kill -9 #{pid})'`
15
15
  Then the stdout should contain:
16
16
  """
17
- <h1>Welcome#index</h1>
17
+ Welcome#index
18
18
  """
19
19
 
20
20
 
@@ -8,10 +8,7 @@ Feature: RSpec
8
8
  Then I have a spec/rails_helper.rb
9
9
  Then I have a spec/support/database_cleaner.rb
10
10
  Then I have a spec/support/factory_girl.rb
11
- Then I have a spec/support/http_basic_auth.rb
12
- Then I have a spec/support/matchers.rb
13
11
  Then I have a spec/support/suppress_log.rb
14
- Then I have a spec/support/uploaded_file.rb
15
12
  Then I have the file spec/support/vcr.rb and contents of this file should include:
16
13
  """
17
14
  c.filter_sensitive_data("<#{key.upcase}>") { value }
@@ -23,4 +20,4 @@ Feature: RSpec
23
20
  Then I have the file spec/rails_helper.rb and contents of this file should include:
24
21
  """
25
22
  config.include ActiveSupport::Testing::TimeHelpers
26
- """
23
+ """
@@ -8,7 +8,7 @@ Feature: Run specs
8
8
  And I run `ruby -e "Bundler.with_clean_env { system 'bundle exec rake' }"`
9
9
  Then the stdout should contain:
10
10
  """
11
- 1 example, 0 failures, 1 pending
11
+ 0 examples, 0 failures
12
12
  """
13
13
  Then the stdout should not contain:
14
14
  """
@@ -32,10 +32,6 @@ Feature: Run without errors
32
32
  """
33
33
  running heroku addons:add heroku-postgresql:dev --app myapponheroku
34
34
  """
35
- Then the stdout should contain:
36
- """
37
- running heroku addons:add pgbackups:auto-month --app myapponheroku
38
- """
39
35
  Then the stdout should contain:
40
36
  """
41
37
  running heroku addons:add logentries --app myapponheroku
@@ -60,15 +56,19 @@ Feature: Run without errors
60
56
  """
61
57
  running heroku config:set LIBRATO_SOURCE=myapponheroku --app myapponheroku
62
58
  """
59
+ Then the stdout should contain:
60
+ """
61
+ running heroku pg:backups schedule DATABASE_URL --app myapponheroku
62
+ """
63
63
  Then the output should contain:
64
64
  """
65
- CONGRATS! INSTALLATION COMPLETE!
65
+ Installation finished!
66
66
  """
67
67
 
68
68
  Scenario: Running pah without heroku
69
69
  When I run `pah myapp_without_heroku` interactively
70
70
  And I type "n"
71
- Then the stdout should contain:
71
+ Then the output should contain:
72
72
  """
73
- CONGRATS! INSTALLATION COMPLETE!
73
+ Installation finished!
74
74
  """
@@ -12,7 +12,7 @@ Given(/^I have created the app "(.*?)" with pah$/) do |app_name|
12
12
  And I type "n"
13
13
  Then the output should contain:
14
14
  """
15
- CONGRATS! INSTALLATION COMPLETE!
15
+ Installation finished!
16
16
  """
17
17
  Then a directory named "#{app_name}" should exist
18
18
  )
@@ -27,6 +27,11 @@ class Heroku < Thor
27
27
  puts "running heroku sharing:add #{domain.join(' ')}"
28
28
  end
29
29
 
30
+ desc 'pg:backups', 'stub of heroku pg:backups'
31
+ define_method 'pg:backups' do |*args|
32
+ puts "running heroku pg:backups #{args.join(' ')}"
33
+ end
34
+
30
35
  desc 'create', 'stub of heroku create'
31
36
  def create(app)
32
37
  puts "running heroku create #{app}"
@@ -1,4 +1,5 @@
1
1
  require 'aruba/cucumber'
2
+ require 'pry'
2
3
 
3
4
  root = Pathname.new(__FILE__).parent.parent.parent
4
5
 
data/lib/pah/cli.rb CHANGED
@@ -6,9 +6,15 @@ module Pah
6
6
 
7
7
  def start(argv)
8
8
  command = Commands.find_by_name(argv[0])
9
- command.new.run(argv)
9
+ command.new(extract_global_options!(argv)).run(argv)
10
10
  end
11
11
 
12
+ private
13
+ def extract_global_options!(argv)
14
+ options = {}
15
+ options[:verbose] = !!argv.delete("--verbose")
16
+ options
17
+ end
12
18
  end
13
19
  end
14
20
  end
@@ -2,13 +2,25 @@ require File.expand_path(File.join('..', '..', '..', 'lib', 'pah', 'version.rb')
2
2
 
3
3
  module Pah
4
4
  class Commands
5
- class App
5
+ class App < Base
6
6
 
7
7
  def run(argv)
8
- template_rb = File.expand_path(File.join('..', '..', '..', 'lib', 'pah', 'rails_template.rb'), File.dirname(__FILE__))
9
- exec "rails _#{::Pah::RAILS_VERSION}_ new #{argv[0]} -T -m #{template_rb}"
8
+ puts "Creating a new rails app in #{argv[0]}".green
9
+ exec build_rails_command(argv[0])
10
10
  end
11
11
 
12
+ private
13
+ def build_rails_command(app_name)
14
+ parts = []
15
+ parts << "rails _#{::Pah::RAILS_VERSION}_ new #{app_name} -T"
16
+ parts << "-q" unless options[:verbose]
17
+ parts << "-m #{template_path}"
18
+ parts.join(" ")
19
+ end
20
+
21
+ def template_path
22
+ File.expand_path(File.join('..', '..', '..', 'lib', 'pah', 'rails_template.rb'), File.dirname(__FILE__))
23
+ end
12
24
  end
13
25
  end
14
26
  end
@@ -0,0 +1,16 @@
1
+ module Pah
2
+ class Commands
3
+ class Base
4
+
5
+ attr_reader :options
6
+
7
+ def initialize(options = {})
8
+ @options = options
9
+ end
10
+
11
+ def run(argv)
12
+ raise "#{self.class} subclasses should implement the #run method"
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,9 +1,10 @@
1
1
  module Pah
2
2
  class Commands
3
- class Help
3
+ class Help < Base
4
4
  BANNER = <<-HEREDOC
5
5
  Usage: pah <project_name> Creates a new rails application using project_name
6
6
  [--version|-v] Prompts the pah, rails and ruby version
7
+ [--verbose] Ouputs in verbose mode
7
8
  HEREDOC
8
9
 
9
10
  def run(*)
@@ -2,7 +2,7 @@ require File.expand_path(File.join('..', '..', '..', 'lib', 'pah', 'version.rb')
2
2
 
3
3
  module Pah
4
4
  class Commands
5
- class Version
5
+ class Version < Base
6
6
  BANNER = <<-HEREDOC
7
7
  Pah version: #{Pah::VERSION}
8
8
  Rails version: #{Pah::RAILS_VERSION}
data/lib/pah/commands.rb CHANGED
@@ -10,6 +10,8 @@ module Pah
10
10
  end
11
11
  end
12
12
 
13
+ require 'colored'
14
+ require 'pah/commands/base'
13
15
  require 'pah/commands/version'
14
16
  require 'pah/commands/help'
15
17
  require 'pah/commands/app'
@@ -16,8 +16,8 @@ gem 'simple_form', '3.1.0'
16
16
  gem 'flutie', '2.0.0'
17
17
  gem 'bourbon', '4.1.1'
18
18
  gem 'neat', '1.7.1'
19
- gem 'bitters', '0.10.1'
20
- gem 'refills', '0.0.2'
19
+ gem 'bitters', '1.0.0'
20
+ gem 'refills', '0.1.0'
21
21
  gem 'normalize-rails', '3.0.1'
22
22
 
23
23
  group :production, :staging do
@@ -52,12 +52,13 @@ group :test do
52
52
  end
53
53
 
54
54
  group :development, :test do
55
- gem 'rspec-rails', '3.1.0'
56
- gem 'factory_girl_rails', '4.5.0'
57
- gem 'pry-rails', '0.3.2'
58
- gem 'dotenv-rails', '1.0.2'
59
- gem 'awesome_print', '1.6.1'
60
- gem 'byebug', '3.5.1'
61
- gem 'web-console', '2.0.0'
62
- gem 'spring', '1.2.0'
55
+ gem 'rspec-rails', '3.1.0'
56
+ gem 'factory_girl_rails', '4.5.0'
57
+ gem 'pry-rails', '0.3.2'
58
+ gem 'dotenv-rails', '1.0.2'
59
+ gem 'awesome_print', '1.6.1'
60
+ gem 'spring-commands-rspec', '1.0.4'
61
+ gem 'byebug', '3.5.1'
62
+ gem 'web-console', '2.0.0'
63
+ gem 'spring', '1.2.0'
63
64
  end
@@ -22,7 +22,7 @@ If you plan to **integrate** this project to Heroku, you'll need:
22
22
  2. `$ git clone <REPOSITORY_URL> PROJECT` - Clone the project
23
23
  3. `$ cd PROJECT` - Go into the project folder
24
24
  4. `$ bin/setup` - Run the setup script
25
- 5. `$ bundle exec rake spec` - Run the specs to see if everything is working fine
25
+ 5. `$ bin/rspec` - Run the specs to see if everything is working fine
26
26
 
27
27
  If everything goes OK, you can now run the project!
28
28
 
@@ -1,45 +1,39 @@
1
1
  require 'pah'
2
2
 
3
- puts "\n========================================================="
4
- puts ' Pah'.yellow.bold
5
- puts "=========================================================\n"
6
-
7
3
  Pah.configure do |config|
8
4
  config.app_name = @app_name
9
5
  end
10
6
 
11
- runner = Pah::Runner.new
7
+ runner = Pah::Runner.new([], self.options)
12
8
  runner.apply_n :config
13
- runner.apply_n :git, 'Initializing new Git repo...'
14
- runner.apply_n :ruby_env, 'Setting up ruby env...'
15
- runner.apply_n :cleanup, 'Removing unnecessary files...'
16
- runner.apply_n :gems, 'Setting up bundler and installing bundled gems (may take a while)...'
17
- runner.apply_n :database, 'Initializing databases...'
18
- runner.apply_n :rspec, 'Setting up RSpec...'
19
- runner.apply_n :layout, 'Adding layout files...'
20
- runner.apply_n :bourbon, 'Setting up Bourbon files...'
21
- runner.apply_n :public, 'Adding public files...'
22
- runner.apply_n :inflection, 'Adding API acronym to inflection file...'
23
- runner.apply_n :secure_headers, 'Adding secure headers...'
24
- runner.apply_n :secret_token, 'Replacing secret token with environment variable...'
25
- runner.apply_n :capybara, 'Adding capybara helpers...'
26
- runner.apply_n :generators, 'Adding generators...'
27
- runner.apply_n :simple_form, 'Configuring simple_form...'
28
- runner.apply_n :letter_opener, 'Adding letter_opener...'
29
- runner.apply_n :mandrill, 'Adding mandrill...'
30
- runner.apply_n :bullet, 'Setting up bullet...'
31
- runner.apply_n :locale, 'Adding locale...'
32
- runner.apply_n :canonical_host, 'Configuring canonical hosts...'
33
- runner.apply_n :puma, 'Configuring Puma...'
34
- runner.apply_n :rack_timeout, 'Setting up Rack::Timeout...'
35
- runner.apply_n :rack_deflater, 'Setting up Rack::Deflater...'
36
- runner.apply_n :jumpup, 'Setting up Jumpup...'
37
- runner.apply_n :newrelic, 'Setting up New Relic...'
38
- runner.apply_n :readme, 'Adding default README...'
39
- runner.apply_n :rollbar, 'Setting up Rollbar...'
40
- runner.apply_n :heroku, 'Configuring Heroku application...'
41
- runner.apply_n :bin, 'Configuring the binstub...'
9
+ runner.apply_n :git, "Initializing new Git repo\n"
10
+ runner.apply_n :ruby_env, "Setting up ruby env\n"
11
+ runner.apply_n :cleanup, "Removing unnecessary files\n"
12
+ runner.apply_n :gems, "Setting up bundler and installing bundled gems (may take a while)"
13
+ runner.apply_n :database, "Initializing databases\n"
14
+ runner.apply_n :rspec, "Setting up RSpec\n"
15
+ runner.apply_n :layout, "Adding layout files\n"
16
+ runner.apply_n :bourbon, "Setting up Bourbon files\n"
17
+ runner.apply_n :public, "Adding public files\n"
18
+ runner.apply_n :inflection, "Adding API acronym to inflection file\n"
19
+ runner.apply_n :secure_headers, "Adding secure headers\n"
20
+ runner.apply_n :secret_token, "Replacing secret token with environment variable\n"
21
+ runner.apply_n :capybara, "Adding capybara helpers\n"
22
+ runner.apply_n :generators, "Adding generators\n"
23
+ runner.apply_n :simple_form, "Configuring simple_form\n"
24
+ runner.apply_n :letter_opener, "Adding letter_opener\n"
25
+ runner.apply_n :mandrill, "Adding mandrill\n"
26
+ runner.apply_n :bullet, "Setting up bullet\n"
27
+ runner.apply_n :locale, "Adding locale\n"
28
+ runner.apply_n :canonical_host, "Configuring canonical hosts\n"
29
+ runner.apply_n :puma, "Configuring Puma\n"
30
+ runner.apply_n :rack_timeout, "Setting up Rack::Timeout\n"
31
+ runner.apply_n :rack_deflater, "Setting up Rack::Deflater\n"
32
+ runner.apply_n :jumpup, "Setting up Jumpup\n"
33
+ runner.apply_n :newrelic, "Setting up New Relic\n"
34
+ runner.apply_n :readme, "Adding default README\n"
35
+ runner.apply_n :rollbar, "Setting up Rollbar\n"
36
+ runner.apply_n :heroku, "Configuring Heroku application\n"
37
+ runner.apply_n :bin, "Configuring the binstub\n"
42
38
 
43
- puts "\n========================================================="
44
- puts ' CONGRATS! INSTALLATION COMPLETE!'.yellow.bold
45
- puts "=========================================================\n\n\n"
39
+ puts "Installation finished!".green.bold
data/lib/pah/runner.rb CHANGED
@@ -1,20 +1,19 @@
1
1
  module Pah
2
2
  class Runner < Rails::Generators::Base
3
+
3
4
  def partials
4
5
  File.join(TEMPLATE_ROOT, 'templates')
5
6
  end
6
7
 
7
8
  def apply_n(partial_name, message = '')
8
- puts message.magenta
9
+ print message.green
9
10
 
10
11
  in_root do
11
12
  Bundler.with_clean_env do
12
13
  require "#{partials}/#{partial_name}"
13
- "::Pah::Templates::#{partial_name.to_s.classify}".constantize.new.call
14
+ "::Pah::Templates::#{partial_name.to_s.classify}".constantize.new([], self.options).call
14
15
  end
15
16
  end
16
-
17
- puts "\n"
18
17
  end
19
18
  end
20
19
  end
data/lib/pah/template.rb CHANGED
@@ -10,7 +10,7 @@ module Pah
10
10
  end
11
11
 
12
12
  def will_you_like_to?(question)
13
- answer = ask("Will you like to #{question} [y,n]".red)
13
+ answer = ask("Will you like to #{question} [y,n]".green)
14
14
  case answer.downcase
15
15
  when 'yes', 'y'
16
16
  true
@@ -27,7 +27,7 @@ module Pah
27
27
 
28
28
  def git_commit(message)
29
29
  message = "#{message}\n\nGenerated by pah version #{Pah::VERSION}"
30
- git commit: "-qm '#{message}'"
30
+ git commit: "-m '#{message}' -q"
31
31
  end
32
32
  end
33
33
  end
@@ -4,7 +4,7 @@ module Pah
4
4
  def call
5
5
  system 'bundle exec spring binstub --all'
6
6
 
7
- git add: 'bin/rake bin/rails bin/spring'
7
+ git add: 'bin/rake bin/rails bin/spring bin/bundle bin/rspec'
8
8
  git_commit 'Add spring bin files'
9
9
  end
10
10
  end
@@ -24,7 +24,7 @@ IMPORTS
24
24
 
25
25
  system "mv #{application_css_path} #{css_path}application.css.scss"
26
26
 
27
- git rm: application_css_path
27
+ git rm: "#{application_css_path} -q"
28
28
  git add: css_path
29
29
  git_commit 'Install bourbon.'
30
30
  end
@@ -2,8 +2,6 @@ module Pah
2
2
  module Templates
3
3
  class Bullet < Pah::Template
4
4
  def call
5
- puts 'Adding bullet... '.magenta
6
-
7
5
  copy_static_file 'config/initializers/bullet.rb'
8
6
 
9
7
  git add: 'config/initializers/bullet.rb'
@@ -2,10 +2,7 @@ module Pah
2
2
  module Templates
3
3
  class Capybara < Pah::Template
4
4
  def call
5
- copy_static_file 'spec/support/acceptance_helpers.rb'
6
- copy_static_file 'spec/support/acceptance_macros.rb'
7
5
  copy_static_file 'spec/support/capybara.rb'
8
- copy_static_file 'spec/acceptance/dummy_spec.rb'
9
6
 
10
7
  git add: 'spec/'
11
8
  git_commit 'Add capybara helpers.'
@@ -2,8 +2,8 @@ module Pah
2
2
  module Templates
3
3
  class Cleanup < Pah::Template
4
4
  def call
5
- git rm: 'README.rdoc'
6
- git rm: 'app/views/layouts/application.html.erb'
5
+ git rm: 'README.rdoc -q'
6
+ git rm: 'app/views/layouts/application.html.erb -q'
7
7
 
8
8
  git_commit 'Remove unnecessary files left over from initial app generation.'
9
9
  end
@@ -4,39 +4,68 @@ module Pah
4
4
  attr_reader :config
5
5
 
6
6
  def call
7
- if (Pah.configuration.heroku[:create?] = will_you_like_to? 'create Heroku apps?'.red)
8
- Pah.configuration.heroku[:deploy?] = will_you_like_to? 'deploy immediately?'.red
7
+ if create_heroku_app?
8
+ deploy_to_heroku?
9
+ add_custom_domain?
9
10
 
10
- Pah.configuration.heroku[:domain] = ask 'Add custom domain (customdomain.com) or leave blank:'.red
11
+ create_app_on_heroku!
11
12
 
12
- create_heroku_app
13
-
14
- Pah.configuration.heroku[:collaborators] = ask "Add collaborators? Type the email's separated by comma (,):".red
13
+ add_collaborators?
15
14
  end
16
15
  end
17
16
 
18
- # heroku questions
19
- def create_heroku_app
20
- say 'Refreshing Heroku user credentials'.magenta
21
- unless system 'heroku auth:login'
22
- puts 'Could not login to Heroku, halting'
23
- exit
24
- end
17
+ def create_app_on_heroku!
18
+ heroku_login_or_halt!
25
19
 
26
20
  created = false
27
21
  until created
28
- Pah.configuration.heroku[:name] = ask "What do you want to call your Heroku app? (#{Pah.configuration.app_name.gsub('_', '')})".red
29
- Pah.configuration.heroku[:name] = Pah.configuration.app_name.gsub('_', '') if Pah.configuration.heroku[:name].blank?
22
+ how_do_you_want_to_name_the_app?
30
23
 
31
- say "Creating Heroku app '#{Pah.configuration.heroku[:name]}.herokuapp.com'".magenta
24
+ say "Creating Heroku app '#{Pah.configuration.heroku[:name]}.herokuapp.com'".green
32
25
 
33
26
  created = system "heroku create #{Pah.configuration.heroku[:name]}"
34
27
 
35
28
  unless created
36
- puts "Heroku '#{Pah.configuration.heroku[:name]}' app already exists or could not be created, please provide a new name"
29
+ puts "Heroku '#{Pah.configuration.heroku[:name]}' app already exists or could not be created, please provide a new name".yellow
37
30
  end
38
31
  end
39
32
  end
33
+
34
+ private
35
+ def heroku_login_or_halt!
36
+ say 'Refreshing Heroku user credentials'.green
37
+ unless system 'heroku auth:login'
38
+ puts 'Could not login to Heroku, halting'.red
39
+ exit
40
+ end
41
+ end
42
+
43
+ def create_heroku_app?
44
+ Pah.configuration.heroku[:create?] = will_you_like_to? 'create Heroku apps?'.green
45
+ end
46
+
47
+ def deploy_to_heroku?
48
+ Pah.configuration.heroku[:deploy?] = will_you_like_to? 'deploy immediately?'.green
49
+ end
50
+
51
+ def add_custom_domain?
52
+ answer = ask 'Add custom domain (customdomain.com) or leave blank:'.green
53
+ Pah.configuration.heroku[:domain] = answer
54
+ end
55
+
56
+ def add_collaborators?
57
+ answer = ask "Add collaborators? Type the email's separated by comma (,):".green
58
+ Pah.configuration.heroku[:collaborators] = answer
59
+ end
60
+
61
+ def how_do_you_want_to_name_the_app?
62
+ answer = ask "How do you want to name your Heroku app? (#{app_name})".green
63
+ Pah.configuration.heroku[:name] = answer.presence || app_name
64
+ end
65
+
66
+ def app_name
67
+ @app_name ||= Pah.configuration.app_name.gsub('_', '')
68
+ end
40
69
  end
41
70
  end
42
71
  end
@@ -12,20 +12,38 @@ module Pah
12
12
  rescue LoadError
13
13
  # Install bundler if needed
14
14
  unless run 'gem install bundler --no-ri --no-rdoc'
15
- puts 'Error installing bundler, will attempt to continue'
15
+ puts 'Error installing bundler, will attempt to continue'.red
16
16
  end
17
17
  require 'bundler'
18
18
  end
19
19
 
20
20
  # Install all other gems needed from Gemfile
21
- unless run 'bundle install --jobs=4'
22
- puts 'Error installing gems, aborting'
21
+ status, output = bundle_install_with_progress
22
+ if status != 0
23
+ puts output
24
+ puts 'Error installing gems, aborting'.red
23
25
  exit 1
24
26
  end
25
27
 
26
28
  git add: 'Gemfile*'
27
29
  git_commit 'Add Gemfile and Gemfile.lock.'
28
30
  end
31
+
32
+ def bundle_install_with_progress
33
+ require 'open3'
34
+ output = ""
35
+ status = 0
36
+ Open3.popen3(ENV, "bundle install --jobs=4") do |stdin, stdout, stderr, wait_thr|
37
+ while line = stdout.gets
38
+ output += line
39
+ print ".".green
40
+ end
41
+ status = wait_thr.value.to_i
42
+ end
43
+ puts ""
44
+ [status, output]
45
+ end
46
+
29
47
  end
30
48
  end
31
49
  end
@@ -4,7 +4,7 @@ module Pah
4
4
  def call
5
5
  copy_static_file '.gitignore'
6
6
 
7
- git :init
7
+ git init: '-q'
8
8
  git add: '--all'
9
9
  git_commit 'Initial commit.'
10
10
  end
@@ -1,5 +1,5 @@
1
1
  class HerokuApp < Rails::Generators::AppGenerator
2
- DEFAULT_ADDONS = %w(heroku-postgresql:dev pgbackups:auto-month logentries
2
+ DEFAULT_ADDONS = %w(heroku-postgresql:dev logentries
3
3
  mandrill:starter rollbar newrelic:stark librato)
4
4
 
5
5
  attr_reader :name, :description, :config
@@ -16,6 +16,7 @@ class HerokuApp < Rails::Generators::AppGenerator
16
16
  add_heroku_git_remote
17
17
  check_canonical_domain
18
18
  check_collaborators
19
+ schedule_backup
19
20
  end
20
21
 
21
22
  def add_addons
@@ -23,17 +24,17 @@ class HerokuApp < Rails::Generators::AppGenerator
23
24
  end
24
25
 
25
26
  def add_secret_token
26
- say "Creating SECRET_KEY_BASE for Heroku '#{name}.herokuapp.com'".magenta
27
+ say "Creating SECRET_KEY_BASE for Heroku '#{name}.herokuapp.com'".green
27
28
  run "heroku config:set SECRET_KEY_BASE=#{SecureRandom.hex(60)} --app #{name}"
28
29
  end
29
30
 
30
31
  def add_heroku_git_remote
31
- say "Adding Heroku git remote for deploy to '#{name}'.".magenta
32
+ say "Adding Heroku git remote for deploy to '#{name}'.".green
32
33
  run "git remote add heroku git@heroku.com:#{name}.git"
33
34
  end
34
35
 
35
36
  def add_heroku_addon(addon)
36
- say "Adding heroku addon [#{addon}] to '#{name}'.".magenta
37
+ say "Adding heroku addon [#{addon}] to '#{name}'.".green
37
38
  run "heroku addons:add #{addon} --app #{name}"
38
39
  end
39
40
 
@@ -46,20 +47,22 @@ class HerokuApp < Rails::Generators::AppGenerator
46
47
  end
47
48
 
48
49
  def add_timezone_config
49
- say 'Adding timezone config on Heroku'.magenta
50
+ say 'Adding timezone config on Heroku'.green
50
51
  run "heroku config:set TZ=America/Sao_Paulo --app #{name}"
51
52
  end
52
53
 
53
54
  def add_librato_source
54
- say 'Configuring LIBRATO_SOURCE environment variable on Heroku'.magenta
55
+ say 'Configuring LIBRATO_SOURCE environment variable on Heroku'.green
55
56
  run "heroku config:set LIBRATO_SOURCE=#{name} --app #{name}"
56
57
  end
57
58
 
58
- def open
59
- say 'Pushing application to heroku...'.magenta
59
+ def schedule_backup
60
+ run "heroku pg:backups schedule DATABASE_URL --app #{name}"
61
+ end
60
62
 
63
+ def open
64
+ say 'Pushing application to heroku...'.green
61
65
  run 'git push heroku master'
62
-
63
66
  run "heroku open --app #{name}"
64
67
  end
65
68
 
@@ -17,7 +17,6 @@ module Pah
17
17
  git add: 'public/500.html'
18
18
 
19
19
  git_commit 'Add public files.'
20
- puts "\n"
21
20
  end
22
21
  end
23
22
  end
@@ -2,7 +2,7 @@ module Pah
2
2
  module Templates
3
3
  class Rollbar < Pah::Template
4
4
  def call
5
- system 'bundle exec rails generate rollbar'
5
+ system 'bundle exec rails generate rollbar -q'
6
6
 
7
7
  search = <<HEREDOC
8
8
  # Here we'll disable in 'test':
@@ -8,10 +8,7 @@ module Pah
8
8
  %w(
9
9
  database_cleaner.rb
10
10
  factory_girl.rb
11
- http_basic_auth.rb
12
- matchers.rb
13
11
  suppress_log.rb
14
- uploaded_file.rb
15
12
  vcr.rb
16
13
  random_timezone.rb
17
14
  ).each do |component|
@@ -2,7 +2,7 @@ module Pah
2
2
  module Templates
3
3
  class SimpleForm < Pah::Template
4
4
  def call
5
- system 'bundle exec rails generate simple_form:install'
5
+ system 'bundle exec rails generate simple_form:install -q'
6
6
 
7
7
  git add: 'config'
8
8
  git add: 'lib/templates'
data/lib/pah/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Pah
2
- VERSION = '0.0.20'
2
+ VERSION = '0.0.21'
3
3
  RUBY_VERSION = '2.2.0'
4
4
  RAILS_VERSION = '4.2.0'
5
5
  end
data/pah.gemspec CHANGED
@@ -26,4 +26,5 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency 'rake'
27
27
  spec.add_development_dependency 'aruba'
28
28
  spec.add_development_dependency 'thor'
29
+ spec.add_development_dependency 'pry'
29
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pah
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.20
4
+ version: 0.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - HE:labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-16 00:00:00.000000000 Z
11
+ date: 2015-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description: A rails application template which born from Startup DEV and now is used
98
112
  to start most projects at HE:labs.
99
113
  email:
@@ -114,6 +128,7 @@ files:
114
128
  - README.md
115
129
  - Rakefile
116
130
  - bin/pah
131
+ - features/binstubs.feature
117
132
  - features/bourbon.feature
118
133
  - features/bullet.feature
119
134
  - features/canonical_host.feature
@@ -156,6 +171,7 @@ files:
156
171
  - lib/pah/cli.rb
157
172
  - lib/pah/commands.rb
158
173
  - lib/pah/commands/app.rb
174
+ - lib/pah/commands/base.rb
159
175
  - lib/pah/commands/help.rb
160
176
  - lib/pah/commands/version.rb
161
177
  - lib/pah/configuration.rb
@@ -182,20 +198,13 @@ files:
182
198
  - lib/pah/files/public/404.html
183
199
  - lib/pah/files/public/500.html
184
200
  - lib/pah/files/public/robots.txt
185
- - lib/pah/files/spec/acceptance/dummy_spec.rb
186
201
  - lib/pah/files/spec/rails_helper.rb
187
202
  - lib/pah/files/spec/spec_helper.rb
188
- - lib/pah/files/spec/support/README
189
- - lib/pah/files/spec/support/acceptance_helpers.rb
190
- - lib/pah/files/spec/support/acceptance_macros.rb
191
203
  - lib/pah/files/spec/support/capybara.rb
192
204
  - lib/pah/files/spec/support/database_cleaner.rb
193
205
  - lib/pah/files/spec/support/factory_girl.rb
194
- - lib/pah/files/spec/support/http_basic_auth.rb
195
- - lib/pah/files/spec/support/matchers.rb
196
206
  - lib/pah/files/spec/support/random_timezone.rb
197
207
  - lib/pah/files/spec/support/suppress_log.rb
198
- - lib/pah/files/spec/support/uploaded_file.rb
199
208
  - lib/pah/files/spec/support/vcr.rb
200
209
  - lib/pah/rails_template.rb
201
210
  - lib/pah/runner.rb
@@ -258,6 +267,7 @@ specification_version: 4
258
267
  summary: A rails application template which born from Startup DEV and now is used
259
268
  to start most projects at HE:labs.
260
269
  test_files:
270
+ - features/binstubs.feature
261
271
  - features/bourbon.feature
262
272
  - features/bullet.feature
263
273
  - features/canonical_host.feature
@@ -1,8 +0,0 @@
1
- require 'rails_helper'
2
-
3
- RSpec.describe 'Homepage', type: :request do
4
- xit do
5
- visit root_path
6
- page.should have_content('Copyright &copy; 2012 App')
7
- end
8
- end
@@ -1 +0,0 @@
1
- ADD HERE SUPPORT FILES FOR OMNIAUTH, PAPERCLIP, CAPYBARA, ETC
@@ -1,28 +0,0 @@
1
- module AcceptanceHelpers
2
- def saop
3
- save_and_open_page
4
- end
5
-
6
- def handle_js_confirm(message = nil, accept = true)
7
- page.execute_script('window.original_confirm_function = window.confirm')
8
- page.execute_script("window.confirm = function(msg) { $.cookie('confirm_message', msg); return #{!!accept}; }")
9
- yield
10
- page.evaluate_script("$.cookie('confirm_message')").should == message unless message.nil?
11
- ensure
12
- page.evaluate_script 'window.confirm = window.original_confirm_function'
13
- end
14
-
15
- def fill_in_autocomplete(capybara_selector, jquery_selector, value)
16
- fill_in capybara_selector, with: value
17
- page.execute_script "$('#{jquery_selector}').keydown()"
18
- end
19
-
20
- def choose_autocomplete(text)
21
- find('ul.ui-autocomplete').should have_content(text)
22
- page.execute_script("$('.ui-menu-item:contains(\"#{text}\")').find('a').trigger('mouseenter').click()")
23
- end
24
- end
25
-
26
- RSpec.configure do |config|
27
- config.include AcceptanceHelpers, type: :request
28
- end
@@ -1,15 +0,0 @@
1
- module AcceptanceMacros
2
- def login!
3
- before(:each) do
4
- @current_user = User.make(email: 'x@example.com', password: 'senha123', password_confirmation: 'senha123')
5
- visit new_user_session_path
6
- fill_in 'Email', with: 'x@example.com'
7
- fill_in 'Senha', with: 'senha123'
8
- click_button 'Entrar'
9
- end
10
- end
11
- end
12
-
13
- RSpec.configure do |config|
14
- config.extend AcceptanceMacros, type: :request
15
- end
@@ -1,26 +0,0 @@
1
- module AuthSpec
2
- def http_basic_login!
3
- request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials('usuario', 'senha')
4
- end
5
- end
6
-
7
- module CapybaraAuthSpec
8
- def http_basic_login!
9
- name = 'usuario'
10
- password = 'senha'
11
- if page.driver.respond_to?(:basic_auth)
12
- page.driver.basic_auth(name, password)
13
- elsif page.driver.respond_to?(:basic_authorize)
14
- page.driver.basic_authorize(name, password)
15
- elsif page.driver.respond_to?(:browser) && page.driver.browser.respond_to?(:basic_authorize)
16
- page.driver.browser.basic_authorize(name, password)
17
- else
18
- fail "I don't know how to log in!"
19
- end
20
- end
21
- end
22
-
23
- RSpec.configure do |config|
24
- config.include AuthSpec, type: :controller
25
- config.include CapybaraAuthSpec, type: :request
26
- end
@@ -1,5 +0,0 @@
1
- RSpec::Matchers.define :be_bad_request do
2
- match do |response|
3
- response.code.to_s =~ /^4/
4
- end
5
- end
@@ -1,18 +0,0 @@
1
- module UploadFileTestHelper
2
- def uploaded_file(filename, content_type = 'text/csv')
3
- t = Tempfile.new([filename.split('/').last, filename.split('.').last])
4
- t.binmode
5
- path = File.join(Rails.root, 'spec', 'fixtures', filename)
6
- FileUtils.copy_file(path, t.path)
7
- ActionDispatch::Http::UploadedFile.new(
8
- filename: filename,
9
- head: "Content-Disposition: form-data; name=\"file\"; filename=\"#{filename}\"\r\nContent-Type: #{content_type}\r\n",
10
- type: content_type,
11
- tempfile: t
12
- )
13
- end
14
- end
15
-
16
- RSpec.configure do |config|
17
- config.include UploadFileTestHelper
18
- end