rxfreader 0.3.4 → 0.3.5

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: c771adeccd1e72c4ece1074e644fe3ed1d368b415b298a766be843fca0d8199b
4
- data.tar.gz: 7ce5c6dc0c1e29031e5ae25e4d7ec11c029380425ab0479b725ba7e16c0cb84e
3
+ metadata.gz: f4cbe4e77e93e40c6fa085b6916e58c9cfb70438c21295877d7890f122961a52
4
+ data.tar.gz: db8ffdb4a7d38a29442f414e5d793ac80effa2653bc5cbc9b3ef78b6cd925369
5
5
  SHA512:
6
- metadata.gz: 13e8b31cca1a5979e6582490babef00147483ce3a077d6b95c3fa2fd3edb6808b8f19e8a49367cc0a99526726b333db474ad2edf366715a0f08e294ee6bd57aa
7
- data.tar.gz: 31aeb2a5b65d78364e81893d229003e81e358e9fb71d40c02ea637b9068b6fa0ea971df7f659c031883fded45d4da3025a118764a3911003743a7793c464fdac
6
+ metadata.gz: 39fbbe11535c2ae606dfe9a11508036747cfd2ac989f62719b695307f28d91bf6a674776f1c307095f671520cf4bc6dac00d918b7a81547861953ed06ecbe805
7
+ data.tar.gz: 1b7867cba68181db1089c5230cfc7d83fe1cac1d2d9811c4a0ac9318fe57e65ac541f75ac7b07be48e772ba03b62de00a62453a08b1dc3d2efee849a9da848e4
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/rxfreader.rb CHANGED
@@ -16,7 +16,8 @@ module RXFRead
16
16
 
17
17
  class FileX
18
18
 
19
- def self.exists?(s) RXFReader.exists?(s) end
19
+ def self.exist?(s) RXFReader.exist?(s) end
20
+ def self.exists?(s) RXFReader.exist?(s) end
20
21
  def self.filetype(s) RXFReader.filetype(s) end
21
22
  def self.read(s) RXFReader.read(s).first end
22
23
 
@@ -31,7 +32,7 @@ end
31
32
  class RXFReader
32
33
  using ColouredText
33
34
 
34
- def self.exists?(filename)
35
+ def self.exist?(filename)
35
36
 
36
37
  type = self.filetype(filename)
37
38
 
@@ -46,145 +47,12 @@ class RXFReader
46
47
 
47
48
  return nil unless filex
48
49
 
