rubiks 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,13 +15,13 @@ module Rubiks
15
15
  if id = cache.read(cache_key)
16
16
  klass.find_by_id(id)
17
17
 
18
- elsif existing_member = klass.where(:natural_key => natural_key).first
18
+ elsif existing_member = klass.where(natural_key_field => natural_key).first
19
19
  cache.write(cache_key, existing_member.id)
20
20
  existing_member
21
21
 
22
22
  else
23
23
  new_member = klass.new
24
- new_member.natural_key = natural_key
24
+ new_member[natural_key_field] = natural_key
25
25
 
26
26
  new_member.save!
27
27
  cache.write(cache_key, new_member.id)
@@ -40,13 +40,13 @@ module Rubiks
40
40
  if id = cache.read(cache_key)
41
41
  id
42
42
 
43
- elsif existing_member = klass.where(:natural_key => natural_key).first
43
+ elsif existing_member = klass.where(natural_key_field => natural_key).first
44
44
  cache.write(cache_key, existing_member.id)
45
45
  existing_member.id
46
46
 
47
47
  else
48
48
  new_member = klass.new
49
- new_member.natural_key = natural_key
49
+ new_member[natural_key_field] = natural_key
50
50
 
51
51
  new_member.save!
52
52
  cache.write(cache_key, new_member.id)
@@ -70,6 +70,26 @@ module Rubiks
70
70
  -1
71
71
  end
72
72
 
73
+ def lookup_time(input)
74
+ date = if input == :now
75
+ Time.now
76
+ elsif input.kind_of? Integer
77
+ Time.at(input)
78
+ else
79
+ Date.parse(input)
80
+ end
81
+
82
+ # 1 HH MM SS 000
83
+ # 11:59 PM = 1235959000
84
+ date.strftime('1%H%M%S000').to_i
85
+ rescue
86
+ -1
87
+ end
88
+
89
+ def natural_key_field
90
+ :natural_key
91
+ end
92
+
73
93
  private
74
94
 
75
95
  def cache
@@ -1,3 +1,3 @@
1
1
  module Rubiks
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubiks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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: 2012-11-15 00:00:00.000000000 Z
12
+ date: 2012-11-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: arel
@@ -213,12 +213,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
213
213
  - - ! '>='
214
214
  - !ruby/object:Gem::Version
215
215
  version: '0'
216
+ segments:
217
+ - 0
218
+ hash: -2306503118888220795
216
219
  required_rubygems_version: !ruby/object:Gem::Requirement
217
220
  none: false
218
221
  requirements:
219
222
  - - ! '>='
220
223
  - !ruby/object:Gem::Version
221
224
  version: '0'
225
+ segments:
226
+ - 0
227
+ hash: -2306503118888220795
222
228
  requirements: []
223
229
  rubyforge_project:
224
230
  rubygems_version: 1.8.24