sentofu 0.2.0 → 0.2.1

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: 6b7dc29a9728152c3aa6e84c7112e37743b19e5261ede35083a8937e92763376
4
- data.tar.gz: '009438a0d7a8d47de159407759b396632292bd77457381cf52826bab414236c5'
3
+ metadata.gz: 438abd6ab431bafd2d9f9cd6ff66202cc311de0d16081b9bcbf62f040ab2dde7
4
+ data.tar.gz: b357331c8ffca74c00130a8965b95be86afbbd8e9300fd3db485b9a2ba5e5200
5
5
  SHA512:
6
- metadata.gz: aeab8b37e947bd378312f9d6505501884b299e68600d314632729804d58c1fee6da15ebdfe0e9890b82ad21be15906faaa99bd2f173e16c0e037d3c8ed6d0784
7
- data.tar.gz: 887c2f98f8b238157cef6fc711cced2634c51a26d096d34e5c4e645e10631719dcfbc19a488b5223c19263d7cd19322078c5b4452e402f2e91a507db7238942e
6
+ metadata.gz: 7d9b1b89c83523e5f8ffdf956f6f7339fa6e42ced07be392609503300ebbe50ac9e68e380edd5125210f07f85488420296efd28c62160ad7d50f0543c20b5779
7
+ data.tar.gz: 39b988baecc334abec4fa15cd52b78a04feb92b1f34f9e5b1f11ecaeaeb0b42a3a0155cfcf3715fb3baca8865eba82637739fc9a5cd33468daeb6cc41d448abc
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
  # CHANGELOG.md
3
3
 
4
4
 
5
+ ## sentofu 0.2.1 released 2019-05-30
6
+
7
+ * Fix version/modified when loading from local yaml
8
+
9
+
5
10
  ## sentofu 0.2.0 released 2019-05-29
6
11
 
7
12
  * Accept a directory for Sentofu.init(x)
data/lib/sentofu/api.rb CHANGED
@@ -186,15 +186,12 @@ module Sentofu
186
186
 
187
187
  def modified
188
188
 
189
- Time.parse(
190
- @spec[:meta]['properties']
191
- .find { |pr| pr['type'] == 'X-Modified' }['value'])
189
+ Time.parse(@spec[:meta][:modified])
192
190
  end
193
191
 
194
192
  def version
195
193
 
196
- @spec[:meta]['properties']
197
- .find { |pr| pr['type'] == 'X-Version' }['value']
194
+ @spec[:meta][:version]
198
195
  end
199
196
 
200
197
  protected
data/lib/sentofu.rb CHANGED
@@ -14,7 +14,7 @@ require 'sentofu/explo'
14
14
 
15
15
  module Sentofu
16
16
 
17
- VERSION = '0.2.0'
17
+ VERSION = '0.2.1'
18
18
 
19
19
  USER_AGENT =
20
20
  "Sentofu #{Sentofu::VERSION} - " +
@@ -55,9 +55,20 @@ module Sentofu
55
55
 
56
56
  paths.each do |path|
57
57
 
58
- api_name = path.match(/api_([^_]+)_\d/)[1]
58
+ m = path.match(/api_([^_]+)_(\d+(?:\.\d+)*)\.yaml\z/)
59
+ next unless m
60
+
61
+ api_name = m[1]
62
+ api_version = m[2]
63
+
59
64
  api_spec = YAML.load(File.read(path))
60
65
 
66
+ api_spec[:meta] = {
67
+ name: api_name,
68
+ version: api_version,
69
+ path: path,
70
+ modified: File.mtime(path).utc.strftime('%FT%RZ') }
71
+
61
72
  init_api(api_name, api_spec)
62
73
  end
63
74
  end
@@ -78,20 +89,26 @@ module Sentofu
78
89
 
79
90
  metas = Sentofu::Http.get_and_parse(doc_uri)
80
91
 
81
- v, u, meta = metas['apis']
92
+ ver, mod, url, meta = metas['apis']
82
93
  .collect { |m|
83
94
  prs = m['properties']
84
95
  [ prs.find { |pr| pr['type'] == 'X-Version' }['value'],
96
+ prs.find { |pr| pr['type'] == 'X-Modified' }['value'],
85
97
  prs.find { |pr| pr['type'] == 'Swagger' }['url'],
86
98
  m ] }
87
- .select { |v, _, _| version_match(v, ver_pattern) }
99
+ .select { |v, _, _, _| version_match(v, ver_pattern) }
88
100
  .sort_by(&:first)
89
101
  .first
90
102
 
91
- spec = Sentofu::Http.get_and_parse(u)
92
- spec[:meta] = meta
103
+ meta[:name] = api_name
104
+ meta[:version] = ver
105
+ meta[:url] = url
106
+ meta[:modified] = mod
93
107
 
94
- init_api(api_name, spec)
108
+ api_spec = Sentofu::Http.get_and_parse(url)
109
+ api_spec[:meta] = meta
110
+
111
+ init_api(api_name, api_spec)
95
112
  end
96
113
  end
97
114
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sentofu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-29 00:00:00.000000000 Z
11
+ date: 2019-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec