business-period 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6098b1a6ef4926e03bce624585c037eaf04cbc67
4
- data.tar.gz: 4e3844c7a1cfae8573cb5afe08fd6aa24f3fbc39
3
+ metadata.gz: ae8d77f79fbae52d0e98e2eb490f869dc939b6a0
4
+ data.tar.gz: 77584003f1eb7564bb403e0140adb011af1fff79
5
5
  SHA512:
6
- metadata.gz: 10251873c3359a732d0bf338a61ce91ab254ab0bd3c71985b849f1b9e97ce57b6adee8257cf850951065a7f24ea8957ca2a493d2215599d97b2d60fb68b5639c
7
- data.tar.gz: 61c2faa61df87564ea89311937158cb7515f70f73a31d05d2138314946369996bc3727fd8d5cc0b4465bd6e3073763dc500631bc9de3cc52ab49988a0d50500b
6
+ metadata.gz: f42cb7a31c9c18bb6797609d8c8b3d49c3cbe484e8bf2758ec580812d09f2ce3353ad14e057ab530437fdef9915883f3b5c89f01f8f1448496313f4fc4708c4a
7
+ data.tar.gz: b78380a4f745c7ecf8353d59db0beca3bbf8c3660f569cb2f44a1588a86b6309534bf1edfe9d1171c31490bcb6d5ee79646c7c648581040ed5d8b19002d694f3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- business-period (0.1.3)
4
+ business-period (0.1.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -26,13 +26,13 @@ Or install it yourself as:
26
26
 
27
27
  There are two ways to initialize:
28
28
 
29
- ##### Default initialization:
29
+ ##### Initialization:
30
30
 
31
31
  ```ruby
32
32
  # config/initializers/business_period.rb
33
33
 
34
- # set locale to get config file from config/holidays path
35
- # set work_days to define which days of week are work days
34
+ # Set locale to get config file from config/holidays path.
35
+ # Set work_days to define which days of week are work days.
36
36
 
37
37
  locale = 'lt'
38
38
  work_days = [1, 2, 3, 4, 5]
@@ -53,50 +53,51 @@ BusinessPeriod::Config.work_days = -> { work_days }
53
53
 
54
54
  ## How it works
55
55
 
56
- 1. Dynamically calculates how many days we have to add to period end (Saturdays/Sundays/Holidays)
57
- 2. Generates new array
58
- 2. Extracts weekends and holidays from newly generated array
59
- 3. Generates result array
56
+ 1. Dynamically calculates how many days we have to add to period end (Saturdays/Sundays/Holidays).
57
+ 2. Generates new array.
58
+ 2. Extracts weekends and holidays from newly generated array.
59
+ 3. Generates result array.
60
60
 
61
61
  ## Usage
62
62
 
63
63
  ```ruby
64
- # set period hash
65
- period = { from_date: 2, to_date: 4 }
64
+ from = 2
65
+ to = 4
66
66
 
67
- # call BusinessPeriod::Days class to calculate period
68
- BusinessPeriod::Days.call(period)
67
+ # You can pass optional parameters if You want to set primary day as starting point.
68
+ # options = { primary_day: Time.now - (3600 * 24) }
69
+
70
+ # Call BusinessPeriod::Days class to calculate period
71
+ BusinessPeriod::Days.call(from, to, options)
69
72
  ```
70
73
 
71
74
  ## Examples
72
- Let's say we have no holidays this month and today is Wednesday
75
+ Let's say we have no holidays this month and today is Wednesday.
73
76
 
74
- let `work_days = [1, 2, 3, 4, 5]` (all days except weekends)
77
+ `work_days = [1, 2, 3, 4, 5]` (all days except weekends)
75
78
 
76
- let `period = { from_date: 2, to_date: 4 }`
79
+ `from = 2`
80
+ `to = 4`
77
81
 
78
- * Begins to count period from the coming day
79
- * Tomorrow (Thursday) is the first valid day
80
- * The second valid day will be Fridary (first business day)
81
- * Fourth business day will be Tuesday (Saturday and Sunday are not in scope)
82
+ * Begins to count period from the coming day.
83
+ * Tomorrow (Thursday) is the first valid day.
84
+ * The second valid day will be Fridary (first business day).
85
+ * Fourth business day will be Tuesday (Saturday and Sunday are not in scope).
82
86
 
83
87
  ```console
84
88
  irb(main):001:0> Time.current
85
89
  => Wed, 12 Sep 2018 05:49:10 UTC +00:00
86
- irb(main):002:0> period = { from_date: 2, to_date: 4 }
87
- => {:from_date=>2, :to_date=>4}
88
- irb(main):003:0> BusinessPeriod::Days.call(period)
90
+ irb(main):002:0> from = 2
91
+ => 2
92
+ irb(main):003:0> to = 4
93
+ => 4
94
+ irb(main):004:0> BusinessPeriod::Days.call(from, to)
89
95
  => {:from_date=>Fri, 14 Sep 2018, :to_date=>Tue, 18 Sep 2018]
90
96
  ```
91
97
 
92
- ## Todo
93
- - [ ] improve specs
94
- - [ ] Add latvian config
95
- - [ ] Add estonian config
96
-
97
98
  ## Development
98
99
 
99
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
100
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
100
101
 
101
102
  ## License
102
103
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module BusinessPeriod
4
4
  class Days < Base
5
- def self.call(from_date:, to_date:, options: {})
5
+ def self.call(from_date = nil, to_date = nil, options = {})
6
6
  new.perform(from_date, to_date, options)
7
7
  end
8
8
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BusinessPeriod
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: business-period
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - matas