diff --git a/.travis.yml b/.travis.yml index 6292636..9a07ce1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,6 @@ language: ruby rvm: -- 2.0 -- 2.1 -- 2.2 +- 2.2.2 - 2.3.3 - 2.4.0 - ruby-head @@ -21,6 +19,7 @@ script: branches: only: - master + - develop-1.0.0 notifications: email: false slack: diff --git a/CHANGELOG.md b/CHANGELOG.md index 19e1b57..f1e9ca5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,30 @@ ## master [full changelog](http://github.com/sue445/rubicure/compare/v0.4.13...master) +## v1.0.0 + +### Breaking changes :bomb: +* Remove `Girl#humanize` + * https://github.com/sue445/rubicure/pull/124 +* Drop support ruby 2.0 and 2.1 + * https://github.com/sue445/rubicure/pull/122 +* Rename: human name of cure princess + * https://github.com/sue445/rubicure/pull/133 +* `Precure.all_stars` returns only from "Futari wa Pretty Cure" to "Maho Girls PreCure" + * https://github.com/sue445/rubicure/pull/138 + * https://github.com/sue445/rubicure/issues/136 + * i.e. "Kirakira Precure Alamode" is not included + * If necessary, please rewrite as follows. + * `Precure.all_stars` -> `Precure.all_girls` + +### Enhancements +* Impl `Girl#full_name` + * https://github.com/sue445/rubicure/pull/135 +* Impl `Precure.all_girls` (a.k.a. `Precure.all`) + * https://github.com/sue445/rubicure/pull/138 + * https://github.com/sue445/rubicure/issues/136 + +### Others * Exclude examples/ from gem file * https://github.com/sue445/rubicure/pull/140 diff --git a/Gemfile b/Gemfile index 2f5b9d5..8f8166c 100644 --- a/Gemfile +++ b/Gemfile @@ -3,22 +3,6 @@ source "https://rubygems.org" # Specify your gem's dependencies in rubicure.gemspec gemspec -if Gem::Version.create(RUBY_VERSION) < Gem::Version.create("2.1.0") - # NOTE: build is failed when use ruby 2.0 and rspec-parameterized 0.3.0+ - # https://travis-ci.org/sue445/rubicure/jobs/114266855 - gem "rspec-parameterized", "< 0.3.0", group: :test -end - -if Gem::Version.create(RUBY_VERSION) < Gem::Version.create("2.1.0") - # NOTE: unparser v0.2.5 drop support ruby < 2.1 - gem "unparser", "< 0.2.5", group: :test -end - -if Gem::Version.create(RUBY_VERSION) < Gem::Version.create("2.2.2") - # NOTE: activesupport 5.x supports only ruby 2.2.2+ - gem "activesupport", ">= 4.0.0", "< 5.0.0" -end - if Gem::Version.create(RUBY_VERSION) < Gem::Version.create("2.3.0") gem "backport_dig" end diff --git a/README.md b/README.md index b94d4fb..76d4dc3 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Inspired by [Acme::PrettyCure](http://perl-users.jp/articles/advent-calendar/201 ## Requirements -* ruby >= 2.0.0 +* ruby >= 2.2.2 * more: [.travis.yml](.travis.yml) ## Installation @@ -32,7 +32,7 @@ Add this line to your application's Gemfile: ```ruby gem 'rubicure' -# for ruby 2.0, 2.1, 2.2 +# for ruby 2.2 gem 'backport_dig' ``` @@ -390,13 +390,38 @@ mirai.attack! プリキュア!ルビーパッショナーレ! ``` +### full_name +When `Rubicure::Girl` has `human_full_name` (i.e. another `human_name`), she returns as `#full_name` + +```ruby +Cure.princess.human_name +# => "白雪ひめ" +Cure.princess.full_name +# => "ヒメルダ・ウインドウ・キュアクイーン・オブ・ザ・ブルースカイ" + +Cure.scarlet.human_name +# => "紅城トワ" +Cure.scarlet.full_name +# => "プリンセス・ホープ・ディライト・トワ" +``` + +`#full_name` returns `#human_name` when she doe's not have `human_full_name` + +```ruby +Cure.miracle.human_name +# => "朝日奈みらい" +Cure.miracle.full_name +# => "朝日奈みらい" +``` + ### Precure allstars ```ruby Precure.all_stars.count -#=> 36 - Precure.all_stars.map(&:precure_name) -#=> ["キュアブラック", "キュアホワイト", "シャイニールミナス", "キュアブルーム", "キュアイーグレット", "キュアドリーム", "キュアルージュ", "キュアレモネード", "キュアミント", "キュアアクア", "ミルキィローズ", "キュアピーチ", "キュアベリー", "キュアパイン", "キュアパッション", "キュアブロッサム", "キュアマリン", "キュアサンシャイン", "キュアムーンライト", "キュアメロディ", "キュアリズム", "キュアビート", "キュアミューズ", "キュアハッピー", "キュアサニー", "キュアピース", "キュアマーチ", "キュアビューティ", "キュアハート", "キュアダイヤモンド", "キュアロゼッタ", "キュアソード", "キュアエース", "キュアラブリー", "キュアプリンセス", "キュアハニー"] +# returns current precure count and names + +Precure.all_stars.include?(Cure.echo) +#=> false Precure.all_stars("2013-10-26").count #=> 33 @@ -434,6 +459,22 @@ Precure.all_stars(:sing_together_miracle_magic).include?(Cure.echo) and [more aliases!](config/movies.yml) +### `Precure.all_girls` (a.k.a. `Precure.all`) +```ruby +Precure.all_girls.count +Precure.all_girls.map(&:precure_name) +# returns current precure count and names + +Precure.all_girls("2013-10-26").count +#=> 33 + +Precure.all_girls.include?(Cure.echo) +#=> true +``` + +#### `Precure.all_girls` vs `Precure.all_stars` +* `Precure.all_girls` returns all precure. (includes "Kirakira Precure Alamode") +* `Precure.all_stars` returns only from "Futari wa Pretty Cure" to "Maho Girls PreCure" ### Equivalence ```ruby diff --git a/config/girls/011_happiness_charge.yml b/config/girls/011_happiness_charge.yml index 0d395b5..df004ac 100644 --- a/config/girls/011_happiness_charge.yml +++ b/config/girls/011_happiness_charge.yml @@ -36,12 +36,13 @@ cure_lovely: &cure_lovely transform_calls: - kururin_mirror_change cure_princess: &cure_princess - girl_name: cure_princess - human_name: 白雪ひめ(ヒメルダ・ウインドウ・キュアクイーン・オブ・ザ・ブルースカイ) - precure_name: キュアプリンセス - cast_name: 潘めぐみ - created_date: 2014-02-02 # episode 1 - color: blue + girl_name: cure_princess + human_name: 白雪ひめ + human_full_name: ヒメルダ・ウインドウ・キュアクイーン・オブ・ザ・ブルースカイ + precure_name: キュアプリンセス + cast_name: 潘めぐみ + created_date: 2014-02-02 # episode 1 + color: blue transform_message: |- (かわルンルン!) プリキュアくるりんミラーチェンジ! diff --git a/config/girls/012_go_princess.yml b/config/girls/012_go_princess.yml index 0437330..17d6fc3 100644 --- a/config/girls/012_go_princess.yml +++ b/config/girls/012_go_princess.yml @@ -71,13 +71,14 @@ cure_twinkle: &cure_twinkle transform_calls: - princess_engage cure_scarlet: &cure_scarlet - girl_name: cure_scarlet - human_name: 紅城トワ - precure_name: キュアスカーレット - cast_name: 沢城みゆき - color: red - created_date: 2015-07-05 # episode 22 - birthday: 12/15 + girl_name: cure_scarlet + human_name: 紅城トワ + human_full_name: プリンセス・ホープ・ディライト・トワ + precure_name: キュアスカーレット + cast_name: 沢城みゆき + color: red + created_date: 2015-07-05 # episode 22 + birthday: 12/15 transform_message: |- プリキュア!プリンセスエンゲージ! 深紅の炎のプリンセス!キュアスカーレット! diff --git a/config/girls/movie.yml b/config/girls/movie.yml index f3dc40e..0bfde2f 100644 --- a/config/girls/movie.yml +++ b/config/girls/movie.yml @@ -3,7 +3,7 @@ cure_echo: &cure_echo human_name: 坂上あゆみ precure_name: キュアエコー cast_name: 能登麻美子 - created_date: + created_date: 2012-03-17 color: white transform_message: |- みんなの思いを守るために diff --git a/examples/all.rb b/examples/all.rb index 5334b3c..930f343 100644 --- a/examples/all.rb +++ b/examples/all.rb @@ -11,12 +11,13 @@ series.girls.each do |girl| puts <] def all_stars(arg = Time.current) - unless @all_stars - @all_stars = [] - Rubicure::Girl.names.each do |girl_name| - @all_stars << Rubicure::Girl.find(girl_name) - end - - @all_stars.uniq!(&:human_name) - end - extra_girls = [] # args is Time or Date @@ -58,10 +49,28 @@ def all_stars(arg = Time.current) end end - girls = @all_stars.select { |girl| girl.created_date && girl.created_date <= date } - girls + extra_girls + all_girls(date) - [Cure.echo] + extra_girls + end + + # @param [Time,Date] arg Time, Date or date like String (ex. "2013-12-16") + # @return [Array] + def all_girls(arg = Time.current) + date = to_date(arg) + + unless @all_girls + @all_girls = [] + Rubicure::Girl.names.each do |girl_name| + @all_girls << Rubicure::Girl.find(girl_name) + end + + @all_girls.uniq!(&:human_name) + end + + @all_girls.select { |girl| girl.created_date && girl.created_date <= date } end + alias_method :all, :all_girls + # iterate with :unmarked, :max_heart, ... # # @yield series diff --git a/lib/rubicure/girl.rb b/lib/rubicure/girl.rb index 844c779..106b2bd 100644 --- a/lib/rubicure/girl.rb +++ b/lib/rubicure/girl.rb @@ -10,6 +10,7 @@ class Girl < Hash ATTRIBUTES = [ :girl_name, :human_name, + :human_full_name, :precure_name, :cast_name, :color, @@ -62,8 +63,6 @@ def humanize! @current_transform_style = nil self end - alias_method :humanize, :humanize! - deprecate humanize: "Use #humanize! instead of #humanize" def attack! raise RequireTransformError, "require transform" if current_attack_message.blank? @@ -89,6 +88,10 @@ def have_birthday? # rubocop:disable Style/PredicateName end alias_method :has_birthday?, :have_birthday? + def full_name + human_full_name.presence || human_name + end + ATTRIBUTES.each do |attribute| define_method attribute do if @current_transform_style diff --git a/lib/rubicure/version.rb b/lib/rubicure/version.rb index 0267b5f..952dc31 100644 --- a/lib/rubicure/version.rb +++ b/lib/rubicure/version.rb @@ -1,3 +1,3 @@ module Rubicure - VERSION = "0.4.13" + VERSION = "1.0.0.pre3" end diff --git a/rubicure.gemspec b/rubicure.gemspec index 2ff9906..d2e8b87 100644 --- a/rubicure.gemspec +++ b/rubicure.gemspec @@ -13,7 +13,7 @@ Gem::Specification.new do |spec| spec.homepage = "https://github.com/sue445/rubicure" spec.license = "MIT" - spec.required_ruby_version = ">= 2.0.0" + spec.required_ruby_version = ">= 2.2.2" spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR) @@ -25,7 +25,7 @@ Gem::Specification.new do |spec| spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] - spec.add_dependency "activesupport", ">= 4.0.0" + spec.add_dependency "activesupport", ">= 5.0.0" spec.add_dependency "hashie", ">= 2.0.5" spec.add_dependency "sengiri_yaml", ">= 0.0.2" diff --git a/spec/core_spec.rb b/spec/core_spec.rb index 4912932..fb6a7f4 100644 --- a/spec/core_spec.rb +++ b/spec/core_spec.rb @@ -44,32 +44,62 @@ context "With arg" do subject { instance.all_stars(arg) } + using RSpec::Parameterized::TableSyntax + + where(:arg, :expected_count, :include_cure_echo) do + "2009-03-20" | 14 | false + "2017-01-17" | 44 | 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 + + describe "#all_girls" do + context "Without arg" do + subject { instance.all_girls } + + let(:precure_count) { 45 } + + its(:count) { should == precure_count } + it { should include Cure.echo } + end + + context "With arg" do + subject { instance.all_girls(arg) } + + using RSpec::Parameterized::TableSyntax + where(:arg, :expected_count, :include_cure_echo) do - [ - ["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], - ] + "2009-03-20" | 14 | false + "2017-01-17" | 45 | true + Date.parse("2010-03-20") | 17 | false + Time.parse("2011-03-19") | 21 | false end with_them do diff --git a/spec/girl_spec.rb b/spec/girl_spec.rb index e8b2d7f..3c27511 100644 --- a/spec/girl_spec.rb +++ b/spec/girl_spec.rb @@ -311,4 +311,18 @@ it { should be false } end end + + describe "#full_name" do + subject { girl.full_name } + + context "has human_full_name" do + let(:girl) { Cure.scarlet } + + it { should eq "プリンセス・ホープ・ディライト・トワ" } + end + + context "don't have human_full_name" do + it { should eq "黄瀬やよい" } + end + end end