capistrano-env 0.1.2 → 0.2.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: 64d3604f8f4b0910b7d41e4a1337fe1311603658
4
- data.tar.gz: 6ca73144083b735338441cab203034083c829c72
3
+ metadata.gz: 550785f8cee8eb6aa25a022631db453481d3bcee
4
+ data.tar.gz: 13c5af95d7e0b000a192062eef021f1e297f01bf
5
5
  SHA512:
6
- metadata.gz: 753420ab58669cfaf5f9ad24bd94fd27a0f1eff648121d30b00cff81ab653553f381e73325c18463354bf05441bcd7fb565539106a235ef3629b44e442844b7a
7
- data.tar.gz: 9c4513ee78d47a15fc06532d270ee64543876bdc4d2ae0163d93129ea9d853ed2ff728183bf6f8a9a3569bd77e69eae9cdf4c54d95f6c4e2f8c4548455df684e
6
+ metadata.gz: 5a082f8b3daec5596c9a82567cc9d513524ed91b411d5e53aac5336756e743d8c6448e04b8f3f43631c52ab449b0e91b1989be54c0c82f4eeac8c13562c792f5
7
+ data.tar.gz: 4a805077d5574262e75bff2b0c159065a8f0c9e7619011b96b7dc63bf63f653d00ecafdf1eba463cd39d54c2fa7834735e00553baf5535ec0e281eec23d7ca42
data/.rubocop.yml CHANGED
@@ -7,4 +7,4 @@ Style/Documentation:
7
7
  Style/FileName:
8
8
  Enabled: false
9
9
  Style/RegexpLiteral:
10
- MaxSlashes: 0
10
+ Enabled: false
data/.travis.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.0.0
4
- - 2.1.2
4
+ - 2.1.3
5
5
  script:
6
6
  - bundle exec rake spec
7
7
  - bundle exec rubocop
data/Gemfile CHANGED
@@ -6,5 +6,7 @@ gemspec
6
6
  group :development, :test do
7
7
  gem 'guard'
8
8
  gem 'guard-rspec'
9
+ gem 'guard-rubocop'
9
10
  gem 'pry'
11
+ gem 'coveralls', require: false
10
12
  end
data/Guardfile CHANGED
@@ -1,16 +1,21 @@
1
1
  # A sample Guardfile
2
2
  # More info at https://github.com/guard/guard#readme
3
3
 
4
- guard :rspec do
4
+ # Note: The cmd option is now required due to the increasing number of ways
5
+ # rspec may be run, below are examples of the most common uses.
6
+ # * bundler: 'bundle exec rspec'
7
+ # * bundler binstubs: 'bin/rspec'
8
+ # * spring: 'bin/rsspec' (This will use spring if running and you have
9
+ # installed the spring binstubs per the docs)
10
+ # * zeus: 'zeus rspec' (requires the server to be started separetly)
11
+ # * 'just' rspec: 'rspec'
12
+ guard :rspec, cmd: 'bundle exec rspec' do
5
13
  watch(%r{^spec/.+_spec\.rb$})
6
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
7
- watch('spec/(spec|rails)_helper.rb') { 'spec' }
14
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
15
+ watch('spec/spec_helper.rb') { 'spec' }
16
+ end
8
17
 
9
- # Rails example
10
- watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
- watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
12
- watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
13
- watch(%r{^spec/support/(.+)\.rb$}) { 'spec' }
14
- watch('config/routes.rb') { 'spec/routing' }
15
- watch('app/controllers/application_controller.rb') { 'spec/controllers' }
18
+ guard :rubocop, cli: '--auto-correct' do
19
+ watch(%r{.+\.rb$})
20
+ watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
16
21
  end
