rubimas 0.3.0 → 0.4.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: 65489f0827f5448a8b46620c7f54b4f8412692be
4
- data.tar.gz: 4b6601a0457b8130eb39d410123e907f69f4b9a0
3
+ metadata.gz: 28842c05027bedc8bd8453c59354120e8ced0d1d
4
+ data.tar.gz: 8ee37e9edb56e078f8a4d31acce1e7ad2148471d
5
5
  SHA512:
6
- metadata.gz: a0322d5d2653f7091b875fc5a7e89957bb29efd50aac9684dc6cd4b8e849548d2177507fb69664295b9a3159e7bd3698e8902284d9c249b47e4b56344d169039
7
- data.tar.gz: f090b728dd5bb01e540ae2bb8f2aed31d64d300b4cb7b11d7dd0de1cc10e53864cd9a7c4e76fb1c164f0e68d0a5811794a40a60ed0d1bc9579c1025c32293618
6
+ metadata.gz: a2e7646777136a31a0ac9ce206ff8f2d31457bbb132f5a7b3341901b5c2c713c8765375c3c79cdcad6d02a0b3076c384a56c669a60b3e5bab91ad11025f5c3dd
7
+ data.tar.gz: 5d2772e2a9c4b6f5e26aa3a0f65f1e4cf81e54a706ad96804e288d983929f56de388b8c0c1ad50bac0f830ae6456ade760dc38e608e90f4e5ede8c1107f55522
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  ## master
2
- [full changelog](http://github.com/imas/rubimas/compare/v0.2.0...master)
2
+ [full changelog](http://github.com/imas/rubimas/compare/v0.4.0...master)
3
+
4
+ ## v0.4.0
5
+ [full changelog](http://github.com/imas/rubimas/compare/v0.3.0...v0.4.0)
6
+
7
+ - Add `find_by_name` method and change `find` method's behavior.
8
+ - https://github.com/imas/rubimas/commit/825bb2c8316918eb1b036e848d8c45c7cb130831
9
+ - `Pro765` module has been removed.
10
+ - https://github.com/imas/rubimas/commit/a4c836b8c229476090659f443969d8a9f10a0732
11
+ - Support more powerful alias to `Rubimas`.
12
+ - https://github.com/imas/rubimas/commit/e36af0b9ff8bc41163c73caf05bbb712f69be1e1
13
+
14
+ ## v0.3.0
15
+ [full changelog](http://github.com/imas/rubimas/compare/v0.2.0...v0.3.0)
16
+
17
+ - Support Emily's a.k.a
18
+ - https://github.com/imas/rubimas/commit/3b3612e4ed59affa76e5ccec7b42bbd226eedf9a
19
+ - Remove ruby 2.0 support.
20
+ - https://github.com/imas/rubimas/commit/56df6b586c05e29a11a83c7aa31aa1872b86d0a2
3
21
 
4
22
  ## v0.2.0
5
23
  [full changelog](http://github.com/imas/rubimas/compare/v0.1.0...v0.2.0)
@@ -1,6 +1,6 @@
1
1
  class Fixnum
2
2
  def production
3
- self == 765 ? Pro765 : super
3
+ self == 765 ? Rubimas : super
4
4
  end
5
5
  alias :pro :production
6
6
  end
data/lib/rubimas/idol.rb CHANGED
@@ -1,73 +1,61 @@
1
1
  module Rubimas
2
2
  class Idol
3
- attr_reader :idol_id, :idol_type, :name, :age, :height, :weight, :bust, :waist, :hip,
3
+ attr_reader :idol_id, :key, :idol_type, :name, :age, :height, :weight, :bust, :waist, :hip,
4
4
  :birthday, :blood_type, :handedness, :hobbies, :talents, :favorites, :color
5
- @@cache = {}
6
- @@id_cache = {}
7
5
  @@config = nil
8
-
9
- def initialize(idol_id: nil, idol_type: nil, name: nil, age: nil, height: nil, weight: nil,
10
- bust: nil, waist: nil, hip: nil, birthday: nil, blood_type: nil, handedness: nil,
11
- hobbies: [], talents: [], favorites: [], color: nil)
12
- @idol_id = idol_id
13
- @idol_type = idol_type
14
- @name = Name.new(name)
15
- @age = age
16
- @height = height
17
- @weight = weight
18
- @bust = bust
19
- @waist = waist
20
- @hip = hip
21
- @birthday = birthday
22
- @blood_type = blood_type
23
- @handedness = handedness
24
- @hobbies = hobbies
25
- @talents = talents
26
- @favorites = favorites
27
- @color = color
6
+ @@all_idols = nil
7
+
8
+ def initialize(**args)
9
+ @idol_id = args[:idol_id]
10
+ @key = args[:key]
11
+ @idol_type = args[:idol_type]
12
+ @name = Name.new(args[:name])
13
+ @age = args[:age]
14
+ @height = args[:height]
15
+ @weight = args[:weight]
16
+ @bust = args[:bust]
17
+ @waist = args[:waist]
18
+ @hip = args[:hip]
19
+ @birthday = args[:birthday]
20
+ @blood_type = args[:blood_type]
21
+ @handedness = args[:handedness]
22
+ @hobbies = args[:hobbies]
23
+ @talents = args[:talents]
24
+ @favorites = args[:favorites]
25
+ @color = args[:color]
28
26
  end
29
-
30
- # @return [Hash] content of config/idols.yml
31
- def self.config
32
- unless @@config
33
- config_file = "#{File.dirname(__FILE__)}/../../config/idols.yml"
34
- @@config = YAML.load_file(config_file).deep_symbolize_keys
27
+ alias_method :id, :idol_id
28
+
29
+ class << self
30
+ def config
31
+ unless @@config
32
+ config_file = "#{File.dirname(__FILE__)}/../../config/idols.yml"
33
+ @@config = YAML.load_file(config_file).deep_symbolize_keys
34
+ end
35
+ @@config
35
36
  end
36
- @@config
37
- end
38
-
39
- # @return [Array<Symbol>]
40
- def self.names
41
- config.keys
42
- end
43
-
44
- # @param idol_name [Symbol]
45
- # @return [Rubimas::Idol]
46
- def self.find(idol_name)
47
- raise "unknown idol: #{idol_name}" unless valid?(idol_name)
48
37
 
49
- unless @@cache[idol_name]
50
- idol_config = config[idol_name] || {}
51
- @@cache[idol_name] = Rubimas::Idol.new(idol_config)
38
+ def names
39
+ config.keys
52
40
  end
53
41
 
54
- @@cache[idol_name]
55
- end
42
+ def all
43
+ @@all_idols ||= config.map { |key, prof| prof[:key] = key; new(prof) }
44
+ end
45
+ alias_method :all_idols, :all
56
46
 
57
- # @param idol_id [Fixnum]
58
- # @return [Rubimas::Idol]
59
- def self.find_by_id(idol_id)
60
- unless @@id_cache[idol_id]
61
- idol_config = config.select { |k, v| v[:idol_id] == idol_id }.values.first
62
- @@id_cache[idol_id] = Rubimas::Idol.new(idol_config)
47
+ def find(idol_id)
48
+ all_idols.find { |idol| idol.id == idol_id }
63
49
  end
50
+ alias_method :find_by_id, :find
64
51
 
65
- @@id_cache[idol_id]
66
- end
52
+ def find_by_name(idol_name)
53
+ all_idols.find { |idol| idol.key == idol_name } || raise("unknown idol: #{idol_name}")
54
+ end
67
55
 
68
- # @param [Symbol] idol_name
69
- def self.valid?(idol_name)
70
- names.include?(idol_name)
56
+ def valid?(idol_name)
57
+ names.include?(idol_name)
58
+ end
71
59
  end
72
60
  end
73
61
  end
@@ -1,3 +1,3 @@
1
1
  module Rubimas
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/rubimas.rb CHANGED
@@ -7,18 +7,13 @@ require "rubimas/idol/name"
7
7
  require "rubimas/core_ext/fixnum"
8
8
 
9
9
  module Rubimas
10
- end
11
-
12
- module Pro765
13
10
  def self.method_missing(name, *args)
14
11
  if Rubimas::Idol.valid?(name)
15
- Rubimas::Idol.find(name)
12
+ Rubimas::Idol.find_by_name(name)
16
13
  else
17
- super
14
+ Rubimas::Idol.send(name, *args)
18
15
  end
19
- end
20
-
21
- def self.find_by_id(idol_id)
22
- Rubimas::Idol.find_by_id(idol_id)
16
+ rescue NoMethodError
17
+ super
23
18
  end
24
19
  end
data/spec/rubimas_spec.rb CHANGED
@@ -63,9 +63,9 @@ describe Rubimas do
63
63
  end
64
64
 
65
65
  with_them do
66
- it { expect( Pro765.send(name) ).to be_an_instance_of Rubimas::Idol }
67
- it { expect( Pro765.send(name).name ).to be_an_instance_of Rubimas::Idol::Name }
68
- it { expect { Pro765.send(name).name.full }.not_to raise_error }
66
+ it { expect( 765.pro.send(name) ).to be_an_instance_of Rubimas::Idol }
67
+ it { expect( 765.pro.send(name).name ).to be_an_instance_of Rubimas::Idol::Name }
68
+ it { expect { 765.pro.send(name).name.full }.not_to raise_error }
69
69
  end
70
70
  end
71
71
  end
@@ -77,7 +77,7 @@ describe Rubimas do
77
77
  where(:name) { idol_who_has_aka }
78
78
 
79
79
  with_them do
80
- it { expect( Pro765.send(name).name.to_s ).to eq Pro765.send(name).name.aka }
80
+ it { expect( 765.pro.send(name).name.to_s ).to eq 765.pro.send(name).name.aka }
81
81
  end
82
82
  end
83
83
 
@@ -85,7 +85,7 @@ describe Rubimas do
85
85
  where(:name) { Rubimas::Idol.names - idol_who_has_aka }
86
86
 
87
87
  with_them do
88
- it { expect( Pro765.send(name).name.to_s ).to eq Pro765.send(name).name.full }
88
+ it { expect( 765.pro.send(name).name.to_s ).to eq 765.pro.send(name).name.full }
89
89
  end
90
90
  end
91
91
 
@@ -95,14 +95,14 @@ describe Rubimas do
95
95
  context 'When she has her fullname.' do
96
96
  where(:name) { Rubimas::Idol.names - idol_nobody_knows_her_fullname }
97
97
  with_them do
98
- it { expect( Pro765.send(name).name.full ).to eq Pro765.send(name).name.full }
98
+ it { expect( 765.pro.send(name).name.full ).to eq 765.pro.send(name).name.full }
99
99
  end
100
100
  end
101
101
 
102
102
  context "When nobody knows the idol's fullname." do
103
103
  where(:name) { idol_nobody_knows_her_fullname }
104
104
  with_them do
105
- it { expect( Pro765.send(name).name.full ).to eq Pro765.send(name).name.aka }
105
+ it { expect( 765.pro.send(name).name.full ).to eq 765.pro.send(name).name.aka }
106
106
  end
107
107
  end
108
108
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubimas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - treby
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-04 00:00:00.000000000 Z
11
+ date: 2016-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -182,11 +182,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
182
  version: '0'
183
183
  requirements: []
184
184
  rubyforge_project:
185
- rubygems_version: 2.5.0
185
+ rubygems_version: 2.5.1
186
186
  signing_key:
187
187
  specification_version: 4
188
188
  summary: The 765 pro idol's information library.
189
189
  test_files:
190
190
  - spec/rubimas_spec.rb
191
191
  - spec/spec_helper.rb
192
- has_rdoc: