hyakunin-issyu 0.8.1 → 1.0.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 +4 -4
- data/README.md +69 -57
- data/config/poets.yml +0 -1
- data/lib/HyakuninIssyu.rb +43 -24
- data/lib/HyakuninIssyu/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e153c78b134a5fb5ceaf141df6a9cc405c06c1b
|
4
|
+
data.tar.gz: d40bb2dc5bb66c33571be7c54fba8ef3c8b9349f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b62720cacb60f8c20c2f31a96347158e177f930cfaa9d65eb512f483836088a3f1e4cab1e907127a7f17ff36f4c00ac327535ddae85510cf770ddb2f625f9dbb
|
7
|
+
data.tar.gz: 727c1a7c2bb3916baa144c1ca67afdeb1dbdd22562be444c9f8b8d40a1a94e34a6e4cd949f9b4e3f65913b484ce5013bec799c7d43b18ff9b06cad79c4390d34
|
data/README.md
CHANGED
@@ -1,19 +1,15 @@
|
|
1
|
-
#
|
1
|
+
# hyakunin-issyu
|
2
2
|
[](https://travis-ci.org/Tomomichi/HyakuninIssyu)
|
3
3
|
[](https://gemnasium.com/Tomomichi/HyakuninIssyu)
|
4
4
|
|
5
|
-
|
6
|
-
You can take any poems of Hyakunin-Issyu, poets info and a commentary on it, in addition to the feature to take the first or last half of the poem.
|
7
|
-
(it may be necessary for building game style Hyakunin-Issyu application)
|
5
|
+
All about Hyakunin-Issyu, 100 poems by 100 poets.
|
8
6
|
|
9
|
-
HyakuninIssyuは、百人一首の歌情報・歌人情報をアプリに取り込むためのGemです。
|
10
|
-
百首すべての歌の歌人情報や解説に加え、上の句、下の句だけの表示も行うことができます。
|
11
7
|
|
12
8
|
## Installation
|
13
9
|
|
14
10
|
Add this line to your application's Gemfile:
|
15
11
|
|
16
|
-
gem '
|
12
|
+
gem 'hyakunin-issyu'
|
17
13
|
|
18
14
|
And then execute:
|
19
15
|
|
@@ -21,81 +17,97 @@ And then execute:
|
|
21
17
|
|
22
18
|
Or install it yourself as:
|
23
19
|
|
24
|
-
$ gem install
|
20
|
+
$ gem install hyakunin-issyu
|
25
21
|
|
26
22
|
## Usage
|
27
|
-
First, you need to make the instance of HyakuninIssyu class.
|
28
23
|
|
29
|
-
|
24
|
+
$ irb
|
25
|
+
irb> require "HyakuninIssyu"
|
30
26
|
|
31
|
-
Then use this to retrieve poem and poet data.
|
32
27
|
|
33
|
-
###Poem
|
34
|
-
|
28
|
+
### Poem | 歌情報
|
29
|
+
To retrieve the 64th poem (it's one of my favourite), you can do:
|
35
30
|
|
36
|
-
|
31
|
+
```ruby
|
32
|
+
poem = HyakuninIssyu.find(64).poem
|
33
|
+
#=> "朝ぼらけ 宇治の川霧 たえだえに あらはれわたる 瀬々の網代木"
|
37
34
|
|
38
|
-
|
39
|
-
|
40
|
-
|
35
|
+
poem.kanji #=> "朝ぼらけ 宇治の川霧 たえだえに あらはれわたる 瀬々の網代木"
|
36
|
+
poem.kana #=> "あさぼらけうじのかわぎりたえだえに あらはれわたるせぜのあじろぎ"
|
37
|
+
poem.en #=> "In the early dawn When the mists on Uji River Slowly lift and clear, From the shallows to the deep, The stakes of fishing nets appear."
|
41
38
|
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
# Retrieve only the first half of the poem
|
40
|
+
poem.first #=> "朝ぼらけ宇治の川霧たえだえに"
|
41
|
+
poem.first.kanji #=> "朝ぼらけ宇治の川霧たえだえに"
|
42
|
+
poem.first.kana #=> "あさぼらけうじのかわぎりたえだえに"
|
43
|
+
poem.first.en #=> "In the early dawn When the mists on Uji River Slowly lift and clear,"
|
45
44
|
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
# Retrieve only the last half of the poem
|
46
|
+
poem.last #=> "あらはれわたる瀬々の網代木"
|
47
|
+
poem.last.kanji #=> "あらはれわたる瀬々の網代木"
|
48
|
+
poem.last.kana #=> "あらはれわたるせぜのあじろぎ"
|
49
|
+
poem.last.en #=> "From the shallows to the deep, The stakes of fishing nets appear."
|
49
50
|
|
50
|
-
|
51
|
+
poem.comment #=> "「朝ぼらけ」は夜明けであたりがほのぼのと明るくなってくる頃..."
|
52
|
+
```
|
51
53
|
|
52
|
-
###Poet
|
53
|
-
To retrieve the poet info
|
54
|
+
### Poet | 歌人情報
|
55
|
+
To retrieve the poet info of the poem, you can do:
|
54
56
|
|
55
|
-
|
57
|
+
```ruby
|
58
|
+
poet = HyakuninIssyu.find(64).poet #=> "権中納言定頼"
|
56
59
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
60
|
+
poet.name #=> "権中納言定頼"
|
61
|
+
poet.name.ja #=> "権中納言定頼"
|
62
|
+
poet.name.en #=> "Fujiwara no Sadayori"
|
63
|
+
poet.period #=> "995-1045"
|
64
|
+
poet.info #=> "本名は藤原定頼(ふじわらの さだより)。平安時代中期の公家・歌人..."
|
61
65
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
+
poet.male? #=> true
|
67
|
+
poet.female? #=> false
|
68
|
+
poet.monk? #=> false
|
69
|
+
poet.semimaru? #=> false
|
70
|
+
```
|
66
71
|
|
67
|
-
###List of poems and poets | データをまとめて扱うとき
|
68
|
-
If you want to list the poems and poets, you can use "poems" and "poets" method to retrieve the raw data of them.
|
69
72
|
|
70
|
-
|
71
|
-
|
72
|
-
poems_data[64].kana #=> "あさぼらけうじのかわぎりたえだえに あらはれわたるせぜのあじろぎ"
|
73
|
-
poems_data[64].en #=> "In the early dawn When the mists on Uji River Slowly lift and clear, From the shallows to the deep, The stakes of fishing nets appear."
|
74
|
-
...
|
73
|
+
### Retrieve all records
|
74
|
+
To retrieve all 100 poems, you can do:
|
75
75
|
|
76
|
-
|
77
|
-
|
78
|
-
poets_data[64].name.en #=> "Fujiwara no Sadayori"
|
79
|
-
poets_data[64].period #=> "995-1045"
|
80
|
-
...
|
76
|
+
```ruby
|
77
|
+
poems = HyakuninIssyu.all
|
81
78
|
|
82
|
-
|
83
|
-
|
79
|
+
poems.each do |p|
|
80
|
+
...
|
81
|
+
end
|
84
82
|
|
83
|
+
poems[64].poem #=> "朝ぼらけ 宇治の川霧 たえだえに あらはれわたる 瀬々の網代木"
|
84
|
+
poems[64].poet #=> "権中納言定頼"
|
85
|
+
```
|
85
86
|
|
86
|
-
|
87
|
-
|
88
|
-
|
87
|
+
### Retrieve sample records
|
88
|
+
```ruby
|
89
|
+
sample_poems = HyakuninIssyu.all.sample
|
90
|
+
#=> [#<HyakuninIssyu::Data:0x007fcffc245918 @id=76>]
|
89
91
|
|
90
|
-
|
92
|
+
sample_poems = HyakuninIssyu.all.sample(5)
|
93
|
+
=> [#<HyakuninIssyu::Data:0x007fcffc245918 @id=23>, #<Hyakunin...]
|
94
|
+
```
|
91
95
|
|
92
|
-
rake HyakuninIssyu:install_img['IMG_PATH']
|
93
96
|
|
94
|
-
|
95
|
-
|
97
|
+
## Assets(images and audio files)
|
98
|
+
If you need images or audio files of Hyakunin-Issyu,
|
99
|
+
please use the bower package "hyakunin-issyu-assets".
|
96
100
|
|
101
|
+
bower install hyakunin-issyu-assets
|
97
102
|
|
98
|
-
|
103
|
+
[hyakunin-issyu-assets](https://github.com/notsobad-jp/hyakunin-issyu-assets)
|
104
|
+
|
105
|
+
|
106
|
+
### License
|
107
|
+
All the images are from Wikipedia and they're under the public license.
|
108
|
+
Audio files are from NHK Library. Please check the license before using it.
|
109
|
+
|
110
|
+
[NHK Creative Library](http://www1.nhk.or.jp/creative/rule.html)
|
99
111
|
|
100
112
|
|
101
113
|
## Contributing
|
data/config/poets.yml
CHANGED
data/lib/HyakuninIssyu.rb
CHANGED
@@ -1,39 +1,38 @@
|
|
1
1
|
require "yaml"
|
2
2
|
|
3
3
|
class HyakuninIssyu
|
4
|
-
|
5
|
-
|
6
|
-
@@poets = YAML.load_file(File.expand_path(File.join('..', '..', 'config', 'poets.yml'), __FILE__))
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.img_path
|
10
|
-
File.expand_path("../../assets/img", __FILE__)
|
11
|
-
end
|
12
|
-
|
13
|
-
def poem(id=nil)
|
14
|
-
return false if id.nil? || id<1 || id>100
|
15
|
-
poem = Poem.new(id)
|
16
|
-
end
|
4
|
+
@@poems = YAML.load_file(File.expand_path(File.join('..', '..', 'config', 'poems.yml'), __FILE__))
|
5
|
+
@@poets = YAML.load_file(File.expand_path(File.join('..', '..', 'config', 'poets.yml'), __FILE__))
|
17
6
|
|
18
|
-
def
|
7
|
+
def self.find(id=nil)
|
19
8
|
return false if id.nil? || id<1 || id>100
|
20
|
-
|
9
|
+
Data.new(id)
|
21
10
|
end
|
22
11
|
|
23
|
-
def
|
24
|
-
|
12
|
+
def self.all
|
13
|
+
all = []
|
25
14
|
for i in 1..100
|
26
|
-
|
15
|
+
all << self.find(i)
|
27
16
|
end
|
28
|
-
|
17
|
+
all
|
29
18
|
end
|
30
19
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
20
|
+
class Data < self
|
21
|
+
def initialize(id)
|
22
|
+
@id = id
|
23
|
+
end
|
24
|
+
|
25
|
+
def inspect
|
26
|
+
self.poem.inspect
|
27
|
+
end
|
28
|
+
|
29
|
+
def poem
|
30
|
+
Poem.new(@id)
|
31
|
+
end
|
32
|
+
|
33
|
+
def poet
|
34
|
+
Poet.new(@id)
|
35
35
|
end
|
36
|
-
return poets
|
37
36
|
end
|
38
37
|
|
39
38
|
class Poem < self
|
@@ -41,6 +40,10 @@ class HyakuninIssyu
|
|
41
40
|
@poem = @@poems[id-1]
|
42
41
|
end
|
43
42
|
|
43
|
+
def inspect
|
44
|
+
self.kanji
|
45
|
+
end
|
46
|
+
|
44
47
|
def id
|
45
48
|
@poem['id']
|
46
49
|
end
|
@@ -84,6 +87,10 @@ class HyakuninIssyu
|
|
84
87
|
@first_en = en_data[0]
|
85
88
|
end
|
86
89
|
|
90
|
+
def inspect
|
91
|
+
self.kanji
|
92
|
+
end
|
93
|
+
|
87
94
|
def kana
|
88
95
|
@first_kana
|
89
96
|
end
|
@@ -112,6 +119,10 @@ class HyakuninIssyu
|
|
112
119
|
@last_en = en_data[1]
|
113
120
|
end
|
114
121
|
|
122
|
+
def inspect
|
123
|
+
self.kanji
|
124
|
+
end
|
125
|
+
|
115
126
|
def kana
|
116
127
|
@last_kana
|
117
128
|
end
|
@@ -131,6 +142,10 @@ class HyakuninIssyu
|
|
131
142
|
@poet = @@poets[id-1]
|
132
143
|
end
|
133
144
|
|
145
|
+
def inspect
|
146
|
+
self.name.inspect
|
147
|
+
end
|
148
|
+
|
134
149
|
def id
|
135
150
|
@poet['id']
|
136
151
|
end
|
@@ -144,6 +159,10 @@ class HyakuninIssyu
|
|
144
159
|
@name = data['name']
|
145
160
|
end
|
146
161
|
|
162
|
+
def inspect
|
163
|
+
self.ja
|
164
|
+
end
|
165
|
+
|
147
166
|
def ja
|
148
167
|
@name['ja']
|
149
168
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyakunin-issyu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tomomichi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|