capistrano-env 0.3.3 → 1.0.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
- SHA1:
3
- metadata.gz: de2601924f5b4619fe34ade9290073fbb837c14c
4
- data.tar.gz: 7d16838643d9b9a305c9e07abc4c4c4ca366a778
2
+ SHA256:
3
+ metadata.gz: 3c67218f02b494ffddd288ae9b13a87275f92f7a50d9f4ee47359a23b1edc7e3
4
+ data.tar.gz: a0c22ec632adfc0fdd70aef263029951872300f0ac9c41dc4b98a001cb1d2b44
5
5
  SHA512:
6
- metadata.gz: 0dbdc4de385df677be57637d5759ca52bd1dc7baef4c29ee4499212b3991f9974e0ed01bd5ac778bd1b21584805ecd94a7e484772abfd55a79ad18cd4236ad52
7
- data.tar.gz: 4e40b96b4b9c2d7f65a6eb971f2559f8aa720565f15601196a6f685d16eb0bb9941bf576e35a6868ec5148d9a9102b302487400253f43046a420ce59db20f701
6
+ metadata.gz: bedaeb21dfc1e856ea6aac665e4fe635174c5c763386f1b0937b5e1eaabbdae8470dd726d712e69ce304b0ec3003637ee054f4bfd737971f84402ebdc9fedff6
7
+ data.tar.gz: b1be64e4900341542466bb6998ed1545ae10fab3d226ba5e959dc473b5300ff7ab27e6129e11254aced6c05d9542aa944d53967f71ab3e7fdda1b02cf03c800c
@@ -1,12 +1,14 @@
1
- Metrics/AbcSize:
2
- Enabled: false
1
+ AllCops:
2
+ Exclude:
3
+ - vendor/bundle/**/*
4
+ - gemfiles/vendor/bundle/**/*
5
+ Metrics/BlockLength:
6
+ Exclude:
7
+ - spec/**/*_spec.rb
3
8
  Metrics/LineLength:
4
- Enabled: false
5
- Metrics/MethodLength:
6
- Enabled: false
9
+ Exclude:
10
+ - spec/**/*_spec.rb
7
11
  Style/Documentation:
8
12
  Enabled: false
9
13
  Style/FileName:
10
14
  Enabled: false
11
- Style/RegexpLiteral:
12
- Enabled: false
@@ -1,10 +1,13 @@
1
1
  language: ruby
2
+ sudo: false
3
+ cache: bundler
2
4
  rvm:
3
- - 2.1.5
4
- - 2.2.1
5
- gemfile:
6
- - gemfiles/cap3.gemfile
7
- - gemfiles/cap2.gemfile
5
+ - 2.3.7
6
+ - 2.4.4
7
+ - 2.5.1
8
+ before_install:
9
+ - gem update --system --no-document
10
+ - gem i bundler
8
11
  script:
9
- - bundle exec rake spec
10
12
  - bundle exec rubocop
13
+ - bundle exec rake spec
data/Guardfile CHANGED
@@ -11,11 +11,12 @@
11
11
  # * 'just' rspec: 'rspec'
12
12
  guard :rspec, cmd: 'bundle exec rspec' do
13
13
  watch(%r{^spec/.+_spec\.rb$})
14
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
14
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
15
15
  watch('spec/spec_helper.rb') { 'spec' }
16
16
  end
17
17
 
18
- guard :rubocop, cli: '--auto-correct' do
19
- watch(%r{.+\.rb$})
18
+ guard :rubocop, cli: '-aD --except Lint/Debugger' do
19
+ watch('Gemfile')
20
+ watch(/.+\.rb$/)
20
21
  watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
21
22
  end
