smart-period 1.0.5 → 1.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +16 -11
- data/{locales → config/locales}/en.yml +0 -0
- data/{locales → config/locales}/fr.yml +0 -0
- data/lib/period.rb +4 -1
- data/lib/period/free_period.rb +0 -3
- data/lib/period/version.rb +1 -1
- data/period.gemspec +18 -4
- metadata +15 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c500abb487503fbb580ad3b346853e287b113d5bbc16dc899fabe85e6dba81a
|
4
|
+
data.tar.gz: d5a17838abad1725ae67669b923f1da6d7b5e40cd2140bb4ad0a27f1295895f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c497e495c3011c9ed626b23324c78e24b2b838f9745d918bd2c059272e367cc75add9fd4063c59ff55dfe5cba101b3afd3306fff722b874daa262e0d3e2b67c
|
7
|
+
data.tar.gz: 83214aeeb0dc8f65341567e7ecf4a02534387c1c4118d8d49bdf5d8aa92f7d8f2bdfb632f4b4dfb6ab9148dd058b8b7077ace8f7822b77f1ecd2ac805d119a2a
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
-
# Smart-Period
|
1
|
+
# Smart-Period [![Gem Version](https://badge.fury.io/rb/smart-period.svg)](https://badge.fury.io/rb/smart-period) [![Code Climate](https://codeclimate.com/github/billaul/period.svg)](https://codeclimate.com/github/billaul/period) [![Inline docs](http://inch-ci.org/github/billaul/period.svg)](http://inch-ci.org/github/billaul/period)
|
2
2
|
|
3
|
-
|
3
|
+
⚠️ This gem will no longer receive any updates
|
4
|
+
⚠️ If you want to access to new awesome features, like endless-period support :hushed:
|
5
|
+
⚠️ Take a look to his successor [ActivePeriod](https://github.com/billaul/active_period) 🥳
|
6
|
+
|
7
|
+
Smart-Period aims to simplify Time-range manipulation.
|
4
8
|
|
5
9
|
## Installation
|
6
10
|
|
@@ -16,11 +20,11 @@ And then execute:
|
|
16
20
|
|
17
21
|
Or install it yourself as:
|
18
22
|
|
19
|
-
$ gem install period
|
23
|
+
$ gem install smart-period
|
20
24
|
|
21
25
|
## Usage
|
22
26
|
|
23
|
-
**Smart-Period** was designed to simplify time-range manipulation, specialy with rails
|
27
|
+
**Smart-Period** was designed to simplify time-range manipulation, specialy with rails and user input
|
24
28
|
|
25
29
|
**Warning** :
|
26
30
|
- A time-range take place between two date and it's different from an abstract duration of time
|
@@ -29,14 +33,20 @@ Or install it yourself as:
|
|
29
33
|
|
30
34
|
## Quick view (TL;DR)
|
31
35
|
``` ruby
|
36
|
+
require 'period'
|
37
|
+
|
32
38
|
# Get all user created today
|
33
39
|
User.where(created_at: Period.today)
|
40
|
+
|
34
41
|
# Get how many weeks there is from the beginning of time ?
|
35
42
|
Period.new('01/01/1970'..Time.now).weeks.count
|
43
|
+
|
36
44
|
# Is Trump still in charge ?
|
37
45
|
Time.now.in? Period.new('20/01/2017'...'20/01/2021')
|
46
|
+
|
38
47
|
# Get the week of an arbitrary date
|
39
48
|
Period.week('24/04/1990')
|
49
|
+
|
40
50
|
# Write a date for me (I18n supported)
|
41
51
|
Period.new('20/01/2017'...'20/01/2021').to_s
|
42
52
|
=> "From the 20 January 2017 to the 19 January 2021 included"
|
@@ -179,7 +189,7 @@ In a Controller, use the error handling to validate the date for you
|
|
179
189
|
```ruby
|
180
190
|
class BookController < ApplicationController
|
181
191
|
def between # match via GET and POST
|
182
|
-
# Default value for
|
192
|
+
# Default value for first display
|
183
193
|
params[:from] ||= 1.month.ago
|
184
194
|
params[:to] ||= Time.now
|
185
195
|
|
@@ -188,7 +198,7 @@ class BookController < ApplicationController
|
|
188
198
|
@books = Book.where(published: Period.new(params[:from]..params[:to]))
|
189
199
|
rescue ArgumentError => e
|
190
200
|
# Period will handle mis-formatted date and incoherent period
|
191
|
-
# I18n is
|
201
|
+
# I18n is supported for errors messages
|
192
202
|
flash[:alert] = e.message
|
193
203
|
end
|
194
204
|
end
|
@@ -255,11 +265,6 @@ No issues will be addressed outside GitHub
|
|
255
265
|
|
256
266
|
* Myself (https://github.com/billaul)
|
257
267
|
|
258
|
-
[![Gem Version](https://fury-badge.herokuapp.com/rb/smart-period.png)](http://badge.fury.io/rb/smart-period)
|
259
|
-
[![Code Climate](https://codeclimate.com/github/billaul/period.png)](https://codeclimate.com/github/billaul/period)
|
260
|
-
[![Inline docs](http://inch-ci.org/github/billaul/period.png)](http://inch-ci.org/github/billaul/period)
|
261
|
-
|
262
|
-
|
263
268
|
## License
|
264
269
|
|
265
270
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
File without changes
|
File without changes
|
data/lib/period.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
require_relative 'period/version.rb'
|
2
2
|
require 'active_support/all'
|
3
3
|
require 'i18n'
|
4
|
-
require_relative 'numeric.rb'
|
5
4
|
|
5
|
+
I18n.load_path << File.expand_path("../config/locales/en.yml", __dir__)
|
6
|
+
I18n.load_path << File.expand_path("../config/locales/fr.yml", __dir__)
|
7
|
+
|
8
|
+
require_relative 'numeric.rb'
|
6
9
|
require_relative 'period/free_period.rb'
|
7
10
|
require_relative 'period/day.rb'
|
8
11
|
require_relative 'period/week.rb'
|
data/lib/period/free_period.rb
CHANGED
data/lib/period/version.rb
CHANGED
data/period.gemspec
CHANGED
@@ -6,13 +6,27 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.name = 'smart-period'
|
7
7
|
spec.version = Period::VERSION
|
8
8
|
spec.authors = ['billau_l']
|
9
|
-
spec.email = ['billau_l@modulotech.fr']
|
10
9
|
|
11
|
-
spec.summary =
|
10
|
+
spec.summary = <<~eos
|
11
|
+
Manage time ranges without brain damage
|
12
|
+
|
13
|
+
DISCONTINUED DEVELOPMENT WARNING
|
14
|
+
The SmartPeriod gem will no longer receive any updates
|
15
|
+
If you want to access to new awesome features, like endless-period
|
16
|
+
Take a look to his successor ActivePeriod
|
17
|
+
eos
|
12
18
|
# spec.description = "Period.new('01/01/2020'..Time.now)"
|
13
19
|
spec.homepage = "https://github.com/billaul/period"
|
14
20
|
spec.license = 'MIT'
|
15
21
|
|
22
|
+
spec.post_install_message = <<~eos
|
23
|
+
+-| DISCONTINUED DEVELOPMENT WARNING |--------------------------------+
|
24
|
+
| The SmartPeriod gem will no longer receive any updates |
|
25
|
+
| If you want to access to new awesome features, like endless-period |
|
26
|
+
| Take a look to his successor ActivePeriod |
|
27
|
+
+---------------------------------------------------------------------+
|
28
|
+
eos
|
29
|
+
|
16
30
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
31
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
32
|
if spec.respond_to?(:metadata)
|
@@ -35,9 +49,9 @@ Gem::Specification.new do |spec|
|
|
35
49
|
end
|
36
50
|
spec.bindir = 'exe'
|
37
51
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
38
|
-
spec.require_paths = %w[lib
|
52
|
+
spec.require_paths = %w[lib config]
|
39
53
|
|
40
|
-
spec.required_ruby_version = '
|
54
|
+
spec.required_ruby_version = '>= 2.5'
|
41
55
|
spec.add_runtime_dependency 'activesupport', '>= 5', '< 7'
|
42
56
|
spec.add_runtime_dependency 'i18n', '~> 1'
|
43
57
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart-period
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- billau_l
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -74,7 +74,6 @@ dependencies:
|
|
74
74
|
version: '10.0'
|
75
75
|
description:
|
76
76
|
email:
|
77
|
-
- billau_l@modulotech.fr
|
78
77
|
executables: []
|
79
78
|
extensions: []
|
80
79
|
extra_rdoc_files: []
|
@@ -87,6 +86,8 @@ files:
|
|
87
86
|
- Rakefile
|
88
87
|
- bin/console
|
89
88
|
- bin/setup
|
89
|
+
- config/locales/en.yml
|
90
|
+
- config/locales/fr.yml
|
90
91
|
- lib/.DS_Store
|
91
92
|
- lib/numeric.rb
|
92
93
|
- lib/period.rb
|
@@ -109,8 +110,6 @@ files:
|
|
109
110
|
- lib/period/version.rb
|
110
111
|
- lib/period/week.rb
|
111
112
|
- lib/period/year.rb
|
112
|
-
- locales/en.yml
|
113
|
-
- locales/fr.yml
|
114
113
|
- period.gemspec
|
115
114
|
homepage: https://github.com/billaul/period
|
116
115
|
licenses:
|
@@ -120,14 +119,19 @@ metadata:
|
|
120
119
|
homepage_uri: https://github.com/billaul/period
|
121
120
|
documentation_uri: https://github.com/billaul/period
|
122
121
|
source_code_uri: https://github.com/billaul/period
|
123
|
-
post_install_message:
|
122
|
+
post_install_message: |
|
123
|
+
+-| DISCONTINUED DEVELOPMENT WARNING |--------------------------------+
|
124
|
+
| The SmartPeriod gem will no longer receive any updates |
|
125
|
+
| If you want to access to new awesome features, like endless-period |
|
126
|
+
| Take a look to his successor ActivePeriod |
|
127
|
+
+---------------------------------------------------------------------+
|
124
128
|
rdoc_options: []
|
125
129
|
require_paths:
|
126
130
|
- lib
|
127
|
-
-
|
131
|
+
- config
|
128
132
|
required_ruby_version: !ruby/object:Gem::Requirement
|
129
133
|
requirements:
|
130
|
-
- - "
|
134
|
+
- - ">="
|
131
135
|
- !ruby/object:Gem::Version
|
132
136
|
version: '2.5'
|
133
137
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -139,5 +143,7 @@ requirements: []
|
|
139
143
|
rubygems_version: 3.1.2
|
140
144
|
signing_key:
|
141
145
|
specification_version: 4
|
142
|
-
summary: Manage time ranges without brain damage
|
146
|
+
summary: Manage time ranges without brain damage DISCONTINUED DEVELOPMENT WARNING
|
147
|
+
The SmartPeriod gem will no longer receive any updates If you want to access to
|
148
|
+
new awesome features, like endless-period Take a look to his successor ActivePeriod
|
143
149
|
test_files: []
|