potassium 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e42b19285cfdc9b98d8481a021a68a08dcb7fb6
4
- data.tar.gz: faa3f6cefda09e5ca429b7d542b39ffdff80d24a
3
+ metadata.gz: e744bb4e04fa650c7190cfb645c050d0ff83691f
4
+ data.tar.gz: 588d03c4d1385f5d74387ab7720b32d45e3d2df3
5
5
  SHA512:
6
- metadata.gz: 71899b46a6e1006027a2fa193f3eb802ef6fe0b8cea1be3cb9def2dbb4e9312cdb97ee3dc643893761e7a6a1c29023606ba9e225ef5a5939743c5dcd789a500e
7
- data.tar.gz: 95725c1f5db91367b0b85eab121bab9ca47ae49b8f97e17c3b229d98897046eb2712f3cc8a9d134710da8e93abea29854b136129cf56dd95bf8fd21cb417624d
6
+ metadata.gz: 49627be487d9b2e423cc51cac06d135ca89b6c1e5e74d1facfd9a504d804ea4956fd6261fb91b1d2b27d9d03e428cadff4a8fc1fc2867d93411082ba730391b6
7
+ data.tar.gz: a723bb7e25ab5849b0b19cce675afd27a7083a1564937ed413189756166620dc77763c5cad3f1ea6827ae1065e19fc5ba04605f610797a3a8c7dfb6ae2e94cf0
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 2.1.0
6
+
7
+ - Fix discard_gem helper
8
+ - Adds install command for database recipe
9
+ - Remove check for heroku pipelines plugins, [#88]
10
+ - Use postgresql by default, [#83]
11
+ - Update ruby to `2.3.1` [#89]
12
+
5
13
  ## 2.0.0
6
14
 
7
15
  Features:
data/circle.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  machine:
2
2
  ruby:
3
- version: 2.3.0
3
+ version: 2.3.1
4
4
  services:
5
5
  - docker
6
6
 
@@ -0,0 +1,3 @@
1
+ .bundle
2
+ .env.local
3
+ vendor/bundle
@@ -1,5 +1,3 @@
1
- APPLICATION_HOST=localhost:3000
2
- ASSET_HOST=localhost:3000
3
1
  AWS_ACCESS_KEY_ID=
4
2
  AWS_SECRET_ACCESS_KEY=
5
3
  DEFAULT_EMAIL_ADDRESS=
@@ -1,4 +1,6 @@
1
- FROM platanus/buildstep
2
- EXPOSE 3000
1
+ FROM platanus/ruby:2.2
3
2
 
4
- RUN /exec bundle install --with test
3
+ RUN mkdir /app
4
+ WORKDIR /app
5
+
6
+ ADD . /app
@@ -1,27 +1,92 @@
1
1
  #!/usr/bin/env bash
2
+ trap "exit" SIGINT SIGTERM
2
3
 
3
- DOCKE_COMPOSE_ARGS="-f docker-compose.ci.yml run"
4
+ command -v docker >/dev/null 2>&1 && docker info >/dev/null || {
5
+ printf >&2 "\e[31mI require docker but it's not installed. Aborting.\e[0m\n"; exit 1;
6
+ }
7
+
8
+ DOCKER_COMPOSE_ARGS="-f docker-compose.ci.yml"
9
+
10
+ # Build Image
11
+ build(){
12
+ docker-compose $DOCKER_COMPOSE_ARGS build test
13
+ }
14
+
15
+ # Wait services to be ready
16
+ wait_services(){
17
+ function test_service {
18
+ docker-compose $DOCKER_COMPOSE_ARGS run test sh -c "nc -z $1 $2"
19
+ }
20
+
21
+ count=0
22
+ # Chain tests together by using &&
23
+ until (
24
+ <% if(selected?(:database, :mysql) || selected?(:database, :postgresql))-%>
25
+ test_service '$<%=get(:database).to_s.upcase%>_HOST' '$<%=get(:database).to_s.upcase%>_PORT' && \
26
+ <% end-%>
27
+ echo "Services ready"
28
+ )
29
+ do
30
+ ((count++))
31
+ if [ $count -gt 50 ]
32
+ then
33
+ echo "Services didn't become ready in time"
34
+ exit 1
35
+ else
36
+ echo "Waiting for services to become ready..."
37
+ fi
38
+ sleep 0.5
39
+ done
40
+ }
41
+
42
+ # Prepare dependencies
43
+ dependencies(){
44
+ docker-compose $DOCKER_COMPOSE_ARGS run test bundle install
45
+ }
46
+
47
+ # Prepare database
48
+ database(){
49
+ docker-compose $DOCKER_COMPOSE_ARGS run test bundle exec rake db:create db:schema:load
50
+ }
51
+
52
+ # Run the specs
53
+ tests(){
54
+ [ -n "$CI" ] && {
55
+ RSPEC_JUNIT_ARGS="-r rspec_junit_formatter --format RspecJunitFormatter -o $HOME/.rspec_reports/junit.xml"
56
+ RSPEC_FORMAT_ARGS="--format progress --no-color"
57
+ }
58
+ docker-compose $DOCKER_COMPOSE_ARGS run test bundle exec rspec spec $RSPEC_FORMAT_ARGS $RSPEC_JUNIT_ARGS
59
+ }
4
60
 
5
- <% if(selected?(:database, :mysql) || selected?(:database, :postgresql))-%>
6
- function test_<%=get(:database).to_s%> {
7
- docker-compose $DOCKE_COMPOSE_ARGS test sh -c 'nc -z $<%=get(:database).to_s.upcase%>_HOST $<%=get(:database).to_s.upcase%>_PORT'
61
+ # Run the complete ci build
62
+ no_ci(){
63
+ build
64
+ wait_services
65
+ dependencies
66
+ database
67
+ tests
8
68
  }
9
69
 
10
- count=0
11
- # Chain tests together by using &&
12
- until ( test_<%=get(:database).to_s%> && echo "Services ready" )
13
- do
14
- ((count++))
15
- if [ ${count} -gt 50 ]
16
- then
17
- echo "Services didn't become ready in time"
18
- exit 1
19
- else
20
- echo "Waiting for services to become ready..."
21
- fi
22
- sleep 0.2
23
- done
24
- <% end-%>
25
-
26
- docker-compose $DOCKE_COMPOSE_ARGS test /exec bundle exec rake db:setup
27
- docker-compose $DOCKE_COMPOSE_ARGS test /exec bundle exec rspec spec
70
+ case "$1" in
71
+ "")
72
+ no_ci
73
+ ;;
74
+ "services")
75
+ wait_services
76
+ ;;
77
+ "deps"|"dependencies")
78
+ dependencies
79
+ ;;
80
+ "db"|"database")
81
+ database
82
+ ;;
83
+ "specs"|"tests")
84
+ tests
85
+ ;;
86
+ "build")
87
+ build
88
+ ;;
89
+ *)
90
+ echo "Usage: cibuild [services|deps|db|specs|build]"
91
+ ;;
92
+ esac
@@ -6,11 +6,13 @@ dependencies:
6
6
  override:
7
7
  - docker-compose -f docker-compose.ci.yml pull
8
8
  - docker-compose -f docker-compose.ci.yml build test
9
+ - bin/cibuild services
10
+ - bin/cibuild deps
9
11
 
10
12
  database:
11
13
  override:
12
- - echo "Skipping database"
14
+ - bin/cibuild db
13
15
 
14
16
  test:
15
17
  override:
16
- - bin/cibuild
18
+ - bin/cibuild tests
@@ -2,5 +2,8 @@ test:
2
2
  build: .
3
3
  dockerfile: Dockerfile.ci
4
4
  working_dir: '/app'
5
+ volumes:
6
+ - ./vendor/bundle:/usr/local/bundle
7
+ - $CIRCLE_TEST_REPORTS/rspec:$HOME/.rspec_reports
5
8
  environment:
6
9
  RAILS_ENV: test
@@ -12,6 +12,7 @@ module GemHelpers
12
12
  end
13
13
 
14
14
  def discard_gem(name)
15
+ ensure_variable(:gems, {})
15
16
  get(:gems).each do |_environments, gems|
16
17
  gems.delete_if do |gem_entry|
17
18
  gem_entry[:name] == name
@@ -9,6 +9,10 @@ class Recipes::Ci < Rails::AppBuilder
9
9
 
10
10
  copy_file '../assets/docker-compose.ci.yml', 'docker-compose.ci.yml'
11
11
 
12
+ gather_gems(:test) do
13
+ gather_gem 'rspec_junit_formatter', '0.2.2'
14
+ end
15
+
12
16
  compose = DockerHelpers.new('docker-compose.ci.yml')
13
17
 
14
18
  if selected?(:database, :mysql)
@@ -1,8 +1,8 @@
1
1
  class Recipes::Database < Rails::AppBuilder
2
2
  def ask
3
3
  databases = {
4
- mysql: "MySQL",
5
4
  postgresql: "PostgreSQL",
5
+ mysql: "MySQL",
6
6
  none: "None, thanks"
7
7
  }
8
8
 
@@ -14,24 +14,31 @@ class Recipes::Database < Rails::AppBuilder
14
14
  end
15
15
 
16
16
  def create
17
- databases = {
18
- mysql: { name: 'mysql', gem_name: 'mysql2', version: '~> 0.3.18', relational: true },
19
- postgresql: { name: 'postgresql', gem_name: 'pg', relational: true }
20
- }
21
-
22
- if db = databases[get(:database)]
17
+ if db = databases(get(:database))
23
18
  if db[:relational]
24
19
  activate_for_active_record(db)
25
20
  end
26
21
  end
27
22
  end
28
23
 
24
+ def install
25
+ ask
26
+ create
27
+ end
28
+
29
29
  private
30
30
 
31
+ def databases(database)
32
+ databases = {
33
+ postgresql: { name: 'postgresql', gem_name: 'pg', relational: true },
34
+ mysql: { name: 'mysql', gem_name: 'mysql2', version: '~> 0.3.18', relational: true }
35
+ }
36
+ databases[database]
37
+ end
38
+
31
39
  def activate_for_active_record(db)
32
40
  remove_file 'config/database.yml'
33
41
  template "../assets/config/database_#{db[:name]}.yml.erb", 'config/database.yml'
34
-
35
42
  discard_gem 'sqlite3'
36
43
  if db[:version]
37
44
  gather_gem db[:gem_name], db[:version]
@@ -56,8 +56,7 @@ class Recipes::Devise < Rails::AppBuilder
56
56
  "# config.pepper = 'onhcylrat7x8bjyr5o15sxaix3vbu0sl'"
57
57
  end
58
58
 
59
- append_to_file '.env.example', 'DEVISE_SECRET_KEY='
60
- append_to_file '.env', 'DEVISE_SECRET_KEY='
59
+ append_to_file '.env.development', 'DEVISE_SECRET_KEY='
61
60
  add_readme_section :internal_dependencies, :devise
62
61
  end
63
62
  end
@@ -4,7 +4,16 @@ class Recipes::Env < Rails::AppBuilder
4
4
  gather_gem('dotenv-rails')
5
5
  end
6
6
 
7
- template '../assets/.env.example.erb', '.env.example'
8
- run "cp .env.example .env"
7
+ template '../assets/.env.development.erb', '.env.development'
8
+ append_to_file '.gitignore', ".env.local\n"
9
+ append_to_file '.gitignore', ".env\n"
10
+
11
+ env_config =
12
+ <<-RUBY.gsub(/^ {7}/, '')
13
+ config.before_configuration do
14
+ Dotenv.load(Dotenv::Railtie.root.join('.env.development'))
15
+ end
16
+ RUBY
17
+ application env_config.strip, env: 'test'
9
18
  end
10
19
  end
@@ -2,10 +2,6 @@ class Recipes::Git < Rails::AppBuilder
2
2
  def create
3
3
  git :init
4
4
  after(:database_creation) do
5
- append_to_file '.gitignore', ".env\n"
6
- append_to_file '.gitignore', ".powder\n"
7
- append_to_file '.gitignore', "vendor/assets/bower_components\n"
8
-
9
5
  git add: "."
