rxfreader 0.1.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.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data/lib/rxfreader.rb +93 -0
- data.tar.gz.sig +0 -0
- metadata +130 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cc1d6de022df3f67e2e4bc5102af35e4142dcba47217cbda194619ab0fe8be33
|
4
|
+
data.tar.gz: cc0fbbe4dfd9c277ac74ff5e8af018efdbdc46805ce259c791cacf093491de23
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 59e9bd0bd724ec2e423cf7487784d4f4fbd72409660489eb66ffeaface68e06e2993886a8faf8ee550cd7613ada879ed8dab25c76cfd0425b9751c8b9538d752
|
7
|
+
data.tar.gz: fec43fcc386324a056a8722c1da8356e5a610e76e3f294f778dde42dc80152f805b7fc10f2a41cefdb5ea13afd999ab02fdd8ad0b827ff0f1e35ff2454049b25
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data/lib/rxfreader.rb
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: rxfreader.rb
|
4
|
+
|
5
|
+
|
6
|
+
require 'gpd-request'
|
7
|
+
require 'rest-client'
|
8
|
+
require 'drb_fileclient'
|
9
|
+
|
10
|
+
|
11
|
+
# RXF originally stands for Read XML File.
|
12
|
+
|
13
|
+
|
14
|
+
module RXFRead
|
15
|
+
|
16
|
+
class FileX
|
17
|
+
|
18
|
+
def self.read(x)
|
19
|
+
RXReader.read(x).first
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
class RXFReaderException < Exception
|
27
|
+
end
|
28
|
+
|
29
|
+
class RXFReader
|
30
|
+
using ColouredText
|
31
|
+
|
32
|
+
def self.read(x, h={})
|
33
|
+
|
34
|
+
opt = {debug: false, auto: false}.merge(h)
|
35
|
+
|
36
|
+
debug = opt[:debug]
|
37
|
+
|
38
|
+
raise RXFReaderException, 'nil found, expected a string' if x.nil?
|
39
|
+
|
40
|
+
if x.strip[/^<(\?xml|[^\?])/] then
|
41
|
+
|
42
|
+
[x, :xml]
|
43
|
+
|
44
|
+
elsif x.lines.length == 1 then
|
45
|
+
|
46
|
+
if x[/^https?:\/\//] then
|
47
|
+
|
48
|
+
puts 'before GPDRequest'.info if debug
|
49
|
+
|
50
|
+
r = if opt[:username] and opt[:password] then
|
51
|
+
GPDRequest.new(opt[:username], opt[:password]).get(x)
|
52
|
+
else
|
53
|
+
response = RestClient.get(x)
|
54
|
+
end
|
55
|
+
|
56
|
+
case r.code
|
57
|
+
when '404'
|
58
|
+
raise(RXFReaderException, "404 %s not found" % x)
|
59
|
+
when '401'
|
60
|
+
raise(RXFReaderException, "401 %s unauthorized access" % x)
|
61
|
+
end
|
62
|
+
|
63
|
+
[r.body, :url]
|
64
|
+
|
65
|
+
elsif x[/^dfs:\/\//] then
|
66
|
+
|
67
|
+
r = DfsFile.read(x)
|
68
|
+
[r, :dfs]
|
69
|
+
|
70
|
+
|
71
|
+
elsif x[/^file:\/\//] or File.exists?(x) then
|
72
|
+
|
73
|
+
puts 'RXFHelper.read before File.read' if debug
|
74
|
+
contents = File.read(File.expand_path(x.sub(%r{^file://}, '')))
|
75
|
+
|
76
|
+
[contents, :file]
|
77
|
+
|
78
|
+
elsif x =~ /\s/
|
79
|
+
[x, :text]
|
80
|
+
elsif DfsFile.exists?(x)
|
81
|
+
[DfsFile.read(x), :dfs]
|
82
|
+
else
|
83
|
+
[x, :unknown]
|
84
|
+
end
|
85
|
+
|
86
|
+
else
|
87
|
+
|
88
|
+
[x, :unknown]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
data.tar.gz.sig
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rxfreader
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Robertson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjIwMjE4MTAzNTUxWhcN
|
15
|
+
MjMwMjE4MTAzNTUxWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQCdbMHr
|
17
|
+
9tJknkfsYJNONtwojS/MVoudZPpy5qLVhGhiiEQmweIVrGzxO2kwsDVhk4cMJUAo
|
18
|
+
NG6Ewsh+rUnypALJiR6tUQmsOdI36sZMbRBpHmrgC4ac5JTcVg6fDyhfjJ2xjjq9
|
19
|
+
tyOH3Yffy1DWmE1JjtRxSdWS6BMmDWm+xAd8YYNg48mvdgQ4qvgHb8YStd6a7GqD
|
20
|
+
91GOdhhammdTYvmainfD1Bf73IOjiZPYUlJ61zMOq9esrea2jAoVXRXhuqlCM0UQ
|
21
|
+
/7njQY90ZTZ3C029BzmVfvAhzs6Bdc3TZG9Mi44ikHwQ7k+2zJRtaVau4En2gUV6
|
22
|
+
J7x5HilStB9suCVHfOTwYYJLbVhSx2bn5C+ABKKS4fGbFFtTy5l/Pd46VvHfVOSw
|
23
|
+
4EaF20KaNXIj20IoFT2v4mWDKrA5mveov2WicdVFascShOUWZ5MzLhUK5td8T45k
|
24
|
+
nd4SCqqZinDUowruvn/pDs8d+c4Q25oq+loe9XxTQ52HVws8pZLSNff1ds0CAwEA
|
25
|
+
AaOBijCBhzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU3oMmT0pn
|
26
|
+
xJk/H/aL/nOsbvEj4nwwJgYDVR0RBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
|
27
|
+
c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1hc3RlckBqYW1lc3JvYmVydHNvbi5ldTAN
|
28
|
+
BgkqhkiG9w0BAQsFAAOCAYEAWWO2jFgbvk7ratfXxiiUsamdRgEJbjcFZW15iOwN
|
29
|
+
NBAeJQzKnQ97N1comijuJNJw1jE0WVLroORENnKq6uBQYxjBFUlPinuW7Hd+EIXv
|
30
|
+
nDQaPMn5DoT+fW1QbRs1jFdo9mFHDa2p9anTiGn0hR4g//cPFTIyLmREhp3C0Ehh
|
31
|
+
PGnTMChNX9UIfhZW7vtV3P1ukoY9p6cBUXS+T3bzswRWcnYxt7+qXkcV8SF8TEm+
|
32
|
+
BYtb1fz6idqHX32lKdHMFlmu4UIbUoRQOKbDvqr7LVCudCLNY4M4/uWfCt+nvup1
|
33
|
+
cU+CMj0M2OPMvtYvdILZnw+NxMeJ4OIbEmqNiGX2Sh8YQwW9LJtGOJUv6X+EsLqx
|
34
|
+
q2cwfl7LsAnFNJVG4FX1QBZxiuQ7cJzdJMg9SgeiWF0pDtj3wl3lRqorDEi5dkkc
|
35
|
+
ZhYGFOGLCyFBzNWg6gwMKjzpzDZB/H0+GTRB2c3+7DVuJWqyC5SbGnVLkT4Q8+B6
|
36
|
+
Ws39Z48SRONdDWtHwAiUtnU+
|
37
|
+
-----END CERTIFICATE-----
|
38
|
+
date: 2022-02-18 00:00:00.000000000 Z
|
39
|
+
dependencies:
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: gpd-request
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0.3'
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 0.3.0
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0.3'
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 0.3.0
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: rest-client
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "~>"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '2.1'
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 2.1.0
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '2.1'
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 2.1.0
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: drb_fileclient
|
82
|
+
requirement: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - "~>"
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0.7'
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.7.3
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.7'
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 0.7.3
|
100
|
+
description:
|
101
|
+
email: digital.robertson@gmail.com
|
102
|
+
executables: []
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- lib/rxfreader.rb
|
107
|
+
homepage: https://github.com/jrobertson/rxfreader
|
108
|
+
licenses:
|
109
|
+
- MIT
|
110
|
+
metadata: {}
|
111
|
+
post_install_message:
|
112
|
+
rdoc_options: []
|
113
|
+
require_paths:
|
114
|
+
- lib
|
115
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
requirements: []
|
126
|
+
rubygems_version: 3.2.22
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: Reads a file from an HTTP address, DFS address, or local location.
|
130
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|