Skip to content

Commit

Permalink
Merge 7640f92 into c7b6472
Browse files Browse the repository at this point in the history
  • Loading branch information
sue445 committed Mar 20, 2016
2 parents c7b6472 + 7640f92 commit 43b183c
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 32 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ rvm:
- ruby-head
bundler_args: "--jobs=2"
cache: bundler
before_install: gem install bundler -v 1.11.2
before_script:
- export CODECLIMATE_REPO_TOKEN=8e9db6ee5f3818e87287a6393086c2ccb9b1b83106c5bfb972211abefd2fe162
- export COVERAGE=true
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## master
[full changelog](http://github.com/sue445/rubicure/compare/v0.4.2...master)

* Add cure echo
* https://github.com/sue445/rubicure/pull/102

## v0.4.2
[full changelog](http://github.com/sue445/rubicure/compare/v0.4.1...v0.4.2)

Expand Down
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,18 +390,36 @@ Precure.all_stars.map(&:precure_name)

Precure.all_stars("2013-10-26").count
#=> 33

Precure.all_stars(:dx).count
#=> 14

Precure.all_stars(:dx2).count
#=> 17

Precure.all_stars(:dx3).count
#=> 21

Precure.all_stars(:new_stage).count
#=> 28
#=> 29
Precure.all_stars(:new_stage).include?(Cure.echo)
#=> true

Precure.all_stars(:new_stage2).count
#=> 32

Precure.all_stars(:new_stage3).count
#=> 36
#=> 37
Precure.all_stars(:new_stage3).include?(Cure.echo)
#=> true

Precure.all_stars(:spring_carnival).count
#=> 40

Precure.all_stars(:sing_together_miracle_magic).count
#=> 44
Precure.all_stars(:sing_together_miracle_magic).include?(Cure.echo)
#=> true
```

and [more aliases!](config/movies.yml)
Expand Down
18 changes: 18 additions & 0 deletions config/girls/movie.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cure_echo: &cure_echo
girl_name: cure_echo
human_name: 坂上あゆみ
precure_name: キュアエコー
cast_name: 能登麻美子
created_date:
color: white
transform_message: |-
みんなの思いを守るために
心をひとつに!
思いよ届け!キュアエコー!
extra_names:
attack_messages:
- |-
世界に響け、みんなの思い!
プリキュア・ハートフルエコー!
echo:
<<: *cure_echo
6 changes: 6 additions & 0 deletions config/movies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ dx3: &dx3
ns1: &ns1
title: 映画 プリキュアオールスターズNewStage みらいのともだち
started_date: 2012-03-17
extra_girls:
- cure_echo
ns:
<<: *ns1
new_stage:
Expand All @@ -32,6 +34,8 @@ new_stage2:
ns3: &ns3
title: 映画 プリキュアオールスターズ NewStage3 永遠のともだち
started_date: 2014-03-15
extra_girls:
- cure_echo
new_stage3:
<<: *ns3
#######################################################
Expand All @@ -44,5 +48,7 @@ spring_carnival:
stmm: &stmm
title: 映画 プリキュアオールスターズ みんなで歌う 奇跡の魔法!
started_date: 2016-03-19
extra_girls:
- cure_echo
sing_together_miracle_magic:
<<: *stmm
6 changes: 5 additions & 1 deletion lib/rubicure/concerns/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ def to_date(arg)
when Date, Time
arg
when String
Date.parse(arg)
begin
Date.parse(arg)
rescue
nil
end
else
nil
end
Expand Down
18 changes: 13 additions & 5 deletions lib/rubicure/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,23 @@ def all_stars(arg = Time.current)
@all_stars.uniq!(&:human_name)
end

begin
extra_girls = []

# args is Time or Date
date = to_date(arg)

unless date
# args is movie name
movie = Rubicure::Movie.find(arg.to_sym)
date = movie.started_date
rescue
# args is Time or Date
date = to_date(arg)

if movie.has_key?(:extra_girls)
extra_girls = movie.extra_girls.map { |girl_name| Rubicure::Girl.find(girl_name.to_sym) }
end
end

@all_stars.select { |girl| girl.created_date && girl.created_date <= date }
girls = @all_stars.select { |girl| girl.created_date && girl.created_date <= date }
girls + extra_girls
end

# iterate with :unmarked, :max_heart, ...
Expand Down
49 changes: 25 additions & 24 deletions spec/core_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,36 +70,37 @@
context "With arg" do
subject { instance.all_stars(arg) }

where(:arg, :expected_count) do
where(:arg, :expected_count, :include_cure_echo) do
[
["2009-03-20", 14],
[Date.parse("2010-03-20"), 17],
[Time.parse("2011-03-19"), 21],

[:dx, 14],
[:dx1, 14],
[:dx2, 17],
[:dx3, 21],

[:ns, 28],
[:ns1, 28],
[:new_stage, 28],
[:new_stage1, 28],
[:ns2, 32],
[:new_stage2, 32],
[:ns3, 36],
[:new_stage3, 36],

[:sc, 40],
[:spring_carnival, 40],

[:stmm, 43],
[:sing_together_miracle_magic, 43],
["2009-03-20", 14, false],
[Date.parse("2010-03-20"), 17, false],
[Time.parse("2011-03-19"), 21, false],

[:dx, 14, false],
[:dx1, 14, false],
[:dx2, 17, false],
[:dx3, 21, false],

[:ns, 29, true],
[:ns1, 29, true],
[:new_stage, 29, true],
[:new_stage1, 29, true],
[:ns2, 32, false],
[:new_stage2, 32, false],
[:ns3, 37, true],
[:new_stage3, 37, true],

[:sc, 40, false],
[:spring_carnival, 40, false],

[:stmm, 44, true],
[:sing_together_miracle_magic, 44, true],
]
end

with_them do
its(:count) { should == expected_count }
it { expect(subject.include?(Cure.echo)).to be include_cure_echo }
end
end
end
Expand Down

0 comments on commit 43b183c

Please sign in to comment.