nicinfo 1.3.0.pre.alpha1 → 1.5.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.
@@ -1,6 +1,6 @@
1
1
  {
2
- "nicInfo_demoUrl" : "https://rdap.arin.net/registry/nameserver/ns2.example.com",
3
- "nicInfo_demoHint" : "nicinfo ns2.example.com",
2
+ "nicInfo_demoUrl" : "https://rdap.arin.net/registry/nameserver/ns2.example.example",
3
+ "nicInfo_demoHint" : "nicinfo ns2.example.example",
4
4
  "rdapConformance":[
5
5
  "rdap_level_0"
6
6
  ],
@@ -1,6 +1,6 @@
1
1
  {
2
- "nicInfo_demoUrl" : "https://rdap.arin.net/registry/nameserver/ns1.example.com",
3
- "nicInfo_demoHint" : "nicinfo ns1.example.com",
2
+ "nicInfo_demoUrl" : "https://rdap.arin.net/registry/nameserver/ns1.example.example",
3
+ "nicInfo_demoHint" : "nicinfo ns1.example.example",
4
4
  "rdapConformance":[
5
5
  "rdap_level_0"
6
6
  ],
@@ -1,5 +1,5 @@
1
1
  {
2
- "nicInfo_demoUrl" : "https://rdap.arin.net/bootstrap/nameserver/ns1.xn--fo-5ja.example",
2
+ "nicInfo_demoUrl" : "https://rdap.arin.net/registry/nameserver/ns1.xn--fo-5ja.example",
3
3
  "nicInfo_demoHint" : "nicinfo ns1.xn--fo-5ja.example",
4
4
  "rdapConformance":[
5
5
  "rdap_level_0"
@@ -25,9 +25,9 @@
25
25
  }
26
26
  ],
27
27
  "handle":"XXXX",
28
- "objectClassName":"entity",
28
+ "objectClassName":"nameserver",
29
29
  "ldhName":"ns1.xn--fo-5ja.example",
30
- "unicodeName":"foo.example",
30
+ "unicodeName":"ns1.foo.example",
31
31
  "status":[ "active" ],
32
32
  "ipAddresses":{
33
33
  "v4":[ "192.0.2.1", "192.0.2.2" ],
@@ -43,9 +43,9 @@
43
43
  ],
44
44
  "links":[
45
45
  {
46
- "value":"https://rdap.arin.net/bootstrap/nameserver/ns1.xn--fo-5ja.example",
46
+ "value":"https://rdap-bootstrap.arin.net/bootstrap/nameserver/ns1.xn--fo-5ja.example",
47
47
  "rel":"self",
48
- "href":"https://rdap.arin.net/bootstrap/nameserver/ns1.xn--fo-5ja.example"
48
+ "href":"https://rdap-bootstrap.arin.net/bootstrap/nameserver/ns1.xn--fo-5ja.example"
49
49
  }
50
50
  ],
51
51
  "port43":"whois.example.net",
@@ -32,7 +32,7 @@ module NicInfo
32
32
  end
33
33
  respObjs = ResponseObjSet.new config
34
34
  obj_array.each do |array_object|
35
- domain = Domain.new( config ).process( array_object )
35
+ domain = config.factory.new_domain.process( array_object )
36
36
  root = domain.to_node
37
37
  data_node.add_root( root )
38
38
  if !domain.entities.empty? or !domain.nameservers.empty?
@@ -112,13 +112,13 @@ module NicInfo
112
112
  @entities = @common.process_entities @objectclass
113
113
  json_nses = NicInfo::get_nameservers json_data
114
114
  json_nses.each do |json_ns|
115
- ns = Ns.new( @config )
115
+ ns = @config.factory.new_ns
116
116
  ns.process( json_ns )
117
117
  @nameservers << ns
118
118
  end if json_nses
119
119
  json_net = NicInfo::get_network json_data
120
120
  if json_net
121
- ip = Ip.new @config
121
+ ip = @config.factory.new_ip
122
122
  ip.process json_net
123
123
  @network = ip
124
124
  end
@@ -140,10 +140,10 @@ module NicInfo
140
140
  def display
141
141
  @config.logger.start_data_item
142
142
  @config.logger.data_title "[ DOMAIN ]"
143
- @config.logger.terse "Handle", NicInfo::get_handle( @objectclass )
144
- @config.logger.extra "Object Class Name", NicInfo::get_object_class_name( @objectclass )
145
- @config.logger.terse "Domain Name", NicInfo::get_ldhName( @objectclass )
146
- @config.logger.datum "I18N Domain Name", NicInfo::get_unicodeName( @objectclass )
143
+ @config.logger.terse "Handle", NicInfo::get_handle( @objectclass ), NicInfo::AttentionType::SUCCESS
144
+ @config.logger.extra "Object Class Name", NicInfo::get_object_class_name( @objectclass, "domain", @config )
145
+ @config.logger.terse "Domain Name", NicInfo::get_ldhName( @objectclass ), NicInfo::AttentionType::SUCCESS
146
+ @config.logger.datum "I18N Domain Name", NicInfo::get_unicodeName( @objectclass ), NicInfo::AttentionType::SUCCESS
147
147
  variants = @objectclass[ "variants" ]
148
148
  variant_no = 1
149
149
  variants.each do |variant|
@@ -21,7 +21,7 @@ require 'nicinfo/data_tree'
21
21
  module NicInfo
22
22
 
23
23
  def NicInfo.display_entity json_data, config, data_tree
24
- entity = Entity.new( config ).process( json_data )
24
+ entity = config.factory.new_entity.process( json_data )
25
25
 
26
26
  respobjs = ResponseObjSet.new config
27
27
  root = entity.to_node
@@ -64,7 +64,7 @@ module NicInfo
64
64
  if entity_array.instance_of? Array
65
65
  display_array = Array.new
66
66
  entity_array.each do |ea|
67
- entity = Entity.new( config ).process( ea )
67
+ entity = config.factory.new_entity.process( ea )
68
68
  display_array << entity
69
69
  end
70
70
  NicInfo.display_object_with_entities( display_array, config, data_tree )
@@ -112,7 +112,8 @@ module NicInfo
112
112
 
113
113
  attr_accessor :fns, :names, :phones, :emails, :adrs, :kind, :titles, :roles, :orgs
114
114
 
115
- def initialize
115
+ def initialize( config )
116
+ @config = config
116
117
  @fns = Array.new
117
118
  @names = Array.new
118
119
  @phones = Array.new
@@ -130,93 +131,103 @@ module NicInfo
130
131
  def process entity
131
132
  if ( vcard = get_vcard( entity ) ) != nil
132
133
  vcardElements = vcard[ 1 ]
133
- vcardElements.each do |element|
134
- if element[ 0 ] == "fn"
135
- @fns << element[ 3 ]
136
- end
137
- if element[ 0 ] == "n"
138
- name = ""
139
- if element[ 3 ][ -1 ].instance_of? Array
140
- name << element[ 3 ][ -1 ].join( ' ' )
134
+ if vcardElements.nil? || vcardElements.size == 0
135
+ @config.conf_msgs << "jCard (vCard) is empty."
136
+ elsif vcardElements[ 0 ][ 0 ] != "version"
137
+ @config.conf_msgs << "jCard (vCard) does not have required version first element."
138
+ end
139
+ if !vcardElements.nil?
140
+ vcardElements.each do |element|
141
+ if element[ 0 ] == "fn"
142
+ @fns << element[ 3 ]
141
143
  end
142
- name << ' ' if name[-1] != ' '
143
- name << element[ 3 ][ 1 ]
144
- if element[ 3 ][ 2 ] && !element[ 3 ][ 2 ].empty?
145
- name << " " << element[ 3 ][ 2 ]
144
+ if element[ 0 ] == "n"
145
+ name = ""
146
+ if element[ 3 ][ -1 ].instance_of? Array
147
+ name << element[ 3 ][ -1 ].join( ' ' )
148
+ end
149
+ name << ' ' if name[-1] != ' '
150
+ name << element[ 3 ][ 1 ]
151
+ if element[ 3 ][ 2 ] && !element[ 3 ][ 2 ].empty?
152
+ name << " " << element[ 3 ][ 2 ]
153
+ end
154
+ if element[ 3 ][ 3 ] && !element[ 3 ][ 3 ].empty?
155
+ name << " " << element[ 3 ][ 3 ]
156
+ end
157
+ name << " " << element[ 3 ][ 0 ]
158
+ if element[ 3 ][ -2 ].instance_of? Array
159
+ name << " " << element[ 3 ][ -2 ].join( ' ' )
160
+ end
161
+ @names << name.strip
146
162
  end
147
- if element[ 3 ][ 3 ] && !element[ 3 ][ 3 ].empty?
148
- name << " " << element[ 3 ][ 3 ]
163
+ if element[ 0 ] == "tel"
164
+ tel = Tel.new
165
+ if (type = element[ 1 ][ "type" ]) != nil
166
+ tel.type << type if type.instance_of? String
167
+ tel.type = type if type.instance_of? Array
168
+ end
169
+ if (str = element[ 3 ] ).start_with?( "tel:" )
170
+ tel.number=str[ /^tel\:([^;]*)/,1 ]
171
+ tel.ext=str[ /[^;]*ext=(.*)/,1 ]
172
+ else
173
+ tel.number=str
174
+ end
175
+ @phones << tel
149
176
  end
150
- name << " " << element[ 3 ][ 0 ]
151
- if element[ 3 ][ -2 ].instance_of? Array
152
- name << " " << element[ 3 ][ -2 ].join( ' ' )
177
+ if element[ 0 ] == "email"
178
+ email = Email.new
179
+ if (type = element[ 1 ][ "type" ]) != nil
180
+ email.type << type if type.instance_of? String
181
+ email.type = type if type.instance_of? Array
182
+ end
183
+ email.addr=element[ 3 ]
184
+ @emails << email
153
185
  end
154
- @names << name
155
- end
156
- if element[ 0 ] == "tel"
157
- tel = Tel.new
158
- if (type = element[ 1 ][ "type" ]) != nil
159
- tel.type << type if type.instance_of? String
160
- tel.type = type if type.instance_of? Array
186
+ if element[ 0 ] == "adr"
187
+ adr = Adr.new
188
+ if (type = element[ 1 ][ "type" ]) != nil
189
+ adr.type << type if type.instance_of? String
190
+ adr.type = type if type.instance_of? Array
191
+ end
192
+ if (label = element[ 1 ][ "label" ]) != nil
193
+ adr.label = label.split( "\n" )
194
+ else
195
+ adr.pobox=element[ 3 ][ 0 ]
196
+ adr.extended=element[ 3 ][ 1 ]
197
+ adr.street=element[ 3 ][ 2 ]
198
+ adr.locality=element[ 3 ][ 3 ]
199
+ adr.region=element[ 3 ][ 4 ]
200
+ adr.postal=element[ 3 ][ 5 ]
201
+ adr.country=element[ 3 ][ 6 ]
202
+ adr.structured=true
203
+ end
204
+ @adrs << adr
161
205
  end
162
- if (str = element[ 3 ] ).start_with?( "tel:" )
163
- tel.number=str[ /^tel\:([^;]*)/,1 ]
164
- tel.ext=str[ /[^;]*ext=(.*)/,1 ]
165
- else
166
- tel.number=str
206
+ if element[ 0 ] == "kind"
207
+ @kind = element[ 3 ]
167
208
  end
168
- @phones << tel
169
- end
170
- if element[ 0 ] == "email"
171
- email = Email.new
172
- if (type = element[ 1 ][ "type" ]) != nil
173
- email.type << type if type.instance_of? String
174
- email.type = type if type.instance_of? Array
209
+ if element[ 0 ] == "title"
210
+ @titles << element[ 3 ]
175
211
  end
176
- email.addr=element[ 3 ]
177
- @emails << email
178
- end
179
- if element[ 0 ] == "adr"
180
- adr = Adr.new
181
- if (type = element[ 1 ][ "type" ]) != nil
182
- adr.type << type if type.instance_of? String
183
- adr.type = type if type.instance_of? Array
212
+ if element[ 0 ] == "role"
213
+ @roles << element[ 3 ]
184
214
  end
185
- if (label = element[ 1 ][ "label" ]) != nil
186
- adr.label = label.split( "\n" )
187
- else
188
- adr.pobox=element[ 3 ][ 0 ]
189
- adr.extended=element[ 3 ][ 1 ]
190
- adr.street=element[ 3 ][ 2 ]
191
- adr.locality=element[ 3 ][ 3 ]
192
- adr.region=element[ 3 ][ 4 ]
193
- adr.postal=element[ 3 ][ 5 ]
194
- adr.country=element[ 3 ][ 6 ]
195
- adr.structured=true
215
+ if element[ 0 ] == "org"
216
+ org = Org.new
217
+ if (type = element[ 1 ][ "type" ]) != nil
218
+ org.type << type if type.instance_of? String
219
+ org.type = type if type.instance_of? Array
220
+ end
221
+ names = element[ 3 ]
222
+ org.names << names if names.instance_of? String
223
+ org.names = org.names + names if names.instance_of? Array
224
+ @orgs << org
196
225
  end
197
- @adrs << adr
198
- end
199
- if element[ 0 ] == "kind"
200
- @kind = element[ 3 ]
201
- end
202
- if element[ 0 ] == "title"
203
- @titles << element[ 3 ]
204
- end
205
- if element[ 0 ] == "role"
206
- @roles << element[ 3 ]
207
- end
208
- if element[ 0 ] == "org"
209
- org = Org.new
210
- if (type = element[ 1 ][ "type" ]) != nil
211
- org.type << type if type.instance_of? String
212
- org.type = type if type.instance_of? Array
213
- end
214
- names = element[ 3 ]
215
- org.names << names if names.instance_of? String
216
- org.names = org.names + names if names.instance_of? Array
217
- @orgs << org
218
226
  end
219
227
  end
228
+ if @fns.empty?
229
+ @config.conf_msgs << "jCard (vCard) has no required 'fn' property."
230
+ end
220
231
  end
221
232
  return self
222
233
  end
@@ -232,7 +243,7 @@ module NicInfo
232
243
 
233
244
  def initialize config
234
245
  @config = config
235
- @jcard = JCard.new
246
+ @jcard = JCard.new( config )
236
247
  @common = CommonJson.new config
237
248
  @entity = nil
238
249
  @asEvents = Array.new
@@ -258,7 +269,7 @@ module NicInfo
258
269
  json_networks = NicInfo::get_networks( @objectclass )
259
270
  json_networks.each do |json_network|
260
271
  if json_network.is_a?( Hash )
261
- network = Ip.new( @config )
272
+ network = @config.factory.new_ip
262
273
  network.process( json_network )
263
274
  @networks << network
264
275
  else
@@ -269,7 +280,7 @@ module NicInfo
269
280
  json_autnums = NicInfo::get_autnums( @objectclass )
270
281
  json_autnums.each do |json_autnum|
271
282
  if json_autnum.is_a?( Hash )
272
- autnum = Autnum.new( @config )
283
+ autnum = @config.factory.new_autnum
273
284
  autnum.process( json_autnum )
274
285
  @autnums << autnum
275
286
  else
@@ -282,20 +293,20 @@ module NicInfo
282
293
  def display
283
294
  @config.logger.start_data_item
284
295
  @config.logger.data_title "[ ENTITY ]"
285
- @config.logger.terse "Handle", NicInfo::get_handle( @objectclass )
286
- @config.logger.extra "Object Class Name", NicInfo::get_object_class_name( @objectclass )
296
+ @config.logger.terse "Handle", NicInfo::get_handle( @objectclass ), NicInfo::AttentionType::SUCCESS
297
+ @config.logger.extra "Object Class Name", NicInfo::get_object_class_name( @objectclass, "entity", @config )
287
298
  @jcard.fns.each do |fn|
288
- @config.logger.terse "Name", fn
299
+ @config.logger.terse "Common Name", fn, NicInfo::AttentionType::SUCCESS
289
300
  end
290
301
  @jcard.names.each do |n|
291
- @config.logger.extra "Name", n
302
+ @config.logger.extra "Formal Name", n, NicInfo::AttentionType::SUCCESS
292
303
  end
293
304
  @jcard.orgs.each do |org|
294
305
  item_value = org.names.join( ", " )
295
306
  if !org.type.empty?
296
307
  item_value << " ( #{org.type.join( ", " )} )"
297
308
  end
298
- @config.logger.terse "Organization", item_value
309
+ @config.logger.terse "Organization", item_value, NicInfo::AttentionType::SUCCESS
299
310
  end
300
311
  @jcard.titles.each do |title|
301
312
  @config.logger.extra "Title", title
@@ -15,40 +15,37 @@
15
15
  require 'nicinfo/config'
16
16
  require 'nicinfo/nicinfo_logger'
17
17
  require 'nicinfo/utils'
18
+ require 'nicinfo/common_json'
18
19
 
19
20
  module NicInfo
20
21
 
21
22
  # deals with RDAP error code structures
22
23
  class ErrorCode
23
24
 
24
- def display_error_code ec, config
25
- config.logger.start_data_item
25
+ attr_accessor :config
26
+
27
+ def initialize( config )
28
+ @config = config
29
+ @common = CommonJson.new( config )
30
+ end
31
+
32
+ def display_error_code ec
33
+ @config.logger.start_data_item
26
34
  title = ec[ "title" ]
27
35
  if title == nil
28
36
  title = ""
29
37
  end
30
- config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "[ ERROR ]", title
31
- config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "Code", ec[ "errorCode" ]
38
+ @config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "[ ERROR ]", title, NicInfo::AttentionType::ERROR
39
+ @config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "Code", ec[ "errorCode" ]
32
40
  description = ec[ "description" ]
33
41
  i = 1
34
42
  description.each do |line|
35
- config.logger.prose NicInfo::DataAmount::NORMAL_DATA, i.to_s, line
43
+ @config.logger.prose NicInfo::DataAmount::NORMAL_DATA, i.to_s, line
36
44
  i = i + 1
37
45
  end
38
46
  links = ec[ "links" ]
39
- if links
40
- alternate = NicInfo.get_alternate_link links
41
- config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "More", alternate if alternate
42
- about = NicInfo.get_about_link links
43
- config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "About", about if about
44
- tos = NicInfo.get_tos_link links
45
- config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "TOS", tos if tos
46
- copyright = NicInfo.get_copyright_link links
47
- config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "(C)", copyright if copyright
48
- license = NicInfo.get_license_link links
49
- config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "License", license if license
50
- end
51
- config.logger.end_data_item
47
+ @common.display_simple_links( links )
48
+ @config.logger.end_data_item
52
49
  end
53
50
 
54
51
  end
@@ -0,0 +1,56 @@
1
+ # Copyright (C) 2017 American Registry for Internet Numbers
2
+ #
3
+ # Permission to use, copy, modify, and/or distribute this software for any
4
+ # purpose with or without fee is hereby granted, provided that the above
5
+ # copyright notice and this permission notice appear in all copies.
6
+ #
7
+ # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
+ # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
+ # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
+ # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
+ # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
+ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
13
+ # IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14
+
15
+ module NicInfo
16
+
17
+ # Creates objects we want to mock
18
+ class Factory
19
+
20
+ attr_accessor :config
21
+
22
+ def initialize( config )
23
+ @config = config
24
+ end
25
+
26
+ def new_error_code
27
+ return ErrorCode.new( config )
28
+ end
29
+
30
+ def new_autnum
31
+ return Autnum.new( config )
32
+ end
33
+
34
+ def new_domain
35
+ return Domain.new( config )
36
+ end
37
+
38
+ def new_entity
39
+ return Entity.new( config )
40
+ end
41
+
42
+ def new_ip
43
+ return Ip.new( config )
44
+ end
45
+
46
+ def new_notices
47
+ return Notices.new( config )
48
+ end
49
+
50
+ def new_ns
51
+ return Ns.new( config )
52
+ end
53
+
54
+ end
55
+
56
+ end