ical_importer 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ical_importer (0.0.2)
4
+ ical_importer (0.0.3)
5
5
  activesupport (~> 3.0.15)
6
6
  i18n
7
7
  ri_cal
@@ -5,8 +5,8 @@ Gem::Specification.new do |gem|
5
5
  gem.authors = ["Jon Phenow"]
6
6
  gem.email = ["jon.phenow@tstmedia.com"]
7
7
  gem.description = %q{Easily import iCal Events from a URL and handle their output}
8
- gem.summary = %q{}
9
- gem.homepage = ""
8
+ gem.summary = %q{Uses RiCal to make a much simpler Event Importing interface.}
9
+ gem.homepage = "http://github.com/tstmedia/ical_importer"
10
10
 
11
11
  gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
12
  gem.files = `git ls-files`.split("\n")
@@ -13,12 +13,12 @@ module IcalImporter
13
13
  # handle recuring events
14
14
  @local_event.tap do |le|
15
15
  if @event.recurs?
16
- rrule = @event.rrule_property.first # only support recurrence on one schedule
16
+ @rrule = @event.rrule_property.first # only support recurrence on one schedule
17
17
  # set out new event's basic rucurring properties
18
- le.attributes = recurrence_attributes rrule
18
+ le.attributes = recurrence_attributes
19
19
 
20
20
  set_date_exclusion
21
- frequency_set rrule
21
+ frequency_set
22
22
  else # make sure we remove this if it changed
23
23
  le.attributes = non_recurrence_attributes
24
24
  end
@@ -44,11 +44,11 @@ module IcalImporter
44
44
  attributes
45
45
  end
46
46
 
47
- def recurrence_attributes(rrule)
47
+ def recurrence_attributes
48
48
  {
49
- :recur_interval => recur_map[rrule.freq],
50
- :recur_interval_value => rrule.interval,
51
- :recur_end_date => rrule.until.try(:to_datetime)
49
+ :recur_interval => recur_map[@rrule.freq],
50
+ :recur_interval_value => @rrule.interval,
51
+ :recur_end_date => @rrule.until.try(:to_datetime)
52
52
  }
53
53
  end
54
54
 
@@ -57,39 +57,40 @@ module IcalImporter
57
57
  @local_event.date_exclusions = @event.exdate.flatten.map{|d| DateExclusion.new(:exclude_date => d)}
58
58
  end
59
59
 
60
- def frequency_set(rrule)
60
+ def frequency_set
61
61
  # if .bounded? is an integer that's googles "recur X times"
62
62
  # if that's the case we try to figure out the date it should be by
63
63
  # multiplying thise "X" times by the frequency that the event recurrs
64
- if rrule.bounded?.is_a? Fixnum # convert X times to a date
65
- case rrule.freq
66
- when "DAILY"
67
- @local_event.recur_end_date = frequency_template.days
68
- when "WEEKLY"
69
- if rrule.to_ical.include?("BYDAY=")
70
- remote_days = rrule.to_ical.split("BYDAY=").last.split(";WKST=").first.split(',')
71
- day_map.each do |abbr, day|
72
- @local_event.send "recur_week_#{day}=", remote_days.include?(abbr)
73
- end
74
- else
75
- remote_days = [@local_event.start_date_time.wday]
76
- wday_map.each do |abbr, day|
77
- @local_event.send "recur_week_#{day}=", remote_days.include?(abbr)
78
- end
64
+ case @rrule.freq
65
+ when "DAILY"
66
+ @local_event.recur_end_date = frequency_template.days if @rrule.bounded?.is_a? Fixnum # convert X times to a date
67
+ when "WEEKLY"
68
+ if @rrule.to_ical.include?("BYDAY=")
69
+ remote_days = @rrule.to_ical.split("BYDAY=").last.split(";WKST=").first.split(',')
70
+ day_map.each do |abbr, day|
71
+ @local_event.send "recur_week_#{day}=", remote_days.include?(abbr)
79
72
  end
80
- # recurrence X times is probably broken - we can select multiple times in a week
73
+ else
74
+ remote_days = [@local_event.start_date_time.wday]
75
+ wday_map.each do |abbr, day|
76
+ @local_event.send "recur_week_#{day}=", remote_days.include?(abbr)
77
+ end
78
+ end
79
+ # recurrence X times is probably broken - we can select multiple times in a week
80
+ begin
81
81
  @local_event.recur_end_date = (frequency_template / remote_days.length).weeks
82
- when "MONTHLY"
83
- @local_event.recur_month_repeat_by = (rrule.to_ical =~ /BYDAY/) ? "day_of_week" : "day_of_month"
84
- @local_event.recur_end_date = frequency_template.months
85
- when "YEARLY"
86
- @local_event.recur_end_date = frequency_template.years
82
+ rescue
87
83
  end
84
+ when "MONTHLY"
85
+ @local_event.recur_month_repeat_by = (@rrule.to_ical =~ /BYDAY/) ? "day_of_week" : "day_of_month"
86
+ @local_event.recur_end_date = frequency_template.months if @rrule.bounded?.is_a? Fixnum # convert X times to a date
87
+ when "YEARLY"
88
+ @local_event.recur_end_date = frequency_template.years if @rrule.bounded?.is_a? Fixnum # convert X times to a date
88
89
  end
89
90
  end
90
91
 
91
92
  def frequency_template
92
- @local_event.start_date_time + (rrule.bounded? * rrule.interval - 1)
93
+ @local_event.start_date_time + (@rrule.bounded? * @rrule.interval - 1)
93
94
  end
94
95
 
95
96
  def recur_map
@@ -1,3 +1,3 @@
1
1
  module IcalImporter
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ical_importer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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: 2012-08-14 00:00:00.000000000 Z
12
+ date: 2012-08-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -144,7 +144,7 @@ files:
144
144
  - spec/spec_helper.rb
145
145
  - spec/support/mn_twins.ics
146
146
  - spec/support/test.ics
147
- homepage: ''
147
+ homepage: http://github.com/tstmedia/ical_importer
148
148
  licenses: []
149
149
  post_install_message:
150
150
  rdoc_options: []
@@ -158,7 +158,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
158
158
  version: '0'
159
159
  segments:
160
160
  - 0
161
- hash: 3297828595298379316
161
+ hash: -1771291853118684846
162
162
  required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  none: false
164
164
  requirements:
@@ -167,13 +167,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
167
  version: '0'
168
168
  segments:
169
169
  - 0
170
- hash: 3297828595298379316
170
+ hash: -1771291853118684846
171
171
  requirements: []
172
172
  rubyforge_project:
173
173
  rubygems_version: 1.8.24
174
174
  signing_key:
175
175
  specification_version: 3
176
- summary: ''
176
+ summary: Uses RiCal to make a much simpler Event Importing interface.
177
177
  test_files:
178
178
  - spec/ical_importer/builder_spec.rb
179
179
  - spec/ical_importer/collector_spec.rb