capistrano-template 0.0.7 → 0.0.8

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: cf1b76bed38d227a7b50b774e670a58bbc31baf5
4
- data.tar.gz: 347549beb8f5546df3002e1c5000e6b0c3d5ca81
3
+ metadata.gz: 7b458e887b43a265af8ce91bda6ec7e465f729ed
4
+ data.tar.gz: 3b19ea31edec13a9dfdaaa499db38b2972104fa4
5
5
  SHA512:
6
- metadata.gz: 9957f08403791cb36451ed1a12fbd036f7a8bb35aaf052330699bc9cb8ccfaff801f5965705daf222eeb35e1f8d69b56ff12ce524819357d5a4aeb0e620fe717
7
- data.tar.gz: 17ee68b87d83147ee93f0552d1a14f52da956b20a425a810aa019c7cdadd25a4055cacda8d5537f90040cd4a3411d28e270361713121386015c4e60959fe620a
6
+ metadata.gz: 30d9ed7fe3aba66ceb09754552706325633988b07bfd80f8c2a357c91b09791b184f2706fa615b6e783a95ca8f7e598da92a10fba6831e044a966bf044cb48bb
7
+ data.tar.gz: 36255e01b86881597082e3517055b6818985075335542f9a3b483e89fef26dca4ad533dbb7487de1a6df769532b0f56c93d8d90bbbd5ae0a5444960630d0932f
data/.travis.yml CHANGED
@@ -3,6 +3,7 @@ rvm:
3
3
  - 2.1.5
4
4
  - 2.2.1
5
5
  - 2.3.1
6
+ - 2.4.0
6
7
  script: bundle exec rake spec rubocop
7
8
  cache: bundler
8
9
  before_install:
data/.versions.conf CHANGED
@@ -1,4 +1,4 @@
1
- ruby=ruby-2.3.1
1
+ ruby=ruby-2.4.0
2
2
  ruby-gemset=capistrano-template
3
3
  #ruby-gem-install=bundler rake
4
4
  #ruby-bundle-install=true
data/CHANGELOG.md CHANGED
@@ -1,23 +1,35 @@
1
- 0.0.7 (Next)
2
- =============
1
+ 0.0.9 (next)
2
+ ==================
3
3
 
