polyrex_calendarbase 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/polyrex_calendarbase.rb +55 -44
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a3f46fd422720f70d48e087ffcd9e21d3179dde
|
4
|
+
data.tar.gz: 281a6be1808fae67b275a49e576014a69793de71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8537b77ee09ca9c1613dfa09ca256304bbf73e2fad367d6d4d1fabec269851dd0b98ce03b2ccadaf3e5d39896c14a4ec6775705b7c4f9d74424d0500b30065f
|
7
|
+
data.tar.gz: 0e2a933fc618e5cbc39f3f318f3b9d891ceede7960f85745ee9e9a64ba46b9055c638df01816c60d3763e840fd0b42557e59f7656cd79968c8b7a2679bb8e98f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/polyrex_calendarbase.rb
CHANGED
@@ -30,7 +30,6 @@ module LIBRARY
|
|
30
30
|
|
31
31
|
lib = File.dirname(__FILE__)
|
32
32
|
File.read filename
|
33
|
-
|
34
33
|
end
|
35
34
|
|
36
35
|
def generate_webpage(xml, xsl)
|
@@ -73,53 +72,56 @@ class Calendar < Polyrex
|
|
73
72
|
end
|
74
73
|
end
|
75
74
|
|
76
|
-
class
|
75
|
+
class PolyrexObjects
|
77
76
|
|
78
|
-
|
79
|
-
|
77
|
+
class Month
|
78
|
+
include LIBRARY
|
80
79
|
|
81
|
-
|
80
|
+
attr_accessor :xslt, :css_layout, :css_style
|
82
81
|
|
83
|
-
|
84
|
-
|
82
|
+
def inspect()
|
83
|
+
"#<CalendarObjects::Month:%s" % __id__
|
84
|
+
end
|
85
|
+
|
86
|
+
def d(n)
|
87
|
+
self.records[n-1]
|
88
|
+
end
|
89
|
+
|
85
90
|
end
|
86
91
|
|
87
|
-
|
88
|
-
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
class Week
|
93
|
-
include LIBRARY
|
92
|
+
class Week
|
93
|
+
include LIBRARY
|
94
94
|
|
95
|
-
|
96
|
-
|
97
|
-
|
95
|
+
def inspect()
|
96
|
+
"#<CalendarObjects::Week:%s" % __id__
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
98
100
|
|
99
|
-
|
100
|
-
|
101
|
-
|
101
|
+
class Day
|
102
|
+
|
103
|
+
def date()
|
104
|
+
Date.parse(self.sdate)
|
105
|
+
end
|
102
106
|
|
103
|
-
|
104
|
-
|
105
|
-
|
107
|
+
def wday()
|
108
|
+
self.date.wday
|
109
|
+
end
|
106
110
|
|
107
|
-
|
108
|
-
|
111
|
+
def day()
|
112
|
+
self.date.day
|
113
|
+
end
|
114
|
+
|
109
115
|
end
|
110
116
|
|
111
|
-
def day()
|
112
|
-
self.date.day
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|
116
|
-
|
117
117
|
end
|
118
118
|
|
119
119
|
|
120
|
+
|
120
121
|
class PolyrexCalendarBase
|
121
122
|
include LIBRARY
|
122
123
|
|
124
|
+
|
123
125
|
attr_accessor :xsl, :css, :calendar, :month_xsl, :month_css
|
124
126
|
attr_reader :day
|
125
127
|
|
@@ -167,7 +169,12 @@ class PolyrexCalendarBase
|
|
167
169
|
CalendarObjects.new(visual_schema)
|
168
170
|
|
169
171
|
end
|
170
|
-
|
172
|
+
|
173
|
+
def find(s)
|
174
|
+
dt = Chronic.parse s, now: Time.local(@year,1,1)
|
175
|
+
self.month(dt.month).d(dt.day)
|
176
|
+
end
|
177
|
+
|
171
178
|
def to_xml()
|
172
179
|
@calendar.to_xml pretty: true
|
173
180
|
end
|
@@ -181,7 +188,12 @@ class PolyrexCalendarBase
|
|
181
188
|
alias import! import_events
|
182
189
|
|
183
190
|
def inspect()
|
184
|
-
%Q(=> #<
|
191
|
+
%Q(=> #<PolyrexCalendarBase:#{self.object_id} @id="#{@id}", @year="#{@year}">)
|
192
|
+
end
|
193
|
+
|
194
|
+
def month(n=nil)
|
195
|
+
r = @calendar.records
|
196
|
+
n ? r[n-1] : r
|
185
197
|
end
|
186
198
|
|
187
199
|
def parse_events(list)
|
@@ -201,16 +213,16 @@ class PolyrexCalendarBase
|
|
201
213
|
end
|
202
214
|
|
203
215
|
def save(filename='calendar.xml')
|
204
|
-
@calendar.save filename
|
216
|
+
@calendar.save filename, pretty: true
|
205
217
|
end
|
206
218
|
|
207
219
|
def this_week()
|
208
220
|
|
209
221
|
dt = DateTime.now
|
210
|
-
days = @calendar.
|
222
|
+
days = @calendar.month(dt.month).day
|
211
223
|
|
212
224
|
r = days.find {|day| day.date.cweek == dt.cweek }
|
213
|
-
pxweek =
|
225
|
+
pxweek = PolyrexObjects::Week.new
|
214
226
|
pxweek.mon = Date::MONTHNAMES[dt.month]
|
215
227
|
pxweek.no = dt.cweek.to_s
|
216
228
|
pxweek.label = ''
|
@@ -239,7 +251,7 @@ class PolyrexCalendarBase
|
|
239
251
|
m, d = dt.month, dt.day
|
240
252
|
record = {title: title, time_start: time_start}
|
241
253
|
|
242
|
-
@calendar.
|
254
|
+
@calendar.month(m).d(d).create.entry record
|
243
255
|
end
|
244
256
|
end
|
245
257
|
|
@@ -259,7 +271,7 @@ class PolyrexCalendarBase
|
|
259
271
|
|
260
272
|
dt = DateTime.parse(event[:date])
|
261
273
|
m, d = dt.month, dt.day
|
262
|
-
@calendar.
|
274
|
+
@calendar.month(m).d(d).method(event_type).call event[:time]
|
263
275
|
end
|
264
276
|
end
|
265
277
|
|
@@ -290,7 +302,7 @@ class PolyrexCalendarBase
|
|
290
302
|
time_end: Time.parse(end_time).strftime("%H:%M%p")
|
291
303
|
}
|
292
304
|
|
293
|
-
@calendar.
|
305
|
+
@calendar.month(m).d(d).create.entry record
|
294
306
|
else
|
295
307
|
|
296
308
|
dt = DateTime.parse(event[:date] + ' ' + event[:time])
|
@@ -299,19 +311,19 @@ class PolyrexCalendarBase
|
|
299
311
|
event[:desc]].compact.join(': ')
|
300
312
|
event_label = "%s at %s" % [title, dt.strftime("%H:%M%p")]
|
301
313
|
|
302
|
-
@calendar.
|
314
|
+
@calendar.month(m).d(d).method(daytype).call event_label
|
303
315
|
end
|
304
316
|
|
305
317
|
else
|
306
318
|
|
307
319
|
event_label = "%s at %s" % [event[:title], dt.strftime("%H:%M%p")]
|
308
|
-
@calendar.
|
320
|
+
@calendar.month(m).d(d).method(daytype).call event_label
|
309
321
|
end
|
310
322
|
|
311
323
|
else
|
312
324
|
|
313
325
|
event_label = "%s" % event[:title]
|
314
|
-
@calendar.
|
326
|
+
@calendar.month(m).d(d).method(daytype).call event_label
|
315
327
|
end
|
316
328
|
|
317
329
|
end
|
@@ -325,7 +337,7 @@ class PolyrexCalendarBase
|
|
325
337
|
|
326
338
|
sd = dt.strftime("%Y-%b-%d ")
|
327
339
|
m, i = dt.month, dt.day
|
328
|
-
cal_day = @calendar.
|
340
|
+
cal_day = @calendar.month(m).d(i)
|
329
341
|
|
330
342
|
cal_day.event = day.title
|
331
343
|
|
@@ -406,4 +418,3 @@ class PolyrexCalendarBase
|
|
406
418
|
end
|
407
419
|
|
408
420
|
end
|
409
|
-
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polyrex_calendarbase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
eGxjKaL2sbouS4fyw4A39SBdlnl+EEAc05wbVgSI3V3Qx6T/opctD22MCO7rCLKx
|
32
32
|
cODimpf9WykDmA==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2014-
|
34
|
+
date: 2014-10-02 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: polyrex
|
metadata.gz.sig
CHANGED
Binary file
|