mhc 1.0.4 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/emacs/Cask +1 -1
- data/emacs/mhc-vars.el +1 -1
- data/emacs/mhc.el +1 -1
- data/lib/mhc/formatter.rb +5 -8
- data/lib/mhc/sync/driver.rb +21 -1
- data/lib/mhc/sync/status.rb +5 -1
- data/lib/mhc/sync/strategy.rb +55 -1
- data/lib/mhc/version.rb +1 -1
- data/samples/DOT.mhc-config.yml +20 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a35853f0483a4ea2ebe72cea18b5f04e11eb115
|
4
|
+
data.tar.gz: abb4fbac0bed6fbfde24a58fd8ca6614ced22c63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fddb81016df1b68e8e321e8c6a152e2498812e089e0d07223ba6c0ec074513adfa53e472622ef42effe4e090d8211fdb5b6d68218a02fc061dde78d83992035
|
7
|
+
data.tar.gz: 1bb78936fb975dfd903eb4b6a795db39ab6bceea1620b69a3217e4c76c5392a2d640845af5924c090d9fb59d9c5c3540026cb3073abb7460fbe787daf3539d0c
|
data/emacs/Cask
CHANGED
data/emacs/mhc-vars.el
CHANGED
data/emacs/mhc.el
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
;; Description: Message Harmonized Calendaring system.
|
4
4
|
;; Author: Yoshinari Nomura <nom@quickhack.net>
|
5
5
|
;; Created: 1994-07-04
|
6
|
-
;; Version: 1.0
|
6
|
+
;; Version: 1.1.0
|
7
7
|
;; Keywords: calendar
|
8
8
|
;; URL: http://www.quickhack.net/mhc
|
9
9
|
;; Package-Requires: ((calfw "20150703"))
|
data/lib/mhc/formatter.rb
CHANGED
@@ -316,20 +316,17 @@ module Mhc
|
|
316
316
|
def format_body(context)
|
317
317
|
events = []
|
318
318
|
@occurrences.each do |oc|
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
else
|
324
|
-
color = ""
|
325
|
-
end
|
319
|
+
class_name = []
|
320
|
+
class_name += oc.categories.map{|c| "mhc-category-#{c.to_s.downcase}"}
|
321
|
+
class_name << (oc.allday? ? "mhc-allday" : "mhc-time-range")
|
322
|
+
|
326
323
|
events << {
|
327
324
|
id: oc.record_id,
|
328
325
|
allDay: oc.allday?,
|
329
326
|
title: oc.subject,
|
330
327
|
start: oc.dtstart.iso8601,
|
331
328
|
end: oc.dtend.iso8601,
|
332
|
-
|
329
|
+
className: class_name
|
333
330
|
}
|
334
331
|
end
|
335
332
|
return events.to_json
|
data/lib/mhc/sync/driver.rb
CHANGED
@@ -23,7 +23,7 @@ module Mhc
|
|
23
23
|
items = count_sync_items(list_cache)
|
24
24
|
if items > max_count
|
25
25
|
STDERR.print "Too many (#{items}) articles to sync... abort\n"
|
26
|
-
return false
|
26
|
+
return false unless dry_run
|
27
27
|
end
|
28
28
|
|
29
29
|
list_cache.each do |uid|
|
@@ -66,6 +66,10 @@ module Mhc
|
|
66
66
|
copy(uid, @db1, @db2, :overwrite)
|
67
67
|
when :overwrite2_to_1
|
68
68
|
copy(uid, @db2, @db1, :overwrite)
|
69
|
+
when :move1_to_2
|
70
|
+
move(uid, @db1, @db2)
|
71
|
+
when :move2_to_1
|
72
|
+
move(uid, @db2, @db1)
|
69
73
|
end
|
70
74
|
end
|
71
75
|
|
@@ -103,6 +107,22 @@ module Mhc
|
|
103
107
|
STDERR.print "COPY: failed.\n"
|
104
108
|
end
|
105
109
|
end
|
110
|
+
|
111
|
+
def move(uid, db1, db2)
|
112
|
+
ev = db1.get(uid)
|
113
|
+
info = db1.syncinfo(uid)
|
114
|
+
|
115
|
+
STDERR.print "MOVING: #{ev.uid}\n"
|
116
|
+
|
117
|
+
if new_info = db2.put(ev)
|
118
|
+
db2.syncinfo(uid).mark_synced(new_info.etag)
|
119
|
+
|
120
|
+
db1.delete(uid)
|
121
|
+
info.mark_synced(nil)
|
122
|
+
else
|
123
|
+
STDERR.print "MOVE: failed.\n"
|
124
|
+
end
|
125
|
+
end
|
106
126
|
end # class Driver
|
107
127
|
end # module Sync
|
108
128
|
end # module Mhc
|
data/lib/mhc/sync/status.rb
CHANGED
data/lib/mhc/sync/strategy.rb
CHANGED
@@ -9,6 +9,8 @@ module Mhc
|
|
9
9
|
return Mirror.new
|
10
10
|
when :sync
|
11
11
|
return Sync.new
|
12
|
+
when :import
|
13
|
+
return Import.new
|
12
14
|
else
|
13
15
|
raise NotImplementedError, "#{strategy} #{strategy.class}"
|
14
16
|
end
|
@@ -110,7 +112,7 @@ module Mhc
|
|
110
112
|
def status_signature(info)
|
111
113
|
return "N" if info.nil?
|
112
114
|
|
113
|
-
return "M" if info.modified?
|
115
|
+
return "M" if info.modified? || info.created?
|
114
116
|
return "U" if info.unmodified?
|
115
117
|
return "N" if info.norecord?
|
116
118
|
return "D" if info.deleted?
|
@@ -228,6 +230,58 @@ module Mhc
|
|
228
230
|
end
|
229
231
|
end # class Mirror
|
230
232
|
|
233
|
+
# * Import from side1 to side2
|
234
|
+
#
|
235
|
+
# Import newly created articles on side1 into side2
|
236
|
+
# All articles in side1 will be deleted after imported into side2.
|
237
|
+
#
|
238
|
+
# Side 2
|
239
|
+
# |---+---------+----------+------------+---------|
|
240
|
+
# S | | M | U | N | D |
|
241
|
+
# i |---+---------+----------+------------+---------|
|
242
|
+
# d | M | ?? DEL1 | ?? DEL1 | MV 1->2 | ?? DEL1 |
|
243
|
+
# e | U | ?? DEL1 | ?? DEL1 | ?? DEL1 | ?? DEL1 |
|
244
|
+
# 1 | N | -- | -- | -- | -- |
|
245
|
+
# | D | -- | -- | -- | -- |
|
246
|
+
# |---+---------+----------+------------+---------|
|
247
|
+
#
|
248
|
+
# + M :: Modified (or Created)
|
249
|
+
# + U :: Unchanged
|
250
|
+
# + N :: No Record
|
251
|
+
# + D :: Deleted
|
252
|
+
#
|
253
|
+
# + -- :: No operation (ignore)
|
254
|
+
# + ?? :: Not occurred in normal cases
|
255
|
+
# + MV :: Move
|
256
|
+
# + DEL :: Delete
|
257
|
+
#
|
258
|
+
class Import < Base
|
259
|
+
def whatnow(side1, side2)
|
260
|
+
actions = {
|
261
|
+
"MM" => :delete1,
|
262
|
+
"MU" => :delete1,
|
263
|
+
"MN" => :move1_to_2,
|
264
|
+
"MD" => :delete1,
|
265
|
+
|
266
|
+
"UM" => :delete1,
|
267
|
+
"UU" => :delete1,
|
268
|
+
"UN" => :delete1,
|
269
|
+
"UD" => :delete1,
|
270
|
+
|
271
|
+
"NM" => :ignore,
|
272
|
+
"NU" => :ignore,
|
273
|
+
"NN" => :ignore,
|
274
|
+
"ND" => :ignore,
|
275
|
+
|
276
|
+
"DM" => :ignore,
|
277
|
+
"DU" => :ignore,
|
278
|
+
"DN" => :ignore,
|
279
|
+
"DD" => :ignore,
|
280
|
+
}
|
281
|
+
return actions[status_pair(side1, side2)]
|
282
|
+
end
|
283
|
+
end # class Import
|
284
|
+
|
231
285
|
end # module Strategy
|
232
286
|
end # module Sync
|
233
287
|
end # module Mhc
|
data/lib/mhc/version.rb
CHANGED
data/samples/DOT.mhc-config.yml
CHANGED
@@ -31,9 +31,13 @@
|
|
31
31
|
# make a new calendar on your Google Calendar,
|
32
32
|
# and backup MHC folder ~/Mai/schedule.
|
33
33
|
#
|
34
|
-
# Currently, the type of STRATEGY in SYNC_CHANNELS allows
|
35
|
-
#
|
36
|
-
#
|
34
|
+
# Currently, the type of STRATEGY in SYNC_CHANNELS allows:
|
35
|
+
# + "mirror" :: mirrors MHC to Google Calendar.
|
36
|
+
# + "import" :: imports newly created (non-recurring) articles
|
37
|
+
# on Google Calendar into MHC.
|
38
|
+
# All articles in Google will be deleted after the import.
|
39
|
+
#
|
40
|
+
# We are planning to support the true two-way sync "sync" soon.
|
37
41
|
#
|
38
42
|
---
|
39
43
|
################################################################
|
@@ -61,6 +65,14 @@ SYNC_CHANNELS:
|
|
61
65
|
CALENDAR2: google_business
|
62
66
|
STRATEGY: mirror
|
63
67
|
|
68
|
+
# After create some articles into google_inbox with Android client,
|
69
|
+
# doing ``mhc sync inbox'' on my Mac will import the articles into my MHC.
|
70
|
+
# All articles in google_inbox will be deleted, after the import.
|
71
|
+
- NAME: inbox
|
72
|
+
CALENDAR1: google_inbox
|
73
|
+
CALENDAR2: master
|
74
|
+
STRATEGY: import
|
75
|
+
|
64
76
|
################################################################
|
65
77
|
CALENDARS:
|
66
78
|
################################################################
|
@@ -114,3 +126,8 @@ CALENDARS:
|
|
114
126
|
- <<: *google_default
|
115
127
|
NAME: google_business
|
116
128
|
URL: https://calendar.google.com/calendar/dav/**************************@group.calendar.google.com/events/
|
129
|
+
|
130
|
+
# Displayname: Android to create articles into:
|
131
|
+
- <<: *google_default
|
132
|
+
NAME: google_inbox
|
133
|
+
URL: https://calendar.google.com/calendar/dav/**************************@group.calendar.google.com/events/
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mhc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoshinari Nomura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|