fnando-recurrence 0.0.6 → 0.0.7

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/History.txt CHANGED
@@ -33,4 +33,9 @@
33
33
  * Code refactoring
34
34
  * Added next and next! methods
35
35
  * Added more specs
36
- * Yearly interval now accepts symbols: jan-dec and january-december
36
+ * Yearly interval now accepts symbols: jan-dec and january-december
37
+
38
+ == 0.0.7 2009-01-06
39
+
40
+ * 1 major enhancement:
41
+ * The events method now accepts :starts and :until dates
data/README.markdown CHANGED
@@ -6,7 +6,7 @@ Recurrence
6
6
  DESCRIPTION:
7
7
  ------------
8
8
 
9
- A simples library that handles recurring events.
9
+ A simple library to handle recurring events.
10
10
 
11
11
 
12
12
  INSTALLATION:
@@ -17,6 +17,12 @@ run the command
17
17
 
18
18
  sudo gem install fnando-recurrence --source=http://gems.github.com
19
19
 
20
+ Sometimes Github just won't build the gem. You can then do the following
21
+
22
+ git clone git://github.com/fnando/recurrence.git
23
+ cd recurrence
24
+ rake gem:install
25
+
20
26
  If you prefer it as a plugin, just run the command
21
27
 
22
28
  script/plugin install git://github.com/fnando/recurrence.git
@@ -61,6 +67,9 @@ USAGE:
61
67
  # Getting an array with all events
62
68
  r.events.each {|date| puts date.to_s } # => Memoized array
63
69
  r.events!.each {|date| puts date.to_s } # => reset items cache and re-execute it
70
+ r.events(:starts => '2009-01-01').each {|date| puts date.to_s }
71
+ r.events(:until => '2009-01-10').each {|date| puts date.to_s }
72
+ r.events(:starts => '2009-01-05', :until => '2009-01-10').each {|date| puts date.to_s }
64
73
 
65
74
  # Iterating events
66
75
  r.each { |date| puts date.to_s } # => Use items method
data/Rakefile CHANGED
@@ -5,8 +5,8 @@ PKG_FILES = %w(init.rb Rakefile recurrence.gemspec History.txt License.txt READM
5
5
 
6
6
  spec = Gem::Specification.new do |s|
7
7
  s.name = "recurrence"
8
- s.version = "0.0.6"
9
- s.summary = "A simples library that handles recurring events"
8
+ s.version = "0.0.7"
9
+ s.summary = "A simple library to handle recurring events"
10
10
  s.authors = ["Nando Vieira"]
11
11
  s.email = ["fnando.vieira@gmail.com"]
12
12
  s.homepage = "http://github.com/fnando/recurrence"
@@ -22,7 +22,7 @@ namespace :gem do
22
22
  # Thanks to the Merb project for this code.
23
23
  desc "Update Github Gemspec"
24
24
  task :update_gemspec do
25
- skip_fields = %w(new_platform original_platform specification_version loaded required_ruby_version rubygems_version platform )
25
+ skip_fields = %w(new_platform original_platform specification_version loaded required_ruby_version rubygems_version platform)
26
26
 
27
27
  result = "# WARNING : RAKE AUTO-GENERATED FILE. DO NOT MANUALLY EDIT!\n"
28
28
  result << "# RUN : 'rake gem:update_gemspec'\n\n"
@@ -61,6 +61,7 @@ namespace :gem do
61
61
 
62
62
  desc "Build gem"
63
63
  task :build => [:update_gemspec] do
64
+ system "rm *.gem"
64
65
  system "gem build #{spec.instance_variable_get('@name')}.gemspec"
65
66
  end
66
67
 
@@ -86,7 +86,12 @@ class Recurrence
86
86
  @event.next!
87
87
  end
88
88
 
89
- def events
89
+ def events(options={})
90
+ options[:starts] = Date.parse(options[:starts]) if options[:starts].is_a?(String)
91
+ options[:until] = Date.parse(options[:until]) if options[:until].is_a?(String)
92
+
93
+ reset! if options[:starts] || options[:until]
94
+
90
95
  @events ||= begin
91
96
  _events = []
92
97
 
@@ -94,16 +99,25 @@ class Recurrence
94
99
  date = @event.next!
95
100
 
96
101
  break if date.nil?
97
- _events << date
102
+
103
+ if options[:starts] && options[:until] && date >= options[:starts] && date <= options[:until]
104
+ _events << date
105
+ elsif options[:starts] && options[:until].nil? && date >= options[:starts]
106
+ _events << date
107
+ elsif options[:until] && options[:starts].nil? && date <= options[:until]
108
+ _events << date
109
+ elsif options[:starts].nil? && options[:until].nil?
110
+ _events << date
111
+ end
98
112
  end
99
113
 
100
114
  _events
101
115
  end
102
116
  end
103
117
 
104
- def events!
118
+ def events!(options={})
105
119
  reset!
106
- events
120
+ events(options)
107
121
  end
108
122
 
109
123
  def each!(&block)
data/recurrence.gemspec CHANGED
@@ -17,10 +17,10 @@ Gem::Specification.new do |s|
17
17
  "lib/recurrence/event.rb",
18
18
  "lib/recurrence.rb"]
19
19
  s.email = ["fnando.vieira@gmail.com"]
20
- s.version = "0.0.6"
20
+ s.version = "0.0.7"
21
21
  s.homepage = "http://github.com/fnando/recurrence"
22
22
  s.name = "recurrence"
23
- s.summary = "A simples library that handles recurring events"
23
+ s.summary = "A simple library to handle recurring events"
24
24
  s.add_dependency "rubigen", ">= 0"
25
25
  s.add_dependency "activesupport", ">= 2.1.1"
26
26
  s.bindir = "bin"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fnando-recurrence
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
@@ -75,6 +75,6 @@ rubyforge_project:
75
75
  rubygems_version: 1.2.0
76
76
  signing_key:
77
77
  specification_version: 2
78
- summary: A simples library that handles recurring events
78
+ summary: A simple library to handle recurring events
79
79
  test_files: []
80
80