expressive 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- expressive (0.0.14)
4
+ expressive (0.0.15)
5
5
  awesome_print (~> 1.0.2)
6
6
  json
7
7
  polyglot (~> 0.3.3)
@@ -1,3 +1,3 @@
1
1
  module Expressive
2
- VERSION = "0.0.14"
2
+ VERSION = "0.0.15"
3
3
  end
@@ -128,6 +128,9 @@ module Expressive
128
128
  define('sum') { |*args| args.flatten.map(&:to_f).reduce(:+) || 0 }
129
129
  define('if') { |*args| args.compact!; args[0] ? args[1] : args[2] }
130
130
  define('round'){|*args| args[0].to_f.round(args[1]) }
131
+ define('$days_ago'){|*args| Time.now - args[0].to_i * 86400 }
132
+ define('$hours_ago'){|*args| Time.now - args[0].to_i * 3600 }
133
+ define('$minutes_ago'){|*args| Time.now - args[0].to_i * 60 }
131
134
  end
132
135
 
133
136
  def to_hash
@@ -144,6 +144,18 @@ describe "Expressive" do
144
144
  end
145
145
  end
146
146
 
147
+ describe "understands time ranges" do
148
+ before do
149
+ @now = Time.now
150
+ Time.stub!(:now).and_return(@now)
151
+ end
152
+
153
+ it { Expressive.run("($days_ago 28)").should eql (@now - 28 * 86400) }
154
+ it { Expressive.run("($hours_ago 7)").should eql (@now - 7 * 3600) }
155
+ it { Expressive.run("($minutes_ago 12)").should eql (@now - 12 * 60) }
156
+ end
157
+
158
+
147
159
  describe "understands using lookup functions" do
148
160
  it "should perform the lookup function (add account and reverse login)" do
149
161
  @scope.add_lookup_function("account_reverse_login", account: "ea") do |options, login|
@@ -159,7 +171,6 @@ describe "Expressive" do
159
171
 
160
172
  Expressive.run('(lookup related_count "matters" (1 2 3) 10)', @scope).should eql ['matters', 3, 10]
161
173
  end
162
-
163
174
  end
164
175
 
165
176
  describe "understands web-hook statements" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expressive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
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-03-21 00:00:00.000000000 Z
12
+ date: 2013-03-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby_gntp
@@ -294,7 +294,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
294
294
  version: '0'
295
295
  segments:
296
296
  - 0
297
- hash: 1436366056289508828
297
+ hash: -2684970889508414071
298
298
  required_rubygems_version: !ruby/object:Gem::Requirement
299
299
  none: false
300
300
  requirements:
@@ -303,7 +303,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
303
303
  version: '0'
304
304
  segments:
305
305
  - 0
306
- hash: 1436366056289508828
306
+ hash: -2684970889508414071
307
307
  requirements: []
308
308
  rubyforge_project:
309
309
  rubygems_version: 1.8.23