Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--format documentation
--color
--require spec_helper
8 changes: 8 additions & 0 deletions Gemfile
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'
47 changes: 47 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
PATH

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.

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
71 changes: 4 additions & 67 deletions Rakefile
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
24 changes: 12 additions & 12 deletions lib/ri_cal/component/t_z_info_timezone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(period.local_ends_at&.to_datetime || DateTime.parse("99990101T000000")).strftime("%Y%m%dT%H%M%S")
(period.local_ends_at && period.local_ends_at.to_datetime || DateTime.parse("99990101T000000")).strftime("%Y%m%dT%H%M%S")

As &. is a Ruby 2.6 feature and this gem is really old and most likely used in old services.

If you insist on using it, you should add spec.required_ruby_version = ">= 2.6.0" to the .gemspec and the version should be raised at least by a minor level.

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")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

end

def add_period(this_period)
Expand Down Expand Up @@ -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
Expand All @@ -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?
Expand All @@ -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)
Expand Down Expand Up @@ -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
Loading