togostanza 1.5.0 → 2.0.0

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
  SHA1:
3
- metadata.gz: 2cebb5d9a634d56c3ccfee2e9566cce3446d13c0
4
- data.tar.gz: 5871e598ffd60ae73012ea2c0df2cb6a8dbe0027
3
+ metadata.gz: a3a84fadcce286880cf1905ef4ba2468e9ab0838
4
+ data.tar.gz: 20df3090d324e8a82b9aafb556eb6cd9b0844e6f
5
5
  SHA512:
6
- metadata.gz: 9eb67b26e503a04f8e064689ba248ca84cc5cf3bd9a69fbb5ae2a27d0bfddeba220d386e5041ba692ca326ad058c4da40cdc152de0917d54cebef5ea3ef55310
7
- data.tar.gz: 1b066ab9948b46112481517e2e221b2deee2a8937490cd2c7fe17659e80ddf511c2c9e5c70ff0f53a9be2658e7daef781af0ad41c96d6a612d4c8422b733b3c3
6
+ metadata.gz: 671db4dce5c8235e401c5e0b40014f5eafb3172133a729d05ca2a80197c2332f3a90dfc4456eb4801048031762d539d21ddb2ad2ed0261cd76dd9aa0384306e0
7
+ data.tar.gz: 34f60db878f722079c567fe7f510829ba226dfac48dd3359694d579638b2a6fe3ae10db9f63eab5af0e1e52b14a9c33edca53f90475fe6a17f2e5a066354115a
@@ -21,6 +21,10 @@ module TogoStanza
21
21
  end
22
22
  end
23
23
 
24
+ before do
25
+ @server_url = request.url.gsub(request.path_info, '')
26
+ end
27
+
24
28
  get '/' do
25
29
  haml :index
26
30
  end
@@ -30,7 +34,7 @@ module TogoStanza
30
34
  "@context" => {
31
35
  stanza: "http://togostanza.org/resource/stanza#"
32
36
  },
33
- "stanza:stanzas" => Stanza.all.map {|stanza| stanza.new.metadata }.compact
37
+ "stanza:stanzas" => Stanza.all.map {|stanza| stanza.new.metadata(@server_url) }.compact
34
38
  }
35
39
 
36
40
  json metadata
@@ -53,13 +57,13 @@ module TogoStanza
53
57
  get '/:id/help' do |id|
54
58
  stanza = Stanza.find(id).new
55
59
 
56
- haml :help, locals: {stanza: stanza.metadata}
60
+ haml :help, locals: {stanza: stanza.metadata(@server_url)}
57
61
  end
58
62
 
59
63
  get '/:id/metadata.json' do |id|
60
64
  @stanza = Stanza.find(id).new
61
65
 
62
- json @stanza.metadata
66
+ json @stanza.metadata(@server_url)
63
67
  end
64
68
  end
65
69
  end
@@ -213,14 +213,40 @@ module TogoStanza::Stanza
213
213
  Tilt.new(path).render(context)
214
214
  end
215
215
 
216
- def metadata
216
+ def metadata(server_url)
217
217
  path = File.join(root, 'metadata.json')
218
218
 
219
219
  if File.exist?(path)
220
- JSON.load(open(path))
220
+ orig = JSON.load(open(path))
221
+ stanza_uri = "#{server_url}/#{orig['id']}"
222
+
223
+ usage_attrs = orig['parameter'].map {|hash|
224
+ "#{hash['key']}=\"#{hash['example']}\""
225
+ }.push("data-stanza=\"#{stanza_uri}\"").join(' ')
226
+
227
+ append_prefix_to_hash_keys(orig.merge(usage: "<div #{usage_attrs}></div>"), 'stanza').merge('@id' => stanza_uri)
221
228
  else
222
229
  nil
223
230
  end
224
231
  end
