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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1c058aa0f117bd28b047082f0bffb7829a65336
4
- data.tar.gz: 33e55550fee0eab49840f679b57f703803bc9ac7
3
+ metadata.gz: 4a35853f0483a4ea2ebe72cea18b5f04e11eb115
4
+ data.tar.gz: abb4fbac0bed6fbfde24a58fd8ca6614ced22c63
5
5
  SHA512:
6
- metadata.gz: 59543a84b06f8f386b7f3bd33ad4ba8116479308d69a2079d1a8c30dc03a38a5433119117852168b746e364ccbec43576cb9ac3b15fc11532ce5ea5bc5389097
7
- data.tar.gz: 2ba5edb349ac06b2e5cc31891c37fe2bde122db6918c0bfec4d9589f1c4c7ccd667adcdb5f99a678a135e5ae2815d0c90164f5fe6aac0da984cf776ab1b3dfa5
6
+ metadata.gz: 1fddb81016df1b68e8e321e8c6a152e2498812e089e0d07223ba6c0ec074513adfa53e472622ef42effe4e090d8211fdb5b6d68218a02fc061dde78d83992035
7
+ data.tar.gz: 1bb78936fb975dfd903eb4b6a795db39ab6bceea1620b69a3217e4c76c5392a2d640845af5924c090d9fb59d9c5c3540026cb3073abb7460fbe787daf3539d0c
data/emacs/Cask CHANGED
@@ -5,7 +5,7 @@
5
5
  (source org)
6
6
  (source melpa)
7
7
 
8
- (package "mhc" "1.0.4" "Message Harmonized Calendaring system") ;; MHC_VERSION
8
+ (package "mhc" "1.1.0" "Message Harmonized Calendaring system") ;; MHC_VERSION
9
9
 
10
10
  (files "mhc.el" "mhc-*.el")
11
11
 
data/emacs/mhc-vars.el CHANGED
@@ -17,7 +17,7 @@
17
17
 
18
18
 
19
19
  ;;; Constants:
20
- (defconst mhc-version "mhc 1.0.4") ;; MHC_VERSION
20
+ (defconst mhc-version "mhc 1.1.0") ;; MHC_VERSION
21
21
 
22
22
 
23
23
  ;;; Configration Variables:
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.4
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
- if oc.categories.map{|c| c.to_s.downcase}.include?('holiday')
320
- color = "red"
321
- elsif oc.allday?
322
- color = "green"
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
- color: color
329
+ className: class_name
333
330
  }
334
331
  end
335
332
  return events.to_json
@@ -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
@@ -29,7 +29,11 @@ module Mhc
29
29
  end
30
30
 
31
31
  def modified?
32
- sync_status == :created or sync_status == :modified
32
+ sync_status == :modified
33
+ end
34
+
35
+ def created?
36
+ sync_status == :created
33
37
  end
34
38
 
35
39
  def unmodified?
@@ -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
@@ -1,4 +1,4 @@
1
1
  module Mhc
2
- VERSION = "1.0.4"
2
+ VERSION = "1.1.0"
3
3
  PRODID = "-//Quickhack.net//MHC #{Mhc::VERSION}//EN"
4
4
  end
@@ -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 only "mirror"
35
- # from MHC to Google Calendar. We are planning to support the
36
- # true two-way sync soon.
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
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-09-23 00:00:00.000000000 Z
11
+ date: 2015-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor