liveblog 0.9.9 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20c20b2aa9d5e0be4711035e111a696981494f0f
4
- data.tar.gz: 4b853b6639ef36c6753757ceef2e48d62c01fe09
3
+ metadata.gz: 669ca13e2b010df1a25cd13f1f73f3d2bf8e6e11
4
+ data.tar.gz: f982be782bd5d907f999fd1f3c7d57ce313fc11c
5
5
  SHA512:
6
- metadata.gz: 6879bbeea21e4e732cd98bfdf159c2267cb7756f4385c9447fac29e97d199c903b604d8741a2e8289b009b71361c3b42d7e7c1f01a991d73bde3a88ac5fabc23
7
- data.tar.gz: d881d27c9a20ea8a4994fdd17f4e9e16348681eafe331e69fdc042a2cf1513dabf060b5147ab04873a7158a62d6be7fce0423443e6f6247517943f3bf280b404
6
+ metadata.gz: e3a46da80daa9240f12ac2de859533fb51a8dc63b3694035827deb33f4c575dadb623e4670d5b69f1ac49d3113801ab4f6884fb64b84c67cccaeb4c7edd20226
7
+ data.tar.gz: ee3903ecfbbbbf0e807169f97f0ee7fed514709c60c802fc2f0690811af723dbe947c82748c9d3bfa6eff877a23c9184cbcb279908e4a2d41fcb2c5409ae651b
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/liveblog.rb CHANGED
@@ -13,7 +13,7 @@ class LiveBlog
13
13
 
14
14
  # the config can either be a hash, a config filepath, or nil
15
15
  #
16
- def initialize(x=nil, config: nil, date: Date.today)
16
+ def initialize(x=nil, config: nil, date: Date.today, plugins: {})
17
17
 
18
18
  config = if x or config then
19
19
 
@@ -55,6 +55,19 @@ class LiveBlog
55
55
  link_today()
56
56
 
57
57
  end
58
+
59
+ # intialize plugins
60
+
61
+ @plugins = plugins.inject([]) do |r, plugin|
62
+
63
+ name, settings = plugin
64
+ return r if settings[:active] == false and !settings[:active]
65
+
66
+ klass_name = 'LiveBlogPlugin' + name.to_s.split(/[-_]/).map{|x| x.capitalize}.join
67
+
68
+ r << Kernel.const_get(klass_name).new(settings: settings, variables: @variables)
69
+
70
+ end
58
71
 
59
72
  end
60
73
 
@@ -183,8 +196,17 @@ EOF
183
196
  record_found = find_hashtag hashtag
184
197
 
185
198
  if record_found then
199
+
186
200
  record_found.x = entry
187
201
  save()
202
+
203
+ @plugins.each do |x|
204
+
205
+ if x.respond_to? :on_update_entry then
206
+ x.on_update_section(raw_entry, hashtag)
207
+ end
208
+
209
+ end
188
210
  [true]
189
211
  else
190
212
  [false, 'record for #' + hashtag + ' not found.']
@@ -203,19 +225,36 @@ EOF
203
225
  return [false, 'rec not found'] unless rec
204
226
 
205
227
  rec.x += "\n\n" + raw_entry.chomp + "\n"
228
+
229
+ @plugins.each do |x|
230
+
231
+ if x.respond_to? :on_new_section_entry then
232
+ x.on_new_section_entry(raw_entry, hashtag)
233
+ end
234
+
235
+ end
236
+
206
237
  [true, 'entry added to section ' + hashtag]
207
238
  end
208
239
 
209
240
  def add_section(raw_entry, hashtag)
210
241
 
211
242
  records = @dx.records
243
+
212
244
  uid = if records then
213
245
  r = records.max_by {|k,v| v[:uid].to_i}
214
246
  r ? r[1][:uid].succ : '1'
215
247
  else
216
248
  '1'
217
249
  end
