state_mate 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +2 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +6 -0
- data/ansible/library/state +59 -0
- data/lib/state_mate.rb +366 -0
- data/lib/state_mate/adapters/defaults.rb +330 -0
- data/lib/state_mate/adapters/git_config.rb +35 -0
- data/lib/state_mate/adapters/json.rb +66 -0
- data/lib/state_mate/adapters/launchd.rb +117 -0
- data/lib/state_mate/adapters/nvram.rb +44 -0
- data/lib/state_mate/adapters/time_machine.rb +60 -0
- data/lib/state_mate/version.rb +3 -0
- data/notes/state-set-steps.md +26 -0
- data/spec/spec_helper.rb +44 -0
- data/spec/state_mate/adapters/defaults/hardware_uuid_spec.rb +15 -0
- data/spec/state_mate/adapters/defaults/hash_deep_write_spec.rb +33 -0
- data/spec/state_mate/adapters/defaults/read_defaults_spec.rb +57 -0
- data/spec/state_mate/adapters/defaults/read_spec.rb +32 -0
- data/spec/state_mate/adapters/defaults/read_type_spec.rb +27 -0
- data/spec/state_mate/adapters/defaults/write_spec.rb +29 -0
- data/spec/state_mate/adapters/git_config/read_spec.rb +36 -0
- data/spec/state_mate/adapters/git_config/write_spec.rb +17 -0
- data/spec/state_mate/adapters/json/read_spec.rb +56 -0
- data/spec/state_mate/adapters/json/write_spec.rb +54 -0
- data/spec/state_mate_spec.rb +7 -0
- data/state_mate.gemspec +25 -0
- data/test/ansible/ansible.cfg +5 -0
- data/test/ansible/clear +2 -0
- data/test/ansible/hosts +1 -0
- data/test/ansible/play +2 -0
- data/test/ansible/playbook.yml +38 -0
- data/test/ansible/read +2 -0
- metadata +167 -0
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
require 'state_mate/adapters/json'
|
6
|
+
|
7
|
+
describe "StateMate::Adapters::JSON.write" do
|
8
|
+
include_context "json"
|
9
|
+
|
10
|
+
context "root value" do
|
11
|
+
let(:value) {
|
12
|
+
{
|
13
|
+
"some_key" => "some value"
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
it "should write the value" do
|
18
|
+
json.write filepath, value
|
19
|
+
expect( JSON.load(File.read(filepath)) ).to eq value
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "deep value" do
|
24
|
+
let(:doc) {
|
25
|
+
{
|
26
|
+
"top-level-key" => {
|
27
|
+
'second-level-key' => "old value"
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
let(:key) {
|
33
|
+
[filepath, "top-level-key", "second-level-key"]
|
34
|
+
}
|
35
|
+
|
36
|
+
let(:value) {
|
37
|
+
"new value"
|
38
|
+
}
|
39
|
+
|
40
|
+
before(:each) {
|
41
|
+
File.open(filepath, 'w') do |f|
|
42
|
+
f.write JSON.dump(doc)
|
43
|
+
end
|
44
|
+
}
|
45
|
+
|
46
|
+
it "should write the value" do
|
47
|
+
json.write key, value
|
48
|
+
expect(
|
49
|
+
JSON.load(File.read(filepath))[key[1]][key[2]]
|
50
|
+
).to eq value
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
data/state_mate.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'state_mate/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "state_mate"
|
8
|
+
spec.version = StateMate::VERSION
|
9
|
+
spec.authors = ["nrser"]
|
10
|
+
spec.email = ["neil@ztkae.com"]
|
11
|
+
spec.summary = %q{i heard it's meant to help you with your state, mate!}
|
12
|
+
spec.homepage = "https://github.com/nrser/state_mate"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
spec.add_development_dependency "rspec"
|
23
|
+
spec.add_dependency 'nrser', '0.0.10'
|
24
|
+
spec.add_dependency 'CFPropertyList', '~> 2.3'
|
25
|
+
end
|
data/test/ansible/clear
ADDED
data/test/ansible/hosts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
localhost ansible_connection=local
|
data/test/ansible/play
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
---
|
2
|
+
- hosts: localhost
|
3
|
+
gather_facts: false
|
4
|
+
tasks:
|
5
|
+
# - name: test defaults
|
6
|
+
# state:
|
7
|
+
# defaults:
|
8
|
+
# - key: com.nrser.state_mate:x
|
9
|
+
# set: 1
|
10
|
+
# - key: com.nrser.state_mate:blah
|
11
|
+
# set:
|
12
|
+
# blow: me
|
13
|
+
# - key: com.nrser.state_mate:key with spaces
|
14
|
+
# set: value with spaces
|
15
|
+
|
16
|
+
# - name: test launchd
|
17
|
+
# state:
|
18
|
+
# launchd:
|
19
|
+
# key:
|
20
|
+
# - /System/Library/LaunchAgents/com.apple.notificationcenterui.plist
|
21
|
+
# - Disabled
|
22
|
+
# set: true
|
23
|
+
|
24
|
+
# - name: Disable local Time Machine snapshots
|
25
|
+
# #
|
26
|
+
# # sudo tmutil disablelocal
|
27
|
+
# #
|
28
|
+
# state:
|
29
|
+
# time_machine:
|
30
|
+
# key: local_backups
|
31
|
+
# set: false
|
32
|
+
# sudo: true
|
33
|
+
- name: test deep key
|
34
|
+
state:
|
35
|
+
defaults:
|
36
|
+
key: com.nrser.state_mate:x
|
37
|
+
set: en_US@currency=USD
|
38
|
+
|
data/test/ansible/read
ADDED
metadata
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: state_mate
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- nrser
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: nrser
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.0.10
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.0.10
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: CFPropertyList
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.3'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.3'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- neil@ztkae.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- ansible/library/state
|
97
|
+
- lib/state_mate.rb
|
98
|
+
- lib/state_mate/adapters/defaults.rb
|
99
|
+
- lib/state_mate/adapters/git_config.rb
|
100
|
+
- lib/state_mate/adapters/json.rb
|
101
|
+
- lib/state_mate/adapters/launchd.rb
|
102
|
+
- lib/state_mate/adapters/nvram.rb
|
103
|
+
- lib/state_mate/adapters/time_machine.rb
|
104
|
+
- lib/state_mate/version.rb
|
105
|
+
- notes/state-set-steps.md
|
106
|
+
- spec/spec_helper.rb
|
107
|
+
- spec/state_mate/adapters/defaults/hardware_uuid_spec.rb
|
108
|
+
- spec/state_mate/adapters/defaults/hash_deep_write_spec.rb
|
109
|
+
- spec/state_mate/adapters/defaults/read_defaults_spec.rb
|
110
|
+
- spec/state_mate/adapters/defaults/read_spec.rb
|
111
|
+
- spec/state_mate/adapters/defaults/read_type_spec.rb
|
112
|
+
- spec/state_mate/adapters/defaults/write_spec.rb
|
113
|
+
- spec/state_mate/adapters/git_config/read_spec.rb
|
114
|
+
- spec/state_mate/adapters/git_config/write_spec.rb
|
115
|
+
- spec/state_mate/adapters/json/read_spec.rb
|
116
|
+
- spec/state_mate/adapters/json/write_spec.rb
|
117
|
+
- spec/state_mate_spec.rb
|
118
|
+
- state_mate.gemspec
|
119
|
+
- test/ansible/ansible.cfg
|
120
|
+
- test/ansible/clear
|
121
|
+
- test/ansible/hosts
|
122
|
+
- test/ansible/play
|
123
|
+
- test/ansible/playbook.yml
|
124
|
+
- test/ansible/read
|
125
|
+
homepage: https://github.com/nrser/state_mate
|
126
|
+
licenses:
|
127
|
+
- MIT
|
128
|
+
metadata: {}
|
129
|
+
post_install_message:
|
130
|
+
rdoc_options: []
|
131
|
+
require_paths:
|
132
|
+
- lib
|
133
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
requirements: []
|
144
|
+
rubyforge_project:
|
145
|
+
rubygems_version: 2.2.2
|
146
|
+
signing_key:
|
147
|
+
specification_version: 4
|
148
|
+
summary: i heard it's meant to help you with your state, mate!
|
149
|
+
test_files:
|
150
|
+
- spec/spec_helper.rb
|
151
|
+
- spec/state_mate/adapters/defaults/hardware_uuid_spec.rb
|
152
|
+
- spec/state_mate/adapters/defaults/hash_deep_write_spec.rb
|
153
|
+
- spec/state_mate/adapters/defaults/read_defaults_spec.rb
|
154
|
+
- spec/state_mate/adapters/defaults/read_spec.rb
|
155
|
+
- spec/state_mate/adapters/defaults/read_type_spec.rb
|
156
|
+
- spec/state_mate/adapters/defaults/write_spec.rb
|
157
|
+
- spec/state_mate/adapters/git_config/read_spec.rb
|
158
|
+
- spec/state_mate/adapters/git_config/write_spec.rb
|
159
|
+
- spec/state_mate/adapters/json/read_spec.rb
|
160
|
+
- spec/state_mate/adapters/json/write_spec.rb
|
161
|
+
- spec/state_mate_spec.rb
|
162
|
+
- test/ansible/ansible.cfg
|
163
|
+
- test/ansible/clear
|
164
|
+
- test/ansible/hosts
|
165
|
+
- test/ansible/play
|
166
|
+
- test/ansible/playbook.yml
|
167
|
+
- test/ansible/read
|