capistrano-env 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +2 -1
- data/.rubocop.yml +10 -0
- data/.travis.yml +3 -0
- data/Guardfile +4 -5
- data/Rakefile +3 -3
- data/capistrano-env.gemspec +17 -16
- data/lib/capistrano/env/config.rb +2 -10
- data/lib/capistrano/env/formatter/ruby_formatter.rb +1 -1
- data/lib/capistrano/env/railtie.rb +2 -2
- data/lib/capistrano/env/version.rb +1 -1
- data/lib/capistrano/env.rb +4 -4
- data/spec/capistrano/env/config_spec.rb +30 -30
- data/spec/capistrano/env/formatter/ruby_formatter_spec.rb +2 -2
- data/spec/capistrano/env/plugin_spec.rb +5 -5
- data/spec/capistrano/env/railtie_spec.rb +5 -5
- data/spec/capistrano/env_spec.rb +1 -1
- data/spec/dummy/capenv.rb +3 -3
- data/spec/dummy/config/boot.rb +1 -1
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/config/initializers/hoge.rb +1 -1
- data/spec/rails_helper.rb +11 -0
- data/spec/spec_helper.rb +59 -11
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8df3f7d4f949a79689126918c6de74338707c745
|
4
|
+
data.tar.gz: eb0809253334ed4c996a9a17808e9917208a72f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 448aa8dd55f3e8ff47e290e76e93254e2872afad63bd3154fe3124e10fe135516608baca5ed8a3da1d06c308b2a496bd7fb34767e2432c7d7ba6242c14793033
|
7
|
+
data.tar.gz: 0eac3447a423e1362d409eafdf95aeaed2dcb1fcfe9b99b5fd7f75b5c2b5a68ac46a8d07a15740839f82a273023020ac9d78cb5a26ca80b73263fb2934c55632
|
data/.rspec
CHANGED
data/.rubocop.yml
ADDED
data/.travis.yml
CHANGED
data/Guardfile
CHANGED
@@ -4,14 +4,13 @@
|
|
4
4
|
guard :rspec do
|
5
5
|
watch(%r{^spec/.+_spec\.rb$})
|
6
6
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
7
|
-
watch('spec/
|
7
|
+
watch('spec/(spec|rails)_helper.rb') { 'spec' }
|
8
8
|
|
9
9
|
# Rails example
|
10
10
|
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
11
11
|
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
12
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$}) {
|
14
|
-
watch('config/routes.rb') {
|
15
|
-
watch('app/controllers/application_controller.rb') {
|
13
|
+
watch(%r{^spec/support/(.+)\.rb$}) { 'spec' }
|
14
|
+
watch('config/routes.rb') { 'spec/routing' }
|
15
|
+
watch('app/controllers/application_controller.rb') { 'spec/controllers' }
|
16
16
|
end
|
17
|
-
|
data/Rakefile
CHANGED
data/capistrano-env.gemspec
CHANGED
@@ -4,26 +4,27 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'capistrano/env/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'capistrano-env'
|
8
8
|
spec.version = Capistrano::Env::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.description =
|
12
|
-
spec.summary =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
9
|
+
spec.authors = ['masarakki']
|
10
|
+
spec.email = ['masaki@hisme.net']
|
11
|
+
spec.description = 'capistrano with environments'
|
12
|
+
spec.summary = 'capistrano with environments'
|
13
|
+
spec.homepage = 'https://github.com/masarakki/capistrano-env'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
|
-
spec.files = `git ls-files`.split(
|
16
|
+
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
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
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_dependency
|
21
|
+
spec.add_dependency 'rails', '>= 3.0', '< 5.0'
|
22
22
|
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
spec.add_development_dependency 'rspec'
|
26
|
+
spec.add_development_dependency 'rspec-rails'
|
27
|
+
spec.add_development_dependency 'rubocop'
|
28
|
+
spec.add_development_dependency 'sqlite3'
|
29
|
+
spec.add_development_dependency 'capistrano', '~> 2'
|
29
30
|
end
|
@@ -27,16 +27,8 @@ module Capistrano
|
|
27
27
|
def envs
|
28
28
|
result = {}
|
29
29
|
@keys.each do |key, block|
|
30
|
-
key_values =
|
31
|
-
|
32
|
-
else
|
33
|
-
ENV.select{|x| x == key }
|
34
|
-
end
|
35
|
-
if block
|
36
|
-
key_values = Hash[key_values.map do |k, v|
|
37
|
-
[block.call(k), v]
|
38
|
-
end]
|
39
|
-
end
|
30
|
+
key_values = key.is_a?(Regexp) ? ENV.select { |x| x =~ key } : ENV.select { |x| x == key }
|
31
|
+
key_values = Hash[key_values.map { |k, v| [block.call(k), v] }] if block
|
40
32
|
result.merge!(key_values)
|
41
33
|
end
|
42
34
|
result.merge(@values)
|
@@ -2,8 +2,8 @@ module Capistrano
|
|
2
2
|
module Env
|
3
3
|
class Railtie < ::Rails::Railtie
|
4
4
|
config.before_configuration do
|
5
|
-
capenv_file = File.expand_path(
|
6
|
-
require capenv_file if File.
|
5
|
+
capenv_file = File.expand_path('./capenv.rb', Rails.root)
|
6
|
+
require capenv_file if File.exist?(capenv_file)
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
data/lib/capistrano/env.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'capistrano/env/version'
|
2
2
|
|
3
3
|
module Capistrano
|
4
4
|
module Env
|
@@ -7,6 +7,6 @@ module Capistrano
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
10
|
+
require 'capistrano/env/plugin'
|
11
|
+
require 'capistrano/env/config'
|
12
|
+
require 'capistrano/env/railtie' if defined? Rails
|
@@ -1,63 +1,63 @@
|
|
1
|
-
require '
|
1
|
+
require 'rails_helper'
|
2
2
|
|
3
3
|
describe Capistrano::Env::Config do
|
4
4
|
let(:config) { described_class.new }
|
5
|
-
describe
|
5
|
+
describe '#formatter' do
|
6
6
|
it { expect(config.formatter).to eq :ruby }
|
7
7
|
end
|
8
8
|
|
9
|
-
describe
|
9
|
+
describe '#formatter class' do
|
10
10
|
it { expect(config.formatter_class).to eq Capistrano::Env::Formatter::RubyFormatter }
|
11
11
|
end
|
12
12
|
|
13
|
-
describe
|
14
|
-
it { expect(config.capenv_file).to eq
|
13
|
+
describe '#capenv_file' do
|
14
|
+
it { expect(config.capenv_file).to eq 'capenv.rb' }
|
15
15
|
end
|
16
16
|
|
17
|
-
describe
|
18
|
-
it
|
17
|
+
describe '#capenv_content' do
|
18
|
+
it do
|
19
19
|
require 'capistrano/env/formatter/ruby_formatter'
|
20
|
-
allow(config).to receive(:envs).and_return(
|
21
|
-
expect(Capistrano::Env::Formatter::RubyFormatter).to receive(:format).with(
|
22
|
-
expect(config.capenv_content).to eq
|
23
|
-
|
20
|
+
allow(config).to receive(:envs).and_return('a' => 'b')
|
21
|
+
expect(Capistrano::Env::Formatter::RubyFormatter).to receive(:format).with('a' => 'b').and_return 'hello'
|
22
|
+
expect(config.capenv_content).to eq 'hello'
|
23
|
+
end
|
24
24
|
end
|
25
25
|
|
26
|
-
describe
|
26
|
+
describe '#add' do
|
27
27
|
before do
|
28
|
-
ENV[
|
29
|
-
ENV[
|
30
|
-
ENV[
|
31
|
-
ENV[
|
28
|
+
ENV['CAPENV_TEST_A'] = 'a'
|
29
|
+
ENV['CAPENV_TEST_B'] = '1,2,3'
|
30
|
+
ENV['CAPENV_TEST'] = '$'
|
31
|
+
ENV['VAPENV_XYZ_A'] = 'X'
|
32
32
|
end
|
33
33
|
|
34
|
-
context
|
34
|
+
context 'with regex' do
|
35
35
|
before do
|
36
|
-
config.add
|
36
|
+
config.add(/^CAPENV_TEST_/)
|
37
37
|
end
|
38
|
-
it { expect(config.envs).to eq(
|
38
|
+
it { expect(config.envs).to eq('CAPENV_TEST_A' => 'a', 'CAPENV_TEST_B' => '1,2,3') }
|
39
39
|
end
|
40
|
-
context
|
40
|
+
context 'with string' do
|
41
41
|
before do
|
42
|
-
config.add
|
42
|
+
config.add 'CAPENV_TEST'
|
43
43
|
end
|
44
|
-
it { expect(config.envs).to eq(
|
44
|
+
it { expect(config.envs).to eq('CAPENV_TEST' => '$') }
|
45
45
|
end
|
46
|
-
describe
|
46
|
+
describe 'overridable' do
|
47
47
|
before do
|
48
|
-
config.add
|
49
|
-
config.add
|
48
|
+
config.add(/^CAPENV_TEST_/)
|
49
|
+
config.add 'CAPENV_TEST_B', 'UNKO'
|
50
50
|
end
|
51
|
-
it { expect(config.envs).to eq(
|
51
|
+
it { expect(config.envs).to eq('CAPENV_TEST_A' => 'a', 'CAPENV_TEST_B' => 'UNKO') }
|
52
52
|
end
|
53
|
-
describe
|
53
|
+
describe 'fix key with block' do
|
54
54
|
before do
|
55
|
-
config.add
|
56
|
-
config.add
|
55
|
+
config.add(/^CAPENV_TEST_/)
|
56
|
+
config.add(/^CAPENV_TEST_/) do |key|
|
57
57
|
key.gsub(/CAPENV_/, '')
|
58
58
|
end
|
59
59
|
end
|
60
|
-
it { expect(config.envs).to eq(
|
60
|
+
it { expect(config.envs).to eq('CAPENV_TEST_A' => 'a', 'CAPENV_TEST_B' => '1,2,3', 'TEST_A' => 'a', 'TEST_B' => '1,2,3') }
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
@@ -2,8 +2,8 @@ require 'spec_helper'
|
|
2
2
|
require 'capistrano/env/formatter/ruby_formatter'
|
3
3
|
|
4
4
|
describe Capistrano::Env::Formatter::RubyFormatter do
|
5
|
-
let(:envs) { {
|
6
|
-
expect_string
|
5
|
+
let(:envs) { { 'HELLO' => 'WORLD', 'HOGE' => '1,2,3' } }
|
6
|
+
expect_string = <<EOF
|
7
7
|
ENV["HELLO"] = "WORLD"
|
8
8
|
ENV["HOGE"] = "1,2,3"
|
9
9
|
EOF
|
@@ -4,18 +4,18 @@ require 'capistrano'
|
|
4
4
|
describe Capistrano::Env::Plugin do
|
5
5
|
let(:capistrano) { Capistrano::Configuration.new }
|
6
6
|
|
7
|
-
describe
|
8
|
-
let(:setup) { capistrano.capenv.use {|config| config.add
|
7
|
+
describe '#capenv' do
|
8
|
+
let(:setup) { capistrano.capenv.use { |config| config.add 'HELLO', 'WORLD' } }
|
9
9
|
|
10
|
-
it
|
10
|
+
it 'add task' do
|
11
11
|
expect(capistrano.capenv).to receive(:add)
|
12
12
|
setup
|
13
13
|
end
|
14
14
|
it { expect(setup).to be_a Capistrano::Env::Config }
|
15
15
|
|
16
|
-
it
|
16
|
+
it 'set default_environment' do
|
17
17
|
setup
|
18
|
-
expect(capistrano.fetch(:default_environment)).to eq
|
18
|
+
expect(capistrano.fetch(:default_environment)).to eq 'HELLO' => 'WORLD'
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
describe
|
5
|
-
it { expect(Rails.configuration.hello).to eq
|
3
|
+
describe 'Capistrano::Env::Railtie' do
|
4
|
+
describe 'use in application.rb' do
|
5
|
+
it { expect(Rails.configuration.hello).to eq 'WORLD' }
|
6
6
|
end
|
7
7
|
|
8
|
-
describe
|
9
|
-
it { expect(Rails.configuration.hoge).to eq
|
8
|
+
describe 'use in initializers' do
|
9
|
+
it { expect(Rails.configuration.hoge).to eq 'HAGE' }
|
10
10
|
end
|
11
11
|
end
|
data/spec/capistrano/env_spec.rb
CHANGED
data/spec/dummy/capenv.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
ENV[
|
2
|
-
ENV[
|
3
|
-
ENV[
|
1
|
+
ENV['HELLO'] = 'WORLD'
|
2
|
+
ENV['HOGE'] = 'HAGE'
|
3
|
+
ENV['TEST'] = '1,2,3'
|
data/spec/dummy/config/boot.rb
CHANGED
@@ -14,7 +14,7 @@ Dummy::Application.configure do
|
|
14
14
|
|
15
15
|
# Configure static asset server for tests with Cache-Control for performance.
|
16
16
|
config.serve_static_assets = true
|
17
|
-
config.static_cache_control =
|
17
|
+
config.static_cache_control = 'public, max-age=3600'
|
18
18
|
|
19
19
|
# Show full error reports and disable caching.
|
20
20
|
config.consider_all_requests_local = true
|
@@ -1 +1 @@
|
|
1
|
-
Rails.configuration.hoge = ENV[
|
1
|
+
Rails.configuration.hoge = ENV['HOGE']
|
@@ -0,0 +1,11 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
|
3
|
+
require 'capistrano'
|
4
|
+
|
5
|
+
ENV['RAILS_ENV'] ||= 'test'
|
6
|
+
require File.expand_path('../dummy/config/environment', __FILE__)
|
7
|
+
require 'rspec/rails'
|
8
|
+
require 'capistrano-env'
|
9
|
+
|
10
|
+
RSpec.configure do |_config|
|
11
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,60 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
RSpec
|
1
|
+
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
|
12
60
|
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.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- masarakki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -86,6 +86,20 @@ dependencies:
|
|
86
86
|
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rubocop
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
89
103
|
- !ruby/object:Gem::Dependency
|
90
104
|
name: sqlite3
|
91
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,6 +137,7 @@ extra_rdoc_files: []
|
|
123
137
|
files:
|
124
138
|
- ".gitignore"
|
125
139
|
- ".rspec"
|
140
|
+
- ".rubocop.yml"
|
126
141
|
- ".travis.yml"
|
127
142
|
- Gemfile
|
128
143
|
- Guardfile
|
@@ -190,6 +205,7 @@ files:
|
|
190
205
|
- spec/dummy/public/robots.txt
|
191
206
|
- spec/dummy/vendor/assets/javascripts/.keep
|
192
207
|
- spec/dummy/vendor/assets/stylesheets/.keep
|
208
|
+
- spec/rails_helper.rb
|
193
209
|
- spec/spec_helper.rb
|
194
210
|
homepage: https://github.com/masarakki/capistrano-env
|
195
211
|
licenses:
|
@@ -269,4 +285,5 @@ test_files:
|
|
269
285
|
- spec/dummy/public/robots.txt
|
270
286
|
- spec/dummy/vendor/assets/javascripts/.keep
|
271
287
|
- spec/dummy/vendor/assets/stylesheets/.keep
|
288
|
+
- spec/rails_helper.rb
|
272
289
|
- spec/spec_helper.rb
|