4
+ 0.0.8 (21/05/2017)
5
+ ==================
6
+
7
+ #### Features
8
+
9
+ * [#12](https://github.com/faber-lotto/capistrano-template/pull/12): Add support for partial rendering (Inspired by [@n-rodriguez]). [@slowjack2k](https://github.com/slowjack2k).
4
10
 
5
- 0.0.6 (28/09/2016)
6
- =============
11
+
12
+ 0.0.7 (28/09/2016)
13
+ ==================
7
14
 
8
15
  #### Features
9
16
 
10
- * [#6](https://github.com/faber-lotto/capistrano-template/6): Add dry run support. [@claudusd](https://github.com/claudusd).
11
- * [#9](https://github.com/faber-lotto/capistrano-template/9): Add support for setting file owner. [@slowjack2k](https://github.com/slowjack2k).
12
- * [#10](https://github.com/faber-lotto/capistrano-template/10): Add support for within block. [@slowjack2k](https://github.com/slowjack2k).
17
+ * [#6](https://github.com/faber-lotto/capistrano-template/pull/6): Add dry run support. [@claudusd](https://github.com/claudusd).
18
+ * [#9](https://github.com/faber-lotto/capistrano-template/pull/9): Add support for setting file owner. [@slowjack2k](https://github.com/slowjack2k).
19
+ * [#10](https://github.com/faber-lotto/capistrano-template/pull/10): Add support for within block. [@slowjack2k](https://github.com/slowjack2k).
20
+
21
+ 0.0.6 (28/09/2016)
22
+ ==================
23
+
24
+ skipped
13
25
 
14
26
  0.0.5 (27/07/2016)
15
27
  ==================
16
28
 
17
29
  #### Features
18
30
 
19
- * [#5](https://github.com/faber-lotto/capistrano-template/5): Enable the usage of locals. [@slowjack2k](https://github.com/slowjack2k).
31
+ * [#5](https://github.com/faber-lotto/capistrano-template/pull/5): Enable the usage of locals. [@slowjack2k](https://github.com/slowjack2k).
20
32
 
21
33
  #### Fixes
22
34
 
23
- * [#4](https://github.com/faber-lotto/capistrano-template/4): Fix for `Digest::Base cannot be directly inherited in Ruby` race condition within ruby digest - [@slowjack2k](https://github.com/slowjack2k).
35
+ * [#4](https://github.com/faber-lotto/capistrano-template/pull/4): Fix for `Digest::Base cannot be directly inherited in Ruby` race condition within ruby digest - [@slowjack2k](https://github.com/slowjack2k).
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in capistrano-template.gemspec
4
4
  gemspec
5
5
 
6
- gem 'simplecov', require: false, group: :test
7
6
  gem 'coveralls', require: false
8
7
  gem 'rubocop', require: false
8
+ gem 'simplecov', require: false, group: :test
9
9
 
data/README.md CHANGED
@@ -78,6 +78,8 @@ In your Capfile:
78
78
  server_name <%= host.properties.fetch(:host_server_name) %>;
79
79
  root <%= remote_path_for(current_path) %>/public;
80
80
 
81
+ <%= render 'partial.conf', indent: 2, locals: { 'other_local' => 'other local value' } %>
82
+
81
83
  location ^~ /assets/ {
82
84
  gzip_static on;
83
85
  expires max;
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'capistrano/template/version'
@@ -28,7 +29,7 @@ the remote host or the content did change)
28
29
  spec.add_development_dependency 'bundler', '~> 1.5'
29
30
  spec.add_development_dependency 'rake'
30
31
 
31
- spec.add_development_dependency 'rspec', '3.0.0'
32
+ spec.add_development_dependency 'rspec', '3.5.0'
32
33
  # show nicely how many specs have to be run
33
34
  spec.add_development_dependency 'fuubar'
34
35
  # extended console
@@ -23,7 +23,7 @@ module Capistrano
23
23
 
24
24
  def paths_for_file(filename)
25
25
  paths.map do |path|
26
- path = path % { host: host }
26
+ path = format(path, host: host)
27
27
  ["#{path}/#{filename}.erb", "#{path}/#{filename}"]
28
28
  end.flatten
29
29
  end
@@ -34,6 +34,17 @@ module Capistrano
34
34
  end
35
35
  end
36
36
 
37
+ def render(from, indent: 0, locals: {})
38
+ template = template_file(from)
39
+ content = Renderer.new(template, self, reader: reader, locals: self.locals.merge(locals)).as_str
40
+
41
+ indented_content(content, indent)
42
+ end
43
+
44
+ def indented_content(content, indent)
45
+ content.split("\n").map { |line| "#{' ' * indent}#{line}" }.join("\n")
46
+ end
47
+
37
48
  def respond_to_missing?(m, include_private)
38
49
  if locals.key?(m)
39
50
  true
@@ -125,29 +125,26 @@ module Capistrano
125
125
  end
126
126
 
127
127
  def digest_cmd
128
- @digest_cmd % { digest: digest,
129
- path: full_to_path }
128
+ format @digest_cmd , digest: digest,
129
+ path: full_to_path
130
130
  end
131
131
 
132
132
  def mode_test_cmd
133
- @mode_test_cmd % {
133
+ format @mode_test_cmd,
134
134
  path: full_to_path,
135
135
  mode: octal_mode_str
136
- }
137
136
  end
138
137
 
139
138
  def user_test_cmd
140
- @user_test_cmd % {
139
+ format @user_test_cmd ,
141
140
  path: full_to_path,
142
141
  user: user
143
- }
144
142
  end
145
143
 
146
144
  def group_test_cmd
147
- @group_test_cmd % {
145
+ format @group_test_cmd,
148
146
  path: full_to_path,
149
147
  group: group
150
- }
151
148
  end
152
149
  end
153
150
  # rubocop: enable Metrics/ModuleLength
@@ -1,15 +1,15 @@
1
1
  namespace :load do
2
2
  # rubocop:disable LineLength
3
3
  task :defaults do
4
- set :templating_digster, ->{ ->(data){ OpenSSL::Digest::MD5.hexdigest(data)} }
4
+ set(:templating_digster, ->{ ->(data){ OpenSSL::Digest::MD5.hexdigest(data)} })
5
5
  set :templating_digest_cmd, %Q{test "Z$(openssl md5 %<path>s| sed 's/^.*= *//')" = "Z%<digest>s" } # alternative %Q{echo "%<digest>s %<path>s" | md5sum -c --status } should return true when the file content is the same
6
6
  set :templating_mode_test_cmd, %Q{ [ "Z$(printf "%%.4o" 0$(stat -c "%%a" %<path>s 2>/dev/null || stat -f "%%A" %<path>s))" != "Z%<mode>s" ] } # mac uses different mode formatter
7
7
  set :templating_user_test_cmd, %Q{ [ "Z$(stat -c "%%U" %<path>s 2>/dev/null)" != "Z%<user>s" ] } # should return true when user is different
8
8
  set :templating_group_test_cmd, %Q{ [ "Z$(stat -c "%%G" %<path>s 2>/dev/null)" != "Z%<group>s" ] } # should return true when group is different
9
- set :templating_paths , ->{ ["config/deploy/templates/#{fetch(:stage)}/%<host>s",
9
+ set(:templating_paths , ->{ ["config/deploy/templates/#{fetch(:stage)}/%<host>s",
10
10
  "config/deploy/templates/#{fetch(:stage)}",
11
11
  "config/deploy/templates/shared/%<host>s",
12
- "config/deploy/templates/shared"].map {|partial_path| (partial_path)} }
12
+ "config/deploy/templates/shared"].map {|partial_path| (partial_path)} })
13
13
  end
14
14
  # rubocop:enable LineLength
15
15
  end
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Template
3
- VERSION = '0.0.7'
3
+ VERSION = '0.0.8'
4
4
  end
5
5
  end
@@ -55,14 +55,11 @@ module Capistrano
55
55
  `#{cmd}`
56
56
  end
57
57
 
58
- def info(*)
59
- end
58
+ def info(*); end
60
59
 
61
- def error(*)
62
- end
60
+ def error(*); end
63
61
 
64
- def pwd_path
65
- end
62
+ def pwd_path; end
66
63
 
67
64
  def dry_run?
68
65
  false
@@ -71,6 +68,7 @@ module Capistrano
71
68
  end
72
69
  end
73
70
 
71
+ # rubocop:disable Metrics/BlockLength
74
72
  describe DSL do
75
73
  subject do
76
74
  Integration::DSLSpec::Dummy.new.tap do |d|
@@ -122,6 +120,7 @@ module Capistrano
122
120
 
123
121
  end
124
122
  end
123
+ # rubocop:enable Metrics/BlockLength
125
124
  end
126
125
  end
127
126
  end
@@ -3,6 +3,7 @@ require 'spec_helper'
3
3
  module Capistrano
4
4
  module Template
5
5
  module Helpers
6
+ # rubocop: disable Metrics/BlockLength
6
7
  describe PathsLookup do
7
8
  subject do
8
9
  PathsLookup.new(lookup_paths, context)
@@ -41,6 +42,7 @@ module Capistrano
41
42
  end
42
43
 
43
44
  end
45
+ # rubocop: enable Metrics/BlockLength
44
46
  end
45
47
  end
46
48
  end
@@ -2,6 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  module Capistrano
4
4
  module Template
5
+ # rubocop: disable Metrics/BlockLength
5
6
  module Helpers
6
7
  describe Uploader do
7
8
 
@@ -95,5 +96,6 @@ module Capistrano
95
96
 
96
97
  end
97
98
  end
99
+ # rubocop: enable Metrics/BlockLength
98
100
  end
99
101
  end
@@ -2,6 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  module Capistrano
4
4
  module Template
5
+ # rubocop: disable Metrics/BlockLength
5
6
  module Helpers
6
7
  describe PathsLookup do
7
8
  subject do
@@ -50,5 +51,6 @@ module Capistrano
50
51
 
51
52
  end
52
53
  end
54
+ # rubocop: enable Metrics/BlockLength
53
55
  end
54
56
  end
@@ -3,22 +3,35 @@ require 'spec_helper'
3
3
  module Capistrano
4
4
  module Template
5
5
  module Helpers
6
+ # rubocop: disable Metrics/BlockLength, Metrics/LineLength
6
7
  describe Renderer do
7
8
 
8
9
  subject do
9
10
  Renderer.new(template_name, context, reader: reader, locals: locals)
10
11
  end
11
12
 
12
- let(:context) { OpenStruct.new(var1: 'my', var2: 'content') }
13
+ let(:context) do
14
+ cnt = OpenStruct.new(var1: 'my', var2: 'content')
15
+ cnt.extend(Capistrano::Template::Helpers::DSL)
16
+ def cnt.template_file(_)
17
+ 'partial.conf'
18
+ end
19
+ cnt
20
+ end
13
21
  let(:locals) { { 'my_local' => 'local content' } }
14
22
  let(:template_name) { 'my_template' }
15
- let(:reader) { double(read: template_content) }
16
- let(:template_content) { '<%=var1%> -- <%=var2%> -- <%= my_local %>' }
23
+ let(:reader) do
24
+ reader = double
25
+ allow(reader).to receive(:read).and_return(main_template_content, partial_template_content)
26
+ reader
27
+ end
28
+ let(:main_template_content) { "<%=var1%> -- <%=var2%>\n<%= render 'partial.conf', indent: 2, locals: { 'my_local' => 'partial local content' } %>\n -- <%= my_local %>" }
29
+ let(:partial_template_content) { "--partial: <%=var1%>\n--partial: <%=var2%>\n--partial: <%= my_local %>" }
17
30
 
18
31
  describe '#as_str' do
19
32
 
20
33
  it 'renders a erb template' do
21
- expect(subject.as_str).to eq('my -- content -- local content')
34
+ expect(subject.as_str).to eq("my -- content\n --partial: my\n --partial: content\n --partial: partial local content\n -- local content")
22
35
  end
23
36
 
24
37
  end
@@ -50,5 +63,6 @@ module Capistrano
50
63
 
51
64
  end
52
65
  end
66
+ # rubocop: enable Metrics/BlockLength, Metrics/LineLength
53
67
  end
54
68
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  module Capistrano
4
4
  module Template
5
- # rubocop: disable Metrics/ModuleLength
5
+ # rubocop: disable Metrics/ModuleLength, Metrics/BlockLength
6
6
  module Helpers
7
7
  describe Uploader do
8
8
 
@@ -147,7 +147,7 @@ module Capistrano
147
147
  allow(subject).to receive(:__check__)
148
148
  subject.permission_changed?
149
149
 
150
- expect(subject).to have_received(:__check__).with(mode_test_cmd % { mode: '0640', path: remote_filename_expented })
150
+ expect(subject).to have_received(:__check__).with(format(mode_test_cmd, mode: '0640', path: remote_filename_expented))
151
151
  end
152
152
  end
153
153
 
@@ -160,12 +160,12 @@ module Capistrano
160
160
  it 'checks the actual user' do
161
161
  allow(subject).to receive(:__check__)
162
162
  subject.user_changed?
163
- expect(subject).to have_received(:__check__).with(user_test_cmd % { user: 'deploy', path: remote_filename_expented })
163
+ expect(subject).to have_received(:__check__).with(format(user_test_cmd, user: 'deploy', path: remote_filename_expented))
164
164
  end
165
165
  end
166
166
 
167
167
  end
168
- # rubocop: enable Metrics/ModuleLength
168
+ # rubocop: enable Metrics/ModuleLength, Metrics/BlockLength
169
169
  end
170
170
  end
171
171
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-template
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dieter Späth
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-28 00:00:00.000000000 Z
11
+ date: 2017-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 3.0.0
61
+ version: 3.5.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 3.0.0
68
+ version: 3.5.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: fuubar
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -178,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
178
  version: '0'
179
179
  requirements: []
180
180
  rubyforge_project:
181
- rubygems_version: 2.5.1
181
+ rubygems_version: 2.6.11
182
182
  signing_key:
183
183
  specification_version: 4
184
184
  summary: Erb-Template rendering and upload for capistrano 3