-
Notifications
You must be signed in to change notification settings - Fork 132
fix compatibilty with tz_info #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| --format documentation | ||
| --color | ||
| --require spec_helper |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| source "https://rubygems.org" | ||
|
|
||
| git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } | ||
|
|
||
| # Specify your gem's dependencies in ri_cal.gemspec | ||
| gemspec | ||
|
|
||
| gem 'byebug' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| PATH | ||
| remote: . | ||
| specs: | ||
| ri_cal (0.8.8) | ||
| activesupport (> 2.2) | ||
| tzinfo (> 2.0) | ||
|
|
||
| GEM | ||
| remote: https://rubygems.org/ | ||
| specs: | ||
| activesupport (6.1.3) | ||
| concurrent-ruby (~> 1.0, >= 1.0.2) | ||
| i18n (>= 1.6, < 2) | ||
| minitest (>= 5.1) | ||
| tzinfo (~> 2.0) | ||
| zeitwerk (~> 2.3) | ||
| byebug (11.1.3) | ||
| concurrent-ruby (1.1.8) | ||
| diff-lcs (1.4.4) | ||
| i18n (1.8.9) | ||
| concurrent-ruby (~> 1.0) | ||
| minitest (5.14.3) | ||
| rake (0.9.6) | ||
| rspec (2.99.0) | ||
| rspec-core (~> 2.99.0) | ||
| rspec-expectations (~> 2.99.0) | ||
| rspec-mocks (~> 2.99.0) | ||
| rspec-core (2.99.2) | ||
| rspec-expectations (2.99.2) | ||
| diff-lcs (>= 1.1.3, < 2.0) | ||
| rspec-mocks (2.99.4) | ||
| tzinfo (2.0.4) | ||
| concurrent-ruby (~> 1.0) | ||
| zeitwerk (2.4.2) | ||
|
|
||
| PLATFORMS | ||
| ruby | ||
|
|
||
| DEPENDENCIES | ||
| bundler | ||
| byebug | ||
| rake (< 10.0) | ||
| ri_cal! | ||
| rspec (< 3.0) | ||
|
|
||
| BUNDLED WITH | ||
| 2.1.4 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,69 +1,6 @@ | ||
| require 'rubygems' | ||
| require 'rake' | ||
| # require 'jeweler' | ||
| require "bundler/gem_tasks" | ||
| require "rspec/core/rake_task" | ||
|
|
||
| begin | ||
| require 'ad_agency' | ||
| Jeweler::Tasks.new do |gem| | ||
| gem.name = "ri_cal" | ||
| gem.summary = %Q{a new implementation of RFC2445 in Ruby} | ||
| gem.description = %Q{A new Ruby implementation of RFC2445 iCalendar. | ||
| RSpec::Core::RakeTask.new(:spec) | ||
|
|
||
| The existing Ruby iCalendar libraries (e.g. icalendar, vpim) provide for parsing and generating icalendar files, | ||
| but do not support important things like enumerating occurrences of repeating events. | ||
|
|
||
| This is a clean-slate implementation of RFC2445. | ||
|
|
||
| A Google group for discussion of this library has been set up http://groups.google.com/group/rical_gem | ||
| } | ||
| gem.email = "rick.denatale@gmail.com" | ||
| gem.homepage = "http://github.com/rubyredrick/ri_cal" | ||
| gem.authors = ["Rick DeNatale"] | ||
| ['.gitignore', 'performance_data/*', 'sample_ical_files/*', 'website/*', 'config/website.yml'].each do |excl| | ||
| gem.files.exclude excl | ||
| end | ||
| gem.extra_rdoc_files.include %w{History.txt copyrights.txt} | ||
| # gem.add_development_dependency "thoughtbot-shoulda", ">= 0" | ||
| # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings | ||
| end | ||
| Jeweler::GemcutterTasks.new | ||
| Jeweler::AdAgencyTasks.new | ||
| # rescue LoadError => ex | ||
| # puts ex | ||
| # puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler" | ||
| end | ||
|
|
||
| require 'rake/testtask' | ||
| Rake::TestTask.new(:test) do |test| | ||
| test.libs << 'lib' << 'test' | ||
| test.pattern = 'test/**/test_*.rb' | ||
| test.verbose = true | ||
| end | ||
|
|
||
| begin | ||
| require 'rcov/rcovtask' | ||
| Rcov::RcovTask.new do |test| | ||
| test.libs << 'test' | ||
| test.pattern = 'test/**/test_*.rb' | ||
| test.verbose = true | ||
| end | ||
| rescue LoadError | ||
| task :rcov do | ||
| abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov" | ||
| end | ||
| end | ||
|
|
||
| Dir['tasks/**/*.rake'].each { |t| load t } | ||
|
|
||
| task :default => [:"spec:with_tzinfo_gem", :"spec:with_active_support"] | ||
|
|
||
|
|
||
| require 'rake/rdoctask' | ||
| Rake::RDocTask.new do |rdoc| | ||
| version = File.exist?('VERSION') ? File.read('VERSION') : "" | ||
|
|
||
| rdoc.rdoc_dir = 'rdoc' | ||
| rdoc.title = "ri_cal #{version}" | ||
| rdoc.rdoc_files.include('README*') | ||
| rdoc.rdoc_files.include('lib/**/*.rb') | ||
| end | ||
| task :default => :spec |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -21,20 +21,20 @@ def initialize(which, this_period, prev_period) | |||||
| @abbreviation = this_period.abbreviation | ||||||
| @rdates = [] | ||||||
| end | ||||||
|
|
||||||
| def daylight? | ||||||
| @which == "DAYLIGHT" | ||||||
| end | ||||||
|
|
||||||
| def period_local_end(period) | ||||||
| (period.local_end || DateTime.parse("99990101T000000")).strftime("%Y%m%dT%H%M%S") | ||||||
| (period.local_ends_at&.to_datetime || DateTime.parse("99990101T000000")).strftime("%Y%m%dT%H%M%S") | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
As If you insist on using it, you should add |
||||||
| end | ||||||
|
|
||||||
| # This assumes a 1 hour shift which is why we use the previous period local end when | ||||||
| # possible | ||||||
| def period_local_start(period) | ||||||
| shift = daylight? ? Rational(-1, 24) : Rational(1, 24) | ||||||
| ((period.local_start || DateTime.parse("16010101T000000")) + shift).strftime("%Y%m%dT%H%M%S") | ||||||
| ((period.local_starts_at&.to_datetime || DateTime.parse("16010101T000000")) + shift).strftime("%Y%m%dT%H%M%S") | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||||||
| end | ||||||
|
|
||||||
| def add_period(this_period) | ||||||
|
|
@@ -68,7 +68,7 @@ class Periods #:nodoc: all | |||||
| def initialize | ||||||
| @dst_period = @std_period = @previous_period = nil | ||||||
| end | ||||||
|
|
||||||
| def empty? | ||||||
| @periods.nil? || @periods.empty? | ||||||
| end | ||||||
|
|
@@ -85,7 +85,7 @@ def log_period(period) | |||||
| @periods ||= [] | ||||||
| @periods << period unless @periods.include?(period) | ||||||
| end | ||||||
|
|
||||||
| def add_period(this_period, force=false) | ||||||
| if @previous_period || force | ||||||
| if this_period.dst? | ||||||
|
|
@@ -109,7 +109,7 @@ def export_to(export_stream) | |||||
| def initialize(tzinfo_timezone) #:nodoc: | ||||||
| @tzinfo_timezone = tzinfo_timezone | ||||||
| end | ||||||
|
|
||||||
| # convert time from this time zone to utc time | ||||||
| def local_to_utc(time) | ||||||
| @tzinfo_timezone.local_to_utc(time.to_ri_cal_ruby_value) | ||||||
|
|
@@ -140,14 +140,14 @@ def export_utc_to(export_stream, utc_start, utc_end) #:nodoc: | |||||
| periods = Periods.new | ||||||
| period = initial_period = tzinfo_timezone.period_for_utc(utc_start) | ||||||
| #start with the period before the one containing utc_start | ||||||
| prev_period = period.utc_start && tzinfo_timezone.period_for_utc(period.utc_start - 1) | ||||||
| prev_period = period.starts_at && tzinfo_timezone.period_for_utc(period.starts_at.to_datetime - 1) | ||||||
| period = prev_period if prev_period | ||||||
| while period && period.utc_start && period.utc_start < utc_end | ||||||
| while period && period.starts_at && period.starts_at.to_datetime < utc_end | ||||||
| periods.add_period(period) | ||||||
| period = period.utc_end && tzinfo_timezone.period_for_utc(period.utc_end + 1) | ||||||
| period = period.ends_at && tzinfo_timezone.period_for_utc(period.ends_at.to_datetime + 1) | ||||||
| end | ||||||
| periods.add_period(initial_period, :force) if periods.empty? | ||||||
| periods.export_to(export_stream) | ||||||
| export_stream.puts "END:VTIMEZONE\n" | ||||||
| end | ||||||
| end | ||||||
| end | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest to add the Gemfile.lock to the .gitignore file.