osc_ruby 0.5.0 → 0.5.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.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/osc_ruby/query_module.rb +32 -5
- data/lib/osc_ruby/query_results.rb +11 -5
- data/lib/osc_ruby/version.rb +1 -1
- data/spec/core/query_results_spec.rb +30 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9dd900e4ff39818907a2bcd69c651e70531d76f6
|
4
|
+
data.tar.gz: a7e53c3d031a15e5f3ffdeed169ff57057a14813
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a106b666faf3e699c10dcfa532dafcf8a536ab12ce678d8ea882679ee83d8df279ea466331c4d9df85f2ecc8c1ac5334b0e89ae0706f485bb81dd27bce9172e8
|
7
|
+
data.tar.gz: e83331741a6a0ef99eee2c870beecc48f56636dec1d6d37c3f17bc3c9e937abeb8e85a87d9c88243cba4d17c29d43ee2071b3c7e85bcfbfb2f348667eaad164a
|
data/README.md
CHANGED
@@ -225,13 +225,13 @@ product_to_delete.destroy(rn_client)
|
|
225
225
|
|
226
226
|
- [x] Make version default to 1.3 but an option to be set in the config class
|
227
227
|
|
228
|
-
- [
|
228
|
+
- [x] Need to update QueryResults to split the queries
|
229
229
|
|
230
|
-
- [
|
230
|
+
- [x] Need to update QueryResults to be able to manipulate the results
|
231
231
|
|
232
|
-
- [ ]
|
232
|
+
- [ ] Figure out subclasses
|
233
233
|
|
234
|
-
- [ ]
|
234
|
+
- [ ] Follow with next Classes (Accounts,ServiceCategories, Incidents)
|
235
235
|
|
236
236
|
- [ ] Allow for the prefer:exclude-null-properties header => update config and connect class, update tests
|
237
237
|
|
@@ -59,10 +59,6 @@ module OSCRuby
|
|
59
59
|
|
60
60
|
final_hash = []
|
61
61
|
|
62
|
-
query_capture = URI.unescape(resource).split('=')[1]
|
63
|
-
|
64
|
-
queries = query_capture.split(';')
|
65
|
-
|
66
62
|
json_input['items'].each do |item|
|
67
63
|
|
68
64
|
item['rows'].each_with_index do |row,row_i|
|
@@ -75,7 +71,7 @@ module OSCRuby
|
|
75
71
|
|
76
72
|
final_hash.push(obj_hash)
|
77
73
|
|
78
|
-
if json_input['items'].count > 1 && (item['rows'].count-1
|
74
|
+
if json_input['items'].count > 1 && (item['rows'].count-1 <= row_i)
|
79
75
|
|
80
76
|
final_hash.push("\n")
|
81
77
|
|
@@ -103,6 +99,37 @@ module OSCRuby
|
|
103
99
|
|
104
100
|
end
|
105
101
|
|
102
|
+
def query_injection(query,json_response)
|
103
|
+
|
104
|
+
queries = query.split(';')
|
105
|
+
|
106
|
+
count = 0
|
107
|
+
|
108
|
+
json_response.each_with_index do |hash,i|
|
109
|
+
if hash == "\n" && queries.count > 1
|
110
|
+
json_response[i] = "Results for #{queries[count]}:"
|
111
|
+
count += 1
|
112
|
+
elsif hash == "\n"
|
113
|
+
json_response.delete_at(i)
|
114
|
+
elsif json_response.last == "\n"
|
115
|
+
json_response.delete_at(json_response.count - 1)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
json_response
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
def remove_new_lines(json_response)
|
124
|
+
json_response.each_with_index do |hash,i|
|
125
|
+
if hash == "\n"
|
126
|
+
json_response.delete_at(i)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
json_response
|
131
|
+
end
|
132
|
+
|
106
133
|
end
|
107
134
|
|
108
135
|
end
|
@@ -11,11 +11,11 @@ module OSCRuby
|
|
11
11
|
|
12
12
|
def initialize; end
|
13
13
|
|
14
|
-
def
|
14
|
+
def query(client,query,return_json = false)
|
15
15
|
|
16
16
|
ValidationsModule::check_client(client)
|
17
17
|
|
18
|
-
ValidationsModule::check_query(query,"
|
18
|
+
ValidationsModule::check_query(query,"query")
|
19
19
|
|
20
20
|
@query = URI.escape("queryResults/?query=#{query}")
|
21
21
|
|
@@ -23,9 +23,15 @@ module OSCRuby
|
|
23
23
|
|
24
24
|
json_response = JSON.parse(response)
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
json_response.unshift("\n")
|
27
|
+
|
28
|
+
if return_json == true
|
29
|
+
json_response_final = QueryModule::query_injection(query,json_response)
|
30
|
+
puts json_response_final
|
31
|
+
end
|
32
|
+
|
33
|
+
QueryModule::remove_new_lines(json_response)
|
34
|
+
|
29
35
|
end
|
30
36
|
|
31
37
|
end
|
data/lib/osc_ruby/version.rb
CHANGED
@@ -21,7 +21,7 @@ describe OSCRuby::QueryResults do
|
|
21
21
|
OSCRuby::QueryResults.new
|
22
22
|
}
|
23
23
|
|
24
|
-
context "#
|
24
|
+
context "#query" do
|
25
25
|
|
26
26
|
it 'should expect client is an instance of OSCRuby::Client class and raise an error if does not' do
|
27
27
|
|
@@ -29,7 +29,7 @@ describe OSCRuby::QueryResults do
|
|
29
29
|
|
30
30
|
client = nil
|
31
31
|
|
32
|
-
expect{query_results.
|
32
|
+
expect{query_results.query(client,'describe')}.to raise_error('Client must have some configuration set; please create an instance of OSCRuby::Client with configuration settings')
|
33
33
|
|
34
34
|
end
|
35
35
|
|
@@ -37,17 +37,41 @@ describe OSCRuby::QueryResults do
|
|
37
37
|
|
38
38
|
expect(client).to be_an(OSCRuby::Client)
|
39
39
|
|
40
|
-
expect{query_results.
|
40
|
+
expect{query_results.query(client,"")}.to raise_error("A query must be specified when using the 'query' method")
|
41
41
|
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'should put results in array of hashes',:vcr do
|
45
45
|
|
46
|
-
expect(query_results.
|
46
|
+
# expect(query_results.query(client,"describe")).not_to eq(nil)
|
47
47
|
|
48
|
-
expect(query_results.
|
48
|
+
expect(query_results.query(client,"describe")).to be_an(Array)
|
49
49
|
|
50
|
-
expect(query_results.
|
50
|
+
# expect(query_results.query(client,"describe answers")).not_to eq(nil)
|
51
|
+
|
52
|
+
expect(query_results.query(client,"describe answers;describe serviceproducts",true)).to be_an(Array)
|
53
|
+
|
54
|
+
# expect(query_results.query(client,"describe answers;describe servicecategories")).not_to eq(nil)
|
55
|
+
|
56
|
+
expect(query_results.query(client,"describe answers;describe servicecategories")).to be_an(Array)
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should be able to manipulate and assign results data',:vcr do
|
61
|
+
|
62
|
+
@answers = query_results.query(client,"select * from answers where ID > 2500")
|
63
|
+
|
64
|
+
@answers.each do |answer|
|
65
|
+
|
66
|
+
expect(answer['id'].to_i).to be_a(Integer)
|
67
|
+
|
68
|
+
expect(answer['answerType']).not_to be(nil)
|
69
|
+
|
70
|
+
expect(answer['answerType']).not_to eq("\n")
|
71
|
+
|
72
|
+
expect{@answer = OSCRuby::Answer.new(answer)}.not_to raise_error
|
73
|
+
|
74
|
+
end
|
51
75
|
|
52
76
|
end
|
53
77
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: osc_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rajan Davis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simplecov
|