increments-schedule 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5f8c7e08e959a65e96f91cf844392f298115ae54
4
- data.tar.gz: 5567438f235e1dcd0b4525ce6e06eda09452fb37
3
+ metadata.gz: 3fe27edbd3d6bb9e8321a6ae62acb19e31fc75d2
4
+ data.tar.gz: d4ac0b3633b9f485d2af3246e5d558d3f8639871
5
5
  SHA512:
6
- metadata.gz: e9643fdafe1b0e436d44ecf254d500d5f1c7d67e238478ebd78aba0bdf2553149764fd92e9579c458122567744895951e50cff399e2bad0cd2e55464f03d4431
7
- data.tar.gz: fcd6bd3d6142069498e9d66b200bbc8d4f3de9b61893d4149621362dfa810388dbf1365fec13fb7edb276fa556c5d9a89330b0a908f4f04001b827b34098b2f0
6
+ metadata.gz: 8bc42c8b190cacd4a9829e71a494aeea0aa7264a8ddb75e6a4db7cd1de5c488879551bc1485611c2b813cd5ab617b27e7b6ec4541eeba08ae73497ea3a6fac5a
7
+ data.tar.gz: 803f794edd1d5fddcc116dba974b601772215e3342678b2f68505380a7d5cea812464789a85f62687bffb1d29775146bef7c637effb1e71a2809becaec4b5f8b
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,16 @@
1
+ Metrics/LineLength:
2
+ Max: 100
3
+
4
+ Style/Documentation:
5
+ Enabled: false
6
+
7
+ Style/EmptyElse:
8
+ Enabled: false
9
+
10
+ Style/GuardClause:
11
+ Enabled: false
12
+
13
+ Style/RegexpLiteral:
14
+ Exclude:
15
+ - '*.gemspec'
16
+ - 'Guardfile'
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm: 2.2
3
+ script: bundle exec rake ci
4
+ sudo: false
5
+ cache: bundler
data/Gemfile CHANGED
@@ -1,4 +1,14 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in increments-schedule.gemspec
4
3
  gemspec
4
+
5
+ group :development, :test do
6
+ gem 'rake', '~> 10.0'
7
+ gem 'rspec', '~> 3.2'
8
+ gem 'rubocop', '~> 0.30'
9
+ gem 'timecop', '~> 0.7'
10
+ end
11
+
12
+ group :development do
13
+ gem 'pry', '~> 0.10'
14
+ end
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
- # Increments::Schedule
1
+ [![Gem Version](http://img.shields.io/gem/v/increments-schedule.svg?style=flat)](http://badge.fury.io/rb/increments-schedule)
2
+ [![Dependency Status](http://img.shields.io/gemnasium/increments/increments-schedule.svg?style=flat)](https://gemnasium.com/increments/increments-schedule)
3
+ [![Build Status](https://travis-ci.org/increments/increments-schedule.svg?branch=master&style=flat)](https://travis-ci.org/increments/increments-schedule)
2
4
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/increments/schedule`. To experiment with that code, run `bin/console` for an interactive prompt.
5
+ # Increments::Schedule
4
6
 
5
- TODO: Delete this and the text above, and describe your gem
7
+ Find out our special remote days and eagerly wait them!
6
8
 
7
9
  ## Installation
8
10
 
@@ -22,7 +24,9 @@ Or install it yourself as:
22
24
 
23
25
  ## Usage
24
26
 
25
- TODO: Write usage instructions here
27
+ * `Increments::Schedule.each_remote_work_day`
28
+ * `Increments::Schedule.each_normal_remote_work_day`
29
+ * `Increments::Schedule.each_special_remote_work_day`
26
30
 
27
31
  ## Development
28
32
 
data/Rakefile CHANGED
@@ -1,2 +1,11 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
2
4
 
5
+ RSpec::Core::RakeTask.new do |task|
6
+ task.verbose = false
7
+ end
8
+
9
+ RuboCop::RakeTask.new
10
+
11
+ task ci: [:spec, :rubocop]
data/bin/console CHANGED
@@ -1,14 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "increments/schedule"
3
+ require 'bundler/setup'
4
+ require 'increments/schedule'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
8
8
 
9
9
  # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
10
+ require 'pry'
11
+ Pry.start
data/bin/setup CHANGED
File without changes
@@ -4,24 +4,22 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'increments/schedule/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "increments-schedule"
7
+ spec.name = 'increments-schedule'
8
8
  spec.version = Increments::Schedule::VERSION
9
- spec.authors = ["Yuji Nakayama"]
10
- spec.email = ["nkymyj@gmail.com"]
9
+ spec.authors = ['Yuji Nakayama']
10
+ spec.email = ['nkymyj@gmail.com']
11
11
 
12
12
  spec.summary = "Increments' schedule"
13
13
  spec.description = spec.summary
14
14
  spec.homepage = 'https://github.com/increments/increments-schedule'
15
- spec.license = "MIT"
15
+ spec.license = 'MIT'
16
16
 
17
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = "exe"
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = 'exe'
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ["lib"]
20
+ spec.require_paths = ['lib']
21
21
 
22
- spec.add_runtime_dependency 'activesupport'
23
- spec.add_runtime_dependency 'holiday_japan'
22
+ spec.add_runtime_dependency 'holiday_japan', '~> 1.1'
24
23
 
25
- spec.add_development_dependency "bundler", "~> 1.8"
26
- spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency 'bundler', '~> 1.3'
27
25
  end
@@ -1,23 +1,22 @@
1
- require "increments/schedule/version"
2
- require 'active_support/all'
1
+ require 'increments/schedule/version'
3
2
  require 'holiday_japan'
4
3
 
5
4
  module Increments
6
5
  module Schedule
7
- module_function
6
+ extend self # rubocop:disable ModuleFunction
8
7
 
9
8
  [
10
- [:each_remote_work_day, proc { |date| remote_work_day?(date) }],
11
- [:each_normal_remote_work_day, proc { |date| normal_remote_work_day?(date) }],
12
- [:each_special_remote_work_day, proc { |date| special_remote_work_day?(date) }]
13
- ].each do |method_name, conditional|
14
- define_method(method_name) do |max_date = nil, &block|
9
+ [:each_remote_work_day, :remote_work_day?],
10
+ [:each_normal_remote_work_day, :normal_remote_work_day?],
11
+ [:each_special_remote_work_day, :special_remote_work_day?]
12
+ ].each do |enumeration_method, predicate_method|
13
+ define_method(enumeration_method) do |max_date = nil, &block|
15
14
  return to_enum(__method__, max_date) unless block
16
15
 
17
- max_date ||= Date.today + 1.year
16
+ max_date ||= Date.today + 365
18
17
 
19
18
  Date.today.upto(max_date) do |date|
20
- block.call(date) if conditional.call(date)
19
+ block.call(date) if send(predicate_method, date)
21
20
  end
22
21
  end
23
22
  end
@@ -27,16 +26,16 @@ module Increments
27
26
  end
28
27
 
29
28
  def normal_remote_work_day?(date)
30
- date.monday?
29
+ date.monday? && !rest_day?(date)
31
30
  end
32
31
 
33
32
  def special_remote_work_day?(date)
34
- office_work_day?(date) &&
35
- !office_work_day?(date.yesterday) && !office_work_day?(date.tomorrow)
33
+ normal_office_work_day?(date) &&
34
+ !normal_office_work_day?(date - 1) && !normal_office_work_day?(date + 1)
36
35
  end
37
36
 
38
37
  def office_work_day?(date)
39
- !rest_day?(date) && !normal_remote_work_day?(date)
38
+ normal_office_work_day?(date) && !remote_work_day?(date)
40
39
  end
41
40
 
42
41
  def rest_day?(date)
@@ -50,5 +49,11 @@ module Increments
50
49
  def holiday?(date)
51
50
  HolidayJapan.check(date)
52
51
  end
52
+
53
+ private
54
+
55
+ def normal_office_work_day?(date)
56
+ !rest_day?(date) && !normal_remote_work_day?(date)
57
+ end
53
58
  end
54
59
  end
@@ -1,5 +1,5 @@
1
1
  module Increments
2
2
  module Schedule
3
- VERSION = "0.1.1"
3
+ VERSION = '0.1.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,71 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: increments-schedule
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuji Nakayama
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-10 00:00:00.000000000 Z
11
+ date: 2015-04-11 00:00:00.000000000 Z
12
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: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: holiday_japan
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: bundler
43
15
  requirement: !ruby/object:Gem::Requirement
44
16
  requirements:
45
17
  - - "~>"
46
18
  - !ruby/object:Gem::Version
47
- version: '1.8'
48
- type: :development
19
+ version: '1.1'
20
+ type: :runtime
49
21
  prerelease: false
50
22
  version_requirements: !ruby/object:Gem::Requirement
51
23
  requirements:
52
24
  - - "~>"
53
25
  - !ruby/object:Gem::Version
54
- version: '1.8'
26
+ version: '1.1'
55
27
  - !ruby/object:Gem::Dependency
56
- name: rake
28
+ name: bundler
57
29
  requirement: !ruby/object:Gem::Requirement
58
30
  requirements:
59
31
  - - "~>"
60
32
  - !ruby/object:Gem::Version
61
- version: '10.0'
33
+ version: '1.3'
62
34
  type: :development
63
35
  prerelease: false
64
36
  version_requirements: !ruby/object:Gem::Requirement
65
37
  requirements:
66
38
  - - "~>"
67
39
  - !ruby/object:Gem::Version
68
- version: '10.0'
40
+ version: '1.3'
69
41
  description: Increments' schedule
70
42
  email:
71
43
  - nkymyj@gmail.com
@@ -74,6 +46,9 @@ extensions: []
74
46
  extra_rdoc_files: []
75
47
  files:
76
48
  - ".gitignore"
49
+ - ".rspec"
50
+ - ".rubocop.yml"
51
+ - ".travis.yml"
77
52
  - Gemfile
78
53
  - LICENSE.txt
79
54
  - README.md