gooday 0.1.1 → 0.1.2
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +44 -3
- data/lib/gooday/index.rb +7 -3
- data/lib/gooday/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03ea6be43169494d1482b5a50628e61d5ce9810ed3515e19a2fce5d9c3ae9366
|
4
|
+
data.tar.gz: 4962c2d8badfdf5cdfce4b092ffe2122f4167073954f5274cb0b8fc989c9fd75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fc8efa4a033377e08f90fee4eee20e0ff6077dc60b41fcf44e30762db6ef7328a1fc7fd2bebaa2eff21bcb1e74f5040eb2ccf18b9656d0235b27cb738237061
|
7
|
+
data.tar.gz: 85f138587b86b19a04828a2c9ba86acc167e0ddd0fb7043e216f0a8601fb3ae9720b6707aea4c7ae79245702c072091df9cc5f170a9a4a79addfe2f466ed4a4f
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -14,7 +14,48 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
14
14
|
|
15
15
|
## Usage
|
16
16
|
|
17
|
-
|
17
|
+
To use Gooday. You have to initialize it. The default language is `English (en)`. The module includes `French (fr)` and `English (en)`
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
require "gooday"
|
21
|
+
|
22
|
+
gooday = Gooday.new(Time.now)
|
23
|
+
```
|
24
|
+
|
25
|
+
### Locale
|
26
|
+
You can change the language by passing the language as an argument:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
gooday.locale("fr")
|
30
|
+
```
|
31
|
+
|
32
|
+
You can also set a locale directory, which will be used to load the language files.
|
33
|
+
(This loads a YAML file)
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
gooday.locale("fr", path: "PATH/TO/LOCALE", target: "yml")
|
37
|
+
```
|
38
|
+
|
39
|
+
### Add & Set
|
40
|
+
You can add days, months, seconds with Gooday. You can also set the date with Gooday.
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
gooday = Gooday.new(Time.now)
|
44
|
+
gooday.set(:month => "April", :day => 2, :year => 2020)
|
45
|
+
gooday.add(:days => 28)
|
46
|
+
```
|
47
|
+
This code sets the date to April, 2 2020 and adds 28 days to it.
|
48
|
+
|
49
|
+
### Date parser
|
50
|
+
With the regexes specified in locales file you can parse the dates.
|
51
|
+
The parsed dates are returned as an array.
|
52
|
+
```ruby
|
53
|
+
gooday = Gooday.new(Time.now)
|
54
|
+
gooday.locale("fr")
|
55
|
+
parsed = date.parse_string("Nous sommes le 17/02/2021. Demain nous serons le 18 Février 2021")
|
56
|
+
puts parsed[0]
|
57
|
+
```
|
58
|
+
|
18
59
|
|
19
60
|
## Development
|
20
61
|
|
@@ -24,7 +65,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
24
65
|
|
25
66
|
## Contributing
|
26
67
|
|
27
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
68
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Senchuu/Gooday. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/Senchuu/gooday/blob/main/CODE_OF_CONDUCT.md).
|
28
69
|
|
29
70
|
## License
|
30
71
|
|
@@ -32,4 +73,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
32
73
|
|
33
74
|
## Code of Conduct
|
34
75
|
|
35
|
-
Everyone interacting in the Gooday project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
76
|
+
Everyone interacting in the Gooday project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Senchuu/gooday/blob/main/CODE_OF_CONDUCT.md).
|
data/lib/gooday/index.rb
CHANGED
@@ -29,15 +29,19 @@ module Gooday
|
|
29
29
|
@zone = context.zone
|
30
30
|
end
|
31
31
|
|
32
|
-
def locale(locale, path:
|
32
|
+
def locale(locale, path: nil, target: "ruby")
|
33
33
|
if target.downcase.match?(/^(yml|yaml)/)
|
34
|
-
raise Gooday::Error, "#{locale.inspect} doesn't exist as a YAML locale format" unless File.exist?(File.expand_path("#{locale}.yml", path))
|
34
|
+
raise Gooday::Error, "#{locale.inspect} doesn't exist as a YAML locale format" unless File.exist?(File.expand_path("#{locale}.yml", File.dirname(path)))
|
35
35
|
|
36
36
|
require "gooday/yaml_parser"
|
37
37
|
@translations = YAMLParser.new(File.expand_path("#{locale}.yml", path))
|
38
38
|
.translations.transform_keys(&:to_sym)
|
39
39
|
else
|
40
|
-
|
40
|
+
if path
|
41
|
+
raise Gooday::Error, "#{locale.inspect} doesn't exist as a RUBY locale format" unless File.file?(File.expand_path("#{locale}.rb", path))
|
42
|
+
else
|
43
|
+
raise Gooday::Error, "#{locale.inspect} doesn't exist as a RUBY locale format" unless File.file?(File.expand_path("./locales/#{locale}.rb", File.dirname(__FILE__)))
|
44
|
+
end
|
41
45
|
|
42
46
|
file = if path
|
43
47
|
File.expand_path("#{locale}.rb", path)
|
data/lib/gooday/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gooday
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Senchuu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Gooday is a date manager written in ruby. It is a simple and easy to
|
14
14
|
use.
|