data/README.md CHANGED
@@ -3,13 +3,8 @@
3
3
  [![Coverage Status](https://img.shields.io/coveralls/masarakki/capistrano-env.svg)](https://coveralls.io/r/masarakki/capistrano-env?branch=master)
4
4
 
5
5
  # Capistrano::Env
6
- Capistrano with Env via file
7
-
8
- ## Notice!
9
6
 
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.
7
+ Capistrano with Env via file
13
8
 
14
9
  ## Installation
15
10
 
@@ -29,45 +24,26 @@ Or install it yourself as:
29
24
 
30
25
  ### 1. set env names in deploy.rb
31
26
 
32
- #### Capistrano 2.x
33
-
34
- in `deploy.rb`
35
-
36
- ```ruby
37
- require 'capistrano/env/v2'
38
-
39
- capenv.use do |env|
40
- env.add /^MYAPP_/
41
- env.add /^MYAPP_/ do |key|
42
- key.gsub /^MYAPP_/, '' # replace keyname like MYAPP_DATABASE_URL => DATABASE_URL
43
- end
44
- env.add 'UNICORN_PROCESSES'
45
- env.add 'HOGE', 'hage'
46
- env.formatter = :dotenv #=> default is :ruby, but it is deprecated now.
47
- end
48
- ```
49
-
50
- #### Capistrano 3.x
51
-
52
27
  in `Capfile`
53
28
 
54
29
  ```ruby
55
- require 'capistrano/env/v3'
30
+ require 'capistrano/env'
56
31
  ```
57
32
 
58
33
  in `deploy.rb`
59
34
 
60
35
  ```ruby
61
- Capistrano::Env.use do |env|
36
+
37
+ # New
38
+ set :capenv, ->(env) {
62
39
  env.add /^MYAPP_/
63
40
  env.add /^MYAPP_/ do |key|
64
41
  key.gsub /^MYAPP_/, '' # replace keyname like MYAPP_DATABASE_URL => DATABASE_URL
65
42
  end
66
43
  env.add 'UNICORN_PROCESSES'
67
44
  env.add 'HOGE', 'hage'
68
- env.formatter = :dotenv #=> default is :ruby, but it is deprecated now.
69
45
  env.filemode = 0644 #=> default is 0640.
70
- end
46
+ }
71
47
  ```
72
48
 
73
49
  ### 2. deploy
@@ -1,5 +1,5 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+
2
+ lib = File.expand_path('lib', __dir__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'capistrano/env/version'
5
5
 
@@ -17,20 +17,19 @@ 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
- spec.post_install_message = 'formatter :ruby is removed! use :dotenv instead of :ruby.'
21
20
 
22
21
  spec.add_dependency 'capistrano'
23
22
  spec.add_dependency 'sshkit'
24
23
 
25
24
  spec.add_development_dependency 'bundler', '~> 1.3'
26
- spec.add_development_dependency 'rake'
27
- spec.add_development_dependency 'rspec'
28
- spec.add_development_dependency 'rubocop'
29
- spec.add_development_dependency 'sqlite3'
25
+ spec.add_development_dependency 'coveralls'
30
26
  spec.add_development_dependency 'guard'
31
27
  spec.add_development_dependency 'guard-rspec'
32
28
  spec.add_development_dependency 'guard-rubocop'
33
29
  spec.add_development_dependency 'pry'
34
30
  spec.add_development_dependency 'pry-doc'
35
- spec.add_development_dependency 'coveralls'
31
+ spec.add_development_dependency 'rake'
32
+ spec.add_development_dependency 'rspec'
33
+ spec.add_development_dependency 'rspec-its'
34
+ spec.add_development_dependency 'rubocop'
36
35
  end
@@ -1 +0,0 @@
1
- require 'capistrano/env/v2' if defined?(Capistrano) && Capistrano.respond_to?(:plugin) # capistrano-2.x
@@ -1,31 +1,3 @@
1
+ require 'capistrano/env/version'
1
2
  require 'capistrano/env/config'
2
-
3
- module Capistrano
4
- module Env
5
- def self.use(&block)
6
- block.call(config)
7
- end
8
-
9
- def self.envs
10
- config.envs
11
- end
12
-
13
- def self.to_s
14
- config.capenv_content
15
- end
16
-
17
- def self.filename
18
- config.capenv_file
19
- end
20
-
21
- def self.filemode
22
- config.capenv_filemode
23
- end
24
-
25
- private
26
-
27
- def self.config
28
- @config ||= Capistrano::Env::Config.new
29
- end
30
- end
31
- end
3
+ load File.expand_path('tasks/env.rake', __dir__)
@@ -0,0 +1,9 @@
1
+ module Capistrano
2
+ module Env
3
+ module Builder
4
+ def content
5
+ envs.map { |k, v| "#{k}=\"#{v}\"\n" }.join
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,64 +1,47 @@
1
- require 'capistrano/env/formatter'
1
+ require 'capistrano/env/builder'
2
2
 
3
3
  module Capistrano
4
4
  module Env
5
5
  class Config
6
- attr_accessor :formatter
7
- attr_accessor :filemode
6
+ include Capistrano::Env::Builder
7
+ attr_accessor :filemode, :filename
8
+ attr_reader :envs
8
9
 
9
10
  def initialize
10
- @values = {}
11
- @keys = []
11
+ @envs = {}
12
+ @filemode = '0640'
13
+ @filename = '.env'
14
+ yield(self) if block_given?
12
15
  end
13
16
 
14
- def formatter
15
- self.formatter = :dotenv unless @formatter
16
- @formatter
17
+ def inspect
18
+ envs
17
19
  end
18
20
 
19
- def filemode
20
- self.filemode = '0640' unless @filemode
21
- @filemode
22
- end
23
-
24
- attr_writer :formatter
25
- attr_writer :filemode
26
-
27
21
  def add(name_or_regexp, val = nil, &block)
28
22
  if val && name_or_regexp.is_a?(String)
29
- @values[name_or_regexp] = val
23
+ set_env(name_or_regexp, val)
30
24
  else
31
- @keys << [name_or_regexp, block]
25
+ find_envs(name_or_regexp).each do |key, value|
26
+ set_env(key, value, &block)
27
+ end
32
28
  end
33
29
  end
34
30
 
35
- def formatter_class
36
- @formatter_class ||= begin
37
- require "capistrano/env/formatter/#{formatter}_formatter"
38
- Capistrano::Env::Formatter.const_get "#{formatter.capitalize}Formatter"
39
- end
40
- end
31
+ private
41
32
 
42
- def envs
43
- result = {}
44
- @keys.each do |key, block|
45
- key_values = key.is_a?(Regexp) ? ENV.select { |x| x =~ key } : ENV.select { |x| x == key }
46
- key_values = Hash[key_values.map { |k, v| [block.call(k), v] }] if block
47
- result.merge!(key_values)
48
- end
49
- result.merge(@values)
33
+ def set_env(key, value)
34
+ key = yield(key) if block_given?
35
+ @envs[key] = value
50
36
  end
51
37
 
52
- def capenv_file
53
- formatter_class.filename
54
- end
55
-
56
- def capenv_content
57
- formatter_class.format(envs)
58
- end
59
-
60
- def capenv_filemode
61
- filemode
38
+ def find_envs(key)
39
+ case key
40
+ when Regexp
41
+ ENV.select { |x| x =~ key }
42
+ else
43
+ ENV.select { |x| x == key }
44
+ end
62
45
  end
63
46
  end
64
47
  end
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Env
3
- VERSION = '0.3.3'
3
+ VERSION = '1.0.0'.freeze
4
4
  end
5
5
  end
@@ -0,0 +1,30 @@
1
+ namespace :capenv do
2
+ desc 'copy .env to release_path'
3
+ task :copy do
4
+ on roles(:all) do
5
+ capenv = fetch(:capenv)
6
+ upload! StringIO.new(capenv.content),
7
+ File.join(fetch(:release_path), capenv.filename),
8
+ mode: capenv.filemode
9
+ end
10
+ end
11
+
12
+ task :set_envs do
13
+ capenv = Capistrano::Env::Config.new(&fetch(:capenv))
14
+ set :capenv, capenv
15
+ set :default_environment, capenv.envs
16
+ end
17
+ end
18
+
19
+ namespace :load do
20
+ task :defautls do
21
+ set :capenv, -> { ->(env) {} }
22
+ end
23
+ end
24
+
25
+ stages.each do |stage|
26
+ after stage, 'capenv:set_envs'
27
+ end
28
+
29
+ before 'deploy:updated', 'capenv:copy'
30
+ before 'deploy:restart', 'capenv:copy'
@@ -0,0 +1,19 @@
1
+ require 'gem_helper'
2
+ require 'capistrano/env/builder'
3
+
4
+ RSpec.describe Capistrano::Env::Builder do
5
+ let(:target) do
6
+ Class.new do
7
+ include Capistrano::Env::Builder
8
+
9
+ def envs
10
+ { 'HELLO' => 'WORLD', 'HOGE' => '1,2,3' }
11
+ end
12
+ end
13
+ end
14
+
15
+ let(:expect_string) { "HELLO=\"WORLD\"\nHOGE=\"1,2,3\"\n" }
16
+
17
+ subject { target.new }
18
+ its(:content) { is_expected.to eq expect_string }
19
+ end
@@ -1,28 +1,20 @@
1
1
  require 'gem_helper'
2
2
  require 'capistrano/env/config'
3
3
 
4
- describe Capistrano::Env::Config do
5
- let(:config) { described_class.new }
6
- describe '#formatter' do
7
- it { expect(config.formatter).to eq :dotenv }
8
- end
9
-
10
- describe '#formatter class' do
11
- it { expect(config.formatter_class).to eq Capistrano::Env::Formatter::DotenvFormatter }
4
+ RSpec.describe Capistrano::Env::Config do
5
+ describe 'new with block' do
6
+ before do
7
+ ENV['CAPENV_TEST_A'] = 'a'
8
+ end
9
+ let(:proc) { ->(env) { env.add(/CAPENV_TEST/) } }
10
+ subject { described_class.new(&proc).envs }
11
+ it { is_expected.to eq('CAPENV_TEST_A' => 'a') }
12
12
  end
13
13
 
14
- describe '#capenv_file' do
15
- it { expect(config.capenv_file).to eq '.env' }
16
- end
14
+ let(:config) { described_class.new }
15
+ subject { config }
17
16
 
18
- describe '#capenv_content' do
19
- it do
20
- require 'capistrano/env/formatter/dotenv_formatter'
21
- allow(config).to receive(:envs).and_return('a' => 'b')
22
- expect(Capistrano::Env::Formatter::DotenvFormatter).to receive(:format).with('a' => 'b').and_return 'hello'
23
- expect(config.capenv_content).to eq 'hello'
24
- end
25
- end
17
+ its(:filename) { is_expected.to eq '.env' }
26
18
 
27
19
  describe '#add' do
28
20
  before do
@@ -31,26 +23,30 @@ describe Capistrano::Env::Config do
31
23
  ENV['CAPENV_TEST'] = '$'
32
24
  ENV['VAPENV_XYZ_A'] = 'X'
33
25
  end
26
+ subject { config.envs }
34
27
 
35
28
  context 'with regex' do
36
29
  before do
37
30
  config.add(/^CAPENV_TEST_/)
38
31
  end
39
- it { expect(config.envs).to eq('CAPENV_TEST_A' => 'a', 'CAPENV_TEST_B' => '1,2,3') }
32
+ it { is_expected.to eq('CAPENV_TEST_A' => 'a', 'CAPENV_TEST_B' => '1,2,3') }
40
33
  end
34
+
41
35
  context 'with string' do
42
36
  before do
43
37
  config.add 'CAPENV_TEST'
44
38
  end
45
- it { expect(config.envs).to eq('CAPENV_TEST' => '$') }
39
+ it { is_expected.to eq('CAPENV_TEST' => '$') }
46
40
  end
41
+
47
42
  describe 'overridable' do
48
43
  before do
49
44
  config.add(/^CAPENV_TEST_/)
50
45
  config.add 'CAPENV_TEST_B', 'UNKO'
51
46
  end
52
- it { expect(config.envs).to eq('CAPENV_TEST_A' => 'a', 'CAPENV_TEST_B' => 'UNKO') }
47
+ it { is_expected.to eq('CAPENV_TEST_A' => 'a', 'CAPENV_TEST_B' => 'UNKO') }
53
48
  end
49
+
54
50
  describe 'fix key with block' do
55
51
  before do
56
52
  config.add(/^CAPENV_TEST_/)
@@ -58,7 +54,8 @@ describe Capistrano::Env::Config do
58
54
  key.gsub(/CAPENV_/, '')
59
55
  end
60
56
  end
61
- it { expect(config.envs).to eq('CAPENV_TEST_A' => 'a', 'CAPENV_TEST_B' => '1,2,3', 'TEST_A' => 'a', 'TEST_B' => '1,2,3') }
57
+
58
+ it { is_expected.to eq('CAPENV_TEST_A' => 'a', 'CAPENV_TEST_B' => '1,2,3', 'TEST_A' => 'a', 'TEST_B' => '1,2,3') }
62
59
  end
63
60
  end
64
61
  end
@@ -1,3 +1,3 @@
1
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
1
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
2
2
  require 'coveralls'
3
3
  Coveralls.wear!
@@ -1,60 +1,5 @@
1
+ require 'pry'
2
+ require 'rspec/its'
3
+
1
4
  RSpec.configure do |_config|
2
- # The settings below are suggested to provide a good initial experience
3
- # with RSpec, but feel free to customize to your heart's content.
4
- # # These two settings work together to allow you to limit a spec run
5
- # # to individual examples or groups you care about by tagging them with
6
- # # `:focus` metadata. When nothing is tagged with `:focus`, all examples
7
- # # get run.
8
- # config.filter_run :focus
9
- # config.run_all_when_everything_filtered = true
10
- #
11
- # # Many RSpec users commonly either run the entire suite or an individual
12
- # # file, and it's useful to allow more verbose output when running an
13
- # # individual spec file.
14
- # if config.files_to_run.one?
15
- # # Use the documentation formatter for detailed output,
16
- # # unless a formatter has already been configured
17
- # # (e.g. via a command-line flag).
18
- # config.default_formatter = 'doc'
19
- # end
20
- #
21
- # # Print the 10 slowest examples and example groups at the
22
- # # end of the spec run, to help surface which specs are running
23
- # # particularly slow.
24
- # config.profile_examples = 10
25
- #
26
- # # Run specs in random order to surface order dependencies. If you find an
27
- # # order dependency and want to debug it, you can fix the order by providing
28
- # # the seed, which is printed after each run.
29
- # # --seed 1234
30
- # config.order = :random
31
- #
32
- # # Seed global randomization in this process using the `--seed` CLI option.
33
- # # Setting this allows you to use `--seed` to deterministically reproduce
34
- # # test failures related to randomization by passing the same `--seed` value
35
- # # as the one that triggered the failure.
36
- # Kernel.srand config.seed
37
- #
38
- # # rspec-expectations config goes here. You can use an alternate
39
- # # assertion/expectation library such as wrong or the stdlib/minitest
40
- # # assertions if you prefer.
41
- # config.expect_with :rspec do |expectations|
42
- # # Enable only the newer, non-monkey-patching expect syntax.
43
- # # For more details, see:
44
- # # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
45
- # expectations.syntax = :expect
46
- # end
47
- #
48
- # # rspec-mocks config goes here. You can use an alternate test double
49
- # # library (such as bogus or mocha) by changing the `mock_with` option here.
50
- # config.mock_with :rspec do |mocks|
51
- # # Enable only the newer, non-monkey-patching expect syntax.
52
- # # For more details, see:
53
- # # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
54
- # mocks.syntax = :expect
55
- #
56
- # # Prevents you from mocking or stubbing a method that does not exist on
57
- # # a real object. This is generally recommended.
58
- # mocks.verify_partial_doubles = true
59
- # end
60
5
  end
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.3.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - masarakki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-29 00:00:00.000000000 Z
11
+ date: 2018-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.3'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rake
56
+ name: coveralls
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rspec
70
+ name: guard
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: rubocop
84
+ name: guard-rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: sqlite3
98
+ name: guard-rubocop
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -109,7 +109,7 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: guard
112
+ name: pry
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
@@ -123,7 +123,7 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: guard-rspec
126
+ name: pry-doc
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
@@ -137,7 +137,7 @@ dependencies:
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
- name: guard-rubocop
140
+ name: rake
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - ">="
@@ -151,7 +151,7 @@ dependencies:
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
- name: pry
154
+ name: rspec
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ">="
@@ -165,7 +165,7 @@ dependencies:
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
- name: pry-doc
168
+ name: rspec-its
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - ">="
@@ -179,7 +179,7 @@ dependencies:
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  - !ruby/object:Gem::Dependency
182
- name: coveralls
182
+ name: rubocop
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
185
  - - ">="
@@ -209,29 +209,21 @@ files:
209
209
  - README.md
210
210
  - Rakefile
211
211
  - capistrano-env.gemspec
212
- - gemfiles/cap2.gemfile
213
- - gemfiles/cap3.gemfile
214
212
  - lib/capistrano-env.rb
215
213
  - lib/capistrano/env.rb
214
+ - lib/capistrano/env/builder.rb
216
215
  - lib/capistrano/env/config.rb
217
- - lib/capistrano/env/formatter.rb
218
- - lib/capistrano/env/formatter/dotenv_formatter.rb
219
- - lib/capistrano/env/v2.rb
220
- - lib/capistrano/env/v2/plugin.rb
221
- - lib/capistrano/env/v3.rb
222
- - lib/capistrano/env/v3/tasks/env.rake
223
216
  - lib/capistrano/env/version.rb
217
+ - lib/capistrano/tasks/env.rake
218
+ - spec/capistrano/env/builder_spec.rb
224
219
  - spec/capistrano/env/config_spec.rb
225
- - spec/capistrano/env/formatter/dotenv_formatter_spec.rb
226
- - spec/capistrano/env/v2/plugin_spec.rb
227
- - spec/capistrano/env_spec.rb
228
220
  - spec/gem_helper.rb
229
221
  - spec/spec_helper.rb
230
222
  homepage: https://github.com/masarakki/capistrano-env
231
223
  licenses:
232
224
  - MIT
233
225
  metadata: {}
234
- post_install_message: formatter :ruby is removed! use :dotenv instead of :ruby.
226
+ post_install_message:
235
227
  rdoc_options: []
236
228
  require_paths:
237
229
  - lib
@@ -247,14 +239,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
247
239
  version: '0'
248
240
  requirements: []
249
241
  rubyforge_project:
250
- rubygems_version: 2.2.2
242
+ rubygems_version: 2.7.6
251
243
  signing_key:
252
244
  specification_version: 4
253
245
  summary: capistrano with environments
254
246
  test_files:
247
+ - spec/capistrano/env/builder_spec.rb
255
248
  - spec/capistrano/env/config_spec.rb
256
- - spec/capistrano/env/formatter/dotenv_formatter_spec.rb
257
- - spec/capistrano/env/v2/plugin_spec.rb
258
- - spec/capistrano/env_spec.rb
259
249
  - spec/gem_helper.rb
260
250
  - spec/spec_helper.rb
@@ -1,6 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in capistrano-env.gemspec
4
- gemspec path: '../'
5
-
6
- gem 'capistrano', '< 3'
@@ -1,6 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in capistrano-env.gemspec
4
- gemspec path: '../'
5
-
6
- gem 'capistrano', ENV['CAPISTRANO_VERSION'] || '>= 3'
@@ -1,11 +0,0 @@
1
- module Capistrano
2
- module Env
3
- module Formatter
4
- class Base
5
- def self.filename
6
- "capenv.#{extname}"
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,15 +0,0 @@
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,4 +0,0 @@
1
- require 'capistrano/env/version'
2
-
3
- require 'capistrano/env/config'
4
- require 'capistrano/env/v2/plugin'
@@ -1,34 +0,0 @@
1
- require 'capistrano'
2
-
3
- module Capistrano
4
- module Env
5
- module Plugin
6
- def use
7
- config = Capistrano::Env::Config.new
8
- yield(config)
9
- add config
10
- set :default_environment, config.envs
11
- config
12
- end
13
-
14
- def add(config)
15
- namespace :deploy do
16
- namespace :capenv do
17
- namespace :copy do
18
- [:release, :current].each do |type|
19
- task type do
20
- path = fetch "#{type}_path".to_sym
21
- parent.parent.parent.upload StringIO.new(config.capenv_content), "#{path}/#{config.capenv_file}"
22
- end
23
- end
24
- end
25
- end
26
- end
27
- before 'deploy:finalize_update', 'deploy:capenv:copy:release'
28
- before 'deploy:restart', 'deploy:capenv:copy:current'
29
- end
30
- end
31
- end
32
- end
33
-
34
- Capistrano.plugin :capenv, Capistrano::Env::Plugin if Capistrano.respond_to?(:plugin)
@@ -1,4 +0,0 @@
1
- require 'capistrano/env/version'
2
- require 'capistrano/env'
3
-
4
- load File.expand_path('../v3/tasks/env.rake', __FILE__)
@@ -1,19 +0,0 @@
1
- namespace :capenv do
2
- desc 'copy .env to release_path'
3
- task :copy do
4
- on roles(:all) do
5
- upload! StringIO.new(Capistrano::Env.to_s), "#{release_path}/#{Capistrano::Env.filename}", mode: Capistrano::Env.filemode
6
- end
7
- end
8
-
9
- task :set_envs do
10
- set :default_environment, Capistrano::Env.envs
11
- end
12
- end
13
-
14
- stages.each do |stage|
15
- after stage, 'capenv:set_envs'
16
- end
17
-
18
- before 'deploy:updated', 'capenv:copy'
19
- before 'deploy:restart', 'capenv:copy'
@@ -1,12 +0,0 @@
1
- require 'gem_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
@@ -1,24 +0,0 @@
1
- require 'gem_helper'
2
- require 'capistrano/env/v2'
3
-
4
- describe Capistrano::Env::Plugin do
5
- before do
6
- skip 'capistrano-3.x not support it' unless Capistrano.respond_to?(:plugin)
7
- end
8
- let(:capistrano) { Capistrano::Configuration.new }
9
-
10
- describe '#capenv' do
11
- let(:setup) { capistrano.capenv.use { |config| config.add 'HELLO', 'WORLD' } }
12
-
13
- it 'add task' do
14
- expect(capistrano.capenv).to receive(:add)
15
- setup
16
- end
17
- it { expect(setup).to be_a Capistrano::Env::Config }
18
-
19
- it 'set default_environment' do
20
- setup
21
- expect(capistrano.fetch(:default_environment)).to eq 'HELLO' => 'WORLD'
22
- end
23
- end
24
- end
@@ -1,14 +0,0 @@
1
- require 'gem_helper'
2
- require 'capistrano/env'
3
-
4
- describe Capistrano::Env do
5
- before do
6
- Capistrano::Env.use do |env|
7
- env.add 'HELLO', 'WORLD'
8
- end
9
- end
10
-
11
- it { expect(Capistrano::Env.to_s.chomp).to eq 'HELLO="WORLD"' }
12
- it { expect(Capistrano::Env.envs).to eq 'HELLO' => 'WORLD' }
13
- it { expect(Capistrano::Env.filename).to eq '.env' }
14
- end