xcskarel 0.3.2 → 0.4.0
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/bin/xcskarel +11 -7
- data/lib/xcskarel/bot.rb +23 -0
- data/lib/{karel → xcskarel}/control.rb +0 -0
- data/lib/xcskarel/filter.rb +49 -0
- data/lib/{karel → xcskarel}/log.rb +0 -0
- data/lib/{karel → xcskarel}/server.rb +1 -2
- data/lib/{karel → xcskarel}/version.rb +1 -1
- data/lib/xcskarel.rb +6 -5
- data/spec/default_spec.rb +11 -0
- data/spec/filter_spec.rb +63 -0
- metadata +68 -7
- data/lib/karel/filter.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46caf18dae4a7b9335230829b1edba21c99dff79
|
4
|
+
data.tar.gz: 52c0f1bee03ed2258867e1ba230c0bbe18810260
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bf83f4ed608340216a8eb86933d2495561369a2fc04d3301f9792fa615f2b066570e4e44a31b9f574da74b8fde50efb154028a4dae88f6a59459b08f00a36d1
|
7
|
+
data.tar.gz: 1e9a267e1b92508c74b621209150b8fa39de410a9913e7df08a5e63a62c3ae58fb6c45db57f51a164accf3473ee7522a06165dd5cb56aba8e6f77939d6911218
|
data/bin/xcskarel
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
$LOAD_PATH.push File.expand_path('../../lib', __FILE__)
|
4
4
|
|
5
|
-
require '
|
5
|
+
require 'XCSKarel'
|
6
6
|
require 'rubygems'
|
7
7
|
require 'commander'
|
8
8
|
|
@@ -12,14 +12,14 @@ class XCSKarelApplication
|
|
12
12
|
include Commander::Methods
|
13
13
|
|
14
14
|
def add_xcs_options(c)
|
15
|
-
c.option '--host Hostname', '(required) Xcode Server\'s hostname or IP address'
|
15
|
+
c.option '--host Hostname', '(required) Xcode Server\'s hostname or IP address (default: localhost)'
|
16
16
|
c.option '--user Username', 'Xcode Server username'
|
17
17
|
c.option '--pass Password', 'Xcode Server password'
|
18
18
|
end
|
19
19
|
|
20
20
|
def create_server_from_options(options)
|
21
|
-
|
22
|
-
XCSKarel::Server.new(
|
21
|
+
host = options.host || "localhost"
|
22
|
+
XCSKarel::Server.new(host, options.user, options.pass)
|
23
23
|
end
|
24
24
|
|
25
25
|
def run
|
@@ -42,9 +42,13 @@ class XCSKarelApplication
|
|
42
42
|
c.action do |args, options|
|
43
43
|
server = create_server_from_options(options)
|
44
44
|
all_bots = server.get_bots
|
45
|
+
# create Bot instances
|
46
|
+
bot_objs = all_bots.map { |json| XCSKarel::Bot.new(json) }
|
47
|
+
bot_files = bot_objs.map { |bot| name = "./xcskarel/#{bot.json['_id']}.json"; bot.to_file(name); name }
|
45
48
|
unless options.no_filter
|
46
|
-
all_bots = XCSKarel.
|
49
|
+
all_bots = XCSKarel::Filter.filter_key_paths(all_bots, ['name', '_id'])
|
47
50
|
end
|
51
|
+
binding.pry
|
48
52
|
out = options.no_pretty ? JSON.generate(all_bots) : JSON.pretty_generate(all_bots)
|
49
53
|
puts out
|
50
54
|
end
|
@@ -61,7 +65,7 @@ class XCSKarelApplication
|
|
61
65
|
server = create_server_from_options(options)
|
62
66
|
all_integrations = server.get_integrations(options.bot)
|
63
67
|
unless options.no_filter
|
64
|
-
all_integrations = XCSKarel.
|
68
|
+
all_integrations = XCSKarel::Filter.filter_key_paths(all_integrations, ['number', '_id', 'currentStep', 'result'])
|
65
69
|
end
|
66
70
|
out = options.no_pretty ? JSON.generate(all_integrations) : JSON.pretty_generate(all_integrations)
|
67
71
|
puts out
|
@@ -77,7 +81,7 @@ class XCSKarelApplication
|
|
77
81
|
server = create_server_from_options(options)
|
78
82
|
all_health = server.get_health
|
79
83
|
unless options.no_filter
|
80
|
-
all_health = XCSKarel.filter_key_paths(all_health, ['uptime'])
|
84
|
+
all_health = XCSKarel::Filter.filter_key_paths(all_health, ['uptime'])
|
81
85
|
end
|
82
86
|
out = options.no_pretty ? JSON.generate(all_health) : JSON.pretty_generate(all_health)
|
83
87
|
puts out
|
data/lib/xcskarel/bot.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module XCSKarel
|
2
|
+
class Bot
|
3
|
+
attr_reader :json
|
4
|
+
def initialize(json)
|
5
|
+
@json = json
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.from_file(file_path)
|
9
|
+
abs_path = File.absolute_path(file_path)
|
10
|
+
raise "No file #{abs_path}" unless File.exist?(abs_path)
|
11
|
+
self.new(File.read(abs_path))
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_file(file_path="./xcskarel/bot.json")
|
15
|
+
abs_path = File.absolute_path(file_path)
|
16
|
+
raise "File #{abs_path} already exists." if File.exist?(abs_path)
|
17
|
+
FileUtils.mkdir_p(File.dirname(abs_path))
|
18
|
+
File.open(abs_path, 'w') do |f|
|
19
|
+
f.puts JSON.pretty_generate(@json) + "\n"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
File without changes
|
@@ -0,0 +1,49 @@
|
|
1
|
+
|
2
|
+
require 'set'
|
3
|
+
|
4
|
+
module XCSKarel
|
5
|
+
module Filter
|
6
|
+
# returns a copy of the passed-in hash with only the provided keypaths kept
|
7
|
+
# e.g. "name" will keep the key "name" at the top level.
|
8
|
+
# supports even nested keypaths
|
9
|
+
def self.filter_key_paths(object, key_paths)
|
10
|
+
|
11
|
+
# array?
|
12
|
+
if object.is_a?(Array)
|
13
|
+
return self.filter_array(object, key_paths)
|
14
|
+
end
|
15
|
+
|
16
|
+
# hash?
|
17
|
+
if object.is_a?(Hash)
|
18
|
+
new_hash = Hash.new
|
19
|
+
unique_key_paths = Set.new(key_paths)
|
20
|
+
object.each do |k,v|
|
21
|
+
|
22
|
+
keys = k.split('.') # key-paths must be separated by a period
|
23
|
+
match = unique_key_paths.select do |key|
|
24
|
+
key.split('.').first == keys.first
|
25
|
+
end.first
|
26
|
+
if match
|
27
|
+
new_hash[keys.first] = filter_key_paths(v, match.split('.').drop(1))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
return new_hash
|
31
|
+
end
|
32
|
+
|
33
|
+
# object?
|
34
|
+
return object
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
# filters each element
|
40
|
+
def self.filter_array(array, key_paths)
|
41
|
+
new_array = Array.new
|
42
|
+
keys = Set.new(key_paths)
|
43
|
+
array.each do |i|
|
44
|
+
new_array << filter_key_paths(i, key_paths)
|
45
|
+
end
|
46
|
+
return new_array
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
File without changes
|
data/lib/xcskarel.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
|
2
|
-
require '
|
3
|
-
require '
|
4
|
-
require '
|
5
|
-
require '
|
6
|
-
require '
|
2
|
+
require 'xcskarel/server'
|
3
|
+
require 'xcskarel/version'
|
4
|
+
require 'xcskarel/log'
|
5
|
+
require 'xcskarel/filter'
|
6
|
+
require 'xcskarel/control'
|
7
|
+
require 'xcskarel/bot'
|
data/spec/filter_spec.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'xcskarel/filter'
|
2
|
+
|
3
|
+
describe XCSKarel do
|
4
|
+
describe XCSKarel::Filter do
|
5
|
+
|
6
|
+
def test(inObj, key_paths)
|
7
|
+
XCSKarel::Filter.filter_key_paths(inObj, key_paths)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "handles empty hash" do
|
11
|
+
expect(test({}, [])).to eq({})
|
12
|
+
end
|
13
|
+
|
14
|
+
it "handles empty array" do
|
15
|
+
expect(test([], [])).to eq([])
|
16
|
+
end
|
17
|
+
|
18
|
+
it "handles flat array of strings" do
|
19
|
+
expect(test(["apples", "oranges"], [])).to eq(["apples", "oranges"])
|
20
|
+
end
|
21
|
+
|
22
|
+
it "filters out everything from a simple hash" do
|
23
|
+
expect(test({"apples" => "green", "oranges" => "orange"}, [])).to eq({})
|
24
|
+
end
|
25
|
+
|
26
|
+
it "lets through only selected keys is a simple hash" do
|
27
|
+
expect(test({"apples" => "green", "oranges" => "orange"}, ["oranges"])).to eq({"oranges" => "orange"})
|
28
|
+
end
|
29
|
+
|
30
|
+
it "handles basic key path with a hash" do
|
31
|
+
obj = {
|
32
|
+
"apples" => "green",
|
33
|
+
"oranges" => {
|
34
|
+
"new" => 2,
|
35
|
+
"old" => -2
|
36
|
+
}
|
37
|
+
}
|
38
|
+
exp = {
|
39
|
+
"oranges" => {
|
40
|
+
"old" => -2
|
41
|
+
}
|
42
|
+
}
|
43
|
+
expect(test(obj, ["oranges.old"])).to eq(exp)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "handles basic key path with an array without popping the key path" do
|
47
|
+
obj = [
|
48
|
+
"apples",
|
49
|
+
{
|
50
|
+
"new" => 2,
|
51
|
+
"old" => -2
|
52
|
+
}
|
53
|
+
]
|
54
|
+
exp = [
|
55
|
+
"apples",
|
56
|
+
{
|
57
|
+
"new" => 2
|
58
|
+
}
|
59
|
+
]
|
60
|
+
expect(test(obj, ["new"])).to eq(exp)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xcskarel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Honza Dvorsky
|
@@ -108,6 +108,62 @@ dependencies:
|
|
108
108
|
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 3.2.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: bundler
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rake
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rspec
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 3.1.0
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 3.1.0
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: fastlane
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
111
167
|
description: Tool for managing your Xcode Server & Bot configurations from the command
|
112
168
|
line
|
113
169
|
email: http://honzadvorsky.com
|
@@ -117,12 +173,15 @@ extensions: []
|
|
117
173
|
extra_rdoc_files: []
|
118
174
|
files:
|
119
175
|
- bin/xcskarel
|
120
|
-
- lib/karel/control.rb
|
121
|
-
- lib/karel/filter.rb
|
122
|
-
- lib/karel/log.rb
|
123
|
-
- lib/karel/server.rb
|
124
|
-
- lib/karel/version.rb
|
125
176
|
- lib/xcskarel.rb
|
177
|
+
- lib/xcskarel/bot.rb
|
178
|
+
- lib/xcskarel/control.rb
|
179
|
+
- lib/xcskarel/filter.rb
|
180
|
+
- lib/xcskarel/log.rb
|
181
|
+
- lib/xcskarel/server.rb
|
182
|
+
- lib/xcskarel/version.rb
|
183
|
+
- spec/default_spec.rb
|
184
|
+
- spec/filter_spec.rb
|
126
185
|
homepage: http://github.com/czechboy0/xcskarel
|
127
186
|
licenses:
|
128
187
|
- MIT
|
@@ -147,5 +206,7 @@ rubygems_version: 2.4.5
|
|
147
206
|
signing_key:
|
148
207
|
specification_version: 4
|
149
208
|
summary: Manage your Xcode Server & Bots from the command line
|
150
|
-
test_files:
|
209
|
+
test_files:
|
210
|
+
- spec/default_spec.rb
|
211
|
+
- spec/filter_spec.rb
|
151
212
|
has_rdoc:
|
data/lib/karel/filter.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'set'
|
3
|
-
|
4
|
-
module XCSKarel
|
5
|
-
# returns a copy of the passed-in hash with only the provided keypaths kept
|
6
|
-
# e.g. "name" will keep the key "name" at the top level.
|
7
|
-
# TODO: support even nested keypaths
|
8
|
-
def self.filter_key_paths(hash, key_paths)
|
9
|
-
new_hash = Hash.new
|
10
|
-
keys = Set.new(key_paths)
|
11
|
-
hash.each do |k,v|
|
12
|
-
if keys.member?(k)
|
13
|
-
new_hash[k] = v
|
14
|
-
end
|
15
|
-
end
|
16
|
-
return new_hash
|
17
|
-
end
|
18
|
-
|
19
|
-
# filters each element
|
20
|
-
def self.filter_array(array, key_paths)
|
21
|
-
new_array = Array.new
|
22
|
-
keys = Set.new(key_paths)
|
23
|
-
array.each do |i|
|
24
|
-
new_array << filter_key_paths(i, key_paths)
|
25
|
-
end
|
26
|
-
return new_array
|
27
|
-
end
|
28
|
-
end
|