mongoid_ice_cube_extension 0.1.2 → 0.2.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: e7a9e72a6bcc80740b498b0f5691ba55204834c6
4
- data.tar.gz: 389d68370cc724c0edb6eff0f4a0b822f154d84f
3
+ metadata.gz: bbd882873aa9c869600d59daf9a44186396c079b
4
+ data.tar.gz: e73132e64bcbe2a3976fab606880c73b10a792f6
5
5
  SHA512:
6
- metadata.gz: 1f080010842b625d3b9095a2ee10dd7d5d103ae504129fdc0c3fabb0e1f95dbe6cc20ce46f6573ecac69be84a75be08c147300170ea361e493a3dd85f9449460
7
- data.tar.gz: 1edfc4da224648cf4c399ca9fc70c1bdd8e622a2e9f43c6f1fbf98ce5dd30fa7b74a6f4c18de60f46ce62f50f2017370cb06b96f35bbf03ba052a3ba0a88e133
6
+ metadata.gz: 5d405c390165b2e7f0fe9dd40366995205fa4670b0545d2dd13911b4733d0d58115476b0fff95aeb792f0562f53a6b72107ecdfd2e0196d590f4018d5c250f32
7
+ data.tar.gz: a9114cbadf31b6949ba11caff89b1a506099da39bfc4cdb108c8525f9f1791c0885e95fcb283fe5dde99b1f70a4ed0f76e5245e771598d1fa1c034e92dfbdf8a
data/.travis.yml CHANGED
@@ -2,7 +2,7 @@ language: ruby
2
2
  cache: bundler
3
3
  script: 'bundle exec rake'
4
4
  rvm:
5
- - 2.1.2
5
+ - 2.2.4
6
6
 
7
7
  notifications:
8
8
  email:
data/README.md CHANGED
@@ -28,6 +28,17 @@ Add to Mongoid models as:
28
28
  field :schedule, type: MongoidIceCubeExtension::Schedule
29
29
  ```
30
30
 
31
+ and
32
+
33
+ ```ruby
34
+ field :schedule, type: MongoidIceCubeExtension::Rule
35
+ ```
36
+
37
+ ## See also
38
+
39
+ * [MongoidRecurring](https://github.com/tomasc/mongoid_recurring) for recurring DateTime fields for Mongoid models.
40
+ * [SimpleFormRecurringSelect](https://github.com/tomasc/simple_form_recurring_select) for adding `IceCube` rules via `SimpleForm` input fields
41
+
31
42
  ## Development
32
43
 
33
44
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,2 +1,3 @@
1
- require "mongoid_ice_cube_extension/schedule"
2
- require "mongoid_ice_cube_extension/version"
1
+ require 'mongoid_ice_cube_extension/rule'
2
+ require 'mongoid_ice_cube_extension/schedule'
3
+ require 'mongoid_ice_cube_extension/version'
@@ -0,0 +1,30 @@
1
+ require 'ice_cube'
2
+
3
+ module MongoidIceCubeExtension
4
+ class Rule
5
+ class << self
6
+ def demongoize(value)
7
+ case value
8
+ when Hash then IceCube::Rule.from_hash(value)
9
+ else value
10
+ end
11
+ end
12
+
13
+ def mongoize(value)
14
+ case value
15
+ when 'null' then nil
16
+ when IceCube::Rule then value.to_hash
17
+ when String then IceCube::Rule.from_hash(JSON.parse(value)).to_hash
18
+ else value
19
+ end
20
+ end
21
+
22
+ def evolve(value)
23
+ case value
24
+ when IceCube::Rule then value.to_hash
25
+ else value
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -2,27 +2,25 @@ require 'ice_cube'
2
2
 
3
3
  module MongoidIceCubeExtension
4
4
  class Schedule
5
-
6
5
  class << self
7
- def demongoize value
6
+ def demongoize(value)
8
7
  return unless value
9
8
  IceCube::Schedule.from_hash(value)
10
9
  end
11
10
 
12
- def mongoize value
11
+ def mongoize(value)
13
12
  case value
14
13
  when IceCube::Schedule then value.to_hash
15
14
  else value
16
15
  end
17
16
  end
18
17
 
19
- def evolve value
18
+ def evolve(value)
20
19
  case value
21
20
  when IceCube::Schedule then value.to_hash
22
21
  else value
23
22
  end
24
23
  end
25
24
  end
26
-
27
25
  end
28
26
  end
@@ -1,3 +1,3 @@
1
1
  module MongoidIceCubeExtension
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_ice_cube_extension
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Celizna
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-23 00:00:00.000000000 Z
11
+ date: 2016-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
@@ -145,6 +145,7 @@ files:
145
145
  - bin/console
146
146
  - bin/setup
147
147
  - lib/mongoid_ice_cube_extension.rb
148
+ - lib/mongoid_ice_cube_extension/rule.rb
148
149
  - lib/mongoid_ice_cube_extension/schedule.rb
149
150
  - lib/mongoid_ice_cube_extension/version.rb
150
151
  - mongoid_ice_cube_extension.gemspec