quarter_time 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/quarter_time/quarter_driven.rb +5 -1
- data/quarter_time.gemspec +2 -2
- data/test/test_quarter_driven.rb +12 -3
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
@@ -2,7 +2,11 @@ module QuarterTime
|
|
2
2
|
module QuarterDriven
|
3
3
|
def self.included(base)
|
4
4
|
base.class_eval do
|
5
|
-
named_scope :for_quarter, lambda{|
|
5
|
+
named_scope :for_quarter, lambda {|*args|
|
6
|
+
quarter_obj = (args[0].is_a?(Quarter) ? args[0] : Quarter.new(args[0],args[1]))
|
7
|
+
{:conditions=>{:year=>quarter_obj.year, :quarter=>quarter_obj.quarter}}
|
8
|
+
}
|
9
|
+
|
6
10
|
|
7
11
|
[:start_date,:end_date,:quarter_stamp].each do |delegated_method|
|
8
12
|
define_method(delegated_method){ self.quarter_obj.send(delegated_method) }
|
data/quarter_time.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{quarter_time}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["evizitei"]
|
12
|
-
s.date = %q{2010-06-
|
12
|
+
s.date = %q{2010-06-22}
|
13
13
|
s.description = %q{A simple gem for dealing with quarter logic. I happen to have a project where half the models in the database recur every three months as part of a "quarter" of the year. Within the code, we constantly are asking "what quarter is this for?", or "show me all the records for this quarter". Well, now I need the same power on another application, so say hello to "quarter_time".}
|
14
14
|
s.email = %q{ethan.vizitei@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/test/test_quarter_driven.rb
CHANGED
@@ -22,9 +22,18 @@ class TestQuarterDriven < Test::Unit::TestCase
|
|
22
22
|
assert_equal "Q2, 2010",@model.quarter_stamp
|
23
23
|
end
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
context "creates a named scope which" do
|
26
|
+
setup do
|
27
|
+
@expected_map = {:conditions=>{:year=>2010,:quarter=>4}}
|
28
|
+
end
|
29
|
+
|
30
|
+
should "find by a quarter object" do
|
31
|
+
assert_equal @expected_map,QuarterDrivenModel.scopes[:for_quarter].call(Quarter.new(2010,4))
|
32
|
+
end
|
33
|
+
|
34
|
+
should "find by year and quarter" do
|
35
|
+
assert_equal @expected_map,QuarterDrivenModel.scopes[:for_quarter].call(2010,4)
|
36
|
+
end
|
28
37
|
end
|
29
38
|
end
|
30
39
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quarter_time
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 2
|
9
8
|
- 3
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- evizitei
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-06-
|
18
|
+
date: 2010-06-22 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|