ncal2gcal 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/ncal2gcal +1 -1
- data/lib/ncal2gcal/counter.rb +36 -0
- data/lib/ncal2gcal/gcal4ruby_gateway.rb +60 -0
- data/lib/ncal2gcal/google_calendar.rb +2 -1
- data/lib/ncal2gcal/string.rb +19 -0
- data/lib/ncal2gcal/sync.rb +9 -80
- data/lib/ncal2gcal/sync_entry.rb +27 -0
- data/ncal2gcal.gemspec +3 -3
- metadata +8 -4
data/bin/ncal2gcal
CHANGED
@@ -20,7 +20,7 @@ opts = OptionParser.new do |opts|
|
|
20
20
|
opts.on("-P", "--gmail-password PASSWORD", "Google mail password") { |conf[:gmail_password]| }
|
21
21
|
opts.on("-C", "--gmail-calendar CALENDAR", "Google calendar (default: 'LotusNotes')") { |conf[:gmail_calendar]| }
|
22
22
|
opts.on("-D", "--days DAYS", "Do not sync events older then DAYS days (default: no limit)") { |days| conf[:days]=days.to_i }
|
23
|
-
opts.on("--sync-desc", "Do sync event description (default: no)") { conf[:sync_desc] }
|
23
|
+
opts.on("--sync-desc", "Do sync event description (default: no)") { |conf[:sync_desc]| }
|
24
24
|
opts.separator ""
|
25
25
|
opts.separator "Example:"
|
26
26
|
opts.separator " ncal2gcal sync -u user123 -p secret123 -d mail123.nsf -U username@gmail.com -P top123secret -C LotusNotes -D 14"
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module NCal2GCal
|
2
|
+
|
3
|
+
class Counter
|
4
|
+
attr_accessor :updates, :inserts, :deletes, :selects, :ignored, :t_start, :t_end
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@updates = 0
|
8
|
+
@inserts = 0
|
9
|
+
@deletes = 0
|
10
|
+
@selects = 0
|
11
|
+
@ignored = 0
|
12
|
+
start
|
13
|
+
end
|
14
|
+
def runtime
|
15
|
+
@t_end - @t_start
|
16
|
+
end
|
17
|
+
def start
|
18
|
+
@t_start = Time.now
|
19
|
+
end
|
20
|
+
def end
|
21
|
+
@t_end = Time.now
|
22
|
+
end
|
23
|
+
def show
|
24
|
+
puts "\nStatistics:"
|
25
|
+
puts "-"*20
|
26
|
+
puts sprintf("Inserts : %05d", @inserts)
|
27
|
+
puts sprintf("Updates : %05d", @updates)
|
28
|
+
puts sprintf("Deletes : %05d", @deletes)
|
29
|
+
puts sprintf("Ingored : %05d", @ignored)
|
30
|
+
puts "-"*20
|
31
|
+
puts sprintf("Total : %05d", @selects)
|
32
|
+
puts "Runtime : #{runtime} sec"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'gcal4ruby'
|
3
|
+
|
4
|
+
##
|
5
|
+
# This is an extension/modification of the classes
|
6
|
+
# in the gcal4ruby-module
|
7
|
+
#
|
8
|
+
# at the moment it is only used to allaw the usage
|
9
|
+
# of the user-relevant end-date in all-day events
|
10
|
+
#
|
11
|
+
module GCal4Ruby
|
12
|
+
DAY_SECS = 86400
|
13
|
+
class Event
|
14
|
+
|
15
|
+
alias :start_time= :start=
|
16
|
+
alias :start_time :start
|
17
|
+
|
18
|
+
def all_day=(is_all_day)
|
19
|
+
if self.end and !(is_all_day == @all_day)
|
20
|
+
is_all_day ? self.end=(self.end()+DAY_SECS) : self.end=(self.end-DAY_SECS)
|
21
|
+
end
|
22
|
+
@all_day = is_all_day
|
23
|
+
end
|
24
|
+
##
|
25
|
+
# The event end date and time
|
26
|
+
# For all_day-events it is the day, when
|
27
|
+
# the event ends (and not the day after
|
28
|
+
# as in the google api)
|
29
|
+
#
|
30
|
+
def end_time=(t)
|
31
|
+
tc = convert_to_time(t)
|
32
|
+
if @all_day
|
33
|
+
self.end = tc + DAY_SECS
|
34
|
+
else
|
35
|
+
self.end = tc
|
36
|
+
end
|
37
|
+
end
|
38
|
+
#
|
39
|
+
# see end_time=()
|
40
|
+
def end_time
|
41
|
+
if @all_day
|
42
|
+
return (self.end-DAY_SECS)
|
43
|
+
else
|
44
|
+
return self.end()
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def convert_to_time(t)
|
49
|
+
if t.is_a?String
|
50
|
+
return Time.parse(t)
|
51
|
+
elsif t.is_a?Time
|
52
|
+
return t
|
53
|
+
else
|
54
|
+
raise "Time must be either Time or String"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
# ---
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#
|
2
|
+
class String
|
3
|
+
def asciify()
|
4
|
+
str = self
|
5
|
+
# ----------------------------------------------------------------
|
6
|
+
# Umlauts
|
7
|
+
# ----------------------------------------------------------------
|
8
|
+
str = str.gsub(/\334/,"Ü") # �
|
9
|
+
str = str.gsub(/\374/,"ü") # �
|
10
|
+
str = str.gsub(/\326/,"Ö") # �
|
11
|
+
str = str.gsub(/\366/,"ö") # �
|
12
|
+
str = str.gsub(/\304/,"Ä") # �
|
13
|
+
str = str.gsub(/\344/,"ä") # �
|
14
|
+
str = str.gsub(/\337/,"ß") # �
|
15
|
+
# bez_neu = Iconv.conv('UTF-8','CP850', bez_neu)
|
16
|
+
#str = str.gsub(/([^\d\w\s\.\[\]-])/, '')
|
17
|
+
return str
|
18
|
+
end
|
19
|
+
end
|
data/lib/ncal2gcal/sync.rb
CHANGED
@@ -6,67 +6,12 @@ require 'dm-core'
|
|
6
6
|
require 'fileutils'
|
7
7
|
require 'ncal2gcal/lotus_notes_calendar'
|
8
8
|
require 'ncal2gcal/google_calendar'
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
str = self
|
13
|
-
# ----------------------------------------------------------------
|
14
|
-
# Sonderzeichenbehandlung
|
15
|
-
# ----------------------------------------------------------------
|
16
|
-
str = str.gsub(/\334/,"Ü") # �
|
17
|
-
str = str.gsub(/\374/,"ü") # �
|
18
|
-
str = str.gsub(/\326/,"Ö") # �
|
19
|
-
str = str.gsub(/\366/,"ö") # �
|
20
|
-
str = str.gsub(/\304/,"Ä") # �
|
21
|
-
str = str.gsub(/\344/,"ä") # �
|
22
|
-
str = str.gsub(/\337/,"ß") # �
|
23
|
-
# bez_neu = Iconv.conv('UTF-8','CP850', bez_neu)
|
24
|
-
#str = str.gsub(/([^\d\w\s\.\[\]-])/, '')
|
25
|
-
return str
|
26
|
-
end
|
27
|
-
end
|
9
|
+
require 'ncal2gcal/string'
|
10
|
+
require 'ncal2gcal/counter'
|
11
|
+
require 'ncal2gcal/sync_entry'
|
28
12
|
|
29
13
|
|
30
14
|
module NCal2GCal
|
31
|
-
raise "environment variable %APPDATA% not set" unless ENV['APPDATA']
|
32
|
-
FileUtils::cd(ENV['APPDATA'])
|
33
|
-
FileUtils::mkdir_p('ncal2gcal')
|
34
|
-
|
35
|
-
db_file = "#{Dir.pwd}/ncal2gcal/ncal2gcal.sqlite"
|
36
|
-
DataMapper::setup(:default, "sqlite3://#{db_file}")
|
37
|
-
|
38
|
-
class Counter
|
39
|
-
attr_accessor :updates, :inserts, :deletes, :selects, :ignored, :t_start, :t_end
|
40
|
-
|
41
|
-
def initialize
|
42
|
-
@updates = 0
|
43
|
-
@inserts = 0
|
44
|
-
@deletes = 0
|
45
|
-
@selects = 0
|
46
|
-
@ignored = 0
|
47
|
-
start
|
48
|
-
end
|
49
|
-
def runtime
|
50
|
-
@t_end - @t_start
|
51
|
-
end
|
52
|
-
def start
|
53
|
-
@t_start = Time.now
|
54
|
-
end
|
55
|
-
def end
|
56
|
-
@t_end = Time.now
|
57
|
-
end
|
58
|
-
def show
|
59
|
-
puts "\nStatistics:"
|
60
|
-
puts "-"*20
|
61
|
-
puts sprintf("Inserts : %05d", @inserts)
|
62
|
-
puts sprintf("Updates : %05d", @updates)
|
63
|
-
puts sprintf("Deletes : %05d", @deletes)
|
64
|
-
puts sprintf("Ingored : %05d", @ignored)
|
65
|
-
puts "-"*20
|
66
|
-
puts sprintf("Total : %05d", @selects)
|
67
|
-
puts "Runtime : #{runtime} sec"
|
68
|
-
end
|
69
|
-
end
|
70
15
|
|
71
16
|
class NotesGoogleSync
|
72
17
|
def initialize(params)
|
@@ -177,21 +122,21 @@ module NCal2GCal
|
|
177
122
|
def init_google_event(notes_event,start_time,end_time)
|
178
123
|
event = @google_calendar.new_event
|
179
124
|
google_event= set_google_event_attrs(notes_event, event,start_time,end_time )
|
180
|
-
google_event.
|
181
|
-
google_event.
|
125
|
+
google_event.start_time = start_time
|
126
|
+
google_event.end_time = end_time
|
182
127
|
return google_event
|
183
128
|
end
|
184
129
|
def set_google_event_attrs(notes_event, google_event,start_time=nil,end_time=nil)
|
185
130
|
google_event.title = notes_event.subject.asciify if notes_event.subject
|
186
131
|
if start_time
|
187
|
-
google_event.
|
132
|
+
google_event.start_time = start_time
|
188
133
|
else
|
189
|
-
google_event.
|
134
|
+
google_event.start_time = notes_event.start_time
|
190
135
|
end
|
191
136
|
if end_time
|
192
|
-
google_event.
|
137
|
+
google_event.end_time = end_time
|
193
138
|
else
|
194
|
-
google_event.
|
139
|
+
google_event.end_time = notes_event.end_time
|
195
140
|
end
|
196
141
|
google_event.where = notes_event.where.asciify if notes_event.where
|
197
142
|
google_event.all_day = notes_event.all_day?
|
@@ -243,20 +188,4 @@ module NCal2GCal
|
|
243
188
|
end
|
244
189
|
end
|
245
190
|
|
246
|
-
class SyncEntry
|
247
|
-
include DataMapper::Resource
|
248
|
-
#storage_names[:repo] = 'ncal2gal_sync_entries'
|
249
|
-
|
250
|
-
property :id, Serial
|
251
|
-
property :sync_time, DateTime
|
252
|
-
property :sync_action, String
|
253
|
-
|
254
|
-
property :lotus_notes_uid, Text, :index=>true
|
255
|
-
property :lotus_notes_last_modified, DateTime
|
256
|
-
property :gcal_id, Text
|
257
|
-
|
258
|
-
end
|
259
|
-
|
260
|
-
# automatically create the SyncEntry table
|
261
|
-
SyncEntry.auto_migrate! unless File.exists?(db_file) #SyncEntry.table_exists?
|
262
191
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
module NCal2GCal
|
3
|
+
raise "environment variable %APPDATA% not set" unless ENV['APPDATA']
|
4
|
+
FileUtils::cd(ENV['APPDATA'])
|
5
|
+
FileUtils::mkdir_p('ncal2gcal')
|
6
|
+
|
7
|
+
db_file = "#{Dir.pwd}/ncal2gcal/ncal2gcal.sqlite"
|
8
|
+
DataMapper::setup(:default, "sqlite3://#{db_file}")
|
9
|
+
|
10
|
+
|
11
|
+
class SyncEntry
|
12
|
+
include DataMapper::Resource
|
13
|
+
#storage_names[:repo] = 'ncal2gal_sync_entries'
|
14
|
+
|
15
|
+
property :id, Serial
|
16
|
+
property :sync_time, DateTime
|
17
|
+
property :sync_action, String
|
18
|
+
|
19
|
+
property :lotus_notes_uid, Text, :index=>true
|
20
|
+
property :lotus_notes_last_modified, DateTime
|
21
|
+
property :gcal_id, Text
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
# automatically create the SyncEntry table
|
26
|
+
SyncEntry.auto_migrate! unless File.exists?(db_file) #SyncEntry.table_exists?
|
27
|
+
end
|
data/ncal2gcal.gemspec
CHANGED
@@ -2,7 +2,7 @@ require "rubygems"
|
|
2
2
|
|
3
3
|
spec = Gem::Specification.new do |s|
|
4
4
|
s.name = %q{ncal2gcal}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.4"
|
6
6
|
s.authors = ["Elias Kugler"]
|
7
7
|
s.email = %q{groesser3@gmail.com}
|
8
8
|
s.files = Dir["lib/**/*"] + Dir["bin/**/*"] + Dir["*.rb"] + ["MIT-LICENSE","ncal2gcal.gemspec"]
|
@@ -15,11 +15,11 @@ spec = Gem::Specification.new do |s|
|
|
15
15
|
s.require_path = "lib"
|
16
16
|
s.default_executable = %q{ncal2gcal}
|
17
17
|
s.executables = ["ncal2gcal"]
|
18
|
-
s.homepage = %q{http://
|
18
|
+
s.homepage = %q{http://rubyforge.org/projects/ncal2gcal/}
|
19
19
|
s.rubyforge_project = %q{ncal2gcal}
|
20
20
|
s.add_dependency("dm-core", ">= 0.10.0")
|
21
21
|
s.add_dependency("do_sqlite3", ">= 0.10.0")
|
22
|
-
s.add_dependency("gcal4ruby", ">=0.
|
22
|
+
s.add_dependency("gcal4ruby", ">=0.3.1")
|
23
23
|
s.add_dependency("log4r", ">=1.0.5")
|
24
24
|
|
25
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ncal2gcal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elias Kugler
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-02-18 00:00:00 +01:00
|
13
13
|
default_executable: ncal2gcal
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 0.
|
43
|
+
version: 0.3.1
|
44
44
|
version:
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
46
|
name: log4r
|
@@ -61,15 +61,19 @@ extensions: []
|
|
61
61
|
extra_rdoc_files:
|
62
62
|
- README.rdoc
|
63
63
|
files:
|
64
|
+
- lib/ncal2gcal/counter.rb
|
65
|
+
- lib/ncal2gcal/gcal4ruby_gateway.rb
|
64
66
|
- lib/ncal2gcal/google_calendar.rb
|
65
67
|
- lib/ncal2gcal/lotus_notes_calendar.rb
|
68
|
+
- lib/ncal2gcal/string.rb
|
66
69
|
- lib/ncal2gcal/sync.rb
|
70
|
+
- lib/ncal2gcal/sync_entry.rb
|
67
71
|
- bin/ncal2gcal
|
68
72
|
- MIT-LICENSE
|
69
73
|
- ncal2gcal.gemspec
|
70
74
|
- README.rdoc
|
71
75
|
has_rdoc: true
|
72
|
-
homepage: http://
|
76
|
+
homepage: http://rubyforge.org/projects/ncal2gcal/
|
73
77
|
licenses: []
|
74
78
|
|
75
79
|
post_install_message:
|