itamae-default_attributes 0.1.0 → 0.1.1
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/lib/itamae/default_attributes.rb +3 -4
- data/lib/itamae/default_attributes/attributes_loader.rb +36 -0
- data/lib/itamae/default_attributes/extension.rb +4 -6
- data/lib/itamae/default_attributes/version.rb +1 -1
- metadata +2 -2
- data/lib/itamae/default_attributes/eval_context.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 957c6c9b309794648a67895b28dcdf1c62bf5a5b
|
4
|
+
data.tar.gz: fc5135ff3747da90969cc17d27e3f548a98cdd34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e558c319411b5ec1fbfe8722e6d6cdc64571de499b1f8443c76d6f2c5cac15338ff1b95732e04d3bfd1a70e0c134a56984b8bbbabd84b49d4bd72bc80e350c4d
|
7
|
+
data.tar.gz: 70624f1f52d9245149d9e16ae23b40eb25f0dd00332cd3d1be586847237e1c7d06430e00be2f205b6fc12db83ca28e095755be9b6e0a2186c1c5711c40ad0f0f
|
@@ -2,13 +2,12 @@ require "itamae/default_attributes/version"
|
|
2
2
|
|
3
3
|
module Itamae
|
4
4
|
module DefaultAttributes
|
5
|
-
def self.loaded_paths
|
6
|
-
@loaded_paths ||= []
|
7
|
-
end
|
8
5
|
end
|
9
6
|
end
|
10
7
|
|
11
|
-
require "itamae/default_attributes/
|
8
|
+
require "itamae/default_attributes/attributes_loader"
|
12
9
|
require "itamae/default_attributes/extension"
|
13
10
|
|
11
|
+
require "itamae/recipe"
|
12
|
+
|
14
13
|
Itamae::Recipe.send(:prepend, Itamae::DefaultAttributes::Extension)
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Itamae
|
2
|
+
module DefaultAttributes
|
3
|
+
class AttributesLoader
|
4
|
+
class << self
|
5
|
+
def loaded?(path)
|
6
|
+
loaded_paths.include?(path)
|
7
|
+
end
|
8
|
+
|
9
|
+
def loaded_paths
|
10
|
+
@loaded_paths ||= []
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_reader :recipe, :path
|
15
|
+
|
16
|
+
def initialize(recipe, path)
|
17
|
+
@recipe = recipe
|
18
|
+
@path = path
|
19
|
+
end
|
20
|
+
|
21
|
+
def load
|
22
|
+
return if self.class.loaded?(path)
|
23
|
+
return unless File.exist?(path)
|
24
|
+
|
25
|
+
instance_eval(File.read(path), path, 1)
|
26
|
+
self.class.loaded_paths << path
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def attributes(attributes_hash)
|
32
|
+
recipe.runner.node.reverse_merge!(attributes_hash)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -2,15 +2,13 @@ module Itamae
|
|
2
2
|
module DefaultAttributes
|
3
3
|
module Extension
|
4
4
|
def load(vars = {})
|
5
|
-
|
5
|
+
attributes_loader.load
|
6
6
|
super
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
10
|
-
|
11
|
-
|
12
|
-
context.instance_eval(File.read(attributes_path), attributes_path, 1)
|
13
|
-
Itamae::DefaultAttributes.loaded_paths << attributes_path
|
9
|
+
def attributes_loader
|
10
|
+
@attributes_loader ||=
|
11
|
+
Itamae::DefaultAttributes::AttributesLoader.new(self, attributes_path)
|
14
12
|
end
|
15
13
|
|
16
14
|
def attributes_path
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itamae-default_attributes
|
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
|
- nownabe
|
@@ -69,7 +69,7 @@ files:
|
|
69
69
|
- bin/setup
|
70
70
|
- itamae-default_attributes.gemspec
|
71
71
|
- lib/itamae/default_attributes.rb
|
72
|
-
- lib/itamae/default_attributes/
|
72
|
+
- lib/itamae/default_attributes/attributes_loader.rb
|
73
73
|
- lib/itamae/default_attributes/extension.rb
|
74
74
|
- lib/itamae/default_attributes/version.rb
|
75
75
|
homepage: https://github.com/nownabe/itamae-default_attributes
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Itamae
|
2
|
-
module DefaultAttributes
|
3
|
-
class EvalContext
|
4
|
-
attr_reader :recipe
|
5
|
-
|
6
|
-
def initialize(recipe)
|
7
|
-
@recipe = recipe
|
8
|
-
end
|
9
|
-
|
10
|
-
def attributes(attributes_hash)
|
11
|
-
recipe.runner.node.reverse_merge!(attributes_hash)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|