49
- filex.exists? filename
50
-
51
- end
52
-
53
- def self.filetype(x)
54
-
55
- return :string if x.lines.length > 1
56
-
57
- case x
58
- when /^https?:\/\//
59
- :http
60
- when /^dfs:\/\//
61
- :dfs
62
- when /^file:\/\//
63
- :file
64
- else
65
-
66
- if File.exists?(x) then
67
- :file
68
- else
69
- :text
70
- end
71
-
72
- end
73
- end
74
-
75
- def self.read(x, h={})
76
-
77
- opt = {debug: false, auto: false}.merge(h)
78
-
79
- debug = opt[:debug]
80
-
81
- raise RXFReaderException, 'nil found, expected a string' if x.nil?
82
-
83
- if x.class.to_s =~ /Rexle$/ then
84
-
85
- [x.xml, :rexle]
86
-
87
- elsif x.strip[/^<(\?xml|[^\?])/] then
88
-
89
- [x, :xml]
90
-
91
- elsif x.lines.length == 1 then
92
-
93
- if x[/^https?:\/\//] then
94
-
95
- puts 'before GPDRequest'.info if debug
96
-
97
- r = if opt[:username] and opt[:password] then
98
- GPDRequest.new(opt[:username], opt[:password]).get(x)
99
- else
100
- response = RestClient.get(x)
101
- end
102
-
103
- case r.code
104
- when '404'
105
- raise(RXFReaderException, "404 %s not found" % x)
106
- when '401'
107
- raise(RXFReaderException, "401 %s unauthorized access" % x)
108
- end
109
-
110
- [r.body, :url]
111
-
112
- elsif x[/^dfs:\/\//] then
113
-
114
- r = DfsFile.read(x).force_encoding('UTF-8')
115
- [r, :dfs]
116
-
117
-
118
- elsif x[/^file:\/\//] or File.exists?(x) then
119
-
120
- puts 'RXFHelper.read before File.read' if debug
121
- contents = File.read(File.expand_path(x.sub(%r{^file://}, '')))
122
-
123
- [contents, :file]
124
-
125
- elsif x =~ /\s/
126
- [x, :text]
127
- elsif DfsFile.exists?(x)
128
- [DfsFile.read(x).force_encoding('UTF-8'), :dfs]
129
- else
130
- [x, :unknown]
131
- end
132
-
133
- else
134
-
135
- [x, :unknown]
136
- end
137
- end
138
-
139
- def self.reveal(uri_str, a=[])
140
-
141
- response = Net::HTTP.get_response(URI.parse(uri_str))
142
- url = case response
143
- when Net::HTTPRedirection then response['location']
144
- end
145
-
146
- return a << uri_str if url.nil?
147
-
148
- reveal(url, a << uri_str)
149
- end
150
-
151
- end
152
- module RXFRead
153
-
154
- class FileX
155
-
156
- def self.exists?(s) RXFReader.exists?(s) end
157
- def self.filetype(s) RXFReader.filetype(s) end
158
- def self.read(s) RXFReader.read(s).first end
50
+ filex.exist? filename
159
51
 
160
52
  end
161
-
162
- end
163
-
164
-
165
- class RXFReaderException < Exception
166
- end
167
-
168
- class RXFReader
169
- using ColouredText
170
-
53
+
171
54
  def self.exists?(filename)
172
-
173
- type = self.filetype(filename)
174
-
175
- filex = case type
176
- when :file
177
- File
178
- when :dfs
179
- DfsFile
180
- else
181
- nil
182
- end
183
-
184
- return nil unless filex
185
-
186
- filex.exists? filename
187
-
55
+ self.exist?(filename)
188
56
  end
189
57
 
190
58
  def self.filetype(x)
@@ -200,7 +68,7 @@ class RXFReader
200
68
  :file
201
69
  else
202
70
 
203
- if File.exists?(x) then
71
+ if File.exist?(x) then
204
72
  :file
205
73
  else
206
74
  :text
@@ -209,10 +77,10 @@ class RXFReader
209
77
  end
210
78
  end
211
79
 
212
- def self.read(x, h={})
213
-
80
+ def self.read(x, h={})
81
+
214
82
  opt = {debug: false, auto: false}.merge(h)
215
-
83
+
216
84
  debug = opt[:debug]
217
85
 
218
86
  raise RXFReaderException, 'nil found, expected a string' if x.nil?
@@ -222,51 +90,51 @@ class RXFReader
222
90
  [x.xml, :rexle]
223
91
 
224
92
  elsif x.strip[/^<(\?xml|[^\?])/] then
225
-
93
+
226
94
  [x, :xml]
227
95
 
228
96
  elsif x.lines.length == 1 then
229
97
 
230
98
  if x[/^https?:\/\//] then
231
-
99
+
232
100
  puts 'before GPDRequest'.info if debug
233
-
101
+
234
102
  r = if opt[:username] and opt[:password] then
235
103
  GPDRequest.new(opt[:username], opt[:password]).get(x)
236
104
  else
237
105
  response = RestClient.get(x)
238
106
  end
239
-
107
+
240
108
  case r.code
241
- when '404'
109
+ when '404'
242
110
  raise(RXFReaderException, "404 %s not found" % x)
243
- when '401'
111
+ when '401'
244
112
  raise(RXFReaderException, "401 %s unauthorized access" % x)
245
113
  end
246
-
114
+
247
115
  [r.body, :url]
248
-
116
+
249
117
  elsif x[/^dfs:\/\//] then
250
-
118
+
251
119
  r = DfsFile.read(x).force_encoding('UTF-8')
252
120
  [r, :dfs]
121
+
253
122
 
254
-
255
- elsif x[/^file:\/\//] or File.exists?(x) then
256
-
123
+ elsif x[/^file:\/\//] or File.exist?(x) then
124
+
257
125
  puts 'RXFHelper.read before File.read' if debug
258
126
  contents = File.read(File.expand_path(x.sub(%r{^file://}, '')))
259
-
127
+
260
128
  [contents, :file]
261
-
129
+
262
130
  elsif x =~ /\s/
263
131
  [x, :text]
264
- elsif DfsFile.exists?(x)
132
+ elsif DfsFile.exist?(x)
265
133
  [DfsFile.read(x).force_encoding('UTF-8'), :dfs]
266
134
  else
267
135
  [x, :unknown]
268
136
  end
269
-
137
+
270
138
  else
271
139
 
272
140
  [x, :unknown]
@@ -288,5 +156,5 @@ class RXFReader
288
156
  reveal(url, a << uri_str)
289
157
  end
290
158
 
291
-
159
+
292
160
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rxfreader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  ZhYGFOGLCyFBzNWg6gwMKjzpzDZB/H0+GTRB2c3+7DVuJWqyC5SbGnVLkT4Q8+B6
36
36
  Ws39Z48SRONdDWtHwAiUtnU+
37
37
  -----END CERTIFICATE-----
38
- date: 2023-01-15 00:00:00.000000000 Z
38
+ date: 2023-01-16 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: gpd-request
metadata.gz.sig CHANGED
Binary file