218
- @dx.create({x: raw_entry.sub(/(#\w+)$/){|x| x.downcase}}, hashtag.downcase, custom_attributes: {uid: uid})
250
+
251
+ @dx.create({x: raw_entry.sub(/(#\w+)$/){|x| x.downcase}}, \
252
+ hashtag.downcase, custom_attributes: {uid: uid})
253
+
254
+ @plugins.each do |x|
255
+ x.on_new_section(raw_entry, hashtag) if x.respond_to? :on_new_section
256
+ end
257
+
219
258
  [true, 'section added']
220
259
  end
221
260
 
@@ -431,7 +470,7 @@ EOF
431
470
  dx.pubdate = rss_timestamp(summary.text('published'))
432
471
  dx.lastbuild_date = Time.now.strftime("%a, %-d %b %Y %H:%M:%S %Z")
433
472
  dx.lang = @rss_lang
434
-
473
+
435
474
  doc.root.xpath('records/section/section/details').each do |x|
436
475
 
437
476
  next if x.elements.empty?
@@ -495,4 +534,4 @@ EOF
495
534
  nil
496
535
  end
497
536
  end
498
- end
537
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liveblog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.9
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  WoOSxvsTN7qoA8F0W4mkDpf+HhHxBOLTPykcHMIlx2gILLnNraaZ1rJlZAqWABGj
32
32
  v8lGgeeqqjd5QA==
33
33
  -----END CERTIFICATE-----
34
- date: 2015-05-12 00:00:00.000000000 Z
34
+ date: 2015-06-11 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: dynarex
@@ -42,7 +42,7 @@ dependencies:
42
42
  version: '1.5'
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
- version: 1.5.20
45
+ version: 1.5.23
46
46
  type: :runtime
47
47
  prerelease: false
48
48
  version_requirements: !ruby/object:Gem::Requirement
@@ -52,7 +52,7 @@ dependencies:
52
52
  version: '1.5'
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: 1.5.20
55
+ version: 1.5.23
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: martile
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -62,7 +62,7 @@ dependencies:
62
62
  version: '0.5'
63
63
  - - ">="
64
64
  - !ruby/object:Gem::Version
65
- version: 0.5.11
65
+ version: 0.5.20
66
66
  type: :runtime
67
67
  prerelease: false
68
68
  version_requirements: !ruby/object:Gem::Requirement
@@ -72,27 +72,27 @@ dependencies:
72
72
  version: '0.5'
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 0.5.11
75
+ version: 0.5.20
76
76
  - !ruby/object:Gem::Dependency
77
77
  name: simple-config
78
78
  requirement: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.3'
82
+ version: '0.6'
83
83
  - - ">="
84
84
  - !ruby/object:Gem::Version
85
- version: 0.3.1
85
+ version: 0.6.0
86
86
  type: :runtime
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
89
89
  requirements:
90
90
  - - "~>"
91
91
  - !ruby/object:Gem::Version
92
- version: '0.3'
92
+ version: '0.6'
93
93
  - - ">="
94
94
  - !ruby/object:Gem::Version
95
- version: 0.3.1
95
+ version: 0.6.0
96
96
  - !ruby/object:Gem::Dependency
97
97
  name: subunit
98
98
  requirement: !ruby/object:Gem::Requirement
metadata.gz.sig CHANGED
@@ -1,3 +1 @@
1
- X<��=��Ė��������w�yՆC}w�����ʍL�Sh
2
- pR���IR(����_���Z���Zp��}�0�Z�e�U�"����w��������$�%C���ʗ���n�!~����ě���3"ƒ�~7�K�=����i�發�$��j����=�fI=y��!�H��KgQ:Y�"՞��W�#�ݡ-�$��?F[UR��
3
- ���VQ>��f��DЛ柗6uV�M�C�}��
1
+ a-�SU���}��)� �\Pʎio\�F�4�t/��WzQ�]�+����ݥ��<�w@e�\ t�a$͡�cP���qgP��2�����a��������Eމ���Lޥ��oKL��ƍU?��Cѡi���)��s�&e'�*��� �˯H���㪴�oae���ğ���O����E�zG�3��;�ĚOM��5=4Z�F��!�UoRϡ��� s(���[!�~���{m��P ����3�>���_>�A