pebbles-tokyu_ruby_kaigi 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0a0f0bdf579fe154b212ed41ef32df6634c6d823
4
+ data.tar.gz: 9709cd7ee8c3e82ddd6974aa6d6efecb43d2293b
5
+ SHA512:
6
+ metadata.gz: 921378f4d2f0259fe60de6d8318e128f4625350ab145d1836ef6ac63bc8bb7dae26135c8324b3dc3352c80691ca8f687ce7b2e14e4f02c97a61c931255655737
7
+ data.tar.gz: 62c8026c0c30775d4e1364daf7a51e483b42dcd6ffe83ce7654b28632093023c2ed87bd0ad3c135b0035d53f3da515894391dd8a33266137cde280986da5137b
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pebbles-tokyu_ruby_kaigi.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 sue445
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # Pebbles::TokyuRubyKaigi
2
+
3
+ Find target day of TokyuRubyKaigi (http://qwik.jp/tokyurb/)
4
+
5
+ ## Definition of TokyuRubyKaigi
6
+
7
+ * 29th day a.k.a Meet day (肉の日)
8
+ * Holiday (Saturday, Sunday or National holiday)
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ gem 'pebbles-tokyu_ruby_kaigi'
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install pebbles-tokyu_ruby_kaigi
23
+
24
+ ## Usage
25
+
26
+ ```sh
27
+ $ tokyu_ruby_kaigi next
28
+ 2014/03/29(Sat)
29
+
30
+ $ tokyu_ruby_kaigi take
31
+ 2014/03/29(Sat)
32
+ 2014/04/29(Tue)
33
+ 2014/06/29(Sun)
34
+ 2014/11/29(Sat)
35
+ 2015/03/29(Sun)
36
+ 2015/04/29(Wed)
37
+ 2015/08/29(Sat)
38
+ 2015/11/29(Sun)
39
+ 2016/04/29(Fri)
40
+ 2016/05/29(Sun)
41
+ ```
42
+
43
+ ## Contributing
44
+
45
+ 1. Fork it ( https://github.com/sue445/pebbles-tokyu_ruby_kaigi/fork )
46
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
47
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
48
+ 4. Push to the branch (`git push origin my-new-feature`)
49
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'pebbles/tokyu_ruby_kaigi/cli'
4
+
5
+ Pebbles::TokyuRubyKaigi::CLI.start(ARGV)
@@ -0,0 +1,22 @@
1
+ require 'pebbles/tokyu_ruby_kaigi'
2
+ require 'thor'
3
+
4
+ module Pebbles
5
+ module TokyuRubyKaigi
6
+ class CLI < Thor
7
+ desc "next", "show next target day of TokyuRubyKaigi"
8
+ def next
9
+ date = Pebbles::TokyuRubyKaigi.find
10
+ puts "#{date.strftime("%Y/%m/%d(%a)")}"
11
+ end
12
+
13
+ desc "take LIMIT", "show target days of TokyuRubyKaigi"
14
+ def take(limit=10)
15
+ dates = Pebbles::TokyuRubyKaigi.take(limit)
16
+ dates.each do |date|
17
+ puts "#{date.strftime("%Y/%m/%d(%a)")}"
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,5 @@
1
+ module Pebbles
2
+ module TokyuRubyKaigi
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,43 @@
1
+ require "pebbles/tokyu_ruby_kaigi/version"
2
+ require "active_support/core_ext"
3
+ require "google_holiday_calendar"
4
+
5
+ module Pebbles
6
+ module TokyuRubyKaigi
7
+ MEET_DAY = 29
8
+
9
+ # find next target day of TokyuRubyKaigi
10
+ # @return [Date]
11
+ def self.find
12
+ take(1).first
13
+ end
14
+
15
+ # take target days of TokyuRubyKaigi
16
+ # @param limit
17
+ # @return [Array<Date>]
18
+ def self.take(limit=10)
19
+ tokyu_ruby_kaigi_dates = []
20
+ meet_date = Date.today.day < MEET_DAY ? next_meet_date(Date.today) : next_meet_date(1.month.past)
21
+
22
+ loop do
23
+ tokyu_ruby_kaigi_dates << meet_date if meet_date.saturday? || meet_date.sunday? || holiday?(meet_date)
24
+ return tokyu_ruby_kaigi_dates if tokyu_ruby_kaigi_dates.length == limit
25
+
26
+ meet_date = next_meet_date(meet_date + 1.month)
27
+ end
28
+ end
29
+
30
+ private
31
+ def self.next_meet_date(date)
32
+ date.change(day: MEET_DAY)
33
+ rescue ArgumentError
34
+ # there is not meet day in February
35
+ date += 1.month
36
+ retry
37
+ end
38
+
39
+ def self.holiday?(date)
40
+ GoogleHolidayCalendar::Calendar.new(country: "japanese", lang: "ja").holiday?(date)
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pebbles/tokyu_ruby_kaigi/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pebbles-tokyu_ruby_kaigi"
8
+ spec.version = Pebbles::TokyuRubyKaigi::VERSION
9
+ spec.authors = ["sue445"]
10
+ spec.email = ["sue445@sue445.net"]
11
+ spec.summary = %q{Find target day of TokyuRubyKaigi}
12
+ spec.description = %q{Find target day of TokyuRubyKaigi}
13
+ spec.homepage = "https://github.com/sue445/pebbles-tokyu_ruby_kaigi"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "activesupport", "~> 4.0.0"
22
+ spec.add_dependency "google_holiday_calendar", "~> 0.0.2"
23
+ spec.add_dependency "thor"
24
+
25
+ spec.add_development_dependency "bundler", ">= 1.5"
26
+ spec.add_development_dependency "rake"
27
+ spec.add_development_dependency "rspec", "3.0.0.beta1"
28
+ spec.add_development_dependency "rspec-its"
29
+ spec.add_development_dependency "delorean"
30
+ end
@@ -0,0 +1,52 @@
1
+ describe Pebbles::TokyuRubyKaigi do
2
+ it 'should have a version number' do
3
+ expect(Pebbles::TokyuRubyKaigi::VERSION).not_to be nil
4
+ end
5
+
6
+ describe "#find" do
7
+ subject{ Pebbles::TokyuRubyKaigi.find }
8
+
9
+ context "on Saturday" do
10
+ before do
11
+ time_travel_to "2014-01-01"
12
+ end
13
+
14
+ it{ should == date("2014-03-29") }
15
+ end
16
+
17
+ context "on Sunday" do
18
+ before do
19
+ time_travel_to "2012-07-01"
20
+ end
21
+
22
+ it{ should == date("2012-07-29") }
23
+ end
24
+
25
+ context "on Holiday" do
26
+ before do
27
+ time_travel_to "2014-04-01"
28
+ end
29
+
30
+ it{ should == date("2014-04-29") }
31
+ end
32
+ end
33
+
34
+ describe "#take" do
35
+ subject{ Pebbles::TokyuRubyKaigi.take(limit) }
36
+
37
+ let(:limit){ 3 }
38
+
39
+ before do
40
+ time_travel_to "2014-03-01"
41
+ end
42
+
43
+ its(:count){ should == limit }
44
+ its([0]){ should == date("2014-03-29") }
45
+ its([1]){ should == date("2014-04-29") }
46
+ its([2]){ should == date("2014-06-29") }
47
+ end
48
+
49
+ def date(str)
50
+ Date.parse(str)
51
+ end
52
+ end
@@ -0,0 +1,18 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'pebbles/tokyu_ruby_kaigi'
3
+
4
+ require 'rspec'
5
+ require 'rspec/its'
6
+ require 'delorean'
7
+
8
+ # Requires supporting ruby files with custom matchers and macros, etc,
9
+ # in spec/support/ and its subdirectories.
10
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
11
+
12
+ RSpec.configure do |config|
13
+ config.include Delorean
14
+
15
+ config.after(:each) do
16
+ back_to_the_present
17
+ end
18
+ end
metadata ADDED
@@ -0,0 +1,173 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pebbles-tokyu_ruby_kaigi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - sue445
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 4.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: google_holiday_calendar
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '1.5'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '1.5'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 3.0.0.beta1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 3.0.0.beta1
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec-its
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: delorean
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Find target day of TokyuRubyKaigi
126
+ email:
127
+ - sue445@sue445.net
128
+ executables:
129
+ - tokyu_ruby_kaigi
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - ".gitignore"
134
+ - ".rspec"
135
+ - ".travis.yml"
136
+ - Gemfile
137
+ - LICENSE.txt
138
+ - README.md
139
+ - Rakefile
140
+ - bin/tokyu_ruby_kaigi
141
+ - lib/pebbles/tokyu_ruby_kaigi.rb
142
+ - lib/pebbles/tokyu_ruby_kaigi/cli.rb
143
+ - lib/pebbles/tokyu_ruby_kaigi/version.rb
144
+ - pebbles-tokyu_ruby_kaigi.gemspec
145
+ - spec/pebbles/tokyu_ruby_kaigi_spec.rb
146
+ - spec/spec_helper.rb
147
+ homepage: https://github.com/sue445/pebbles-tokyu_ruby_kaigi
148
+ licenses:
149
+ - MIT
150
+ metadata: {}
151
+ post_install_message:
152
+ rdoc_options: []
153
+ require_paths:
154
+ - lib
155
+ required_ruby_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ required_rubygems_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ requirements: []
166
+ rubyforge_project:
167
+ rubygems_version: 2.2.2
168
+ signing_key:
169
+ specification_version: 4
170
+ summary: Find target day of TokyuRubyKaigi
171
+ test_files:
172
+ - spec/pebbles/tokyu_ruby_kaigi_spec.rb
173
+ - spec/spec_helper.rb