From 92a4511cf31adc1e3dd0b9fc82fff013983f9780 Mon Sep 17 00:00:00 2001 From: sue445 Date: Fri, 22 Aug 2014 18:04:47 +0900 Subject: [PATCH 1/2] Fix: Pullreviews * Add documentation to the following class * Indent when as deep as case. * Space between { and | missing * Space missing to the left of { * Surrounding space missing in default value assignment * Avoid using {} for multi line blocks. * Enable cure fortune test * Use instead all matcher * Space missing inside } --- lib/rubicure/concerns/util.rb | 13 +++---- lib/rubicure/core.rb | 7 ++-- lib/rubicure/girl.rb | 7 ++-- lib/rubicure/movie.rb | 5 ++- lib/rubicure/series.rb | 6 ++-- spec/core_spec.rb | 12 +++---- spec/girl_spec.rb | 46 ++++++++++++------------- spec/movie_spec.rb | 18 +++++----- spec/rubicure_spec.rb | 20 +++++------ spec/series_spec.rb | 56 +++++++++++++++---------------- spec/spec_helper.rb | 2 +- spec/support/array_instance_of.rb | 12 ------- 12 files changed, 101 insertions(+), 103 deletions(-) delete mode 100644 spec/support/array_instance_of.rb diff --git a/lib/rubicure/concerns/util.rb b/lib/rubicure/concerns/util.rb index 250150a..bb53216 100644 --- a/lib/rubicure/concerns/util.rb +++ b/lib/rubicure/concerns/util.rb @@ -1,5 +1,6 @@ module Rubicure module Concerns + # utility methods module Util # @param arg # @return [Date] arg is String or Date @@ -7,12 +8,12 @@ module Util # @return [nil] arg is other def to_date(arg) case arg - when Date, Time - arg - when String - Date.parse(arg) - else - nil + when Date, Time + arg + when String + Date.parse(arg) + else + nil end end end diff --git a/lib/rubicure/core.rb b/lib/rubicure/core.rb index 919ea66..ad5cc5a 100644 --- a/lib/rubicure/core.rb +++ b/lib/rubicure/core.rb @@ -1,6 +1,7 @@ module Rubicure require "singleton" + # generic methods class Core include Singleton include Enumerable @@ -32,14 +33,14 @@ def now # @param [Time,Date,String,Symbol] arg Time, Date or date like String (ex. "2013-12-16") # @return [Array] - def all_stars(arg=Time.current) + 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!{|girl| girl.human_name } + @all_stars.uniq! { |girl| girl.human_name } end begin @@ -50,7 +51,7 @@ def all_stars(arg=Time.current) date = to_date(arg) end - @all_stars.select{|girl| girl.created_date && girl.created_date <= date } + @all_stars.select { |girl| girl.created_date && girl.created_date <= date } end # iterate with :unmarked, :max_heart, ... diff --git a/lib/rubicure/girl.rb b/lib/rubicure/girl.rb index c494cc8..ee2a756 100644 --- a/lib/rubicure/girl.rb +++ b/lib/rubicure/girl.rb @@ -1,4 +1,7 @@ module Rubicure + # Precure girl (ex. Cure Peace, Cure Rosetta, Cure Honey) + # + # this is record of "config/girls.yml" class Girl attr_reader :human_name, :precure_name, :transform_message, :extra_names, :current_state, :state_names, :created_date @@ -16,7 +19,7 @@ def initialize(human_name: nil, precure_name: nil, transform_message: nil, extra @state_names += @extra_names unless @extra_names.empty? end - def == (other) + def ==(other) other.is_a?(self.class) && self.human_name == other.human_name end @@ -62,7 +65,7 @@ def self.names def self.uniq_names uniq_names = [] config.each do |name, series| - uniq_names << name unless uniq_names.any?{|uniq_name| config[uniq_name][:precure_name] == series[:precure_name] } + uniq_names << name unless uniq_names.any? { |uniq_name| config[uniq_name][:precure_name] == series[:precure_name] } end uniq_names end diff --git a/lib/rubicure/movie.rb b/lib/rubicure/movie.rb index 25e4fa0..3a10749 100644 --- a/lib/rubicure/movie.rb +++ b/lib/rubicure/movie.rb @@ -1,4 +1,7 @@ module Rubicure + # Precure All Stars Movie + # + # this is record of "config/movies.yml" class Movie < Hash include Hashie::Extensions::MethodAccess @@ -14,7 +17,7 @@ def self.names def self.uniq_names uniq_names = [] config.each do |name, series| - uniq_names << name unless uniq_names.any?{|uniq_name| config[uniq_name][:title] == series[:title] } + uniq_names << name unless uniq_names.any? { |uniq_name| config[uniq_name][:title] == series[:title] } end uniq_names end diff --git a/lib/rubicure/series.rb b/lib/rubicure/series.rb index 6a18f05..f90649d 100644 --- a/lib/rubicure/series.rb +++ b/lib/rubicure/series.rb @@ -1,4 +1,6 @@ module Rubicure + # Precure TV series (ex. Smile Precure, Dokidoki Orecure) + # this is record of "config/series.yml" class Series < Hash include Hashie::Extensions::MethodAccess include Rubicure::Concerns::Util @@ -8,7 +10,7 @@ class Series < Hash # @param [Rubicure::Series,Rubicure::Girl] other # @return [Boolean] other is same Rubicure::Series or Rubicure::Series include Rubicure::Girl - def === (other) + def ===(other) case other when self.class self == other @@ -58,7 +60,7 @@ def self.names def self.uniq_names uniq_names = [] config.each do |name, series| - uniq_names << name unless uniq_names.any?{|uniq_name| config[uniq_name][:title] == series[:title] } + uniq_names << name unless uniq_names.any? { |uniq_name| config[uniq_name][:title] == series[:title] } end uniq_names end diff --git a/spec/core_spec.rb b/spec/core_spec.rb index 4cced55..b51bd11 100644 --- a/spec/core_spec.rb +++ b/spec/core_spec.rb @@ -1,5 +1,5 @@ describe Rubicure::Core do - let(:instance){ Rubicure::Core.instance } + let(:instance) { Rubicure::Core.instance } describe "#now" do subject{ instance.now } @@ -9,7 +9,7 @@ time_travel_to "2013-01-01" end - its(:title){ should == "スマイルプリキュア!" } + its(:title) { should == "スマイルプリキュア!" } end context "when not on air" do @@ -17,7 +17,7 @@ time_travel_to "2013-02-01" end - it{ expect{ subject }.to raise_error } + it { expect{ subject }.to raise_error } end end @@ -52,7 +52,7 @@ end end - it{ expect{|b| instance.each_with_series(&b) }.to yield_successive_args *@expected_series } + it { expect{|b| instance.each_with_series(&b) }.to yield_successive_args *@expected_series } end describe "#all_stars" do @@ -68,7 +68,7 @@ @precure_count = human_names.uniq.count end - its(:count){ should == @precure_count } + its(:count) { should == @precure_count } end context "With arg" do @@ -95,7 +95,7 @@ end with_them do - its(:count){ should == expected_count } + its(:count) { should == expected_count } end end end diff --git a/spec/girl_spec.rb b/spec/girl_spec.rb index b9abed0..fc85561 100644 --- a/spec/girl_spec.rb +++ b/spec/girl_spec.rb @@ -1,17 +1,17 @@ describe Rubicure::Girl do - let(:girl){ + let(:girl) do Rubicure::Girl.new( human_name: human_name, precure_name: precure_name, extra_names: extra_names, transform_message: transform_message ) - } + end let(:human_name) { "黄瀬やよい" } let(:precure_name) { "キュアピース" } let(:extra_names) { %w(プリンセスピース ウルトラピース) } - let(:transform_message){ + let(:transform_message) { <" do - let(:futari_wa_pretty_cure){ Rubicure::Series.find(:unmarked) } + let(:futari_wa_pretty_cure) { Rubicure::Series.find(:unmarked) } - it{ expect(Precure.title).to eq futari_wa_pretty_cure.title } - it{ expect(Precure.girls.count).to eq futari_wa_pretty_cure.girls.count } + it { expect(Precure.title).to eq futari_wa_pretty_cure.title } + it { expect(Precure.girls.count).to eq futari_wa_pretty_cure.girls.count } end end @@ -100,18 +100,18 @@ [:lovely], [:princess], [:honey], - #[:fortune], + [:fortune], ] end with_them do - it{ expect( Cure.send(name) ).to be_an_instance_of Rubicure::Girl } - it{ expect( Cure.send(name).precure_name ).to be_start_with "キュア" } + it { expect( Cure.send(name) ).to be_an_instance_of Rubicure::Girl } + it { expect( Cure.send(name).precure_name ).to be_start_with "キュア" } end context "When precure who not starting 'cure'" do - it{ expect( Shiny.luminous.precure_name ).to eq "シャイニールミナス"} - it{ expect( Milky.rose.precure_name ).to eq "ミルキィローズ"} + it { expect( Shiny.luminous.precure_name ).to eq "シャイニールミナス" } + it { expect( Milky.rose.precure_name ).to eq "ミルキィローズ" } end end end diff --git a/spec/series_spec.rb b/spec/series_spec.rb index 195dafa..dc2a9c2 100644 --- a/spec/series_spec.rb +++ b/spec/series_spec.rb @@ -3,23 +3,23 @@ subject{ series.on_air?(date) } context "when ended title" do - let(:series) { + let(:series) do Rubicure::Series[ started_date: Date.parse("2012-02-05"), ended_date: Date.parse("2013-01-27"), ] - } + end context "when Date arg" do - let(:date){ Date.parse("2013-01-01") } + let(:date) { Date.parse("2013-01-01") } - it{ should be true } + it { should be true } end context "when date like String arg" do - let(:date){ "2013-01-01" } + let(:date) { "2013-01-01" } - it{ should be true } + it { should be true } end end @@ -30,26 +30,26 @@ ] } - let(:date){ Date.parse("2013-12-01") } + let(:date) { Date.parse("2013-12-01") } - it{ should be true } + it { should be true } end end describe "#girls" do subject{ series.girls } - let(:series) { + let(:series) do Rubicure::Series[ girls: %w(cure_happy cure_sunny cure_peace cure_march cure_beauty) ] - } + end - it{ should have_exactly(5).girls } - it{ should array_instance_of Rubicure::Girl } + it { should have_exactly(5).girls } + it { should all(be_instance_of Rubicure::Girl) } end - let(:series_names) { + let(:series_names) do [ :unmarked, :max_heart, @@ -63,13 +63,13 @@ :dokidoki, :happiness_charge, ] - } + end describe "#===" do - let(:series){ Rubicure::Series.find(series_name) } - let(:series_name){ :smile } - let(:girl){ Rubicure::Girl.find(girl_name) } - let(:girl_name){ :peace } + let(:series) { Rubicure::Series.find(series_name) } + let(:series_name) { :smile } + let(:girl) { Rubicure::Girl.find(girl_name) } + let(:girl_name) { :peace } context "same series" do it { expect(series === series).to be true } @@ -77,8 +77,8 @@ end context "other series" do - let(:other_series){ Rubicure::Series.find(:dokidoki) } - let(:other_girl){ Rubicure::Girl.find(:passion) } + let(:other_series) { Rubicure::Series.find(:dokidoki) } + let(:other_girl) { Rubicure::Girl.find(:passion) } it { expect(series === other_series).to be false } it { expect(series === other_girl).to be false } end @@ -95,30 +95,30 @@ describe "#names" do subject{ Rubicure::Series.names } - it{ should include *series_names } + it { should include *series_names } end describe "#uniq_names" do subject{ Rubicure::Series.uniq_names } - it{ should include *series_names } - its(:count){ should == series_names.count } + it { should include *series_names } + its(:count) { should == series_names.count } end describe "#find" do subject{ Rubicure::Series.find(series_name) } context "when exists" do - let(:series_name){ :smile } + let(:series_name) { :smile } - its(:title){ should == "スマイルプリキュア!" } - its(:girls){ should have_exactly(5).girls } + its(:title) { should == "スマイルプリキュア!" } + its(:girls) { should have_exactly(5).girls } end context "when not exists" do - let(:series_name){ :ashita_no_nadja } + let(:series_name) { :ashita_no_nadja } - it{ expect{subject}.to raise_error } + it { expect{ subject }.to raise_error } end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ef1f758..577fe66 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -31,7 +31,7 @@ # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. -Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} +Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f } RSpec.configure do |config| # The settings below are suggested to provide a good initial experience diff --git a/spec/support/array_instance_of.rb b/spec/support/array_instance_of.rb deleted file mode 100644 index a149480..0000000 --- a/spec/support/array_instance_of.rb +++ /dev/null @@ -1,12 +0,0 @@ -require "rspec" - -=begin -example) -[1, 2, 3].should array_instance_of Fixnum -=end - -RSpec::Matchers.define :array_instance_of do |element_class| - match do |array| - array.class == Array && array.all? {|element| element.class == element_class} - end -end From 75955780a90d2112792e3e91ce09850b96d81cac Mon Sep 17 00:00:00 2001 From: sue445 Date: Fri, 22 Aug 2014 19:18:48 +0900 Subject: [PATCH 2/2] Fix: houndci --- spec/core_spec.rb | 4 ++-- spec/girl_spec.rb | 4 ++-- spec/rubicure_spec.rb | 4 ++-- spec/series_spec.rb | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/core_spec.rb b/spec/core_spec.rb index b51bd11..542cffe 100644 --- a/spec/core_spec.rb +++ b/spec/core_spec.rb @@ -17,7 +17,7 @@ time_travel_to "2013-02-01" end - it { expect{ subject }.to raise_error } + it { expect { subject }.to raise_error } end end @@ -52,7 +52,7 @@ end end - it { expect{|b| instance.each_with_series(&b) }.to yield_successive_args *@expected_series } + it { expect { |b| instance.each_with_series(&b) }.to yield_successive_args *@expected_series } end describe "#all_stars" do diff --git a/spec/girl_spec.rb b/spec/girl_spec.rb index fc85561..c4e3b7e 100644 --- a/spec/girl_spec.rb +++ b/spec/girl_spec.rb @@ -11,13 +11,13 @@ let(:human_name) { "黄瀬やよい" } let(:precure_name) { "キュアピース" } let(:extra_names) { %w(プリンセスピース ウルトラピース) } - let(:transform_message) { + let(:transform_message) do <