10
6
  git commit: %{ -m 'Initial commit' }
11
7
  end
@@ -10,12 +10,12 @@ class Recipes::Github < Rails::AppBuilder
10
10
  end
11
11
  end
12
12
  set(:github_repo_name, repo_name)
13
- set(:github_repo_create, github_repo_create)
13
+ set(:github_repo, github_repo_create)
14
14
  set(:github_repo_private, github_repo_private)
15
15
  end
16
16
 
17
17
  def create
18
- github_repo_create(get(:github_repo_name), get(:github_repo_private))
18
+ github_repo_create(get(:github_repo_name), get(:github_repo_private)) if selected?(:github_repo)
19
19
  end
20
20
 
21
21
  private
@@ -107,12 +107,6 @@ class Recipes::Heroku < Rails::AppBuilder
107
107
  end
108
108
 
109
109
  def add_app_to_pipeline(app_env_name, environment)
110
- pipelines_plugin = `heroku plugins | grep pipelines`
111
- if pipelines_plugin.empty?
112
- puts "You need heroku pipelines plugin. Run: heroku plugins:install heroku-pipelines"
113
- exit 1
114
- end
115
-
116
110
  pipeline = `heroku pipelines:info \
117
111
  #{heroku_pipeline_name} 2>/dev/null | grep #{heroku_pipeline_name}`
118
112
  pipeline_command = pipeline.empty? ? "create" : "add"
@@ -30,8 +30,8 @@ class Recipes::Paperclip < Rails::AppBuilder
30
30
  }
31
31
  RUBY
32
32
  application paperclip_config.strip, env: 'production'
33
- append_to_file '.env.example', 'AWS_BUCKET='
34
- append_to_file '.env', 'AWS_BUCKET='
33
+ append_to_file '.env.development', 'AWS_BUCKET='
34
+ append_to_file '.gitignore', "/public/system/*\n"
35
35
  add_readme_section :internal_dependencies, :paperclip
36
36
  end
37
37
  end
@@ -30,6 +30,20 @@ class Recipes::Pundit < Rails::AppBuilder
30
30
  gem_exists?(/pundit/)
31
31
  end
32
32
 
33
+ def install_admin_pundit
34
+ initializer = "config/initializers/active_admin.rb"
35
+ gsub_file initializer, /# config\.authorization_adapter =[^\n]+\n/ do
36
+ "config.authorization_adapter = ActiveAdmin::PunditAdapter\n"
37
+ end
38
+
39
+ template "../assets/active_admin/pundit_page_policy.rb",
40
+ "app/policies/active_admin/page_policy.rb"
41
+ template "../assets/active_admin/comment_policy.rb",
42
+ "app/policies/active_admin/comment_policy.rb"
43
+ template "../assets/active_admin/admin_user_policy.rb",
44
+ "app/policies/admin_user_policy.rb"
45
+ end
46
+
33
47
  private
34
48
 
35
49
  def run_pundit_installer
@@ -44,18 +58,4 @@ class Recipes::Pundit < Rails::AppBuilder
44
58
  add_readme_section :internal_dependencies, :pundit
45
59
  end
46
60
  end
47
-
48
- def install_admin_pundit
49
- initializer = "config/initializers/active_admin.rb"
50
- gsub_file initializer, /# config\.authorization_adapter =[^\n]+\n/ do
51
- "config.authorization_adapter = ActiveAdmin::PunditAdapter\n"
52
- end
53
-
54
- template "../assets/active_admin/pundit_page_policy.rb",
55
- "app/policies/active_admin/page_policy.rb"
56
- template "../assets/active_admin/comment_policy.rb",
57
- "app/policies/active_admin/comment_policy.rb"
58
- template "../assets/active_admin/admin_user_policy.rb",
59
- "app/policies/admin_user_policy.rb"
60
- end
61
61
  end
@@ -3,21 +3,17 @@ require 'semantic'
3
3
 
4
4
  class Recipes::Ruby < Rails::AppBuilder
5
5
  def create
6
- info 'Getting platanus latest ruby version...'
7
6
  info "Using ruby version #{version_alias}"
8
7
  create_file '.ruby-version', version_alias
9
8
  end
10
9
 
11
10
  private
12
11
 
13
- def latest
14
- Net::HTTP.get(URI.parse('http://ruby.platan.us/latest'))
15
- rescue
16
- RUBY_VERSION
12
+ def version
13
+ Potassium::RUBY_VERSION
17
14
  end
18
15
 
19
16
  def version_alias
20
- version = latest
21
17
  Semantic::Version.new(version).instance_eval { "#{major}.#{minor}" }
22
18
  end
23
19
  end
@@ -3,7 +3,7 @@ class Recipes::Style < Rails::AppBuilder
3
3
  copy_file '../assets/.rubocop.yml', '.rubocop.yml'
4
4
  copy_file '../assets/.ruby_style.yml', '.ruby_style.yml'
5
5
  copy_file '../assets/.hound.yml', '.hound.yml'
6
- append_to_file '.gitignore', '.rubocop-http*\n'
6
+ append_to_file '.gitignore', ".rubocop-http*\n"
7
7
  add_readme_header :style_guide
8
8
  end
9
9
 
@@ -1,5 +1,6 @@
1
1
  module Potassium
2
- VERSION = "2.0.0"
2
+ VERSION = "2.1.0"
3
+ RUBY_VERSION = "2.3.1"
3
4
  RAILS_VERSION = "~> 4.2.0"
4
5
  RUBOCOP_VERSION = "~> 0.38.0"
5
6
  end
@@ -35,4 +35,18 @@ RSpec.describe "A new project" do
35
35
 
36
36
  expect(hound_config_file).to include("config_file: .ruby_style.yml")
37
37
  end
38
+
39
+ it "configures postgresql" do
40
+ database_config_file = IO.read("#{project_path}/config/database.yml")
41
+ gemfile = IO.read("#{project_path}/Gemfile")
42
+
43
+ expect(database_config_file).to include(%{adapter: postgresql})
44
+ expect(gemfile).to include %{gem 'pg'}
45
+ end
46
+
47
+ it "configures the correct ruby version" do
48
+ ruby_version_file = IO.read("#{project_path}/.ruby-version")
49
+
50
+ expect(ruby_version_file).to eq("2.3")
51
+ end
38
52
  end
@@ -8,9 +8,7 @@ class FakeHeroku
8
8
  end
9
9
 
10
10
  def run!
11
- if @args.first == "plugins"
12
- puts "heroku-pipelines@0.29.0"
13
- elsif @args.first == "pipelines:info"
11
+ if @args.first == "pipelines:info"
14
12
  if FakeHeroku.has_created_pipeline?
15
13
  puts "=== dummy-app\nstaging:\tpl-dummy-app-staging\nproduction:\tpl-dummy-app-production"
16
14
  end
@@ -52,7 +52,7 @@ module PotassiumTestHelpers
52
52
 
53
53
  def default_arguments
54
54
  {
55
- "db" => "mysql",
55
+ "db" => "postgresql",
56
56
  "lang" => "es",
57
57
  "heroku" => false,
58
58
  "admin" => false,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: potassium
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - juliogarciag
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-22 00:00:00.000000000 Z
11
+ date: 2016-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -177,6 +177,7 @@ files:
177
177
  - ".hound.yml"
178
178
  - ".rspec"
179
179
  - ".rubocop.yml"
180
+ - ".ruby-version"
180
181
  - ".ruby_style.yml"
181
182
  - CHANGELOG.md
182
183
  - Gemfile
@@ -190,8 +191,9 @@ files:
190
191
  - lib/potassium.rb
191
192
  - lib/potassium/assets/.bowerrc
192
193
  - lib/potassium/assets/.buildpacks
194
+ - lib/potassium/assets/.dockerignore
193
195
  - lib/potassium/assets/.editorconfig
194
- - lib/potassium/assets/.env.example.erb
196
+ - lib/potassium/assets/.env.development.erb
195
197
  - lib/potassium/assets/.hound.yml
196
198
  - lib/potassium/assets/.pryrc
197
199
  - lib/potassium/assets/.rubocop.yml