osc_ruby 1.4.0 → 1.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3befd00fc6195cab16ccef73d6809fc649e311a13ceccb258ed9ce9e6eac185
4
- data.tar.gz: 4b05e0a96af0fa60bf9fbbb3369b389f86d630034e96a5625360ed9e57755d00
3
+ metadata.gz: 693d56c32ec069be28667eae3e70a31eedd98fae1b50b9403854e7471afb6f58
4
+ data.tar.gz: 5ac52a3d9c6afb56d299a6ffa78c35f2191e06bad8ec586ff83f2488e21bc04b
5
5
  SHA512:
6
- metadata.gz: 02bc4af753950b70a25cb37e31ba06cfcd4c9d16d2f50ce74d1a9279451cc005111641ee03036d5da0488c5ddf18ca89dd7c9c9b6b9bcf5a1ee3c5d43ce57777
7
- data.tar.gz: 98808cf54cce0667c90529b4546fe6e8b79a14dd3259581b5a470e0909c2e689a2bbbe8e8e26fc0b5f787df659ac9fdaf2b241d2332c2ee975600c520462bb82
6
+ metadata.gz: c5d54e3c07c866018faa38ec87546e28dd74df52deaf27303966ab1571f49fb1f8f74d0bad42cb8a9e69573b585d72d62d0bec284a77cb990e384d36c9b28226
7
+ data.tar.gz: 6c9f8474cc60c75a4ea32d74c17b6d277ad738db91e3b9d359146bfebf71bf5ac4cf1541fe55bc68d441ffe1859ae5d6c49efc3a7eb28237590f887f4e7f2e88
data/.travis.yml CHANGED
@@ -1,12 +1,15 @@
1
+ env:
2
+ global:
3
+ - CC_TEST_REPORTER_ID=3cf6bec1eab840d45119164e7e2fd517f5e73c9c34a68051cd09eea110a22884
1
4
  language: ruby
2
5
  rvm:
3
6
  - 2.2.0
4
- addons:
5
- code_climate:
6
- repo_token:
7
- secure: jhiFV5qK92z9GNZNgifvOmzoYmghcTFcuHYn21B5pkcIFmUJRYL03FK4QHqinFQ4BvjHnKlGTEgRPvglivvPBtIwpGMwuDF0oX0JHeTNLXuAXk8Dd6SAap+udSc2fOZYBg7H8PNmhSVpP97fYu23JsLmhRN8lnoO/yYyFUn/xUZIufOhpPj5RBMtR/XmxXiqS1tnsuHpSs7P+Kp/h6sr8QUOw1pJALEAqHGw2WmdxGrI76GQc0bylLFGMITkCbAiTxVQA3QnjLKFYCHq8zo1U0QZiW78+ubbV22oZS1EVATAb4SyqlqFd2bJA9wYjL2J4tYl1I+RvgVSspMsksHs72uIYHDTNSsEuQTnMCxtkq7WJLbYjRW3Tzbqn124ize/NmJqHcJ70Bc8Tzc3CkgEuJNF/cK266r0UkNTu+m65OTElyic14y+wCzeU8r/aDfX9vQKPBpOFpvHuoWMC54iiGIPjLVZb0AYvI2i3weK2dcCh7ZFD+FsFoMAzyaFFFJP4ANH7R08ewVpTjdud4O8WiQBJOW08dXE9inOF+4hqUho2FdrTWQLvMbanVXOmQXsODeEy7zxFUi1I1wVcX1AktEACmcX2ruose8UiScRu7Tr2R6mhgPa4UAf1YhhBClYafeqtCBi1rRrHkgOkaofhKbU3hHHF5cQwDP2v2jUYEI=
8
7
  before_install:
9
- - "gem install bundler"
8
+ - gem install bundler
9
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
10
+ - chmod +x ./cc-test-reporter
11
+ - ./cc-test-reporter before-build
12
+ - bundle install
10
13
  script: bundle exec rake spec
11
- after_success:
12
- - bundle exec codeclimate-test-reporter
14
+ after_script:
15
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- osc_ruby (1.3.2)
4
+ osc_ruby (1.4.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,14 +1,13 @@
1
1
  require 'osc_ruby/modules/validations_module'
2
2
  require 'osc_ruby/modules/normalize_module'
3
- require 'osc_ruby/modules/query_module'
3
+ require_relative '../../ext/string.rb'
4
4
  require 'json'
5
5
 
6
6
  module OSCRuby
7
7
 
8
8
  class QueryResults
9
9
 
10
- include QueryModule
11
- include ValidationsModule
10
+ include ValidationsModule, NormalizeModule
12
11
 
13
12
  def initialize; end
14
13
 
@@ -19,8 +18,17 @@ module OSCRuby
19
18
  ValidationsModule::check_query(query,"query")
20
19
 
21
20
  @query = URI.escape("queryResults/?query=#{query}")
21
+
22
+ obj_to_find = OSCRuby::Connect.get(client,@query)
22
23
 
23
- response = QueryModule::find(client,@query)
24
+ if obj_to_find.code.to_i == 200 || obj_to_find.code.to_i == 201
25
+
26
+ response = NormalizeModule::normalize(obj_to_find)
27
+ else
28
+
29
+ response = obj_to_find.body
30
+
31
+ end
24
32
 
25
33
  JSON.parse(response)
26
34
 
@@ -1,4 +1,5 @@
1
1
  require 'osc_ruby/client'
2
+ require 'osc_ruby/modules/validations_module'
2
3
 
3
4
  require 'net/http'
4
5
  require 'openssl'
@@ -7,9 +8,11 @@ require 'cgi'
7
8
 
8
9
  module OSCRuby
9
10
 
11
+ # This class is purely to provide the underlying methods for CRUD functionality using Net::HTTP, URI, and OpenSSL
10
12
  class Connect
11
- # This class is purely to provide the underlying methods for CRUD functionality using Net::HTTP, URI, and OpenSSL
12
13
 
14
+ include ValidationsModule
15
+
13
16
  def self.get(client,resource_url = nil)
14
17
 
15
18
  @final_config = get_check(client,resource_url)
@@ -166,11 +169,7 @@ module OSCRuby
166
169
 
167
170
  def self.check_client_config(client)
168
171
 
169
- if client.nil?
170
- raise ArgumentError, "Client must have some configuration set; please create an instance of OSCRuby::Client with configuration settings"
171
- else
172
- @config = client.config
173
- end
172
+ @config = ValidationsModule::check_client(client).config
174
173
 
175
174
  if @config.nil?
176
175
  raise ArgumentError, "Client configuration cannot be nil or blank"
@@ -7,69 +7,6 @@ module OSCRuby
7
7
 
8
8
  class << self
9
9
 
10
- def extract_attributes(obj)
11
-
12
- empty_arr = [{}]
13
-
14
- obj_vars = obj.instance_variables
15
-
16
- obj_vars.each do |var|
17
-
18
- # Make sure to get rid of the empty ID
19
- # otherwise everything gets all screwed up
20
-
21
- if var.to_s != '@id'
22
-
23
- obj_attr = var.to_s.delete("@")
24
-
25
- obj_attr_val = obj.instance_variable_get(var)
26
-
27
- empty_arr[0][obj_attr] = obj_attr_val
28
-
29
- end
30
-
31
- end
32
-
33
- empty_arr
34
-
35
- end
36
-
37
- def check_for_id(id)
38
-
39
- if id.nil? == true
40
-
41
- raise ArgumentError, 'ID cannot be nil'
42
-
43
- elsif id.class != Fixnum
44
-
45
- raise ArgumentError, 'ID must be an integer'
46
-
47
- end
48
-
49
- end
50
-
51
- def check_object_for_id(obj,class_name)
52
-
53
- if obj.id.nil?
54
-
55
- raise ArgumentError, "#{class_name} must have a valid ID set"
56
-
57
- end
58
-
59
- end
60
-
61
- def check_attributes(attributes)
62
-
63
- if attributes.class != Hash
64
-
65
- puts attributes
66
-
67
- raise ArgumentError, "Attributes must be a hash; please use the appropriate data structure"
68
-
69
- end
70
-
71
- end
72
-
73
10
  def check_query(query,method_name = "where")
74
11
 
75
12
  if query.empty?
@@ -78,16 +15,6 @@ module OSCRuby
78
15
 
79
16
  end
80
17
 
81
- end
82
-
83
- def check_attributes_request(attributes_request,class_name)
84
-
85
- if attributes_request.empty?
86
-
87
- raise ArgumentError, "The attributes you are requesting for the #{class_name} object must be specified when using the 'select' method"
88
-
89
- end
90
-
91
18
  end
92
19
 
93
20
  def check_client(client)
@@ -97,69 +24,7 @@ module OSCRuby
97
24
  raise ArgumentError, "Client must have some configuration set; please create an instance of OSCRuby::Client with configuration settings"
98
25
 
99
26
  end
100
-
101
- end
102
-
103
- def attr_hash_exists_and_is_type_of(obj,key,val,class_of_value)
104
-
105
- return obj[0][key][val].nil? || obj[0][key][val].class != class_of_value
106
-
107
- end
108
-
109
- def check_for_names(obj_attrs,class_name)
110
-
111
- if obj_attrs[0]['names'].count == 0 || obj_attrs[0]['names'][0]['labelText'].nil? || obj_attrs[0]['names'][0]['language'].nil?
112
-
113
- raise ArgumentError, "#{class_name} should at least have one name set"
114
-
115
- end
116
-
117
- obj_attrs
118
-
119
- end
120
-
121
- def check_for_parents(obj_attrs)
122
-
123
- if !obj_attrs[0]['parent'].nil? && obj_attrs[0]['parent'].is_a?(Hash) && !obj_attrs[0]['parent'].key?('id') && !obj_attrs[0]['parent'].key?('lookupName')
124
-
125
- obj_attrs[0].delete('parent')
126
-
127
- end
128
-
129
- obj_attrs
130
-
131
- end
132
-
133
- def check_interfaces(empty_arr)
134
-
135
- if empty_arr[0]['adminVisibleInterfaces'].empty?
136
-
137
- empty_arr[0].delete('adminVisibleInterfaces')
138
-
139
- end
140
-
141
- if empty_arr[0]['endUserVisibleInterfaces'].empty?
142
-
143
- empty_arr[0].delete('endUserVisibleInterfaces')
144
-
145
- end
146
-
147
- empty_arr
148
-
149
- end
150
-
151
- def check_obj_for_errors(obj_to_check)
152
-
153
- json_obj = JSON.parse(obj_to_check.body)
154
-
155
- if !json_obj.nil? && json_obj['items'][0]['rows'].count == 0
156
-
157
- puts obj_to_check.body
158
-
159
- raise ArgumentError, 'There were no objects matching your query; please try again.'
160
-
161
- end
162
-
27
+ client
163
28
  end
164
29
 
165
30
  end
@@ -1,3 +1,3 @@
1
1
  module OSCRuby
2
- VERSION = "1.4.0"
2
+ VERSION = "1.4.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: osc_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rajan Davis
@@ -168,7 +168,6 @@ files:
168
168
  - lib/osc_ruby/configuration.rb
169
169
  - lib/osc_ruby/connect.rb
170
170
  - lib/osc_ruby/modules/normalize_module.rb
171
- - lib/osc_ruby/modules/query_module.rb
172
171
  - lib/osc_ruby/modules/validations_module.rb
173
172
  - lib/osc_ruby/version.rb
174
173
  - osc_ruby.gemspec
@@ -1,55 +0,0 @@
1
- require 'osc_ruby/connect'
2
- require 'osc_ruby/modules/validations_module'
3
- require 'osc_ruby/modules/normalize_module'
4
- require_relative '../../ext/string.rb'
5
-
6
- module OSCRuby
7
-
8
- module QueryModule
9
-
10
- class << self
11
-
12
- include ValidationsModule, NormalizeModule
13
-
14
- def find(rn_client,resource)
15
-
16
- obj_to_find = OSCRuby::Connect.get(rn_client,resource)
17
-
18
- if obj_to_find.code.to_i == 200 || obj_to_find.code.to_i == 201
19
-
20
- # ValidationsModule::check_obj_for_errors(obj_to_find)
21
-
22
- NormalizeModule::normalize(obj_to_find)
23
- else
24
-
25
- puts obj_to_find.body
26
-
27
- obj_to_find.body
28
-
29
- end
30
-
31
- end
32
-
33
- def create(rn_client,resource,json_content)
34
-
35
- OSCRuby::Connect.post_or_patch(rn_client,resource,json_content)
36
-
37
- end
38
-
39
- def update(rn_client,resource,json_content)
40
-
41
- OSCRuby::Connect.post_or_patch(rn_client,resource,json_content,true)
42
-
43
- end
44
-
45
- def destroy(rn_client,resource)
46
-
47
- OSCRuby::Connect.delete(rn_client,resource)
48
-
49
- end
50
-
51
- end
52
-
53
- end
54
-
55
- end