itamae 1.1.14 → 1.1.15
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/itamae/resource.rb +1 -0
- data/lib/itamae/resource/gem_package.rb +75 -0
- data/lib/itamae/version.txt +1 -1
- data/spec/integration/default_spec.rb +4 -0
- data/spec/integration/recipes/default.rb +11 -0
- data/spec/integration/recipes/included.rb +8 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb42826bba792530fdfbde606bce17da2fe48f68
|
4
|
+
data.tar.gz: 28962bf4afabcc6d4fd72e69a554427cf787aab0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5179c4d4a9041b15cfa4e0373e3b6dc0c9442a7b83523debd430fc0893916cd2001be66d4665b0afaf52ca571552f8f2ed8174e64840b177c88e439616984d83
|
7
|
+
data.tar.gz: eb6a9f40068cd75fc0e78ac9f23daeb57735c92a30c98abf52e02c49111c8d36454c3006a8aa78b9794e4da844da74ad87709587819e60e8b94cfc374038aefe
|
data/CHANGELOG.md
CHANGED
data/lib/itamae/resource.rb
CHANGED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'itamae'
|
2
|
+
|
3
|
+
module Itamae
|
4
|
+
module Resource
|
5
|
+
class GemPackage < Base
|
6
|
+
define_attribute :action, default: :install
|
7
|
+
define_attribute :package_name, type: String, default_name: true
|
8
|
+
define_attribute :gem_binary, type: String, default: 'gem'
|
9
|
+
define_attribute :version, type: String
|
10
|
+
|
11
|
+
def pre_action
|
12
|
+
case @current_action
|
13
|
+
when :install
|
14
|
+
attributes.installed = true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def set_current_attributes
|
19
|
+
installed = installed_gems.find {|g| g[:name] == attributes.package_name }
|
20
|
+
current.installed = !!installed
|
21
|
+
|
22
|
+
if current.installed
|
23
|
+
versions = installed[:versions]
|
24
|
+
if versions.include?(attributes.version)
|
25
|
+
current.version = attributes.version
|
26
|
+
else
|
27
|
+
current.version = versions.first
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def action_install(action_options)
|
33
|
+
if current.installed
|
34
|
+
if attributes.version && current.version != attributes.version
|
35
|
+
install!
|
36
|
+
updated!
|
37
|
+
end
|
38
|
+
else
|
39
|
+
install!
|
40
|
+
updated!
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def action_upgrade(action_options)
|
45
|
+
return if current.installed && attributes.version && current.version == attributes.version
|
46
|
+
|
47
|
+
install!
|
48
|
+
updated!
|
49
|
+
end
|
50
|
+
|
51
|
+
def installed_gems
|
52
|
+
gems = []
|
53
|
+
run_command([attributes.gem_binary, 'list', '-l']).stdout.each_line do |line|
|
54
|
+
if /\A([^ ]+) \(([^\)]+)\)\z/ =~ line.strip
|
55
|
+
name = $1
|
56
|
+
versions = $2.split(', ')
|
57
|
+
gems << {name: name, versions: versions}
|
58
|
+
end
|
59
|
+
end
|
60
|
+
gems
|
61
|
+
end
|
62
|
+
|
63
|
+
def install!
|
64
|
+
cmd = [attributes.gem_binary, 'install']
|
65
|
+
if attributes.version
|
66
|
+
cmd << '-v' << attributes.version
|
67
|
+
end
|
68
|
+
cmd << attributes.package_name
|
69
|
+
|
70
|
+
run_command(cmd)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
data/lib/itamae/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.15
|
@@ -1,4 +1,5 @@
|
|
1
1
|
include_recipe "./included.rb"
|
2
|
+
include_recipe "./included.rb" # including the same recipe is expected to be skipped.
|
2
3
|
|
3
4
|
user "create itamae user" do
|
4
5
|
uid 123
|
@@ -26,6 +27,16 @@ end
|
|
26
27
|
|
27
28
|
######
|
28
29
|
|
30
|
+
gem_package 'tzinfo' do
|
31
|
+
version '1.1.0'
|
32
|
+
end
|
33
|
+
|
34
|
+
gem_package 'tzinfo' do
|
35
|
+
version '1.2.2'
|
36
|
+
end
|
37
|
+
|
38
|
+
######
|
39
|
+
|
29
40
|
execute "echo -n > /tmp/notifies"
|
30
41
|
|
31
42
|
execute "echo -n 1 >> /tmp/notifies" do
|
@@ -1 +1,9 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
included_flag_file = Pathname.new("/tmp/included_rb_is_included")
|
3
|
+
if included_flag_file.exist? && included_flag_file.read == $$.to_s
|
4
|
+
raise "included.rb should not be included twice."
|
5
|
+
else
|
6
|
+
included_flag_file.write($$.to_s)
|
7
|
+
end
|
8
|
+
|
1
9
|
execute "touch /tmp/included_recipe"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itamae
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryota Arai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02
|
11
|
+
date: 2015-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -171,6 +171,7 @@ files:
|
|
171
171
|
- lib/itamae/resource/directory.rb
|
172
172
|
- lib/itamae/resource/execute.rb
|
173
173
|
- lib/itamae/resource/file.rb
|
174
|
+
- lib/itamae/resource/gem_package.rb
|
174
175
|
- lib/itamae/resource/git.rb
|
175
176
|
- lib/itamae/resource/group.rb
|
176
177
|
- lib/itamae/resource/link.rb
|