by_star 0.9.0 → 1.0.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/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source :gemcutter
2
+
3
+ group :test do
4
+ gem 'rspec', '2.0.0.beta.22'
5
+ gem 'mysql'
6
+ gem 'sqlite3-ruby'
7
+ end
8
+
9
+ # Specify your gem's dependencies in by_star.gemspec
10
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,59 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ by_star (0.0.1)
5
+ activerecord (>= 2.0.0)
6
+ chronic
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ activemodel (3.0.0)
12
+ activesupport (= 3.0.0)
13
+ builder (~> 2.1.2)
14
+ i18n (~> 0.4.1)
15
+ activerecord (3.0.0)
16
+ activemodel (= 3.0.0)
17
+ activesupport (= 3.0.0)
18
+ arel (~> 1.0.0)
19
+ tzinfo (~> 0.3.23)
20
+ activesupport (3.0.0)
21
+ arel (1.0.1)
22
+ activesupport (~> 3.0.0)
23
+ builder (2.1.2)
24
+ chronic (0.2.3)
25
+ hoe (>= 1.2.1)
26
+ diff-lcs (1.1.2)
27
+ hoe (2.6.1)
28
+ rake (>= 0.8.7)
29
+ rubyforge (>= 2.0.4)
30
+ i18n (0.4.1)
31
+ json_pure (1.4.6)
32
+ mysql (2.8.1)
33
+ rake (0.8.7)
34
+ rspec (2.0.0.beta.22)
35
+ rspec-core (= 2.0.0.beta.22)
36
+ rspec-expectations (= 2.0.0.beta.22)
37
+ rspec-mocks (= 2.0.0.beta.22)
38
+ rspec-core (2.0.0.beta.22)
39
+ rspec-expectations (2.0.0.beta.22)
40
+ diff-lcs (>= 1.1.2)
41
+ rspec-mocks (2.0.0.beta.22)
42
+ rspec-core (= 2.0.0.beta.22)
43
+ rspec-expectations (= 2.0.0.beta.22)
44
+ rubyforge (2.0.4)
45
+ json_pure (>= 1.1.7)
46
+ sqlite3-ruby (1.3.1)
47
+ tzinfo (0.3.23)
48
+
49
+ PLATFORMS
50
+ ruby
51
+
52
+ DEPENDENCIES
53
+ activerecord (>= 2.0.0)
54
+ bundler (>= 1.0.0)
55
+ by_star!
56
+ chronic
57
+ mysql
58
+ rspec (= 2.0.0.beta.22)
59
+ sqlite3-ruby
data/Rakefile CHANGED
@@ -1,51 +1,2 @@
1
- # encoding: utf-8
2
- require 'rubygems'
3
- require 'rake'
4
-
5
- begin
6
- require 'jeweler'
7
- Jeweler::Tasks.new do |gem|
8
- gem.name = "by_star"
9
- gem.summary = %Q{ActiveRecord extension for easier date scopes and time ranges}
10
- gem.description = %Q{ActiveRecord extension for easier date scopes and time ranges}
11
- gem.email = "radarlistener@gmail.com"
12
- gem.homepage = "http://github.com/radar/by_star"
13
- gem.authors = ["Ryan Bigg", "Mislav Marohnić"]
14
- gem.add_development_dependency "rspec"
15
- gem.add_dependency('chronic', '~> 0.2.3')
16
- gem.files << "lib/**/*"
17
- end
18
- Jeweler::GemcutterTasks.new
19
- rescue LoadError
20
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
21
- end
22
-
23
- require 'spec/rake/spectask'
24
- Spec::Rake::SpecTask.new(:spec) do |spec|
25
- spec.libs << 'lib' << 'spec'
26
- spec.spec_files = FileList['spec/**/*_spec.rb']
27
- end
28
-
29
- Spec::Rake::SpecTask.new(:rcov) do |spec|
30
- spec.libs << 'lib' << 'spec'
31
- spec.pattern = 'spec/**/*_spec.rb'
32
- spec.rcov = true
33
- end
34
-
35
- task :spec => :check_dependencies
36
- task :default => :spec
37
-
38
- require 'rake/rdoctask'
39
- Rake::RDocTask.new do |rdoc|
40
- if File.exist?('VERSION')
41
- version = File.read('VERSION')
42
- else
43
- version = ""
44
- end
45
-
46
- rdoc.rdoc_dir = 'rdoc'
47
- rdoc.title = "by_star #{version}"
48
- rdoc.rdoc_files.include('README*')
49
- rdoc.rdoc_files.include('lib/**/*.rb')
50
- end
51
-
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/by_star.gemspec CHANGED
@@ -1,71 +1,24 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
2
+ require File.expand_path("../lib/by_star/version", __FILE__)
5
3
 
