itamae-plugin-resource-remote_template_directory 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4d804778d8d9f92478cef8c13ef381db7165ba17
4
+ data.tar.gz: c2e046a12627ba24e29327cc94002e0a490f75d9
5
+ SHA512:
6
+ metadata.gz: 34160a42a1cc4cb49dcc5c69dbbdba0d54840e2e9d101d6a6ba9a6e21482a606bcb42e1085888828788fea9aa357c0f26dacb753945ee6120472fbdd2c5f5a17
7
+ data.tar.gz: 2be0004e3269f8342ae0f45640131d43e476e0ce7846f04c33989f60269928efb09566fc2b57041431f7ff9e37fe0c2d6f0fd01118e7a537f65372599d3922c1
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /vendor
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.15.3
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in itamae-plugin-resource-remote_template_directory.gemspec
6
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 tyage
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,75 @@
1
+ # Itamae::Plugin::Resource::RemoteTemplateDirectory
2
+
3
+ Extended remote_directory resource which each local file is template.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'itamae-plugin-resource-remote_template_directory'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install itamae-plugin-resource-remote_template_directory
20
+
21
+ ## Usage
22
+
23
+ Basic actions and attributes are same as [remote_directory resource](https://github.com/itamae-kitchen/itamae/wiki/remote_directory-resource).
24
+ Also, `variables` attribute of [template resource](https://github.com/itamae-kitchen/itamae/wiki/template-resource) is available.
25
+
26
+ Here is sample recipe and its result.
27
+
28
+ `recipe.rb`
29
+
30
+ ```rb
31
+ node.reverse_merge!(
32
+ var: 'value of node var'
33
+ )
34
+
35
+ remote_template_directory 'copy directory' do
36
+ source 'sample_directories'
37
+ path '/tmp/remote_template_directory'
38
+ variables(
39
+ var1: 'value of var1',
40
+ var2: 'value of var2'
41
+ )
42
+ end
43
+ ```
44
+
45
+ `sample_directories/test`
46
+
47
+ ```rb
48
+ here is template
49
+ <%= @var1 %>
50
+ <%= @var2 %>
51
+ <%= node[:var] %>
52
+ ```
53
+
54
+ `/tmp/remote_template_directory/test`
55
+
56
+ ```
57
+ here is template
58
+ value of var1
59
+ value of var2
60
+ value of node var
61
+ ```
62
+
63
+ ## Development
64
+
65
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake true` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
66
+
67
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
68
+
69
+ ## Contributing
70
+
71
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/itamae-plugin-resource-remote_template_directory.
72
+
73
+ ## License
74
+
75
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,34 @@
1
+ require 'rake'
2
+ require 'rspec/core/rake_task'
3
+
4
+ task :spec => 'spec:all'
5
+ task :default => :spec
6
+
7
+ namespace :itamae do
8
+ task 'localhost' do
9
+ system('bundle exec itamae local spec/recipe.rb') || abort
10
+ end
11
+ end
12
+
13
+ namespace :spec do
14
+
15
+ targets = []
16
+ Dir.glob('./spec/*').each do |dir|
17
+ next unless File.directory?(dir)
18
+ target = File.basename(dir)
19
+ target = "_#{target}" if target == "default"
20
+ targets << target
21
+ end
22
+
23
+ task :all => targets
24
+ task :default => :all
25
+
26
+ targets.each do |target|
27
+ original_target = target == "_default" ? target[1..-1] : target
28
+ desc "Run serverspec tests to #{original_target}"
29
+ RSpec::Core::RakeTask.new(target.to_sym) do |t|
30
+ ENV['TARGET_HOST'] = original_target
31
+ t.pattern = "spec/#{original_target}/*_spec.rb"
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "itamae/plugin/resource/remote_template_directory"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "itamae-plugin-resource-remote_template_directory"
7
+ spec.version = "0.1.0"
8
+ spec.authors = ["tyage"]
9
+ spec.email = ["namatyage@gmail.com"]
10
+
11
+ spec.summary = %q{Extended itamae's remote_directory resource which each local file is template.}
12
+ spec.description = %q{Extended itamae's remote_directory resource which each local file is template.}
13
+ spec.homepage = "https://github.com/tyage/itamae-plugin-resource-remote_template_directory"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_dependency "itamae"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.15"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec"
28
+ spec.add_development_dependency "serverspec"
29
+ end
@@ -0,0 +1,36 @@
1
+ require 'itamae'
2
+ require 'pathname'
3
+
4
+ module Itamae
5
+ module Plugin
6
+ module Resource
7
+ class RemoteTemplateDirectory < ::Itamae::Resource::RemoteDirectory
8
+ define_attribute :variables, type: Hash, default: {}
9
+
10
+ def pre_action
11
+ super
12
+
13
+ directory = ::File.expand_path(attributes.source, ::File.dirname(@recipe.path))
14
+ src = ::File.expand_path(directory, ::File.dirname(@recipe.path))
15
+
16
+ render_and_send_directory(src)
17
+ end
18
+
19
+ def render_and_send_directory(src_path)
20
+ ::Dir[ ::File.join(src_path, '**', '*') ]
21
+ .reject { |p| ::File.directory? p }
22
+ .each { |source_file|
23
+ relative_path = Pathname.new(source_file).relative_path_from(Pathname.new(src_path))
24
+ remote_file = ::File.expand_path(relative_path, @temppath)
25
+
26
+ content = ::Itamae::Resource::Template::RenderContext.new(self).render_file(source_file)
27
+ local_file = Tempfile.open('itamae')
28
+ local_file.write(content)
29
+ local_file.close
30
+ backend.send_file(local_file.path, remote_file)
31
+ }
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: itamae-plugin-resource-remote_template_directory
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - tyage
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-08-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: itamae
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.15'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.15'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: serverspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Extended itamae's remote_directory resource which each local file is
84
+ template.
85
+ email:
86
+ - namatyage@gmail.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".travis.yml"
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - bin/console
99
+ - bin/setup
100
+ - itamae-plugin-resource-remote_template_directory.gemspec
101
+ - lib/itamae/plugin/resource/remote_template_directory.rb
102
+ homepage: https://github.com/tyage/itamae-plugin-resource-remote_template_directory
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.6.11
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: Extended itamae's remote_directory resource which each local file is template.
126
+ test_files: []