rxfreader 0.3.4 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c771adeccd1e72c4ece1074e644fe3ed1d368b415b298a766be843fca0d8199b
4
- data.tar.gz: 7ce5c6dc0c1e29031e5ae25e4d7ec11c029380425ab0479b725ba7e16c0cb84e
3
+ metadata.gz: 17291a502508f8b12f3a005bcd180b63e4c462fdecf428ce53a0f3bf5ddc983c
4
+ data.tar.gz: d6f34a350e06629dadeae1e60d6510c47351cc14b218fd24b22536399df5cfe1
5
5
  SHA512:
6
- metadata.gz: 13e8b31cca1a5979e6582490babef00147483ce3a077d6b95c3fa2fd3edb6808b8f19e8a49367cc0a99526726b333db474ad2edf366715a0f08e294ee6bd57aa
7
- data.tar.gz: 31aeb2a5b65d78364e81893d229003e81e358e9fb71d40c02ea637b9068b6fa0ea971df7f659c031883fded45d4da3025a118764a3911003743a7793c464fdac
6
+ metadata.gz: 50b68a8ff3a33f871c45971782557a13f8373adac2f1c8fb910594c778f281d9593edb3ae26aaa9dbb6d575b1f1b094090a33bfa24a3999042066489d4a0c914
7
+ data.tar.gz: ff4d1e7f5cd1b16e092519e3e1154c93f2dd7495bd2eb25c9bebfe65266df6f78489ad063655913c664f84690f94900d8a009e07577c95943f407b67eaf915e4
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/rxfreader.rb CHANGED
@@ -16,7 +16,9 @@ module RXFRead
16
16
 
17
17
  class FileX
18
18
 
19
- def self.exists?(s) RXFReader.exists?(s) end
19
+ def self.dirname(s) RXFReader.dirname(s) end
20
+ def self.exist?(s) RXFReader.exist?(s) end
21
+ def self.exists?(s) RXFReader.exist?(s) end
20
22
  def self.filetype(s) RXFReader.filetype(s) end
21
23
  def self.read(s) RXFReader.read(s).first end
22
24
 
@@ -31,7 +33,11 @@ end
31
33
  class RXFReader
32
34
  using ColouredText
33
35
 
34
- def self.exists?(filename)
36
+ def self.dirname(s)
37
+ File.dirname s
38
+ end
39
+
40
+ def self.exist?(filename)
35
41
 
36
42
  type = self.filetype(filename)
37
43
 
@@ -46,145 +52,12 @@ class RXFReader
46
52
 
47
53
  return nil unless filex
48
54
 
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
55
+ filex.exist? filename
71
56
 
72
- end
73
57
  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
159
-
160
- end
161
-
162
- end
163
-
164
-
165
- class RXFReaderException < Exception
166
- end
167
-
168
- class RXFReader
169
- using ColouredText
170
-
58
+
171
59
  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
-
60
+ self.exist?(filename)
188
61
  end
189
62
 
190
63
  def self.filetype(x)
@@ -200,7 +73,7 @@ class RXFReader
200
73
  :file
201
74
  else
202
75
 
203
- if File.exists?(x) then
76
+ if File.exist?(x) then
204
77
  :file
205
78
  else
206
79
  :text
@@ -209,10 +82,10 @@ class RXFReader
209
82
  end
210
83
  end
211
84
 
212
- def self.read(x, h={})
213
-
85
+ def self.read(x, h={})
86
+
214
87
  opt = {debug: false, auto: false}.merge(h)
215
-
88
+
216
89
  debug = opt[:debug]
217
90
 
218
91
  raise RXFReaderException, 'nil found, expected a string' if x.nil?
@@ -222,51 +95,51 @@ class RXFReader
222
95
  [x.xml, :rexle]
223
96
 
224
97
  elsif x.strip[/^<(\?xml|[^\?])/] then
225
-
98
+
226
99
  [x, :xml]
227
100
 
228
101
  elsif x.lines.length == 1 then
229
102
 
230
103
  if x[/^https?:\/\//] then
231
-
104
+
232
105
  puts 'before GPDRequest'.info if debug
233
-
106
+
234
107
  r = if opt[:username] and opt[:password] then
235
108
  GPDRequest.new(opt[:username], opt[:password]).get(x)
236
109
  else
237
110
  response = RestClient.get(x)
238
111
  end
239
-
112
+
240
113
  case r.code
241
- when '404'
114
+ when '404'
242
115
  raise(RXFReaderException, "404 %s not found" % x)
243
- when '401'
116
+ when '401'
244
117
  raise(RXFReaderException, "401 %s unauthorized access" % x)
245
118
  end
246
-
119
+
247
120
  [r.body, :url]
248
-
121
+
249
122
  elsif x[/^dfs:\/\//] then
250
-
123
+
251
124
  r = DfsFile.read(x).force_encoding('UTF-8')
252
125
  [r, :dfs]
126
+
253
127
 
254
-
255
- elsif x[/^file:\/\//] or File.exists?(x) then
256
-
128
+ elsif x[/^file:\/\//] or File.exist?(x) then
129
+
257
130
  puts 'RXFHelper.read before File.read' if debug
258
131
  contents = File.read(File.expand_path(x.sub(%r{^file://}, '')))
259
-
132
+
260
133
  [contents, :file]
261
-
134
+
262
135
  elsif x =~ /\s/
263
136
  [x, :text]
264
- elsif DfsFile.exists?(x)
137
+ elsif DfsFile.exist?(x)
265
138
  [DfsFile.read(x).force_encoding('UTF-8'), :dfs]
266
139
  else
267
140
  [x, :unknown]
268
141
  end
269
-
142
+
270
143
  else
271
144
 
272
145
  [x, :unknown]
@@ -288,5 +161,5 @@ class RXFReader
288
161
  reveal(url, a << uri_str)
289
162
  end
290
163
 
291
-
164
+
292
165
  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.6
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-02-18 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: gpd-request
@@ -83,20 +83,20 @@ dependencies:
83
83
  requirements:
84
84
  - - "~>"
85
85
  - !ruby/object:Gem::Version
86
- version: '0.1'
86
+ version: '0.2'
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 0.1.3
89
+ version: 0.2.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0.1'
96
+ version: '0.2'
97
97
  - - ">="
98
98
  - !ruby/object:Gem::Version
99
- version: 0.1.3
99
+ version: 0.2.0
100
100
  description:
101
101
  email: digital.robertson@gmail.com
102
102
  executables: []
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  requirements: []
126
- rubygems_version: 3.4.1
126
+ rubygems_version: 3.4.4
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: Reads a file from an HTTP address, DFS address, or local location.
metadata.gz.sig CHANGED
Binary file