232
+
233
+ private
234
+
235
+ def append_prefix_to_hash_keys(hash, prefix)
236
+ hash.each_with_object({}) do |(key, value), new_hash|
237
+ new_hash["#{prefix}:#{key}"] = expand_values(value, prefix)
238
+ end
239
+ end
240
+
241
+ def expand_values(value, prefix)
242
+ case value
243
+ when Hash
244
+ append_prefix_to_hash_keys(value, prefix)
245
+ when Array
246
+ value.map {|v| expand_values(v, prefix) }
247
+ else
248
+ value
249
+ end
250
+ end
225
251
  end
226
252
  end
@@ -1,3 +1,3 @@
1
1
  module TogoStanza
2
- VERSION = '1.5.0'
2
+ VERSION = '2.0.0'
3
3
  end
@@ -1,24 +1,23 @@
1
1
  {
2
- "@id": "http://togogenome.org/stanza/foo",
3
- "stanza:label": "Foo Stanza",
4
- "stanza:definition": "This is Foo Stanza.",
5
- "stanza:parameter": [
6
- { "stanza:key": "name",
7
- "stanza:example": "alice",
8
- "stanza:description": "Name",
9
- "stanza:required": true
2
+ "id": "foo",
3
+ "label": "Foo Stanza",
4
+ "definition": "This is Foo Stanza.",
5
+ "parameter": [
6
+ { "key": "name",
7
+ "example": "alice",
8
+ "description": "Name",
9
+ "required": true
10
10
  }
11
11
  ],
12
- "stanza:usage": "<div data-stanza=\"http://togogenome.org/stanza/foo\" data-stanza-name=\"alice\"></div>",
13
- "stanza:type": "Stanza",
14
- "stanza:context": "Gene",
15
- "stanza:display": "Table",
16
- "stanza:provider": "DBCLS",
17
- "stanza:license": "CC-BY",
18
- "stanza:author": "author name",
19
- "stanza:address": "name@example.org",
20
- "stanza:contributor": [ "Taro Stanza", "Hanako Stanza" ],
21
- "stanza:version": "1",
22
- "stanza:created": "2015-02-27",
23
- "stanza:updated": "2015-02-27"
12
+ "type": "Stanza",
13
+ "context": "Gene",
14
+ "display": "Table",
15
+ "provider": "DBCLS",
16
+ "license": "CC-BY",
17
+ "author": "author name",
18
+ "address": "name@example.org",
19
+ "contributor": [ "Taro Stanza", "Hanako Stanza" ],
20
+ "version": "1",
21
+ "created": "2015-02-27",
22
+ "updated": "2015-02-27"
24
23
  }
@@ -26,6 +26,7 @@ describe 'Metadata' do
26
26
  json = JSON.parse(page.body)
27
27
 
28
28
  json.should include('stanza:label' => 'Foo Stanza')
29
+ json.should include('@id' => "http://www.example.com/foo")
29
30
  end
30
31
  end
31
32
  end
@@ -1,18 +1,23 @@
1
1
  {
2
- "@id": "http://togogenome.org/stanza/<%= stanza_id %>",
3
- "stanza:label": "",
4
- "stanza:definition": "",
5
- "stanza:parameter": [
2
+ "id": "<%= stanza_id %>",
3
+ "label": "",
4
+ "definition": "",
5
+ "parameter": [
6
+ {
7
+ "key": "",
8
+ "example": "",
9
+ "description": "",
10
+ "required": true
11
+ }
6
12
  ],
7
- "stanza:usage": "<div data-stanza=\"http://togogenome.org/stanza/<%= stanza_id %>\"></div>",
8
- "stanza:type": "Stanza",
9
- "stanza:context": "",
10
- "stanza:display": "",
11
- "stanza:provider": "provider of this stanza",
12
- "stanza:license": "",
13
- "stanza:author": "author name",
14
- "stanza:address": "name@example.org",
15
- "stanza:contributor": [],
16
- "stanza:created": "<%= Date.today %>",
17
- "stanza:updated": "<%= Date.today %>"
13
+ "type": "Stanza",
14
+ "context": "",
15
+ "display": "",
16
+ "provider": "provider of this stanza",
17
+ "license": "",
18
+ "author": "author name",
19
+ "address": "name@example.org",
20
+ "contributor": [],
21
+ "created": "<%= Date.today %>",
22
+ "updated": "<%= Date.today %>"
18
23
  }
data/togostanza.gemspec CHANGED
@@ -27,12 +27,12 @@ Gem::Specification.new do |spec|
27
27
  spec.add_runtime_dependency 'sprockets', '~> 3.4'
28
28
  spec.add_runtime_dependency 'thor', '~> 0.19'
29
29
 
30
- spec.add_development_dependency 'appraisal', '~> 0'
31
- spec.add_development_dependency 'bundler', '~> 0'
32
- spec.add_development_dependency 'capybara', '~> 0'
33
- spec.add_development_dependency 'rake', '~> 0'
34
- spec.add_development_dependency 'rspec', '~> 0'
35
- spec.add_development_dependency 'rspec-its', '~> 0'
30
+ spec.add_development_dependency 'appraisal', '~> 0.5'
31
+ spec.add_development_dependency 'bundler', '~> 1.10'
32
+ spec.add_development_dependency 'capybara', '~> 2.2'
33
+ spec.add_development_dependency 'rake', '~> 0.9'
34
+ spec.add_development_dependency 'rspec', '~> 3.3'
35
+ spec.add_development_dependency 'rspec-its', '~> 1.2'
36
36
 
37
37
  spec.required_ruby_version = '>= 1.9.3'
38
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: togostanza
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keita Urashima
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-05 00:00:00.000000000 Z
11
+ date: 2015-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -156,84 +156,84 @@ dependencies:
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: '0'
159
+ version: '0.5'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: '0'
166
+ version: '0.5'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: bundler
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: '0'
173
+ version: '1.10'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: '0'
180
+ version: '1.10'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: capybara
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
185
  - - "~>"
186
186
  - !ruby/object:Gem::Version
187
- version: '0'
187
+ version: '2.2'
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
- version: '0'
194
+ version: '2.2'
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: rake
197
197
  requirement: !ruby/object:Gem::Requirement
198
198
  requirements:
199
199
  - - "~>"
200
200
  - !ruby/object:Gem::Version
201
- version: '0'
201
+ version: '0.9'
202
202
  type: :development
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
- version: '0'
208
+ version: '0.9'
209
209
  - !ruby/object:Gem::Dependency
210
210
  name: rspec
211
211
  requirement: !ruby/object:Gem::Requirement
212
212
  requirements:
213
213
  - - "~>"
214
214
  - !ruby/object:Gem::Version
215
- version: '0'
215
+ version: '3.3'
216
216
  type: :development
217
217
  prerelease: false
218
218
  version_requirements: !ruby/object:Gem::Requirement
219
219
  requirements:
220
220
  - - "~>"
221
221
  - !ruby/object:Gem::Version
222
- version: '0'
222
+ version: '3.3'
223
223
  - !ruby/object:Gem::Dependency
224
224
  name: rspec-its
225
225
  requirement: !ruby/object:Gem::Requirement
226
226
  requirements:
227
227
  - - "~>"
228
228
  - !ruby/object:Gem::Version
229
- version: '0'
229
+ version: '1.2'
230
230
  type: :development
231
231
  prerelease: false
232
232
  version_requirements: !ruby/object:Gem::Requirement
233
233
  requirements:
234
234
  - - "~>"
235
235
  - !ruby/object:Gem::Version
236
- version: '0'
236
+ version: '1.2'
237
237
  description:
238
238
  email:
239
239
  - ursm@esm.co.jp
@@ -351,3 +351,4 @@ test_files:
351
351
  - spec/lib/togostanza/stanza/base_spec.rb
352
352
  - spec/lib/togostanza/stanza/grouping_spec.rb
353
353
  - spec/spec_helper.rb
354
+ has_rdoc: