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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f4c7c673f748182c1af385f707f69200035d8220
4
- data.tar.gz: 4bdc6dadadb812f0636cd5ca22e591768275c347
3
+ metadata.gz: 2e153c78b134a5fb5ceaf141df6a9cc405c06c1b
4
+ data.tar.gz: d40bb2dc5bb66c33571be7c54fba8ef3c8b9349f
5
5
  SHA512:
6
- metadata.gz: 4f7214b2cfa75ba62304f5e3644ccd6ebf6cb47d13b68c59aabab30a15af3a0bc54d3853d13643d2385362db3f050ad92ef1652d9ea6e5197bf1625d12bc4717
7
- data.tar.gz: bbd050aabb865f27d6e8440a296ee92026f223eb48493cbb76d9737d75c162772e3694485bfbf81707bb56221b1e131931131319294f1ed79e6f07656799c0d0
6
+ metadata.gz: b62720cacb60f8c20c2f31a96347158e177f930cfaa9d65eb512f483836088a3f1e4cab1e907127a7f17ff36f4c00ac327535ddae85510cf770ddb2f625f9dbb
7
+ data.tar.gz: 727c1a7c2bb3916baa144c1ca67afdeb1dbdd22562be444c9f8b8d40a1a94e34a6e4cd949f9b4e3f65913b484ce5013bec799c7d43b18ff9b06cad79c4390d34
data/README.md CHANGED
@@ -1,19 +1,15 @@
1
- # HyakuninIssyu
1
+ # hyakunin-issyu
2
2
  [![Build Status](https://travis-ci.org/Tomomichi/HyakuninIssyu.png?branch=master)](https://travis-ci.org/Tomomichi/HyakuninIssyu)
3
3
  [![Dependency Status](https://gemnasium.com/Tomomichi/HyakuninIssyu.png)](https://gemnasium.com/Tomomichi/HyakuninIssyu)
4
4
 
5
- "HyakuninIssyu" is a Gem for installing poems and poets info of Hyakunin-Issyu, 100 poems by 100 poets into your apps.
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 'HyakuninIssyu'
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 HyakuninIssyu
20
+ $ gem install hyakunin-issyu
25
21
 
26
22
  ## Usage
27
- First, you need to make the instance of HyakuninIssyu class.
28
23
 
29
- data = HyakuninIssyu.new
24
+ $ irb
25
+ irb> require "HyakuninIssyu"
30
26
 
31
- Then use this to retrieve poem and poet data.
32
27
 
33
- ###Poem Info | 歌情報の取得
34
- When retrieving the 64th poem (it's one of my favourite), what you can do is:
28
+ ### Poem | 歌情報
29
+ To retrieve the 64th poem (it's one of my favourite), you can do:
35
30
 
36
- poem_data = data.poem(64)
31
+ ```ruby
32
+ poem = HyakuninIssyu.find(64).poem
33
+ #=> "朝ぼらけ 宇治の川霧 たえだえに あらはれわたる 瀬々の網代木"
37
34
 
38
- poem_data.kanji #=> "朝ぼらけ 宇治の川霧 たえだえに あらはれわたる 瀬々の網代木"
39
- poem_data.kana #=> "あさぼらけうじのかわぎりたえだえに あらはれわたるせぜのあじろぎ"
40
- poem_data.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."
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
- poem_data.first.kanji #=> "朝ぼらけ宇治の川霧たえだえに"
43
- poem_data.first.kana #=> "あさぼらけうじのかわぎりたえだえに"
44
- poem_data.first.en #=> "In the early dawn When the mists on Uji River Slowly lift and clear,"
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
- poem_data.last.kanji #=> "あらはれわたる瀬々の網代木"
47
- poem_data.last.kana #=> "あらはれわたるせぜのあじろぎ"
48
- poem_data.last.en #=> "From the shallows to the deep, The stakes of fishing nets appear."
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
- poem_data.comment #=> "「朝ぼらけ」は夜明けであたりがほのぼのと明るくなってくる頃..."
51
+ poem.comment #=> "「朝ぼらけ」は夜明けであたりがほのぼのと明るくなってくる頃..."
52
+ ```
51
53
 
52
- ###Poet Info | 歌人情報の取得
53
- To retrieve the poet info for the same poem,
54
+ ### Poet | 歌人情報
55
+ To retrieve the poet info of the poem, you can do:
54
56
 
55
- poet_data = data.poet(64)
57
+ ```ruby
58
+ poet = HyakuninIssyu.find(64).poet #=> "権中納言定頼"
56
59
 
57
- poet_data.name.ja #=> "権中納言定頼"
58
- poet_data.name.en #=> "Fujiwara no Sadayori"
59
- poet_data.period #=> "995-1045"
60
- poet_data.info #=> "本名は藤原定頼(ふじわらの さだより)。平安時代中期の公家・歌人..."
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
- poet_data.male? #=> true
63
- poet_data.female? #=> false
64
- poet_data.monk? #=> false
65
- poet_data.semimaru? #=> false
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
- poems_data = data.poems
71
- poems_data[64].kanji #=> "朝ぼらけ 宇治の川霧 たえだえに あらはれわたる 瀬々の網代木"
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
- poets_data = data.poets
77
- poets_data[64].name.ja #=> "権中納言定頼"
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
- You can use all the method which were shown before, for each content of the poems/poets data.
83
- Use these to retrieve many poems and poets at the same time.
79
+ poems.each do |p|
80
+ ...
81
+ end
84
82
 
83
+ poems[64].poem #=> "朝ぼらけ 宇治の川霧 たえだえに あらはれわたる 瀬々の網代木"
84
+ poems[64].poet #=> "権中納言定頼"
85
+ ```
85
86
 
86
- ##Use image files of the cards
87
- Image files of the Hyakunin-Issyu cards are installed in this gem.
88
- If you wanna use these, it's better to copy them to your project directory.
87
+ ### Retrieve sample records
88
+ ```ruby
89
+ sample_poems = HyakuninIssyu.all.sample
90
+ #=> [#<HyakuninIssyu::Data:0x007fcffc245918 @id=76>]
89
91
 
90
- The rake task for this is set. Just run the following:
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
- then "hyakunin-issyu" directory will be created under your IMG_PATH, and
95
- all the images will be copied there.
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
- **All the images used in this gem are from Wikipedia and they're under the public license.
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
@@ -997,4 +997,3 @@
997
997
  monk: 0
998
998
  period: 1197-1242
999
999
  info: じゅんとくいん。第84代天皇。後鳥羽天皇(99歌)の第三皇子。父・後鳥羽天皇の期待を受け、皇権示威に努めた。父と共に倒幕を企て承久の乱に加わったが失敗。佐渡に流され、断食の末に頭に焼け石を乗せて死んだと伝わる。
1000
-
data/lib/HyakuninIssyu.rb CHANGED
@@ -1,39 +1,38 @@
1
1
  require "yaml"
2
2
 
3
3
  class HyakuninIssyu
4
- def initialize
5
- @@poems = YAML.load_file(File.expand_path(File.join('..', '..', 'config', 'poems.yml'), __FILE__))
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 poet(id=nil)
7
+ def self.find(id=nil)
19
8
  return false if id.nil? || id<1 || id>100
20
- poet = Poet.new(id)
9
+ Data.new(id)
21
10
  end
22
11
 
23
- def poems
24
- poems = Array.new
12
+ def self.all
13
+ all = []
25
14
  for i in 1..100
26
- poems[i] = Poem.new(i)
15
+ all << self.find(i)
27
16
  end
28
- return poems
17
+ all
29
18
  end
30
19
 
31
- def poets
32
- poets = Array.new
33
- for i in 1..100
34
- poets[i] = Poet.new(i)
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
@@ -1,3 +1,3 @@
1
1
  class HyakuninIssyu
2
- VERSION = "0.8.1"
2
+ VERSION = "1.0.0"
3
3
  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.8.1
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-22 00:00:00.000000000 Z
11
+ date: 2015-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler