guard-knife 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.
- data/ChangeLog +4 -0
- data/guard-knife.gemspec +2 -2
- data/lib/guard/knife.rb +22 -13
- metadata +8 -7
data/ChangeLog
CHANGED
data/guard-knife.gemspec
CHANGED
data/lib/guard/knife.rb
CHANGED
@@ -3,7 +3,7 @@ require 'guard/guard'
|
|
3
3
|
|
4
4
|
module Guard
|
5
5
|
class Knife < Guard
|
6
|
-
VERSION = '0.1.
|
6
|
+
VERSION = '0.1.1'
|
7
7
|
|
8
8
|
# Initialize a Guard.
|
9
9
|
# @param [Array<Guard::Watcher>] watchers the Guard file watchers
|
@@ -39,9 +39,8 @@ module Guard
|
|
39
39
|
# @param [Array<String>] paths the changes files or paths
|
40
40
|
# @raise [:task_has_failed] when run_on_change has failed
|
41
41
|
def run_on_change(paths)
|
42
|
+
paths = normalize(paths)
|
42
43
|
paths.each do |path|
|
43
|
-
next if path.match(/\.swp$/) # vim swap file
|
44
|
-
|
45
44
|
upload(path)
|
46
45
|
end
|
47
46
|
end
|
@@ -52,10 +51,20 @@ module Guard
|
|
52
51
|
def run_on_deletion(paths)
|
53
52
|
end
|
54
53
|
|
54
|
+
def normalize(paths)
|
55
|
+
paths.map! do |path|
|
56
|
+
next if path.match(/\.swp$/) # vim swap file
|
57
|
+
|
58
|
+
# only upload cookbook once in case many files change
|
59
|
+
path.gsub(/^(cookbooks\/[^\/]*)\/.*$/, '\1')
|
60
|
+
end
|
61
|
+
paths.compact.uniq
|
62
|
+
end
|
63
|
+
|
55
64
|
def upload(path)
|
56
|
-
if path.match(/^cookbooks\/([^\/]*)
|
65
|
+
if path.match(/^cookbooks\/([^\/]*)/)
|
57
66
|
upload_cookbook($1)
|
58
|
-
elsif path.match(/^data_bags\/(.*)\/(.*)$/)
|
67
|
+
elsif path.match(/^data_bags\/(.*)\/(.*).json$/)
|
59
68
|
data_bag = $1
|
60
69
|
item = $2
|
61
70
|
upload_databag(data_bag, item)
|
@@ -80,33 +89,33 @@ module Guard
|
|
80
89
|
|
81
90
|
def upload_cookbook(cookbook)
|
82
91
|
if system("knife cookbook upload #{cookbook} #{knife_options}")
|
83
|
-
::Guard::Notifier.notify("Cookbook #{cookbook} uploaded")
|
92
|
+
::Guard::Notifier.notify("Cookbook #{cookbook} uploaded", :title => 'Knife')
|
84
93
|
else
|
85
|
-
::Guard::Notifier.notify("Cookbook #{cookbook} failed to upload", :image => :failed)
|
94
|
+
::Guard::Notifier.notify("Cookbook #{cookbook} failed to upload", :title => 'Knife', :image => :failed)
|
86
95
|
end
|
87
96
|
end
|
88
97
|
|
89
98
|
def upload_databag(data_bag, item)
|
90
99
|
if system("knife data bag from file #{data_bag} #{item} #{knife_options}")
|
91
|
-
::Guard::Notifier.notify("Data bag #{data_bag} upload")
|
100
|
+
::Guard::Notifier.notify("Data bag #{data_bag} upload", :title => 'Knife')
|
92
101
|
else
|
93
|
-
::Guard::Notifier.notify("Data bag #{data_bag} failed to upload", :image => :failed)
|
102
|
+
::Guard::Notifier.notify("Data bag #{data_bag} failed to upload", :title => 'Knife', :image => :failed)
|
94
103
|
end
|
95
104
|
end
|
96
105
|
|
97
106
|
def upload_environment(environment)
|
98
107
|
if system("knife environment from file #{environment} #{knife_options}")
|
99
|
-
::Guard::Notifier.notify("Environment #{environment} uploaded")
|
108
|
+
::Guard::Notifier.notify("Environment #{environment} uploaded", :title => 'Knife')
|
100
109
|
else
|
101
|
-
::Guard::Notifier.notify("Environment #{environment} failed to upload", :image => :failed)
|
110
|
+
::Guard::Notifier.notify("Environment #{environment} failed to upload", :title => 'Knife', :image => :failed)
|
102
111
|
end
|
103
112
|
end
|
104
113
|
|
105
114
|
def upload_role(role)
|
106
115
|
if system("knife role from file #{role} #{knife_options}")
|
107
|
-
::Guard::Notifier.notify("Role #{role} uploaded")
|
116
|
+
::Guard::Notifier.notify("Role #{role} uploaded", :title => 'Knife')
|
108
117
|
else
|
109
|
-
::Guard::Notifier.notify("Role #{role} upload failed", :image => :failed)
|
118
|
+
::Guard::Notifier.notify("Role #{role} upload failed", :title => 'Knife', :image => :failed)
|
110
119
|
end
|
111
120
|
end
|
112
121
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-knife
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: guard
|
16
|
-
requirement: &
|
16
|
+
requirement: &14436540 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *14436540
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: chef
|
27
|
-
requirement: &
|
27
|
+
requirement: &14435980 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0.10'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *14435980
|
36
36
|
description: Guard for Chef using knife to upload files
|
37
37
|
email: github@erisiandiscord.de
|
38
38
|
executables: []
|
@@ -69,8 +69,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
69
|
version: '0'
|
70
70
|
requirements: []
|
71
71
|
rubyforge_project: ''
|
72
|
-
rubygems_version: 1.8.
|
72
|
+
rubygems_version: 1.8.17
|
73
73
|
signing_key:
|
74
74
|
specification_version: 2
|
75
75
|
summary: Guard for Chef using knife
|
76
76
|
test_files: []
|
77
|
+
has_rdoc:
|