dater 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dater (0.2.5)
4
+ dater (0.2.6)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ <a href="https://codeclimate.com/repos/522a36ddf3ea0037550215e4/feed"><img src="https://codeclimate.com/repos/522a36ddf3ea0037550215e4/badges/776a40c87545905e8195/gpa.png" /></a>
2
+
1
3
  Dater
2
4
  =====
3
5
 
@@ -48,7 +50,11 @@ Or install it yourself as:
48
50
 
49
51
  date.for("yesterday") # => yyyy-mm-dd (date of yesterday)
50
52
 
51
- If the argument is nil, it will return the date of today.
53
+ If the argument is nil, it will return nil. But you can initialize Dater object with 'today_for_nil' flag like:
54
+
55
+ date = Dater::Resolver.new("%Y-%m-%d", true)
56
+
57
+ date.for #=> yyyy-mm-dd (date of today)
52
58
 
53
59
  You'll find format directives at following link:
54
60
 
@@ -60,7 +66,7 @@ It does not work correctly with leap-years and calculates months of 30 days only
60
66
 
61
67
  Si deseas usar esta gema en español puedes inicializar la clase de la siguiente manera:
62
68
 
63
- date=Dater::Resolver.new('%Y-%m-%d', "es")
69
+ date=Dater::Resolver.new('%Y-%m-%d', false "es")
64
70
 
65
71
  Con eso puedes pasar argumentos en idioma español (por ejemplo 'en 2 días', 'en 10 meses', 'en 1 año')
66
72
 
data/lib/dater/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dater
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
data/lib/dater.rb CHANGED
@@ -9,10 +9,10 @@ module Dater
9
9
  attr_accessor :format, :lang
10
10
 
11
11
  DICTIONARY = {
12
- day: { "en"=>/days/, "es" => /(dias|días)/,"pt" => /dias/, :mult => 86400},
13
- week: { "en"=>/weeks/, "es" => /semanas/, "pt" => /semanas/, :mult => 604800},
14
- month: { "en"=>/months/, "es" => /meses/, "pt" => /meses/, :mult => 2592000},
15
- year: { "en"=>/years/, "es" => /años/, "pt" => /anos/, :mult => 31536000},
12
+ day: { "en"=>/day/, "es" => /(dia|día)/, "pt" => /dia/, :mult => 86400},
13
+ week: { "en"=>/week/, "es" => /semana/, "pt" => /semana/, :mult => 604800},
14
+ month: { "en"=>/month/, "es" => /mes/, "pt" => /mes/, :mult => 2592000},
15
+ year: { "en"=>/year/, "es" => /año/, "pt" => /ano/, :mult => 31536000},
16
16
  today: { "en"=>'today', "es" => 'hoy', "pt" => 'hoje' },
17
17
  tomorrow: { "en"=>'tomorrow', "es" => 'mañana', "pt" => 'manhã' },
18
18
  yesterday:{ "en"=>'yesterday',"es" => 'ayer', "pt" => 'ontem' }
@@ -21,8 +21,9 @@ module Dater
21
21
  # Creates a Dater::Resolver object
22
22
  #
23
23
  # @param [String] format = date format
24
+ # @param [Boolean] today_for_nil = Indicates if must return today'd date if argument in for method is nil
24
25
  # @param [String] lang = languaje for matching (en=english, es=spanish, pt=portuguese)
25
- def initialize(format='%Y-%m-%d', lang="en", today_for_nil=false)
26
+ def initialize(format='%Y-%m-%d', today_for_nil=false, lang="en")
26
27
  @today_for_nil=today_for_nil
27
28
  @format=format
28
29
  @lang=lang if ["en","es","pt"].include? lang
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dater
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-11 00:00:00.000000000 Z
12
+ date: 2013-09-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler