hibachi 0.0.1.pre → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hibachi/node.rb +6 -4
- data/lib/hibachi/persistence.rb +1 -1
- data/lib/hibachi/querying.rb +6 -0
- data/lib/hibachi/recipe.rb +5 -5
- data/lib/hibachi/version.rb +1 -1
- data/spec/fixtures/chef.json +0 -3
- data/spec/hibachi/chef_runner_spec.rb +2 -2
- data/spec/hibachi/{store_spec.rb → persistence_spec.rb} +4 -2
- data/spec/hibachi/recipe_spec.rb +39 -16
- data/spec/support/mock_setting.rb +1 -2
- data/spec/support/singleton_setting.rb +5 -0
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54dc5e3824748620f18d9f3042b2ddd98416a874
|
4
|
+
data.tar.gz: 245a686100d27ee774ef1c4f9bd0d56b113c4d66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f0070bd2bf79c7c7e33d2374c04cdc0cf1b8f2bb9938d008cb345c14aca44b0991ec7b14f6b5ba73ad1930487f6b97c4f4299e2741710910e0da499985ef219
|
7
|
+
data.tar.gz: 56b4d417289b1ee8579056eaeb9477d896b937396041e819382249719e0e42a4a99938e75bda9b9c5d164a29f49d3cb3109d285696d2e3e578d363a3408675a4
|
data/lib/hibachi/node.rb
CHANGED
@@ -11,7 +11,7 @@ module Hibachi
|
|
11
11
|
include ActiveModel::Model
|
12
12
|
include Enumerable
|
13
13
|
|
14
|
-
attr_accessor :
|
14
|
+
attr_accessor :file_path
|
15
15
|
|
16
16
|
validates :file_path, presence: true
|
17
17
|
|
@@ -45,7 +45,7 @@ module Hibachi
|
|
45
45
|
attributes[key]
|
46
46
|
end
|
47
47
|
|
48
|
-
# Set the attribute at a given key.
|
48
|
+
# Set the attribute at a given key and update the JSON.
|
49
49
|
def []= key, value
|
50
50
|
merge! key => value
|
51
51
|
end
|
@@ -74,8 +74,10 @@ module Hibachi
|
|
74
74
|
@attributes ||= parsed_json_attributes[Hibachi.config.cookbook] || {}
|
75
75
|
end
|
76
76
|
|
77
|
-
|
78
|
-
|
77
|
+
def method_missing(method, *arguments)
|
78
|
+
attributes.send method, *arguments if attributes.respond_to? method
|
79
|
+
super
|
80
|
+
end
|
79
81
|
|
80
82
|
protected
|
81
83
|
# All attributes as parsed from the Chef JSON.
|
data/lib/hibachi/persistence.rb
CHANGED
data/lib/hibachi/querying.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Hibachi
|
2
2
|
module Querying
|
3
|
+
include Enumerable
|
4
|
+
|
3
5
|
# Write the given attrs to config and re-run Chef.
|
4
6
|
def create from_attributes={}
|
5
7
|
model = new from_attributes
|
@@ -13,6 +15,10 @@ module Hibachi
|
|
13
15
|
node[recipe_name].map { |from_params| new from_params }
|
14
16
|
end
|
15
17
|
|
18
|
+
def each
|
19
|
+
all.each { |model| yield model }
|
20
|
+
end
|
21
|
+
|
16
22
|
# Find all objects of this type matching the given search
|
17
23
|
# criteria. Uses the all() method to scope calls from within the
|
18
24
|
# proper JSON for this class, and instantiates objects based on
|
data/lib/hibachi/recipe.rb
CHANGED
@@ -13,8 +13,8 @@ module Hibachi
|
|
13
13
|
# touch this name. By default, this creates a 'collection' recipe.
|
14
14
|
def recipe name, options={}
|
15
15
|
self.recipe_name = name
|
16
|
-
from_opts =
|
17
|
-
self.recipe_type = ActiveSupport::StringInquirer.new from_opts
|
16
|
+
from_opts = options[:type] || 'collection'
|
17
|
+
self.recipe_type = ActiveSupport::StringInquirer.new from_opts.to_s
|
18
18
|
end
|
19
19
|
|
20
20
|
# An alias for `recipe` to give parity to `singleton_recipe`.
|
@@ -38,11 +38,11 @@ module Hibachi
|
|
38
38
|
# Return the recipe type as set in the class definition. It's a
|
39
39
|
# StringInquirer, so it defines methods that allow us to test
|
40
40
|
# whether this is a `collection?` or a `singleton?`.
|
41
|
-
def
|
41
|
+
def recipe_type
|
42
42
|
self.class.recipe_type
|
43
43
|
end
|
44
44
|
|
45
|
-
delegate :collection?, :to => :
|
46
|
-
delegate :singleton?, :to => :
|
45
|
+
delegate :collection?, :to => :recipe_type
|
46
|
+
delegate :singleton?, :to => :recipe_type
|
47
47
|
end
|
48
48
|
end
|
data/lib/hibachi/version.rb
CHANGED
data/spec/fixtures/chef.json
CHANGED
@@ -13,12 +13,12 @@ module Hibachi
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "runs chef" do
|
16
|
-
subject.
|
16
|
+
allow(subject).to receive(:run).and_return true
|
17
17
|
expect(subject.run_chef(:pro)).to eq(true)
|
18
18
|
end
|
19
19
|
|
20
20
|
it "runs chef in the background" do
|
21
|
-
subject.
|
21
|
+
allow(subject).to receive(:run_chef_in_bg).and_return true
|
22
22
|
expect(subject.run_chef(:pro, background: true)).to eq(true)
|
23
23
|
end
|
24
24
|
end
|
@@ -1,9 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'hibachi/
|
2
|
+
require 'hibachi/persistence'
|
3
3
|
|
4
4
|
module Hibachi
|
5
|
-
describe
|
5
|
+
describe Persistence do
|
6
6
|
it "creates a new model from scratch" do
|
7
|
+
expect(MockSetting.recipe_name).to eq(:mock_settings)
|
8
|
+
expect(MockSetting).to be_singleton
|
7
9
|
setting = MockSetting.create(name: 'from-scratch')
|
8
10
|
expect(setting).to be_persisted
|
9
11
|
expect(setting.destroy).to eq(true)
|
data/spec/hibachi/recipe_spec.rb
CHANGED
@@ -3,30 +3,53 @@ require 'hibachi/recipe'
|
|
3
3
|
|
4
4
|
module Hibachi
|
5
5
|
describe Recipe do
|
6
|
-
|
7
|
-
|
6
|
+
context "with a singleton setting" do
|
7
|
+
subject { SingletonSetting }
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
it "sets the recipe in the class definition" do
|
10
|
+
expect(subject.recipe_name).to eq(:singleton_settings)
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
it "sets the type of recipe in the class definition" do
|
14
|
+
expect(subject.recipe_type).to eq('singleton')
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
it "is a singleton" do
|
18
|
+
expect(subject).to be_singleton
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
21
|
+
context "with an instantiated setting" do
|
22
|
+
let(:setting) { subject.new name: 'test' }
|
23
|
+
|
24
|
+
it "is a singleton" do
|
25
|
+
expect(setting).to be_singleton
|
26
|
+
end
|
27
|
+
end
|
22
28
|
end
|
23
29
|
|
24
|
-
context "with
|
25
|
-
subject {
|
30
|
+
context "with a collection setting" do
|
31
|
+
subject { MockSetting }
|
26
32
|
|
27
|
-
it "
|
28
|
-
expect(subject).to
|
33
|
+
it "sets the recipe in the class definition" do
|
34
|
+
expect(subject.recipe_name).to eq(:mock_settings)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "sets the type of recipe in the class definition" do
|
38
|
+
expect(subject.recipe_type).to eq('collection')
|
39
|
+
end
|
40
|
+
|
41
|
+
it "is a collection" do
|
42
|
+
expect(subject).to be_collection
|
43
|
+
end
|
44
|
+
|
45
|
+
context "with an instantiated setting" do
|
46
|
+
let(:setting) { subject.new name: 'test' }
|
47
|
+
|
48
|
+
it "is a collection" do
|
49
|
+
expect(setting).to be_collection
|
50
|
+
end
|
29
51
|
end
|
30
52
|
end
|
53
|
+
|
31
54
|
end
|
32
55
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hibachi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Scott
|
@@ -214,12 +214,13 @@ files:
|
|
214
214
|
- spec/hibachi/configuration_spec.rb
|
215
215
|
- spec/hibachi/model_spec.rb
|
216
216
|
- spec/hibachi/node_spec.rb
|
217
|
+
- spec/hibachi/persistence_spec.rb
|
217
218
|
- spec/hibachi/recipe_spec.rb
|
218
|
-
- spec/hibachi/store_spec.rb
|
219
219
|
- spec/hibachi_spec.rb
|
220
220
|
- spec/spec_helper.rb
|
221
221
|
- spec/support/mock_setting.rb
|
222
222
|
- spec/support/mock_singleton.rb
|
223
|
+
- spec/support/singleton_setting.rb
|
223
224
|
homepage: http://github.com/tubbo/hibachi
|
224
225
|
licenses:
|
225
226
|
- NCSA
|
@@ -235,9 +236,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
235
236
|
version: '0'
|
236
237
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
237
238
|
requirements:
|
238
|
-
- - '
|
239
|
+
- - '>='
|
239
240
|
- !ruby/object:Gem::Version
|
240
|
-
version:
|
241
|
+
version: '0'
|
241
242
|
requirements: []
|
242
243
|
rubyforge_project:
|
243
244
|
rubygems_version: 2.0.3
|
@@ -290,10 +291,11 @@ test_files:
|
|
290
291
|
- spec/hibachi/configuration_spec.rb
|
291
292
|
- spec/hibachi/model_spec.rb
|
292
293
|
- spec/hibachi/node_spec.rb
|
294
|
+
- spec/hibachi/persistence_spec.rb
|
293
295
|
- spec/hibachi/recipe_spec.rb
|
294
|
-
- spec/hibachi/store_spec.rb
|
295
296
|
- spec/hibachi_spec.rb
|
296
297
|
- spec/spec_helper.rb
|
297
298
|
- spec/support/mock_setting.rb
|
298
299
|
- spec/support/mock_singleton.rb
|
300
|
+
- spec/support/singleton_setting.rb
|
299
301
|
has_rdoc:
|