togostanza 1.2.2 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: feff200c04b172dbf93674165cef73d4e2432717
4
- data.tar.gz: 6dcbe4dac0882915a682b26ca69b597285b0dc30
3
+ metadata.gz: de2bb4688cc93399337e9abecabae51456ab1403
4
+ data.tar.gz: 55a3943993b9773f9e06cd5f46728fa951cfeb6a
5
5
  SHA512:
6
- metadata.gz: 2cea6cdb5e858b346db2d7ea8761c09539ee78abae30618da7f664812f46465c45d2a1d12e66eb19d9be6d5af2f30d8e72ea4c19ae67e6d5729cff2741f2606b
7
- data.tar.gz: 9185b04d45877f93179462ed5bf3865d5d75d30ffb0d1773fb4f5696461246046ac9ed42c6ad158cfa4173d1b6cc002a7ec972aab4633b5a535e9022285fbe0e
6
+ metadata.gz: 2cb8e3171ae7b79e7418fe627a522058579dc70c403df1e1ff765cf02b083b6407cdd5cdbea8dc8b13870f9e03f5ff362018c630a801c6228f91d179150b26a1
7
+ data.tar.gz: 5f310e6972a9fee2ec33ba2466a1655602b651e9d780565afa33f800b4eff2b4223db6f326bf8b172af1e0265dea327d652e36bdc0883d3c19e9216670e15df2
@@ -25,6 +25,17 @@ module TogoStanza
25
25
  haml :index
26
26
  end
27
27
 
28
+ get '/metadata.json' do
29
+ metadata = {
30
+ "@context" => {
31
+ stanza: "http://togostanza.org/resource/stanza#"
32
+ },
33
+ "stanza:stanzas" => Stanza.all.map {|stanza| stanza.new.metadata }.compact
34
+ }
35
+
36
+ json metadata
37
+ end
38
+
28
39
  get '/:id.json' do |id|
29
40
  json Stanza.find(id).new(params).context
30
41
  end
@@ -60,5 +71,11 @@ module TogoStanza
60
71
  json enabled: false, count: 0, urls: []
61
72
  end
62
73
  end
74
+
75
+ get '/:id/metadata.json' do |id|
76
+ @stanza = Stanza.find(id).new
77
+
78
+ json @stanza.metadata
79
+ end
63
80
  end
64
81
  end
@@ -41,12 +41,13 @@ module TogoStanza
41
41
  end
42
42
 
43
43
  def create_files
44
- template 'Gemfile.erb', "#{file_name}/Gemfile"
45
- template 'gemspec.erb', "#{file_name}/#{file_name}.gemspec"
46
- template 'lib.rb.erb', "#{file_name}/lib/#{file_name}.rb"
47
- template 'stanza.rb.erb', "#{file_name}/stanza.rb"
48
- template 'template.hbs.erb', "#{file_name}/template.hbs"
49
- template 'help.md.erb', "#{file_name}/help.md"
44
+ template 'Gemfile.erb', "#{file_name}/Gemfile"
45
+ template 'gemspec.erb', "#{file_name}/#{file_name}.gemspec"
46
+ template 'lib.rb.erb', "#{file_name}/lib/#{file_name}.rb"
47
+ template 'stanza.rb.erb', "#{file_name}/stanza.rb"
48
+ template 'template.hbs.erb', "#{file_name}/template.hbs"
49
+ template 'help.md.erb', "#{file_name}/help.md"
50
+ template 'metadata.json.erb', "#{file_name}/metadata.json"
50
51
 
51
52
  create_file "#{file_name}/assets/#{stanza_id}/.keep"
52
53
  end
@@ -221,5 +221,15 @@ module TogoStanza::Stanza
221
221
 
222
222
  TogoStanza::Markdown.render(File.read(path))
223
223
  end
224
+
225
+ def metadata
226
+ path = File.join(root, 'metadata.json')
227
+
228
+ if File.exist?(path)
229
+ JSON.load(open(path))
230
+ else
231
+ nil
232
+ end
233
+ end
224
234
  end
225
235
  end
@@ -1,3 +1,3 @@
1
1
  module TogoStanza
2
- VERSION = '1.2.2'
2
+ VERSION = '1.3.0'
3
3
  end
@@ -0,0 +1,24 @@
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
10
+ }
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"
24
+ }
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Metadata' do
4
+ describe '/metadata.json' do
5
+ before do
6
+ # 実行順により base_spec で作られた Classオブジェクトが返って来て意図通りのテストにならないため
7
+ allow(TogoStanza::Stanza).to receive(:all).and_return([BarStanza, FooStanza])
8
+
9
+ visit '/metadata.json'
10
+ end
11
+
12
+ it 'should return metadata as JSON' do
13
+ json = JSON.parse(page.body)
14
+
15
+ json["stanza:stanzas"].class.should eq(Array)
16
+ json["stanza:stanzas"].first.should include('stanza:label' => 'Foo Stanza')
17
+ end
18
+ end
19
+
20
+ describe '/:id/metadata.json' do
21
+ before do
22
+ visit '/foo/metadata.json'
23
+ end
24
+
25
+ it 'should return metadata as JSON' do
26
+ json = JSON.parse(page.body)
27
+
28
+ json.should include('stanza:label' => 'Foo Stanza')
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,20 @@
1
+ {
2
+ "@context": {
3
+ "stanza": "http://togostanza.org/resource/stanza#"
4
+ },
5
+ "@id": "http://togogenome.org/stanza/<%= stanza_id %>",
6
+ "stanza:label": "",
7
+ "stanza:definition": "",
8
+ "stanza:parameters": [
9
+ ],
10
+ "stanza:usage": "<div data-stanza=\"http://togogenome.org/stanza/<%= stanza_id %>\"></div>",
11
+ "stanza:type": "stanza:Stanza",
12
+ "stanza:context": "",
13
+ "stanza:display": "",
14
+ "stanza:provider": "provider of this stanza",
15
+ "stanza:license": "",
16
+ "stanza:author": "author name",
17
+ "stanza:address": "name@example.org",
18
+ "stanza:created": "<%= Date.today %>",
19
+ "stanza:updated": "<%= Date.today %>"
20
+ }
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.2.2
4
+ version: 1.3.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-01-06 00:00:00.000000000 Z
11
+ date: 2015-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -297,11 +297,13 @@ files:
297
297
  - spec/dummy/config.ru
298
298
  - spec/dummy/foo_stanza/help.md
299
299
  - spec/dummy/foo_stanza/lib/foo_stanza.rb
300
+ - spec/dummy/foo_stanza/metadata.json
300
301
  - spec/dummy/foo_stanza/stanza.rb
301
302
  - spec/dummy/foo_stanza/template.hbs
302
303
  - spec/features/api_spec.rb
303
304
  - spec/features/help_spec.rb
304
305
  - spec/features/listing_spec.rb
306
+ - spec/features/metadata_spec.rb
305
307
  - spec/features/rendering_spec.rb
306
308
  - spec/features/resource_spec.rb
307
309
  - spec/lib/togostanza/stanza/base_spec.rb
@@ -316,6 +318,7 @@ files:
316
318
  - templates/stanza/gemspec.erb
317
319
  - templates/stanza/help.md.erb
318
320
  - templates/stanza/lib.rb.erb
321
+ - templates/stanza/metadata.json.erb
319
322
  - templates/stanza/stanza.rb.erb
320
323
  - templates/stanza/template.hbs.erb
321
324
  - togostanza.gemspec
@@ -354,11 +357,13 @@ test_files:
354
357
  - spec/dummy/config.ru
355
358
  - spec/dummy/foo_stanza/help.md
356
359
  - spec/dummy/foo_stanza/lib/foo_stanza.rb
360
+ - spec/dummy/foo_stanza/metadata.json
357
361
  - spec/dummy/foo_stanza/stanza.rb
358
362
  - spec/dummy/foo_stanza/template.hbs
359
363
  - spec/features/api_spec.rb
360
364
  - spec/features/help_spec.rb
361
365
  - spec/features/listing_spec.rb
366
+ - spec/features/metadata_spec.rb
362
367
  - spec/features/rendering_spec.rb
363
368
  - spec/features/resource_spec.rb
364
369
  - spec/lib/togostanza/stanza/base_spec.rb