bixby-client 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.testguardrc +1 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +72 -61
- data/VERSION +1 -1
- data/bixby-client.gemspec +10 -6
- data/lib/bixby-client/app/file_finder.rb +3 -3
- data/lib/bixby-client/command.rb +0 -1
- data/lib/bixby-client/model/base.rb +0 -1
- data/lib/bixby-client/script/bundle.rb +33 -0
- data/lib/bixby-client/script/distro.rb +53 -0
- data/lib/bixby-client/script/platform.rb +45 -0
- data/lib/bixby-client/script/util.rb +92 -0
- data/lib/bixby-client/script.rb +2 -2
- data/lib/bixby-client/script_util.rb +9 -67
- data/lib/bixby-client.rb +0 -1
- data/test/bixby-client/test_platform_util.rb +1 -1
- metadata +50 -46
- data/lib/bixby-client/platform_util.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b1ab8b11923a68cf2ca2fb540e13c8f0dbd8bb4
|
4
|
+
data.tar.gz: 9e2abea5674649715b23956c56f454462e442192
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0c2549066a15b23499cd859d236e19313eb4028fbe6aeb8ca79c2b44e4e7ee4a8ae3fe0ed16791aa177cec57d776de327ad1d0ceca5bc79979f329e6fed801a
|
7
|
+
data.tar.gz: 0c522e7306639bb74eef984fe63536115513a313e4953ac142c69d5c57bbe775e05ed27e500faabce98c0bf24bbf1b3b629f3306b229e4e1038ddc87c10ea8b1
|
data/.testguardrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--micron
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
GIT
|
2
2
|
remote: git://github.com/chetan/micron.git
|
3
|
-
revision:
|
3
|
+
revision: 17e46aaf88e16870fa4ac0374016434823c2c46e
|
4
4
|
specs:
|
5
5
|
micron (0.5.0)
|
6
6
|
ansi
|
@@ -9,23 +9,23 @@ GIT
|
|
9
9
|
|
10
10
|
GIT
|
11
11
|
remote: https://github.com/chetan/api_auth.git
|
12
|
-
revision:
|
12
|
+
revision: 2ced7ba3afcc4d81e8a24e3d89f569b38b1e10a0
|
13
13
|
branch: bixby
|
14
14
|
specs:
|
15
15
|
api-auth (1.0.3)
|
16
16
|
|
17
17
|
GIT
|
18
18
|
remote: https://github.com/chetan/jeweler.git
|
19
|
-
revision:
|
19
|
+
revision: b1f048d0ee6bc9febbcadb52b75b77e734782eb4
|
20
20
|
branch: bixby
|
21
21
|
specs:
|
22
|
-
jeweler (
|
22
|
+
jeweler (2.0.1)
|
23
23
|
builder
|
24
|
-
bundler (
|
24
|
+
bundler (>= 1.0)
|
25
25
|
git (>= 1.2.5)
|
26
|
-
github_api
|
26
|
+
github_api
|
27
27
|
highline (>= 1.6.15)
|
28
|
-
nokogiri (
|
28
|
+
nokogiri (>= 1.5.10)
|
29
29
|
rake
|
30
30
|
rdoc
|
31
31
|
|
@@ -40,7 +40,7 @@ GIT
|
|
40
40
|
|
41
41
|
GIT
|
42
42
|
remote: https://github.com/chetan/test_guard.git
|
43
|
-
revision:
|
43
|
+
revision: 178e47e2e57dc83060d6cabc18f206916b9d02f2
|
44
44
|
specs:
|
45
45
|
test_guard (0.2.1)
|
46
46
|
awesome_print
|
@@ -53,10 +53,10 @@ GIT
|
|
53
53
|
GEM
|
54
54
|
remote: https://rubygems.org/
|
55
55
|
specs:
|
56
|
-
addressable (2.3.
|
56
|
+
addressable (2.3.6)
|
57
57
|
ansi (1.4.3)
|
58
58
|
awesome_print (1.2.0)
|
59
|
-
bixby-common (0.4.
|
59
|
+
bixby-common (0.4.12)
|
60
60
|
api-auth
|
61
61
|
faye-websocket
|
62
62
|
httpi
|
@@ -66,8 +66,11 @@ GEM
|
|
66
66
|
builder (3.2.2)
|
67
67
|
celluloid (0.15.2)
|
68
68
|
timers (~> 1.1.0)
|
69
|
+
celluloid-io (0.15.0)
|
70
|
+
celluloid (>= 0.15.0)
|
71
|
+
nio4r (>= 0.5.0)
|
69
72
|
coderay (1.1.0)
|
70
|
-
colorize (0.
|
73
|
+
colorize (0.7.2)
|
71
74
|
columnize (0.3.6)
|
72
75
|
coveralls (0.7.0)
|
73
76
|
multi_json (~> 1.3)
|
@@ -75,112 +78,119 @@ GEM
|
|
75
78
|
simplecov (>= 0.7)
|
76
79
|
term-ansicolor
|
77
80
|
thor
|
78
|
-
crack (0.4.
|
79
|
-
safe_yaml (~> 0.
|
81
|
+
crack (0.4.2)
|
82
|
+
safe_yaml (~> 1.0.0)
|
80
83
|
curb (0.8.5)
|
81
|
-
debugger (1.6.
|
84
|
+
debugger (1.6.6)
|
82
85
|
columnize (>= 0.3.1)
|
83
86
|
debugger-linecache (~> 1.2.0)
|
84
|
-
debugger-ruby_core_source (~> 1.2
|
87
|
+
debugger-ruby_core_source (~> 1.3.2)
|
85
88
|
debugger-linecache (1.2.0)
|
86
89
|
debugger-pry (0.1.1)
|
87
90
|
debugger (~> 1)
|
88
91
|
pry (>= 0.9.9)
|
89
|
-
debugger-ruby_core_source (1.2
|
92
|
+
debugger-ruby_core_source (1.3.2)
|
93
|
+
descendants_tracker (0.0.4)
|
94
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
90
95
|
easycov (0.4.0)
|
91
96
|
multi_json
|
92
97
|
simplecov
|
93
98
|
simplecov-console
|
94
99
|
simplecov-html
|
95
100
|
eventmachine (1.0.3)
|
96
|
-
faraday (0.
|
97
|
-
multipart-post (
|
98
|
-
faye-websocket (0.7.
|
101
|
+
faraday (0.9.0)
|
102
|
+
multipart-post (>= 1.2, < 3)
|
103
|
+
faye-websocket (0.7.2)
|
99
104
|
eventmachine (>= 0.12.0)
|
100
|
-
websocket-driver (>= 0.3.
|
105
|
+
websocket-driver (>= 0.3.1)
|
101
106
|
ffi (1.9.3)
|
102
107
|
fuzzy_file_finder (1.0.4)
|
103
108
|
git (1.2.6)
|
104
|
-
github_api (0.
|
105
|
-
addressable
|
106
|
-
|
109
|
+
github_api (0.11.3)
|
110
|
+
addressable (~> 2.3)
|
111
|
+
descendants_tracker (~> 0.0.1)
|
112
|
+
faraday (~> 0.8, < 0.10)
|
107
113
|
hashie (>= 1.2)
|
108
|
-
multi_json (
|
109
|
-
nokogiri (~> 1.
|
114
|
+
multi_json (>= 1.7.5, < 2.0)
|
115
|
+
nokogiri (~> 1.6.0)
|
110
116
|
oauth2
|
111
117
|
growl (1.0.3)
|
112
|
-
hashie (2.
|
113
|
-
highline (1.6.
|
118
|
+
hashie (2.1.1)
|
119
|
+
highline (1.6.21)
|
114
120
|
hirb (0.7.1)
|
115
121
|
hitimes (1.2.1)
|
116
|
-
httpauth (0.2.0)
|
117
122
|
httpi (2.1.0)
|
118
123
|
rack
|
119
124
|
rubyntlm (~> 0.3.2)
|
120
125
|
json (1.8.1)
|
121
|
-
jwt (0.1.
|
126
|
+
jwt (0.1.11)
|
122
127
|
multi_json (>= 1.5)
|
123
|
-
listen (2.
|
128
|
+
listen (2.7.1)
|
124
129
|
celluloid (>= 0.15.2)
|
130
|
+
celluloid-io (>= 0.15.0)
|
125
131
|
rb-fsevent (>= 0.9.3)
|
126
132
|
rb-inotify (>= 0.9)
|
127
133
|
little-plugger (1.1.3)
|
128
|
-
logging (1.8.
|
134
|
+
logging (1.8.2)
|
129
135
|
little-plugger (>= 1.1.3)
|
130
|
-
multi_json (>= 1.
|
131
|
-
metaclass (0.0.
|
136
|
+
multi_json (>= 1.8.4)
|
137
|
+
metaclass (0.0.4)
|
132
138
|
method_source (0.8.2)
|
133
|
-
mime-types (2.
|
134
|
-
|
135
|
-
|
139
|
+
mime-types (2.2)
|
140
|
+
mini_portile (0.5.3)
|
141
|
+
mixlib-shellout (1.4.0)
|
142
|
+
mocha (1.0.0)
|
136
143
|
metaclass (~> 0.0.1)
|
137
|
-
multi_json (1.
|
144
|
+
multi_json (1.9.2)
|
138
145
|
multi_xml (0.5.5)
|
139
|
-
multipart-post (
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
+
multipart-post (2.0.0)
|
147
|
+
nio4r (1.0.0)
|
148
|
+
nokogiri (1.6.1)
|
149
|
+
mini_portile (~> 0.5.0)
|
150
|
+
oauth2 (0.9.3)
|
151
|
+
faraday (>= 0.8, < 0.10)
|
152
|
+
jwt (~> 0.1.8)
|
153
|
+
multi_json (~> 1.3)
|
146
154
|
multi_xml (~> 0.5)
|
147
155
|
rack (~> 1.2)
|
148
|
-
oj (2.
|
149
|
-
pry (0.9.12.
|
156
|
+
oj (2.7.3)
|
157
|
+
pry (0.9.12.6)
|
150
158
|
coderay (~> 1.0)
|
151
159
|
method_source (~> 0.8)
|
152
160
|
slop (~> 3.4)
|
161
|
+
psych (2.0.5)
|
153
162
|
rack (1.5.2)
|
154
|
-
rake (10.
|
163
|
+
rake (10.2.2)
|
155
164
|
rb-fchange (0.0.6)
|
156
165
|
ffi
|
157
|
-
rb-fsevent (0.9.
|
158
|
-
rb-inotify (0.9.
|
166
|
+
rb-fsevent (0.9.4)
|
167
|
+
rb-inotify (0.9.3)
|
159
168
|
ffi (>= 0.5.0)
|
160
|
-
rdoc (4.
|
169
|
+
rdoc (4.1.1)
|
161
170
|
json (~> 1.4)
|
162
|
-
redcarpet (3.
|
171
|
+
redcarpet (3.1.1)
|
163
172
|
rest-client (1.6.7)
|
164
173
|
mime-types (>= 1.16)
|
165
174
|
rubyntlm (0.3.4)
|
166
|
-
safe_yaml (0.
|
167
|
-
semver2 (3.3.
|
175
|
+
safe_yaml (1.0.2)
|
176
|
+
semver2 (3.3.3)
|
168
177
|
simplecov-console (0.1.3)
|
169
178
|
colorize
|
170
179
|
hirb
|
171
180
|
simplecov
|
172
181
|
simplecov-html (0.7.1)
|
173
|
-
slop (3.
|
174
|
-
term-ansicolor (1.
|
175
|
-
tins (~> 0
|
176
|
-
thor (0.
|
182
|
+
slop (3.5.0)
|
183
|
+
term-ansicolor (1.3.0)
|
184
|
+
tins (~> 1.0)
|
185
|
+
thor (0.19.1)
|
186
|
+
thread_safe (0.3.3)
|
177
187
|
timers (1.1.0)
|
178
|
-
tins (
|
179
|
-
webmock (1.
|
188
|
+
tins (1.1.0)
|
189
|
+
webmock (1.17.4)
|
180
190
|
addressable (>= 2.2.7)
|
181
191
|
crack (>= 0.3.2)
|
182
|
-
websocket-driver (0.3.
|
183
|
-
yard (0.8.7.
|
192
|
+
websocket-driver (0.3.2)
|
193
|
+
yard (0.8.7.4)
|
184
194
|
|
185
195
|
PLATFORMS
|
186
196
|
ruby
|
@@ -202,6 +212,7 @@ DEPENDENCIES
|
|
202
212
|
multi_json
|
203
213
|
oj
|
204
214
|
pry
|
215
|
+
psych
|
205
216
|
rb-fchange
|
206
217
|
rb-fsevent
|
207
218
|
rb-inotify
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/bixby-client.gemspec
CHANGED
@@ -2,15 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: bixby-client 0.
|
5
|
+
# stub: bixby-client 0.5.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "bixby-client"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.5.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
12
13
|
s.authors = ["Chetan Sarva"]
|
13
|
-
s.date = "
|
14
|
+
s.date = "2014-05-02"
|
14
15
|
s.description = "Bixby Client"
|
15
16
|
s.email = "chetan@pixelcop.net"
|
16
17
|
s.executables = ["bixby"]
|
@@ -20,6 +21,7 @@ Gem::Specification.new do |s|
|
|
20
21
|
]
|
21
22
|
s.files = [
|
22
23
|
".document",
|
24
|
+
".testguardrc",
|
23
25
|
".travis.yml",
|
24
26
|
"Gemfile",
|
25
27
|
"Gemfile.lock",
|
@@ -50,8 +52,11 @@ Gem::Specification.new do |s|
|
|
50
52
|
"lib/bixby-client/modules/monitoring.rb",
|
51
53
|
"lib/bixby-client/modules/repository.rb",
|
52
54
|
"lib/bixby-client/patch/shellout.rb",
|
53
|
-
"lib/bixby-client/platform_util.rb",
|
54
55
|
"lib/bixby-client/script.rb",
|
56
|
+
"lib/bixby-client/script/bundle.rb",
|
57
|
+
"lib/bixby-client/script/distro.rb",
|
58
|
+
"lib/bixby-client/script/platform.rb",
|
59
|
+
"lib/bixby-client/script/util.rb",
|
55
60
|
"lib/bixby-client/script_util.rb",
|
56
61
|
"tasks/coverage.rake",
|
57
62
|
"tasks/coveralls.rake",
|
@@ -77,8 +82,7 @@ Gem::Specification.new do |s|
|
|
77
82
|
]
|
78
83
|
s.homepage = "http://github.com/chetan/bixby-client"
|
79
84
|
s.licenses = ["MIT"]
|
80
|
-
s.
|
81
|
-
s.rubygems_version = "2.1.5"
|
85
|
+
s.rubygems_version = "2.2.2"
|
82
86
|
s.summary = "Bixby Client"
|
83
87
|
|
84
88
|
if s.respond_to? :specification_version then
|
@@ -23,9 +23,9 @@ module Bixby
|
|
23
23
|
return s if File.exists? s
|
24
24
|
|
25
25
|
# try searching
|
26
|
-
matches = find_all_files(@root).
|
27
|
-
|
28
|
-
|
26
|
+
matches = find_all_files(@root).
|
27
|
+
find_all { |f| f.include?("/bin/") && f.include?(script) }.
|
28
|
+
sort { |a,b| ld(script, File.basename(a)) <=> ld(script, File.basename(b)) }
|
29
29
|
|
30
30
|
return matches if matches.size == 1 # only one result, just return it
|
31
31
|
|
data/lib/bixby-client/command.rb
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
module Bixby
|
3
|
+
module Script
|
4
|
+
module Bundle
|
5
|
+
|
6
|
+
# Load the libraries for the given bundle. Searches all available
|
7
|
+
# repositories.
|
8
|
+
def use_bundle(name)
|
9
|
+
repos = Dir.glob(File.join(Bixby.repo_path, "*"))
|
10
|
+
repos.each do |repo|
|
11
|
+
next if not File.directory? repo
|
12
|
+
|
13
|
+
lib = File.join(repo, name, "lib")
|
14
|
+
$: << lib
|
15
|
+
if File.directory? lib then
|
16
|
+
Dir.glob(File.join(lib, "*.rb")).each{ |f| require f }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end # Bundle
|
22
|
+
end # Script
|
23
|
+
end # Bixby
|
24
|
+
|
25
|
+
module Bixby
|
26
|
+
# Bixby.use_bundle
|
27
|
+
extend Bixby::Script::Bundle
|
28
|
+
end
|
29
|
+
|
30
|
+
class Object
|
31
|
+
# naked use_bundle "foo" in scripts
|
32
|
+
include Bixby::Script::Bundle
|
33
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
|
2
|
+
module Bixby
|
3
|
+
module Script
|
4
|
+
module Distro
|
5
|
+
|
6
|
+
def etc_issue
|
7
|
+
return @_etc_issue if @_etc_issue
|
8
|
+
@_etc_issue = if linux? then
|
9
|
+
File.read("/etc/issue").strip
|
10
|
+
else
|
11
|
+
nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def ubuntu?
|
16
|
+
etc_issue =~ /Ubuntu/
|
17
|
+
end
|
18
|
+
|
19
|
+
def ubuntu_version
|
20
|
+
# e.g., Ubuntu 13.04
|
21
|
+
etc_issue =~ /Ubuntu (\d+\.\d+(\.\d+)?)/
|
22
|
+
ver = $1
|
23
|
+
ver = "#{ver}.0" if ver.split(/\./).size == 2
|
24
|
+
SemVer.parse("v#{ver}")
|
25
|
+
end
|
26
|
+
|
27
|
+
def centos?
|
28
|
+
etc_issue =~ /CentOS/
|
29
|
+
end
|
30
|
+
alias_method :cent?, :centos?
|
31
|
+
|
32
|
+
def centos_version
|
33
|
+
# e.g., CentOS release 5.10
|
34
|
+
etc_issue =~ /CentOS release (\d+\.\d+)/
|
35
|
+
ver = $1
|
36
|
+
SemVer.parse("v#{ver}.0")
|
37
|
+
end
|
38
|
+
|
39
|
+
def amazon_linux?
|
40
|
+
etc_issue =~ /^Amazon Linux/
|
41
|
+
end
|
42
|
+
alias_method :amazon?, :amazon_linux?
|
43
|
+
alias_method :amazonlinux?, :amazon_linux?
|
44
|
+
|
45
|
+
def amazon_linux_version
|
46
|
+
# e.g., Amazon Linux AMI 2013.09
|
47
|
+
etc_issue =~ /^Amazon Linux AMI (\d+\.\d+)/
|
48
|
+
SemVer.parse($1)
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
|
2
|
+
module Bixby
|
3
|
+
module Script
|
4
|
+
module Platform
|
5
|
+
|
6
|
+
def uname
|
7
|
+
RUBY_PLATFORM
|
8
|
+
end
|
9
|
+
|
10
|
+
def osx?
|
11
|
+
uname =~ /darwin/
|
12
|
+
end
|
13
|
+
alias_method :darwin?, :osx?
|
14
|
+
alias_method :mac?, :osx?
|
15
|
+
|
16
|
+
def linux?
|
17
|
+
uname =~ /linux/
|
18
|
+
end
|
19
|
+
|
20
|
+
def solaris?
|
21
|
+
uname =~ /solaris/
|
22
|
+
end
|
23
|
+
|
24
|
+
def windows?
|
25
|
+
uname =~ /mswin|mingw|bccwin|wince|cygwin/
|
26
|
+
end
|
27
|
+
alias_method :win?, :windows?
|
28
|
+
|
29
|
+
def bsd?
|
30
|
+
uname =~ /freebsd|netbsd|openbsd/
|
31
|
+
end
|
32
|
+
|
33
|
+
# architectures
|
34
|
+
|
35
|
+
def amd64?
|
36
|
+
RbConfig::CONFIG['target_cpu'] == "x86_64"
|
37
|
+
end
|
38
|
+
|
39
|
+
def x86?
|
40
|
+
RbConfig::CONFIG['target_cpu'] =~ /i[3-6]86/
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
|
2
|
+
require "bixby-client/patch/shellout"
|
3
|
+
|
4
|
+
module Bixby
|
5
|
+
module Script
|
6
|
+
module Util
|
7
|
+
|
8
|
+
# Reads JSON data from STDIN
|
9
|
+
#
|
10
|
+
# @return [Object] data found on STDIN (can be Hash, Array, String, etc)
|
11
|
+
def get_json_input
|
12
|
+
input = read_stdin()
|
13
|
+
input.strip! if input
|
14
|
+
(input.nil? or input.empty?) ? {} : MultiJson.load(input)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Read all available data on STDIN without blocking
|
18
|
+
# (i.e., if no data is available, none will be returned)
|
19
|
+
#
|
20
|
+
# @return [String] data
|
21
|
+
def read_stdin
|
22
|
+
buff = []
|
23
|
+
while true do
|
24
|
+
begin
|
25
|
+
buff << STDIN.read_nonblock(64000)
|
26
|
+
rescue
|
27
|
+
break
|
28
|
+
end
|
29
|
+
end
|
30
|
+
return buff.join('')
|
31
|
+
end
|
32
|
+
|
33
|
+
# Simple wrapper around Mixlib::ShellOut
|
34
|
+
#
|
35
|
+
# @param [Array] args
|
36
|
+
#
|
37
|
+
# @return [Mixlib::ShellOut]
|
38
|
+
def systemu(*args)
|
39
|
+
cmd = Mixlib::ShellOut.new(*args)
|
40
|
+
cmd.run_command
|
41
|
+
cmd
|
42
|
+
end
|
43
|
+
|
44
|
+
def logged_systemu(*args)
|
45
|
+
cmd = systemu(*args)
|
46
|
+
logger && logger.debug {
|
47
|
+
s = cmd.command
|
48
|
+
s += "\nSTATUS: #{cmd.exitstatus}" if !cmd.success?
|
49
|
+
s += "\nSTDOUT:\n#{cmd.stdout}" if !cmd.stdout.strip.empty?
|
50
|
+
s += "\nSTDERR:\n#{cmd.stderr}" if !cmd.stderr.strip.empty?
|
51
|
+
s
|
52
|
+
}
|
53
|
+
cmd
|
54
|
+
end
|
55
|
+
|
56
|
+
# Simple wrapper around #systemu which prepends sudo to the command
|
57
|
+
#
|
58
|
+
# @param [Array] args
|
59
|
+
#
|
60
|
+
# @return [Mixlib::ShellOut]
|
61
|
+
def sudo(*args)
|
62
|
+
if args.last.kind_of? Hash then
|
63
|
+
opts = args.last
|
64
|
+
if opts[:env] && opts[:env]["PATH"] then
|
65
|
+
path = opts[:env]["PATH"]
|
66
|
+
args[0] = "env PATH=#{path} #{args.first}"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
args[0] = "sudo #{args.first}"
|
70
|
+
systemu(*args)
|
71
|
+
end
|
72
|
+
|
73
|
+
# Like #sudo, except log command and results
|
74
|
+
#
|
75
|
+
# @param [Array] args
|
76
|
+
#
|
77
|
+
# @return [Mixlib::ShellOut]
|
78
|
+
def logged_sudo(*args)
|
79
|
+
cmd = sudo(*args)
|
80
|
+
logger && logger.debug {
|
81
|
+
s = cmd.command
|
82
|
+
s += "\nSTATUS: #{cmd.exitstatus}" if !cmd.success?
|
83
|
+
s += "\nSTDOUT:\n#{cmd.stdout}" if !cmd.stdout.strip.empty?
|
84
|
+
s += "\nSTDERR:\n#{cmd.stderr}" if !cmd.stderr.strip.empty?
|
85
|
+
s
|
86
|
+
}
|
87
|
+
cmd
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
data/lib/bixby-client/script.rb
CHANGED
@@ -1,74 +1,16 @@
|
|
1
1
|
|
2
|
-
require "bixby-client/
|
2
|
+
require "bixby-client/script/bundle"
|
3
|
+
require "bixby-client/script/distro"
|
4
|
+
require "bixby-client/script/platform"
|
5
|
+
require "bixby-client/script/util"
|
3
6
|
|
4
7
|
module Bixby
|
5
|
-
|
6
8
|
module ScriptUtil
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
def use_bundle(name)
|
13
|
-
repos = Dir.glob(File.join(Bixby.repo_path, "*"))
|
14
|
-
repos.each do |repo|
|
15
|
-
next if not File.directory? repo
|
16
|
-
|
17
|
-
lib = File.join(repo, name, "lib")
|
18
|
-
$: << lib
|
19
|
-
if File.directory? lib then
|
20
|
-
Dir.glob(File.join(lib, "*.rb")).each{ |f| require f }
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
end # UseBundle
|
26
|
-
|
27
|
-
include UseBundle
|
28
|
-
|
29
|
-
# Reads JSON data from STDIN
|
30
|
-
#
|
31
|
-
# @return [Object] data found on STDIN (can be Hash, Array, String, etc)
|
32
|
-
def get_json_input
|
33
|
-
input = read_stdin()
|
34
|
-
input.strip! if input
|
35
|
-
(input.nil? or input.empty?) ? {} : MultiJson.load(input)
|
36
|
-
end
|
37
|
-
|
38
|
-
# Read all available data on STDIN without blocking
|
39
|
-
# (i.e., if no data is available, none will be returned)
|
40
|
-
#
|
41
|
-
# @return [String] data
|
42
|
-
def read_stdin
|
43
|
-
buff = []
|
44
|
-
while true do
|
45
|
-
begin
|
46
|
-
buff << STDIN.read_nonblock(64000)
|
47
|
-
rescue
|
48
|
-
break
|
49
|
-
end
|
50
|
-
end
|
51
|
-
return buff.join('')
|
52
|
-
end
|
53
|
-
|
54
|
-
# Simple wrapper around Mixlib::ShellOut
|
55
|
-
#
|
56
|
-
# @param [Array] args
|
57
|
-
#
|
58
|
-
# @return [Mixlib::ShellOut]
|
59
|
-
def systemu(*args)
|
60
|
-
cmd = Mixlib::ShellOut.new(*args)
|
61
|
-
cmd.run_command
|
62
|
-
cmd
|
63
|
-
end
|
64
|
-
|
65
|
-
end # ScriptUtil
|
66
|
-
end # Bixby
|
67
|
-
|
68
|
-
module Bixby
|
69
|
-
extend Bixby::ScriptUtil::UseBundle
|
70
|
-
end
|
10
|
+
include Bixby::Script::Bundle
|
11
|
+
include Bixby::Script::Distro
|
12
|
+
include Bixby::Script::Platform
|
13
|
+
include Bixby::Script::Util
|
71
14
|
|
72
|
-
|
73
|
-
include Bixby::ScriptUtil::UseBundle
|
15
|
+
end
|
74
16
|
end
|
data/lib/bixby-client.rb
CHANGED
metadata
CHANGED
@@ -1,279 +1,279 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bixby-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chetan Sarva
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bixby-common
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: multi_json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: oj
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: httpi
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: curb
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: mixlib-shellout
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: fuzzy_file_finder
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: api-auth
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: yard
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: redcarpet
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- -
|
143
|
+
- - ">="
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '0'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- -
|
150
|
+
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: bundler
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- -
|
157
|
+
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: '0'
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- -
|
164
|
+
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: jeweler
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
|
-
- -
|
171
|
+
- - ">="
|
172
172
|
- !ruby/object:Gem::Version
|
173
173
|
version: '0'
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
|
-
- -
|
178
|
+
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: pry
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
|
-
- -
|
185
|
+
- - ">="
|
186
186
|
- !ruby/object:Gem::Version
|
187
187
|
version: '0'
|
188
188
|
type: :development
|
189
189
|
prerelease: false
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
|
-
- -
|
192
|
+
- - ">="
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
195
|
- !ruby/object:Gem::Dependency
|
196
196
|
name: debugger
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
198
198
|
requirements:
|
199
|
-
- -
|
199
|
+
- - ">="
|
200
200
|
- !ruby/object:Gem::Version
|
201
201
|
version: '0'
|
202
202
|
type: :development
|
203
203
|
prerelease: false
|
204
204
|
version_requirements: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
206
|
-
- -
|
206
|
+
- - ">="
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: '0'
|
209
209
|
- !ruby/object:Gem::Dependency
|
210
210
|
name: debugger-pry
|
211
211
|
requirement: !ruby/object:Gem::Requirement
|
212
212
|
requirements:
|
213
|
-
- -
|
213
|
+
- - ">="
|
214
214
|
- !ruby/object:Gem::Version
|
215
215
|
version: '0'
|
216
216
|
type: :development
|
217
217
|
prerelease: false
|
218
218
|
version_requirements: !ruby/object:Gem::Requirement
|
219
219
|
requirements:
|
220
|
-
- -
|
220
|
+
- - ">="
|
221
221
|
- !ruby/object:Gem::Version
|
222
222
|
version: '0'
|
223
223
|
- !ruby/object:Gem::Dependency
|
224
224
|
name: test_guard
|
225
225
|
requirement: !ruby/object:Gem::Requirement
|
226
226
|
requirements:
|
227
|
-
- -
|
227
|
+
- - ">="
|
228
228
|
- !ruby/object:Gem::Version
|
229
229
|
version: '0'
|
230
230
|
type: :development
|
231
231
|
prerelease: false
|
232
232
|
version_requirements: !ruby/object:Gem::Requirement
|
233
233
|
requirements:
|
234
|
-
- -
|
234
|
+
- - ">="
|
235
235
|
- !ruby/object:Gem::Version
|
236
236
|
version: '0'
|
237
237
|
- !ruby/object:Gem::Dependency
|
238
238
|
name: rb-inotify
|
239
239
|
requirement: !ruby/object:Gem::Requirement
|
240
240
|
requirements:
|
241
|
-
- -
|
241
|
+
- - ">="
|
242
242
|
- !ruby/object:Gem::Version
|
243
243
|
version: '0'
|
244
244
|
type: :development
|
245
245
|
prerelease: false
|
246
246
|
version_requirements: !ruby/object:Gem::Requirement
|
247
247
|
requirements:
|
248
|
-
- -
|
248
|
+
- - ">="
|
249
249
|
- !ruby/object:Gem::Version
|
250
250
|
version: '0'
|
251
251
|
- !ruby/object:Gem::Dependency
|
252
252
|
name: rb-fsevent
|
253
253
|
requirement: !ruby/object:Gem::Requirement
|
254
254
|
requirements:
|
255
|
-
- -
|
255
|
+
- - ">="
|
256
256
|
- !ruby/object:Gem::Version
|
257
257
|
version: '0'
|
258
258
|
type: :development
|
259
259
|
prerelease: false
|
260
260
|
version_requirements: !ruby/object:Gem::Requirement
|
261
261
|
requirements:
|
262
|
-
- -
|
262
|
+
- - ">="
|
263
263
|
- !ruby/object:Gem::Version
|
264
264
|
version: '0'
|
265
265
|
- !ruby/object:Gem::Dependency
|
266
266
|
name: rb-fchange
|
267
267
|
requirement: !ruby/object:Gem::Requirement
|
268
268
|
requirements:
|
269
|
-
- -
|
269
|
+
- - ">="
|
270
270
|
- !ruby/object:Gem::Version
|
271
271
|
version: '0'
|
272
272
|
type: :development
|
273
273
|
prerelease: false
|
274
274
|
version_requirements: !ruby/object:Gem::Requirement
|
275
275
|
requirements:
|
276
|
-
- -
|
276
|
+
- - ">="
|
277
277
|
- !ruby/object:Gem::Version
|
278
278
|
version: '0'
|
279
279
|
description: Bixby Client
|
@@ -285,8 +285,9 @@ extra_rdoc_files:
|
|
285
285
|
- LICENSE
|
286
286
|
- README.rdoc
|
287
287
|
files:
|
288
|
-
- .document
|
289
|
-
- .
|
288
|
+
- ".document"
|
289
|
+
- ".testguardrc"
|
290
|
+
- ".travis.yml"
|
290
291
|
- Gemfile
|
291
292
|
- Gemfile.lock
|
292
293
|
- LICENSE
|
@@ -316,8 +317,11 @@ files:
|
|
316
317
|
- lib/bixby-client/modules/monitoring.rb
|
317
318
|
- lib/bixby-client/modules/repository.rb
|
318
319
|
- lib/bixby-client/patch/shellout.rb
|
319
|
-
- lib/bixby-client/platform_util.rb
|
320
320
|
- lib/bixby-client/script.rb
|
321
|
+
- lib/bixby-client/script/bundle.rb
|
322
|
+
- lib/bixby-client/script/distro.rb
|
323
|
+
- lib/bixby-client/script/platform.rb
|
324
|
+
- lib/bixby-client/script/util.rb
|
321
325
|
- lib/bixby-client/script_util.rb
|
322
326
|
- tasks/coverage.rake
|
323
327
|
- tasks/coveralls.rake
|
@@ -350,17 +354,17 @@ require_paths:
|
|
350
354
|
- lib
|
351
355
|
required_ruby_version: !ruby/object:Gem::Requirement
|
352
356
|
requirements:
|
353
|
-
- -
|
357
|
+
- - ">="
|
354
358
|
- !ruby/object:Gem::Version
|
355
359
|
version: '0'
|
356
360
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
357
361
|
requirements:
|
358
|
-
- -
|
362
|
+
- - ">="
|
359
363
|
- !ruby/object:Gem::Version
|
360
364
|
version: '0'
|
361
365
|
requirements: []
|
362
366
|
rubyforge_project:
|
363
|
-
rubygems_version: 2.
|
367
|
+
rubygems_version: 2.2.2
|
364
368
|
signing_key:
|
365
369
|
specification_version: 4
|
366
370
|
summary: Bixby Client
|
@@ -1,25 +0,0 @@
|
|
1
|
-
|
2
|
-
module Bixby
|
3
|
-
module PlatformUtil
|
4
|
-
|
5
|
-
def uname
|
6
|
-
RUBY_PLATFORM
|
7
|
-
end
|
8
|
-
|
9
|
-
def osx?
|
10
|
-
uname =~ /darwin/
|
11
|
-
end
|
12
|
-
alias :darwin? :osx?
|
13
|
-
alias :mac? :osx?
|
14
|
-
|
15
|
-
def linux?
|
16
|
-
uname =~ /linux/
|
17
|
-
end
|
18
|
-
|
19
|
-
def win?
|
20
|
-
|
21
|
-
end
|
22
|
-
alias :windows? :win?
|
23
|
-
|
24
|
-
end # PlatformUtil
|
25
|
-
end # Bixby
|