data/README.md CHANGED
@@ -1,7 +1,16 @@
1
- # Capistrano::Env
1
+ [![Build Status](https://travis-ci.org/masarakki/capistrano-env.svg?branch=master)](https://travis-ci.org/masarakki/capistrano-env?branch=master)
2
+ [![Dependency Status](https://gemnasium.com/masarakki/capistrano-env.svg)](https://gemnasium.com/masarakki/capistrano-env)
3
+ [![Coverage Status](https://img.shields.io/coveralls/masarakki/capistrano-env.svg)](https://coveralls.io/r/masarakki/capistrano-env?branch=master)
2
4
 
5
+ # Capistrano::Env
3
6
  Capistrano with Env via file
4
7
 
8
+ ## Notice!
9
+
10
+ `ruby_formatter` will deprecated at `0.2.x` and it will be removed at next version (`>= 0.3`).
11
+ Now `dotenv_formatter` is avaiable, it create `.env` file instead of `capenv.rb` file,
12
+ and use `dotenv` or `dotenv-rails` gem to read `.env` file.
13
+
5
14
  ## Installation
6
15
 
7
16
  Add this line to your application's Gemfile:
@@ -29,6 +38,7 @@ capenv.use do |env|
29
38
  end
30
39
  env.add 'UNICORN_PROCESSES'
31
40
  env.add 'HOGE', 'hage'
41
+ env.formatter = :dotenv #=> default is :ruby, but it is deprecated now.
32
42
  end
33
43
  ```
34
44
 
@@ -38,8 +48,8 @@ end
38
48
  bundle exec cap production deploy
39
49
  ```
40
50
 
41
- - automaticaly create #{current_path}/capenv.rb
42
- - automaticaly load #{current_path}/capenv.rb in rails boot
51
+ - automaticaly create #{current_path}/.env
52
+ - automaticaly load #{current_path}/.env if you use dotenv-rails
43
53
  - you should load manualy in other framework
44
54
  - you can use ENV['ENV_NAME'] in application
45
55
 
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
-
20
+ spec.post_install_message = 'formatter :ruby is deprecated! use :dotenv instead of :ruby.'
21
21
  spec.add_dependency 'rails', '>= 3.0', '< 5.0'
22
22
 
23
23
  spec.add_development_dependency 'bundler', '~> 1.3'
@@ -4,11 +4,20 @@ module Capistrano
4
4
  attr_accessor :formatter
5
5
 
6
6
  def initialize
7
- @formatter = :ruby
8
7
  @values = {}
9
8
  @keys = []
10
9
  end
11
10
 
11
+ def formatter
12
+ self.formatter = :ruby unless @formatter
13
+ @formatter
14
+ end
15
+
16
+ def formatter=(value)
17
+ warn 'formatter :ruby is deprecated! use :dotenv with dotenv(-rails).gem' if value == :ruby
18
+ @formatter = value
19
+ end
20
+
12
21
  def add(name_or_regexp, val = nil, &block)
13
22
  if val && name_or_regexp.is_a?(String)
14
23
  @values[name_or_regexp] = val
@@ -19,7 +28,7 @@ module Capistrano
19
28
 
20
29
  def formatter_class
21
30
  @formatter_class ||= begin
22
- require "capistrano/env/formatter/#{@formatter}_formatter"
31
+ require "capistrano/env/formatter/#{formatter}_formatter"
23
32
  Capistrano::Env::Formatter.const_get "#{formatter.capitalize}Formatter"
24
33
  end
25
34
  end
@@ -35,7 +44,7 @@ module Capistrano
35
44
  end
36
45
 
37
46
  def capenv_file
38
- "capenv.#{formatter_class.file_ext}"
47
+ formatter_class.filename
39
48
  end
40
49
 
41
50
  def capenv_content
@@ -0,0 +1,15 @@
1
+ module Capistrano
2
+ module Env
3
+ module Formatter
4
+ class DotenvFormatter
5
+ def self.filename
6
+ '.env'
7
+ end
8
+
9
+ def self.format(envs)
10
+ envs.map { |k, v| "#{k}=\"#{v}\"\n" }.join
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,8 +1,8 @@
1
1
  module Capistrano
2
2
  module Env
3
3
  module Formatter
4
- class RubyFormatter
5
- def self.file_ext
4
+ class RubyFormatter < Base
5
+ def self.extname
6
6
  'rb'
7
7
  end
8
8
 
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Env
3
- VERSION = '0.1.2'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
@@ -3,6 +3,11 @@ require 'capistrano/env/version'
3
3
  module Capistrano
4
4
  module Env
5
5
  module Formatter
6
+ class Base
7
+ def self.filename
8
+ "capenv.#{extname}"
9
+ end
10
+ end
6
11
  end
7
12
  end
8
13
  end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+ require 'capistrano/env/formatter/dotenv_formatter'
3
+
4
+ describe Capistrano::Env::Formatter::DotenvFormatter do
5
+ let(:envs) { { 'HELLO' => 'WORLD', 'HOGE' => '1,2,3' } }
6
+ expect_string = <<EOF
7
+ HELLO="WORLD"
8
+ HOGE="1,2,3"
9
+ EOF
10
+ it { expect(described_class.format(envs)).to eq expect_string }
11
+ it { expect(described_class.filename).to eq '.env' }
12
+ end
@@ -8,4 +8,5 @@ ENV["HELLO"] = "WORLD"
8
8
  ENV["HOGE"] = "1,2,3"
9
9
  EOF
10
10
  it { expect(described_class.format(envs)).to eq expect_string }
11
+ it { expect(described_class.filename).to eq 'capenv.rb' }
11
12
  end
data/spec/rails_helper.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
2
 
3
+ require 'coveralls'
4
+ Coveralls.wear!
3
5
  require 'capistrano'
4
6
 
5
7
  ENV['RAILS_ENV'] ||= 'test'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-env
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - masarakki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-06 00:00:00.000000000 Z
11
+ date: 2014-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -148,11 +148,13 @@ files:
148
148
  - lib/capistrano-env.rb
149
149
  - lib/capistrano/env.rb
150
150
  - lib/capistrano/env/config.rb
151
+ - lib/capistrano/env/formatter/dotenv_formatter.rb
151
152
  - lib/capistrano/env/formatter/ruby_formatter.rb
152
153
  - lib/capistrano/env/plugin.rb
153
154
  - lib/capistrano/env/railtie.rb
154
155
  - lib/capistrano/env/version.rb
155
156
  - spec/capistrano/env/config_spec.rb
157
+ - spec/capistrano/env/formatter/dotenv_formatter_spec.rb
156
158
  - spec/capistrano/env/formatter/ruby_formatter_spec.rb
157
159
  - spec/capistrano/env/plugin_spec.rb
158
160
  - spec/capistrano/env/railtie_spec.rb
@@ -211,7 +213,7 @@ homepage: https://github.com/masarakki/capistrano-env
211
213
  licenses:
212
214
  - MIT
213
215
  metadata: {}
214
- post_install_message:
216
+ post_install_message: formatter :ruby is deprecated! use :dotenv instead of :ruby.
215
217
  rdoc_options: []
216
218
  require_paths:
217
219
  - lib
@@ -233,6 +235,7 @@ specification_version: 4
233
235
  summary: capistrano with environments
234
236
  test_files:
235
237
  - spec/capistrano/env/config_spec.rb
238
+ - spec/capistrano/env/formatter/dotenv_formatter_spec.rb
236
239
  - spec/capistrano/env/formatter/ruby_formatter_spec.rb
237
240
  - spec/capistrano/env/plugin_spec.rb
238
241
  - spec/capistrano/env/railtie_spec.rb