rubicure 0.0.7 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.hound.yml +5 -0
- data/CHANGELOG.md +8 -1
- data/README.md +34 -2
- data/config/girls.yml +322 -4
- data/lib/rubicure/concerns/util.rb +7 -6
- data/lib/rubicure/core.rb +4 -3
- data/lib/rubicure/girl.rb +39 -5
- data/lib/rubicure/movie.rb +4 -1
- data/lib/rubicure/series.rb +4 -2
- data/lib/rubicure/version.rb +1 -1
- data/spec/core_spec.rb +10 -9
- data/spec/girl_spec.rb +51 -28
- data/spec/movie_spec.rb +12 -12
- data/spec/rubicure_spec.rb +10 -10
- data/spec/series_spec.rb +35 -35
- data/spec/spec_helper.rb +6 -2
- metadata +3 -4
- data/spec/support/array_instance_of.rb +0 -12
@@ -1,5 +1,6 @@
|
|
1
1
|
module Rubicure
|
2
2
|
module Concerns
|
3
|
+
# utility methods
|
3
4
|
module Util
|
4
5
|
# @param arg
|
5
6
|
# @return [Date] arg is String or Date
|
@@ -7,12 +8,12 @@ module Rubicure
|
|
7
8
|
# @return [nil] arg is other
|
8
9
|
def to_date(arg)
|
9
10
|
case arg
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
when Date, Time
|
12
|
+
arg
|
13
|
+
when String
|
14
|
+
Date.parse(arg)
|
15
|
+
else
|
16
|
+
nil
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|
data/lib/rubicure/core.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Rubicure
|
2
2
|
require "singleton"
|
3
3
|
|
4
|
+
# generic methods
|
4
5
|
class Core
|
5
6
|
include Singleton
|
6
7
|
include Enumerable
|
@@ -32,14 +33,14 @@ module Rubicure
|
|
32
33
|
|
33
34
|
# @param [Time,Date,String,Symbol] arg Time, Date or date like String (ex. "2013-12-16")
|
34
35
|
# @return [Array<Rubicure::Girl>]
|
35
|
-
def all_stars(arg=Time.current)
|
36
|
+
def all_stars(arg = Time.current)
|
36
37
|
unless @all_stars
|
37
38
|
@all_stars = []
|
38
39
|
Rubicure::Girl.names.each do |girl_name|
|
39
40
|
@all_stars << Rubicure::Girl.find(girl_name)
|
40
41
|
end
|
41
42
|
|
42
|
-
@all_stars.uniq!{|girl| girl.human_name }
|
43
|
+
@all_stars.uniq! { |girl| girl.human_name }
|
43
44
|
end
|
44
45
|
|
45
46
|
begin
|
@@ -50,7 +51,7 @@ module Rubicure
|
|
50
51
|
date = to_date(arg)
|
51
52
|
end
|
52
53
|
|
53
|
-
@all_stars.select{|girl| girl.created_date && girl.created_date <= date }
|
54
|
+
@all_stars.select { |girl| girl.created_date && girl.created_date <= date }
|
54
55
|
end
|
55
56
|
|
56
57
|
# iterate with :unmarked, :max_heart, ...
|
data/lib/rubicure/girl.rb
CHANGED
@@ -1,11 +1,17 @@
|
|
1
1
|
module Rubicure
|
2
|
+
# Precure girl (ex. Cure Peace, Cure Rosetta, Cure Honey)
|
3
|
+
#
|
4
|
+
# this is record of "config/girls.yml"
|
2
5
|
class Girl
|
3
|
-
attr_reader :human_name, :precure_name, :transform_message, :extra_names,
|
6
|
+
attr_reader :human_name, :precure_name, :transform_message, :extra_names,
|
7
|
+
:current_state, :state_names, :created_date, :attack_messages
|
4
8
|
|
5
9
|
@@cache = {}
|
6
10
|
@@config = nil
|
11
|
+
@@sleep_sec = 1
|
7
12
|
|
8
|
-
def initialize(human_name: nil, precure_name: nil, transform_message: nil, extra_names: [],
|
13
|
+
def initialize(human_name: nil, precure_name: nil, transform_message: nil, extra_names: [],
|
14
|
+
created_date: nil, attack_messages: [])
|
9
15
|
@human_name = human_name
|
10
16
|
@precure_name = precure_name
|
11
17
|
@transform_message = transform_message
|
@@ -14,9 +20,10 @@ module Rubicure
|
|
14
20
|
@current_state = 0
|
15
21
|
@state_names = [@human_name, @precure_name]
|
16
22
|
@state_names += @extra_names unless @extra_names.empty?
|
23
|
+
@attack_messages = [""] + attack_messages
|
17
24
|
end
|
18
25
|
|
19
|
-
def ==
|
26
|
+
def ==(other)
|
20
27
|
other.is_a?(self.class) && self.human_name == other.human_name
|
21
28
|
end
|
22
29
|
|
@@ -31,7 +38,7 @@ module Rubicure
|
|
31
38
|
@current_state += 1
|
32
39
|
@current_state = 0 unless @current_state < @state_names.length
|
33
40
|
|
34
|
-
|
41
|
+
print_by_line @transform_message if @current_state == 1
|
35
42
|
|
36
43
|
self
|
37
44
|
end
|
@@ -40,6 +47,14 @@ module Rubicure
|
|
40
47
|
@current_state = 0
|
41
48
|
end
|
42
49
|
|
50
|
+
def attack!
|
51
|
+
raise "require transform" if current_attack_message.blank?
|
52
|
+
|
53
|
+
print_by_line current_attack_message
|
54
|
+
|
55
|
+
current_attack_message
|
56
|
+
end
|
57
|
+
|
43
58
|
# @param girl_name [Symbol]
|
44
59
|
# @return [Rubicure::Girl]
|
45
60
|
def self.find(girl_name)
|
@@ -62,7 +77,7 @@ module Rubicure
|
|
62
77
|
def self.uniq_names
|
63
78
|
uniq_names = []
|
64
79
|
config.each do |name, series|
|
65
|
-
uniq_names << name unless uniq_names.any?{|uniq_name| config[uniq_name][:precure_name] == series[:precure_name] }
|
80
|
+
uniq_names << name unless uniq_names.any? { |uniq_name| config[uniq_name][:precure_name] == series[:precure_name] }
|
66
81
|
end
|
67
82
|
uniq_names
|
68
83
|
end
|
@@ -87,5 +102,24 @@ module Rubicure
|
|
87
102
|
def self.valid?(girl_name)
|
88
103
|
names.include?(girl_name)
|
89
104
|
end
|
105
|
+
|
106
|
+
def self.sleep_sec=(sleep_sec)
|
107
|
+
@@sleep_sec = sleep_sec
|
108
|
+
end
|
109
|
+
|
110
|
+
private
|
111
|
+
|
112
|
+
def current_attack_message
|
113
|
+
attack_messages[current_state]
|
114
|
+
end
|
115
|
+
|
116
|
+
def print_by_line(message)
|
117
|
+
index = 0
|
118
|
+
message.each_line do |line|
|
119
|
+
sleep(@@sleep_sec) if index > 0
|
120
|
+
puts line
|
121
|
+
index += 1
|
122
|
+
end
|
123
|
+
end
|
90
124
|
end
|
91
125
|
end
|
data/lib/rubicure/movie.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
module Rubicure
|
2
|
+
# Precure All Stars Movie
|
3
|
+
#
|
4
|
+
# this is record of "config/movies.yml"
|
2
5
|
class Movie < Hash
|
3
6
|
include Hashie::Extensions::MethodAccess
|
4
7
|
|
@@ -14,7 +17,7 @@ module Rubicure
|
|
14
17
|
def self.uniq_names
|
15
18
|
uniq_names = []
|
16
19
|
config.each do |name, series|
|
17
|
-
uniq_names << name unless uniq_names.any?{|uniq_name| config[uniq_name][:title] == series[:title] }
|
20
|
+
uniq_names << name unless uniq_names.any? { |uniq_name| config[uniq_name][:title] == series[:title] }
|
18
21
|
end
|
19
22
|
uniq_names
|
20
23
|
end
|
data/lib/rubicure/series.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
module Rubicure
|
2
|
+
# Precure TV series (ex. Smile Precure, Dokidoki Orecure)
|
3
|
+
# this is record of "config/series.yml"
|
2
4
|
class Series < Hash
|
3
5
|
include Hashie::Extensions::MethodAccess
|
4
6
|
include Rubicure::Concerns::Util
|
@@ -8,7 +10,7 @@ module Rubicure
|
|
8
10
|
|
9
11
|
# @param [Rubicure::Series,Rubicure::Girl] other
|
10
12
|
# @return [Boolean] other is same Rubicure::Series or Rubicure::Series include Rubicure::Girl
|
11
|
-
def ===
|
13
|
+
def ===(other)
|
12
14
|
case other
|
13
15
|
when self.class
|
14
16
|
self == other
|
@@ -58,7 +60,7 @@ module Rubicure
|
|
58
60
|
def self.uniq_names
|
59
61
|
uniq_names = []
|
60
62
|
config.each do |name, series|
|
61
|
-
uniq_names << name unless uniq_names.any?{|uniq_name| config[uniq_name][:title] == series[:title] }
|
63
|
+
uniq_names << name unless uniq_names.any? { |uniq_name| config[uniq_name][:title] == series[:title] }
|
62
64
|
end
|
63
65
|
uniq_names
|
64
66
|
end
|
data/lib/rubicure/version.rb
CHANGED
data/spec/core_spec.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
describe Rubicure::Core do
|
2
|
-
let(:instance){ Rubicure::Core.instance }
|
2
|
+
let(:instance) { Rubicure::Core.instance }
|
3
3
|
|
4
4
|
describe "#now" do
|
5
|
-
subject{ instance.now }
|
5
|
+
subject { instance.now }
|
6
6
|
|
7
7
|
context "when on air" do
|
8
8
|
before do
|
9
9
|
time_travel_to "2013-01-01"
|
10
10
|
end
|
11
11
|
|
12
|
-
its(:title){ should == "スマイルプリキュア!" }
|
12
|
+
its(:title) { should == "スマイルプリキュア!" }
|
13
13
|
end
|
14
14
|
|
15
15
|
context "when not on air" do
|
@@ -17,7 +17,7 @@ describe Rubicure::Core do
|
|
17
17
|
time_travel_to "2013-02-01"
|
18
18
|
end
|
19
19
|
|
20
|
-
it{ expect{ subject }.to raise_error }
|
20
|
+
it { expect { subject }.to raise_error }
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -37,6 +37,7 @@ EOS
|
|
37
37
|
precure_name: #{girl.precure_name}
|
38
38
|
extra_names: #{girl.extra_names}
|
39
39
|
state_names: #{girl.state_names}
|
40
|
+
attack_messages: #{girl.attack_messages}
|
40
41
|
transform_message:
|
41
42
|
#{girl.transform_message}
|
42
43
|
EOS
|
@@ -52,12 +53,12 @@ EOS
|
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
55
|
-
it{ expect{|b| instance.each_with_series(&b) }.to yield_successive_args *@expected_series }
|
56
|
+
it { expect { |b| instance.each_with_series(&b) }.to yield_successive_args *@expected_series }
|
56
57
|
end
|
57
58
|
|
58
59
|
describe "#all_stars" do
|
59
60
|
context "Without arg" do
|
60
|
-
subject{ instance.all_stars }
|
61
|
+
subject { instance.all_stars }
|
61
62
|
|
62
63
|
before do
|
63
64
|
human_names = []
|
@@ -68,11 +69,11 @@ EOS
|
|
68
69
|
@precure_count = human_names.uniq.count
|
69
70
|
end
|
70
71
|
|
71
|
-
its(:count){ should == @precure_count }
|
72
|
+
its(:count) { should == @precure_count }
|
72
73
|
end
|
73
74
|
|
74
75
|
context "With arg" do
|
75
|
-
subject{ instance.all_stars(arg) }
|
76
|
+
subject { instance.all_stars(arg) }
|
76
77
|
|
77
78
|
where(:arg, :expected_count) do
|
78
79
|
[
|
@@ -95,7 +96,7 @@ EOS
|
|
95
96
|
end
|
96
97
|
|
97
98
|
with_them do
|
98
|
-
its(:count){ should == expected_count }
|
99
|
+
its(:count) { should == expected_count }
|
99
100
|
end
|
100
101
|
end
|
101
102
|
end
|
data/spec/girl_spec.rb
CHANGED
@@ -1,27 +1,34 @@
|
|
1
1
|
describe Rubicure::Girl do
|
2
|
-
let(:girl)
|
2
|
+
let(:girl) do
|
3
3
|
Rubicure::Girl.new(
|
4
4
|
human_name: human_name,
|
5
5
|
precure_name: precure_name,
|
6
6
|
extra_names: extra_names,
|
7
|
-
transform_message: transform_message
|
7
|
+
transform_message: transform_message,
|
8
|
+
attack_messages: attack_messages,
|
8
9
|
)
|
9
|
-
|
10
|
+
end
|
10
11
|
|
11
12
|
let(:human_name) { "黄瀬やよい" }
|
12
13
|
let(:precure_name) { "キュアピース" }
|
13
14
|
let(:extra_names) { %w(プリンセスピース ウルトラピース) }
|
14
|
-
let(:transform_message)
|
15
|
+
let(:transform_message) do
|
15
16
|
<<EOF
|
16
17
|
プリキュアスマイルチャージ!
|
17
18
|
GO! GO! Let's GO ピース!
|
18
19
|
ピカピカピカリンジャンケンポン! キュアピース!
|
19
20
|
EOF
|
20
|
-
|
21
|
+
end
|
22
|
+
let(:attack_messages) do
|
23
|
+
[
|
24
|
+
"プリキュアピースサンダー!",
|
25
|
+
"プリキュアピースサンダーハリケーン!",
|
26
|
+
]
|
27
|
+
end
|
21
28
|
|
22
29
|
describe "#name" do
|
23
30
|
context "when before transform" do
|
24
|
-
it{ expect(girl.name).to eq human_name }
|
31
|
+
it { expect(girl.name).to eq human_name }
|
25
32
|
end
|
26
33
|
|
27
34
|
context "when after 1st transform" do
|
@@ -29,7 +36,7 @@ EOF
|
|
29
36
|
girl.transform!
|
30
37
|
end
|
31
38
|
|
32
|
-
it{ expect(girl.name).to eq precure_name }
|
39
|
+
it { expect(girl.name).to eq precure_name }
|
33
40
|
end
|
34
41
|
|
35
42
|
context "when after 2nd transform" do
|
@@ -38,7 +45,7 @@ EOF
|
|
38
45
|
girl.transform!
|
39
46
|
end
|
40
47
|
|
41
|
-
it{ expect(girl.name).to eq extra_names[0] }
|
48
|
+
it { expect(girl.name).to eq extra_names[0] }
|
42
49
|
end
|
43
50
|
|
44
51
|
context "when after 3nd transform" do
|
@@ -48,7 +55,7 @@ EOF
|
|
48
55
|
girl.transform!
|
49
56
|
end
|
50
57
|
|
51
|
-
it{ expect(girl.name).to eq extra_names[1] }
|
58
|
+
it { expect(girl.name).to eq extra_names[1] }
|
52
59
|
end
|
53
60
|
|
54
61
|
context "when after final transform" do
|
@@ -60,51 +67,67 @@ EOF
|
|
60
67
|
end
|
61
68
|
|
62
69
|
# return to human
|
63
|
-
it{ expect(girl.name).to eq human_name }
|
70
|
+
it { expect(girl.name).to eq human_name }
|
64
71
|
end
|
65
72
|
end
|
66
73
|
|
67
74
|
describe "#==" do
|
68
|
-
subject{ girl == other_girl }
|
75
|
+
subject { girl == other_girl }
|
69
76
|
|
70
77
|
context "same object" do
|
71
|
-
let(:other_girl){ girl }
|
72
|
-
it{ should be true }
|
78
|
+
let(:other_girl) { girl }
|
79
|
+
it { should be true }
|
73
80
|
end
|
74
81
|
|
75
82
|
context "copied object" do
|
76
|
-
let(:other_girl){ girl.dup }
|
77
|
-
it{ should be true }
|
83
|
+
let(:other_girl) { girl.dup }
|
84
|
+
it { should be true }
|
78
85
|
end
|
79
86
|
|
80
87
|
context "precure and human" do
|
81
|
-
let(:transformed_girl){ girl.dup.transform! }
|
82
|
-
let(:other_girl){ transformed_girl }
|
88
|
+
let(:transformed_girl) { girl.dup.transform! }
|
89
|
+
let(:other_girl) { transformed_girl }
|
83
90
|
|
84
|
-
it{ expect(girl.name).not_to eq transformed_girl.name }
|
85
|
-
it{ should be true }
|
91
|
+
it { expect(girl.name).not_to eq transformed_girl.name }
|
92
|
+
it { should be true }
|
86
93
|
end
|
87
94
|
|
88
95
|
context "other precure" do
|
89
|
-
let(:other_girl){ Rubicure::Girl.find(:passion) }
|
90
|
-
it{ should be false }
|
96
|
+
let(:other_girl) { Rubicure::Girl.find(:passion) }
|
97
|
+
it { should be false }
|
91
98
|
end
|
92
99
|
end
|
93
100
|
|
94
101
|
describe "#find" do
|
95
|
-
subject{ Rubicure::Girl.find(girl_name) }
|
102
|
+
subject { Rubicure::Girl.find(girl_name) }
|
96
103
|
|
97
|
-
let(:girl_name){ :peace }
|
104
|
+
let(:girl_name) { :peace }
|
98
105
|
|
99
|
-
it{ should be_an_instance_of Rubicure::Girl }
|
100
|
-
its(:precure_name){ should == "キュアピース" }
|
106
|
+
it { should be_an_instance_of Rubicure::Girl }
|
107
|
+
its(:precure_name) { should == "キュアピース" }
|
101
108
|
end
|
102
109
|
|
103
110
|
describe "#uniq_names" do
|
104
|
-
subject{ Rubicure::Girl.uniq_names }
|
111
|
+
subject { Rubicure::Girl.uniq_names }
|
105
112
|
|
106
|
-
let(:containing_name_alias_count){ Rubicure::Girl.names.count }
|
113
|
+
let(:containing_name_alias_count) { Rubicure::Girl.names.count }
|
107
114
|
|
108
|
-
its(:count){ should < containing_name_alias_count }
|
115
|
+
its(:count) { should < containing_name_alias_count }
|
116
|
+
end
|
117
|
+
|
118
|
+
describe "#attack!" do
|
119
|
+
subject { girl.attack! }
|
120
|
+
|
121
|
+
context "When human" do
|
122
|
+
it { expect { subject }.to raise_error }
|
123
|
+
end
|
124
|
+
|
125
|
+
context "When precure" do
|
126
|
+
before do
|
127
|
+
girl.transform!
|
128
|
+
end
|
129
|
+
|
130
|
+
it { should eq "プリキュアピースサンダー!" }
|
131
|
+
end
|
109
132
|
end
|
110
133
|
end
|
data/spec/movie_spec.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
describe Rubicure::Movie do
|
2
|
-
let(:movie_names)
|
2
|
+
let(:movie_names) do
|
3
3
|
[
|
4
4
|
:dx1,
|
5
5
|
:dx2,
|
@@ -8,34 +8,34 @@ describe Rubicure::Movie do
|
|
8
8
|
:ns2,
|
9
9
|
:ns3,
|
10
10
|
]
|
11
|
-
|
11
|
+
end
|
12
12
|
|
13
13
|
describe "#names" do
|
14
|
-
subject{ Rubicure::Movie.names }
|
14
|
+
subject { Rubicure::Movie.names }
|
15
15
|
|
16
|
-
it{ should include *movie_names }
|
16
|
+
it { should include *movie_names }
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "#uniq_names" do
|
20
|
-
subject{ Rubicure::Movie.uniq_names }
|
20
|
+
subject { Rubicure::Movie.uniq_names }
|
21
21
|
|
22
|
-
it{ should include *movie_names }
|
23
|
-
its(:count){ should == movie_names.count }
|
22
|
+
it { should include *movie_names }
|
23
|
+
its(:count) { should == movie_names.count }
|
24
24
|
end
|
25
25
|
|
26
26
|
describe "#find" do
|
27
|
-
subject{ Rubicure::Movie.find(movie_name) }
|
27
|
+
subject { Rubicure::Movie.find(movie_name) }
|
28
28
|
|
29
29
|
context "when exists" do
|
30
|
-
let(:movie_name){ :dx }
|
30
|
+
let(:movie_name) { :dx }
|
31
31
|
|
32
|
-
its(:title){ should == "映画 プリキュアオールスターズDX みんなともだちっ☆奇跡の全員大集合!" }
|
32
|
+
its(:title) { should == "映画 プリキュアオールスターズDX みんなともだちっ☆奇跡の全員大集合!" }
|
33
33
|
end
|
34
34
|
|
35
35
|
context "when not exists" do
|
36
|
-
let(:movie_name){ :ashita_no_nadja }
|
36
|
+
let(:movie_name) { :ashita_no_nadja }
|
37
37
|
|
38
|
-
it{ expect{subject}.to raise_error }
|
38
|
+
it { expect{ subject }.to raise_error }
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|