montrose 0.5.0 → 0.6.0

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: e2af0b4abedbea2421c73f457fcdbd66390870f1
4
- data.tar.gz: dafba1cbbd0f14757bc95ffe81764a065947e2fa
3
+ metadata.gz: c6586fb7cc1e8bfb5bf4a60b01dc27687703b613
4
+ data.tar.gz: 2de01900143bb357b8250d7213b02f18d63f7f6e
5
5
  SHA512:
6
- metadata.gz: f3c9e25c8f3e30cf8df3037e653f3c515ea25c3bf9d144da520a4e4a5e043a8a51c8b8eefe449d4c83ac0b87ab47d5a0c0e14a58e875846a1d9995a9472501c0
7
- data.tar.gz: fb805c48e5e6d9880e6c3c091ea738bf2b6f4e21a59afa78cf3c467ad062cdf12f5802f46078138fbde9e74030f6d3893a83fee5877fc527b1c66da38c609312
6
+ metadata.gz: 97c05ddc454035a90a397d3aa0b498baedee44288a0e1488c57629e62ff5516542e023deac99ec2ac26b2ac3e612836e8f15d18da08403f77ef848564ea23b37
7
+ data.tar.gz: e8e8d506f11e6dade4915e3af9c4a518102a1eb5199a499485975020334744ba67a2943db5ccaa094cff05827c2172ec912c42d23dd69bd09107cf16c23e7843
@@ -1,3 +1,10 @@
1
+ ### 0.6.0 - (2016-01-05)
2
+
3
+ * enhancements
4
+ * Alias `every` to `frequency`
5
+ * Handle JSON and hashes in Recurrence serialization
6
+ * Handle blank and nil objects in Recurrence deserialization
7
+
1
8
  ### 0.5.0 - (2016-11-23)
2
9
 
3
10
  * enhancements
data/README.md CHANGED
@@ -335,7 +335,7 @@ Montrose.every(:month, day: :friday, interval: 2)
335
335
  Montrose.r(every: :month, day: :friday, interval: 2)
336
336
 
337
337
  Montrose.monthly(day: { friday: [1] }) # 1st Friday of the month
338
- Montrose.monthly(day: { Sunday: [1, -1] }) # first and last Sunday of the month
338
+ Montrose.monthly(day: { sunday: [1, -1] }) # first and last Sunday of the month
339
339
 
340
340
  Montrose.monthly(mday: 7..13, day: :saturday) # first Saturday that follow the first Sunday of the month
341
341
 
@@ -79,7 +79,6 @@ module Montrose
79
79
  def_option :month
80
80
  def_option :interval
81
81
  def_option :total
82
- def_option :between
83
82
  def_option :at
84
83
  def_option :on
85
84
  def_option :except
@@ -147,6 +146,9 @@ module Montrose
147
146
  @every = parsed.fetch(:every)
148
147
  end
149
148
 
149
+ alias frequency every
150
+ alias frequency= every=
151
+
150
152
  def starts=(time)
151
153
  @starts = as_time(time) || self.class.default_starts
152
154
  end
@@ -224,16 +224,27 @@ module Montrose
224
224
 
225
225
  def dump(obj)
226
226
  return nil if obj.nil?
227
- unless obj.is_a?(self)
228
- fail SerializationError,
229
- "Object was supposed to be a #{self}, but was a #{obj.class}. -- #{obj.inspect}"
230
- end
227
+ return dump(load(obj)) if obj.is_a?(String)
228
+
229
+ hash = case obj
230
+ when Hash
231
+ obj
232
+ when self
233
+ obj.to_hash
234
+ else
235
+ fail SerializationError,
236
+ "Object was supposed to be a #{self}, but was a #{obj.class}. -- #{obj.inspect}"
237
+ end
231
238
 
232
- JSON.dump(obj.to_hash)
239
+ JSON.dump(hash)
233
240
  end
234
241
 
235
242
  def load(json)
243
+ return nil if json.blank?
244
+
236
245
  new JSON.parse(json)
246
+ rescue JSON::ParserError => e
247
+ fail SerializationError, "Could not parse JSON: #{e}"
237
248
  end
238
249
  end
239
250
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Montrose
3
- VERSION = "0.5.0".freeze
3
+ VERSION = "0.6.0".freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: montrose
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ross Kaffenberger
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-23 00:00:00.000000000 Z
11
+ date: 2017-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -212,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
212
212
  version: '0'
213
213
  requirements: []
214
214
  rubyforge_project:
215
- rubygems_version: 2.5.1
215
+ rubygems_version: 2.4.5.1
216
216
  signing_key:
217
217
  specification_version: 4
218
218
  summary: Recurring events in Ruby