itamae 1.0.0.beta7 → 1.0.0.beta8

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: ef47c5b46afec4cac24288684ac44b1255f143b9
4
- data.tar.gz: 2166fff3decaf2661fdfbb0cd85507c44e24264a
3
+ metadata.gz: 42aaacb52f264283b58b0fe62dd723ec02a6f6f5
4
+ data.tar.gz: c288561f91f88f46979c43c4bd809f0ccb8a38b8
5
5
  SHA512:
6
- metadata.gz: 74ddbf1ad246f5c9b19a50a3e721543ca4b08d20c919e78bd6014fde7d9295afffdec00831327f99bf03aa979bec50bc94af841482a35dfb99c943b3b2885892
7
- data.tar.gz: 85b8732740ffbe73919cb630f67ace5aeeff435e10d43390244ff20a08c438489e65977c0c2f894796954d8586772ebea2fbbb8f0c26c055ce6f989e7977985c
6
+ metadata.gz: 8977726e0c923e4055af6ce1c0492e5e375cc461cc3d67516650c12354e6a6aff10cdd1aac4317fb5866609246efe204c1a8191de2164b55b1d93f6ec7c9f97b
7
+ data.tar.gz: b500d236ff804664009b79747be7e52068462a28dedb3b099f5a72f547da1f8df631d9e5bc3851b3e26a335a5ba1f984ce5fe279558d68a84fc76f356868f002
data/Rakefile CHANGED
@@ -62,3 +62,16 @@ namespace :spec do
62
62
  end
63
63
  end
64
64
  end
65
+
66
+ namespace :release do
67
+ desc "Bump up version and commit"
68
+ task :bump_up_version do
69
+ version_file = File.expand_path("lib/itamae/version.txt")
70
+ current_version = File.read(version_file)
71
+ open(version_file, "w") do |f|
72
+ f.write current_version.succ
73
+ end
74
+ system "git add #{version_file}"
75
+ system "git commit -m 'Bump up version'"
76
+ end
77
+ end
data/itamae.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  spec.add_runtime_dependency "thor"
21
- spec.add_runtime_dependency "specinfra", "2.0.0.beta36"
21
+ spec.add_runtime_dependency "specinfra", "2.0.0.beta37"
22
22
  spec.add_runtime_dependency "hashie"
23
23
  spec.add_runtime_dependency "ansi"
24
24
 
@@ -84,8 +84,8 @@ module Itamae
84
84
  end
85
85
  end
86
86
 
87
- def copy_file(*args)
88
- Specinfra::Runner.copy_file(*args)
87
+ def send_file(*args)
88
+ Specinfra::Runner.send_file(*args)
89
89
  end
90
90
  end
91
91
  end
@@ -108,9 +108,11 @@ module Itamae
108
108
 
109
109
  private
110
110
 
111
- def method_missing(method, *args)
111
+ def method_missing(method, *args, &block)
112
112
  if args.size == 1 && self.class.defined_attributes[method]
113
113
  return @attributes[method] = args.first
114
+ elsif args.size == 0 && block_given?
115
+ return @attributes[method] = block
114
116
  elsif args.size == 0 && @attributes.has_key?(method)
115
117
  return @attributes[method]
116
118
  end
@@ -162,12 +164,12 @@ module Itamae
162
164
  end
163
165
  end
164
166
 
165
- def copy_file(src, dst)
166
- Logger.debug " Copying a file from '#{src}' to '#{dst}'..."
167
+ def send_file(src, dst)
168
+ Logger.debug " Sending a file from '#{src}' to '#{dst}'..."
167
169
  unless ::File.exist?(src)
168
170
  raise Error, "The file '#{src}' doesn't exist."
169
171
  end
170
- backend.copy_file(src, dst)
172
+ backend.send_file(src, dst)
171
173
  end
172
174
 
173
175
  def only_if(command)
@@ -22,7 +22,7 @@ module Itamae
22
22
  end
23
23
 
24
24
  @temppath = ::File.join(runner.tmpdir, Time.now.to_f.to_s)
25
- copy_file(src, @temppath)
25
+ send_file(src, @temppath)
26
26
  end
27
27
 
28
28
  def set_current_attributes
@@ -70,12 +70,10 @@ module Itamae
70
70
  end
71
71
 
72
72
  if run_specinfra(:check_file_is_file, path)
73
- # TODO: specinfra
74
- run_command(["cp", path, "#{path}.bak"])
73
+ run_specinfra(:copy_file, path, "#{path}.bak")
75
74
  end
76
75
 
77
- # TODO: specinfra
78
- run_command(["mv", @temppath, path])
76
+ run_specinfra(:move_file, @temppath, path)
79
77
  end
80
78
  end
81
79
  end
@@ -0,0 +1,15 @@
1
+ require 'itamae'
2
+
3
+ module Itamae
4
+ module Resource
5
+ class LocalRubyBlock < Base
6
+ define_attribute :action, default: :run
7
+ define_attribute :block, type: Proc
8
+
9
+ def run_action
10
+ block.call
11
+ end
12
+ end
13
+ end
14
+ end
15
+
@@ -9,6 +9,7 @@ require 'itamae/resource/execute'
9
9
  require 'itamae/resource/mail_alias'
10
10
  require 'itamae/resource/service'
11
11
  require 'itamae/resource/link'
12
+ require 'itamae/resource/local_ruby_block'
12
13
 
13
14
  module Itamae
14
15
  module Resource
@@ -1,3 +1,3 @@
1
1
  module Itamae
2
- VERSION = "1.0.0.beta7"
2
+ VERSION = File.read(File.expand_path("../version.txt", __FILE__))
3
3
  end
@@ -0,0 +1 @@
1
+ 1.0.0.beta8
@@ -110,3 +110,12 @@ execute "test $(ps h -C nginx | wc -l) -eq 0" # test
110
110
  link "/tmp-link" do
111
111
  to "/tmp"
112
112
  end
113
+
114
+ #####
115
+
116
+ local_ruby_block "greeting" do
117
+ block do
118
+ Itamae::Logger.info "板前"
119
+ end
120
+ end
121
+
@@ -23,10 +23,10 @@ module Itamae
23
23
  describe "#create_action" do
24
24
  it "copies a file" do
25
25
  recipe.stub(:path).and_return("/recipe_dir/recipe_file")
26
- expect(subject).to receive(:copy_file).with("/recipe_dir/source.file", %r{^/tmp/itamae/[\d\.]+$})
26
+ expect(subject).to receive(:send_file).with("/recipe_dir/source.file", %r{^/tmp/itamae/[\d\.]+$})
27
27
  expect(subject).to receive(:run_specinfra).with(:check_file_is_file, "/path/to/dst").and_return(true)
28
- expect(subject).to receive(:run_command).with(["cp", "/path/to/dst", "/path/to/dst.bak"])
29
- expect(subject).to receive(:run_command).with(["mv", %r{/tmp/itamae/[\d\.]+}, "/path/to/dst"])
28
+ expect(subject).to receive(:run_specinfra).with(:copy_file, "/path/to/dst", "/path/to/dst.bak")
29
+ expect(subject).to receive(:run_specinfra).with(:move_file, %r{/tmp/itamae/[\d\.]+}, "/path/to/dst")
30
30
  subject.pre_action
31
31
  subject.create_action
32
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itamae
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta7
4
+ version: 1.0.0.beta8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryota Arai
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 2.0.0.beta36
33
+ version: 2.0.0.beta37
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 2.0.0.beta36
40
+ version: 2.0.0.beta37
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: hashie
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -165,6 +165,7 @@ files:
165
165
  - lib/itamae/resource/execute.rb
166
166
  - lib/itamae/resource/file.rb
167
167
  - lib/itamae/resource/link.rb
168
+ - lib/itamae/resource/local_ruby_block.rb
168
169
  - lib/itamae/resource/mail_alias.rb
169
170
  - lib/itamae/resource/package.rb
170
171
  - lib/itamae/resource/remote_file.rb
@@ -173,6 +174,7 @@ files:
173
174
  - lib/itamae/resource_collection.rb
174
175
  - lib/itamae/runner.rb
175
176
  - lib/itamae/version.rb
177
+ - lib/itamae/version.txt
176
178
  - spec/integration/Vagrantfile
177
179
  - spec/integration/default_spec.rb
178
180
  - spec/integration/recipes/default.rb