6
4
  Gem::Specification.new do |s|
7
- s.name = %q{by_star}
8
- s.version = "0.9.0"
5
+ s.name = "by_star"
6
+ s.version = ByStar::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = []
9
+ s.email = []
10
+ s.homepage = "http://rubygems.org/gems/by_star"
11
+ s.summary = "ActiveRecord extension for easier date scopes and time ranges"
12
+ s.description = "ActiveRecord extension for easier date scopes and time ranges"
9
13
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Ryan Bigg", "Mislav Marohni\304\207"]
12
- s.date = %q{2010-07-29}
13
- s.description = %q{ActiveRecord extension for easier date scopes and time ranges}
14
- s.email = %q{radarlistener@gmail.com}
15
- s.extra_rdoc_files = [
16
- "README.markdown"
17
- ]
18
- s.files = [
19
- ".gitignore",
20
- "MIT-LICENSE",
21
- "README.markdown",
22
- "Rakefile",
23
- "VERSION",
24
- "by_star.gemspec",
25
- "cleaner.rb",
26
- "lib/by_star.rb",
27
- "lib/calculations.rb",
28
- "lib/calculations/count.rb",
29
- "lib/calculations/sum.rb",
30
- "lib/neighbours.rb",
31
- "lib/range_calculations.rb",
32
- "lib/shared.rb",
33
- "lib/time_ext.rb",
34
- "lib/vanilla.rb",
35
- "rails/init.rb",
36
- "spec/by_star_spec.rb",
37
- "spec/database.yml",
38
- "spec/fixtures/models.rb",
39
- "spec/fixtures/schema.rb",
40
- "spec/spec_helper.rb",
41
- "tmp/.gitignore"
42
- ]
43
- s.homepage = %q{http://github.com/radar/by_star}
44
- s.rdoc_options = ["--charset=UTF-8"]
45
- s.require_paths = ["lib"]
46
- s.rubygems_version = %q{1.3.6}
47
- s.summary = %q{ActiveRecord extension for easier date scopes and time ranges}
48
- s.test_files = [
49
- "spec/by_star_spec.rb",
50
- "spec/fixtures/models.rb",
51
- "spec/fixtures/schema.rb",
52
- "spec/spec_helper.rb"
53
- ]
14
+ s.required_rubygems_version = ">= 1.3.6"
15
+ s.rubyforge_project = "by_star"
54
16
 
55
- if s.respond_to? :specification_version then
56
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
57
- s.specification_version = 3
17
+ s.add_development_dependency "bundler", ">= 1.0.0"
18
+ s.add_dependency "activerecord", ">= 2.0.0"
19
+ s.add_dependency "chronic"
58
20
 
59
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
60
- s.add_development_dependency(%q<rspec>, [">= 0"])
61
- s.add_runtime_dependency(%q<chronic>, ["~> 0.2.3"])
62
- else
63
- s.add_dependency(%q<rspec>, [">= 0"])
64
- s.add_dependency(%q<chronic>, ["~> 0.2.3"])
65
- end
66
- else
67
- s.add_dependency(%q<rspec>, [">= 0"])
68
- s.add_dependency(%q<chronic>, ["~> 0.2.3"])
69
- end
21
+ s.files = `git ls-files`.split("\n")
22
+ s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
23
+ s.require_path = 'lib'
70
24
  end
71
-
File without changes
data/lib/by_star.rb CHANGED
@@ -1,12 +1,16 @@
1
1
  require 'chronic'
2
- require 'shared'
3
- require 'range_calculations'
4
- require 'time_ext'
5
- require 'vanilla'
6
- require 'neighbours'
7
-
8
- Dir[File.dirname(__FILE__) + '/calculations/*.rb'].each { |file| require file }
9
- require 'calculations'
2
+
3
+ require 'by_star/shared'
4
+ require 'by_star/range_calculations'
5
+ require 'by_star/time_ext'
6
+ require 'by_star/vanilla'
7
+ require 'by_star/neighbours'
8
+
9
+ require 'by_star/calculations/count'
10
+ require 'by_star/calculations/sum'
11
+
12
+ require 'by_star/calculations'
13
+
10
14
  module ByStar
11
15
 
12
16
  def self.included(base)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,3 @@
1
+ module ByStar
2
+ VERSION = "1.0.0"
3
+ end
data/spec/by_star_spec.rb CHANGED
@@ -30,19 +30,18 @@ describe Post do
30
30
  end
31
31
 
32
32
  def find(*args)
33
- method = description_args.first.sub(' ', '_')
34
- Post.send(method, *args)
33
+ Post.send(subject, *args)
35
34
  end
36
35
 
37
36
  def size(*args)
38
- method = description_args.first.sub(' ', '_')
39
- Post.send(method, *args).size
37
+ Post.send(subject, *args).size
40
38
  end
41
39
 
42
40
  ["mysql", "sqlite3"].each do |adapter|
43
41
  ActiveRecord::Base.establish_connection(YAML::load_file(File.dirname(__FILE__) + "/database.yml")[adapter])
44
42
 
45
43
  describe "by year" do
44
+ subject { "by_year" }
46
45
  it "should be able to find all the posts in the current year" do
47
46
  size.should eql(this_years_posts)
48
47
  end
@@ -60,9 +59,7 @@ describe Post do
60
59
  end
61
60
 
62
61
  it "should error when given an invalid year" do
63
- # This is broken on 1.8.6 (and previous versions), any patchlevel after & before 111
64
- major, minor, trivial = RUBY_VERSION.split(".").map(&:to_i)
65
- if major == 1 && ((minor == 8 && trivial <= 6) || (minor <= 8)) && RUBY_PATCHLEVEL.to_i > 111
62
+ if RUBY_VERSION < "1.8.7"
66
63
  lambda { find(1901) }.should raise_error(ByStar::ParseError, "Invalid arguments detected, year may possibly be outside of valid range (1902-2039)")
67
64
  lambda { find(2039) }.should raise_error(ByStar::ParseError, "Invalid arguments detected, year may possibly be outside of valid range (1902-2039)")
68
65
  else
@@ -95,6 +92,7 @@ describe Post do
95
92
  end
96
93
 
97
94
  describe "by month" do
95
+ subject { "by_month" }
98
96
 
99
97
  it "should be able to find posts for the current month" do
100
98
  size.should eql(10)
@@ -153,6 +151,7 @@ describe Post do
153
151
  end
154
152
 
155
153
  describe "by fortnight" do
154
+ subject { "by_fortnight" }
156
155
 
157
156
  it "should be able to find posts in the current fortnight" do
158
157
  size.should eql(10)
@@ -178,6 +177,7 @@ describe Post do
178
177
  end
179
178
 
180
179
  describe "by week" do
180
+ subject { "by_week" }
181
181
 
182
182
  it "should be able to find posts in the current week" do
183
183
  stub_time
@@ -228,6 +228,8 @@ describe Post do
228
228
  end
229
229
 
230
230
  describe "by weekend" do
231
+ subject { "by_weekend" }
232
+
231
233
  it "should be able to find the posts on the weekend of the 1st of January" do
232
234
  case Time.zone.now.wday
233
235
  when 5 # Friday
@@ -263,6 +265,7 @@ describe Post do
263
265
  end
264
266
 
265
267
  describe "by day" do
268
+ subject { "by_day" }
266
269
  it "should be able to find a post for today" do
267
270
  stub_time
268
271
  size.should eql(1)
@@ -279,6 +282,7 @@ describe Post do
279
282
  end
280
283
 
281
284
  describe "today" do
285
+ subject { "today" }
282
286
  it "should show the post for today" do
283
287
  find.map(&:text).should include("Today's post")
284
288
  end
@@ -292,18 +296,21 @@ describe Post do
292
296
  end
293
297
 
294
298
  describe "tomorrow" do
299
+ subject { "tomorrow" }
295
300
  it "should show the post for tomorrow" do
296
301
  find.map(&:text).should include("Tomorrow's post")
297
302
  end
298
303
  end
299
304
 
300
305
  describe "yesterday" do
306
+ subject { "yesterday" }
307
+
301
308
  it "should show the post for yesterday" do
302
- find.map(&:text).should include("Yesterday's post")
309
+ find.map(&:text).should include("Yesterday")
303
310
  end
304
311
 
305
312
  it "should be able find yesterday, given a Date" do
306
- find(Time.now).map(&:text).should include("Yesterday's post")
313
+ find(Time.now).map(&:text).should include("Yesterday")
307
314
  end
308
315
 
309
316
  it "should be able to use an alternative field" do
@@ -315,6 +322,7 @@ describe Post do
315
322
  end
316
323
 
317
324
  describe "tomorrow" do
325
+ subject { "tomorrow" }
318
326
  it "should show the post for tomorrow" do
319
327
  find.map(&:text).should include("Tomorrow's post")
320
328
  end
@@ -331,6 +339,7 @@ describe Post do
331
339
  end
332
340
 
333
341
  describe "past" do
342
+ subject { "past" }
334
343
 
335
344
  before do
336
345
  stub_time
@@ -365,6 +374,7 @@ describe Post do
365
374
  end
366
375
 
367
376
  describe "future" do
377
+ subject { "future" }
368
378
  before do
369
379
  stub_time
370
380
  end
@@ -408,6 +418,7 @@ describe Post do
408
418
  end
409
419
 
410
420
  describe "between" do
421
+ subject { "between" }
411
422
  it "should find posts between last tuesday and next tuesday" do
412
423
  stub_time
413
424
  size("last tuesday", "next tuesday").should eql(2)
@@ -651,7 +662,7 @@ describe Post do
651
662
 
652
663
  describe "previous" do
653
664
  it "should find the post previous to it" do
654
- subject.previous.text.should eql("Yesterday's post")
665
+ subject.previous.text.should eql("Yesterday")
655
666
  end
656
667
 
657
668
  it "should find the previous event" do
@@ -675,12 +686,12 @@ describe Post do
675
686
  describe "chaining of methods" do
676
687
  # a by_star and a by_direction method, in that order
677
688
  it "should be able to chain today and past" do
678
- Post.today.past.size.should eql(4)
689
+ Post.today.past.size.should eql(5)
679
690
  end
680
691
 
681
692
  # a by_direction and by_star method, in that order
682
693
  it "should be able to chain together past and today" do
683
- Post.past.today.size.should eql(4)
694
+ Post.past.today.size.should eql(5)
684
695
  end
685
696
 
686
697
  end
@@ -13,7 +13,7 @@ end
13
13
 
14
14
  class Event < ActiveRecord::Base
15
15
  by_star_field :start_time
16
- named_scope :secret, :conditions => { :public => false }
16
+ scope :secret, :conditions => { :public => false }
17
17
  end
18
18
 
19
19
  class Invoice < ActiveRecord::Base
@@ -101,4 +101,4 @@ Event.create(:name => "1st of August", :start_time => "01-08-#{Time.zone.now
101
101
 
102
102
  Event.create(:name => "FBI meeting", :start_time => "02-03-#{Time.zone.now.year}".to_time, :public => false)
103
103
 
104
- Invoice.first.day_entries.create(:spent_at => Time.zone.now + 1.hour, :name => "Working harder, better, faster stronger.")
104
+ # Invoice.first.day_entries.create(:spent_at => Time.zone.now + 1.hour, :name => "Working harder, better, faster stronger.")
data/spec/spec_helper.rb CHANGED
@@ -9,17 +9,13 @@ $:.unshift(File.join(File.dirname(__FILE__), "../lib"))
9
9
  require 'active_support'
10
10
  require 'active_support/core_ext/string/conversions'
11
11
  require 'by_star'
12
- require 'spec'
12
+ require 'rspec'
13
13
 
14
14
  # Define time zone before loading test_helper
15
15
  zone = "UTC"
16
16
  Time.zone = zone
17
17
  ActiveRecord::Base.default_timezone = zone
18
18
 
19
- # bootstraping the plugin through init.rb
20
- # tests how it would load in a real application
21
- load File.dirname(__FILE__) + "/../rails/init.rb"
22
-
23
19
  YAML::load_file(File.dirname(__FILE__) + "/database.yml").each do |key, connection|
24
20
  ActiveRecord::Base.establish_connection(connection)
25
21
  load File.dirname(__FILE__) + "/fixtures/schema.rb"
metadata CHANGED
@@ -1,75 +1,98 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: by_star
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 23
4
5
  prerelease: false
5
6
  segments:
7
+ - 1
6
8
  - 0
7
- - 9
8
9
  - 0
9
- version: 0.9.0
10
+ version: 1.0.0
10
11
  platform: ruby
11
- authors:
12
- - Ryan Bigg
13
- - "Mislav Marohni\xC4\x87"
12
+ authors: []
13
+
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-29 00:00:00 +10:00
18
+ date: 2010-10-02 00:00:00 +10:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: rspec
22
+ name: bundler
23
23
  prerelease: false
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
25
26
  requirements:
26
27
  - - ">="
27
28
  - !ruby/object:Gem::Version
29
+ hash: 23
28
30
  segments:
31
+ - 1
29
32
  - 0
30
- version: "0"
33
+ - 0
34
+ version: 1.0.0
31
35
  type: :development
32
36
  version_requirements: *id001
33
37
  - !ruby/object:Gem::Dependency
34
- name: chronic
38
+ name: activerecord
35
39
  prerelease: false
36
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - ~>
43
+ - - ">="
39
44
  - !ruby/object:Gem::Version
45
+ hash: 15
40
46
  segments:
41
- - 0
42
47
  - 2
43
- - 3
44
- version: 0.2.3
48
+ - 0
49
+ - 0
50
+ version: 2.0.0
45
51
  type: :runtime
46
52
  version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: chronic
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 3
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ type: :runtime
66
+ version_requirements: *id003
47
67
  description: ActiveRecord extension for easier date scopes and time ranges
48
- email: radarlistener@gmail.com
68
+ email: []
69
+
49
70
  executables: []
50
71
 
51
72
  extensions: []
52
73
 
53
- extra_rdoc_files:
54
- - README.markdown
74
+ extra_rdoc_files: []
75
+
55
76
  files:
56
77
  - .gitignore
78
+ - Gemfile
79
+ - Gemfile.lock
57
80
  - MIT-LICENSE
58
81
  - README.markdown
59
82
  - Rakefile
60
- - VERSION
61
83
  - by_star.gemspec
62
84
  - cleaner.rb
85
+ - init.rb
63
86
  - lib/by_star.rb
64
- - lib/calculations.rb
65
- - lib/calculations/count.rb
66
- - lib/calculations/sum.rb
67
- - lib/neighbours.rb
68
- - lib/range_calculations.rb
69
- - lib/shared.rb
70
- - lib/time_ext.rb
71
- - lib/vanilla.rb
72
- - rails/init.rb
87
+ - lib/by_star/calculations.rb
88
+ - lib/by_star/calculations/count.rb
89
+ - lib/by_star/calculations/sum.rb
90
+ - lib/by_star/neighbours.rb
91
+ - lib/by_star/range_calculations.rb
92
+ - lib/by_star/shared.rb
93
+ - lib/by_star/time_ext.rb
94
+ - lib/by_star/vanilla.rb
95
+ - lib/by_star/version.rb
73
96
  - spec/by_star_spec.rb
74
97
  - spec/database.yml
75
98
  - spec/fixtures/models.rb
@@ -77,37 +100,40 @@ files:
77
100
  - spec/spec_helper.rb
78
101
  - tmp/.gitignore
79
102
  has_rdoc: true
80
- homepage: http://github.com/radar/by_star
103
+ homepage: http://rubygems.org/gems/by_star
81
104
  licenses: []
82
105
 
83
106
  post_install_message:
84
- rdoc_options:
85
- - --charset=UTF-8
107
+ rdoc_options: []
108
+
86
109
  require_paths:
87
110
  - lib
88
111
  required_ruby_version: !ruby/object:Gem::Requirement
112
+ none: false
89
113
  requirements:
90
114
  - - ">="
91
115
  - !ruby/object:Gem::Version
116
+ hash: 3
92
117
  segments:
93
118
  - 0
94
119
  version: "0"
95
120
  required_rubygems_version: !ruby/object:Gem::Requirement
121
+ none: false
96
122
  requirements:
97
123
  - - ">="
98
124
  - !ruby/object:Gem::Version
125
+ hash: 23
99
126
  segments:
100
- - 0
101
- version: "0"
127
+ - 1
128
+ - 3
129
+ - 6
130
+ version: 1.3.6
102
131
  requirements: []
103
132
 
104
- rubyforge_project:
105
- rubygems_version: 1.3.6
133
+ rubyforge_project: by_star
134
+ rubygems_version: 1.3.7
106
135
  signing_key:
107
136
  specification_version: 3
108
137
  summary: ActiveRecord extension for easier date scopes and time ranges
109
- test_files:
110
- - spec/by_star_spec.rb
111
- - spec/fixtures/models.rb
112
- - spec/fixtures/schema.rb
113
- - spec/spec_helper.rb
138
+ test_files: []
139
+
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.9.0