by_star 0.2.5 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/README.markdown +88 -0
- data/VERSION +1 -1
- data/by_star.gemspec +11 -2
- data/lib/by_star.rb +10 -303
- data/lib/calculations.rb +23 -0
- data/lib/calculations/count.rb +15 -0
- data/lib/calculations/sum.rb +14 -0
- data/lib/range_calculations.rb +23 -0
- data/lib/shared.rb +6 -0
- data/lib/time_ext.rb +20 -0
- data/lib/vanilla.rb +273 -0
- data/spec/by_star_spec.rb +410 -357
- data/spec/database.yml +9 -0
- data/spec/fixtures/models.rb +18 -0
- data/spec/fixtures/schema.rb +6 -0
- data/spec/spec_helper.rb +5 -6
- metadata +11 -2
data/spec/database.yml
ADDED
data/spec/fixtures/models.rb
CHANGED
@@ -15,6 +15,12 @@ class Event < ActiveRecord::Base
|
|
15
15
|
named_scope :private, :conditions => { :public => false }
|
16
16
|
end
|
17
17
|
|
18
|
+
class Invoice < ActiveRecord::Base
|
19
|
+
def self.factory(value, created_at = nil)
|
20
|
+
create!(:value => value, :created_at => created_at, :number => value)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
18
24
|
## seed data:
|
19
25
|
|
20
26
|
year = Time.zone.now.year
|
@@ -25,6 +31,18 @@ year = Time.zone.now.year
|
|
25
31
|
end
|
26
32
|
end
|
27
33
|
|
34
|
+
1.upto(12) do |month|
|
35
|
+
month.times do |n|
|
36
|
+
Invoice.factory n * 1000 + 1000, Time.local(year, month, 1)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Invoice from last year
|
41
|
+
Invoice.factory 10000, Time.local(Time.now.year-1, 1, 1)
|
42
|
+
|
43
|
+
# Invoice without a number
|
44
|
+
Invoice.create!(:value => 10000, :number => nil)
|
45
|
+
|
28
46
|
Post.factory "Today's post", Time.zone.now
|
29
47
|
Post.factory "Yesterday's post", Time.zone.now - 1.day
|
30
48
|
Post.factory "Tomorrow's post", Time.zone.now + 1.day
|
data/spec/fixtures/schema.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -2,10 +2,6 @@ require 'rubygems'
|
|
2
2
|
require 'activerecord'
|
3
3
|
require 'fileutils'
|
4
4
|
FileUtils.mkdir_p("tmp")
|
5
|
-
ActiveRecord::Base.establish_connection(
|
6
|
-
:adapter => "sqlite3",
|
7
|
-
:database => ":memory:"
|
8
|
-
)
|
9
5
|
|
10
6
|
ActiveRecord::Base.logger = Logger.new("tmp/activerecord.log")
|
11
7
|
$:.unshift(File.join(File.dirname(__FILE__), "../lib"))
|
@@ -19,8 +15,11 @@ zone = "UTC"
|
|
19
15
|
Time.zone = zone
|
20
16
|
ActiveRecord::Base.default_timezone = zone
|
21
17
|
|
22
|
-
|
23
|
-
|
18
|
+
YAML::load_file(File.dirname(__FILE__) + "/database.yml").each do |key, connection|
|
19
|
+
ActiveRecord::Base.establish_connection(connection)
|
20
|
+
load File.dirname(__FILE__) + "/fixtures/schema.rb"
|
21
|
+
load File.dirname(__FILE__) + "/fixtures/models.rb"
|
22
|
+
end
|
24
23
|
|
25
24
|
# bootstraping the plugin through init.rb
|
26
25
|
# tests how it would load in a real application
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: by_star
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Bigg
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-10-
|
13
|
+
date: 2009-10-17 00:00:00 +10:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -38,9 +38,18 @@ files:
|
|
38
38
|
- Rakefile
|
39
39
|
- VERSION
|
40
40
|
- by_star.gemspec
|
41
|
+
- by_star.sqlite3
|
41
42
|
- lib/by_star.rb
|
43
|
+
- lib/calculations.rb
|
44
|
+
- lib/calculations/count.rb
|
45
|
+
- lib/calculations/sum.rb
|
46
|
+
- lib/range_calculations.rb
|
47
|
+
- lib/shared.rb
|
48
|
+
- lib/time_ext.rb
|
49
|
+
- lib/vanilla.rb
|
42
50
|
- rails/init.rb
|
43
51
|
- spec/by_star_spec.rb
|
52
|
+
- spec/database.yml
|
44
53
|
- spec/fixtures/models.rb
|
45
54
|
- spec/fixtures/schema.rb
|
46
55
|
- spec/spec_helper.rb
|