automatic 12.3.0 → 12.3.1

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.
Files changed (52) hide show
  1. data/Gemfile +1 -0
  2. data/README.md +54 -36
  3. data/Rakefile +14 -0
  4. data/VERSION +1 -1
  5. data/automatic.gemspec +17 -5
  6. data/bin/automatic +37 -3
  7. data/bin/automatic-config +77 -0
  8. data/config/default.yml +9 -12
  9. data/doc/ChangeLog +32 -8
  10. data/doc/PLUGINS +205 -0
  11. data/doc/PLUGINS.ja +2 -3
  12. data/doc/README +488 -0
  13. data/doc/README.ja +195 -131
  14. data/lib/automatic/feed_parser.rb +1 -9
  15. data/lib/automatic/log.rb +1 -9
  16. data/lib/automatic/opml.rb +239 -0
  17. data/lib/automatic/pipeline.rb +16 -10
  18. data/lib/automatic/recipe.rb +3 -4
  19. data/lib/automatic.rb +32 -38
  20. data/lib/config/validator.rb +83 -0
  21. data/plugins/custom_feed/svn_log.rb +1 -1
  22. data/plugins/filter/ignore.rb +9 -1
  23. data/plugins/notify/ikachan.rb +7 -6
  24. data/plugins/publish/hatena_bookmark.rb +6 -9
  25. data/script/build +63 -0
  26. data/spec/lib/automatic/pipeline_spec.rb +55 -0
  27. data/spec/lib/automatic_spec.rb +77 -0
  28. data/spec/lib/pipeline_spec.rb +67 -0
  29. data/spec/plugins/filter/ignore_spec.rb +16 -0
  30. data/spec/plugins/filter/image_spec.rb +4 -4
  31. data/spec/plugins/filter/tumblr_resize_spec.rb +4 -4
  32. data/spec/plugins/notify/ikachan_spec.rb +30 -0
  33. data/spec/plugins/publish/console_spec.rb +1 -2
  34. data/spec/plugins/publish/hatena_bookmark_spec.rb +36 -1
  35. data/spec/plugins/store/full_text_spec.rb +0 -2
  36. data/spec/plugins/store/permalink_spec.rb +0 -1
  37. data/spec/plugins/store/target_link_spec.rb +0 -1
  38. data/spec/plugins/subscription/feed_spec.rb +0 -1
  39. data/spec/spec_helper.rb +6 -4
  40. data/spec/user_dir/plugins/store/mock.rb +12 -0
  41. data/test/fixtures/sampleOPML.xml +11 -0
  42. data/test/integration/test_activerecord.yml +2 -2
  43. data/test/integration/test_fulltext.yml +3 -3
  44. data/test/integration/test_hatenabookmark.yml +6 -2
  45. data/test/integration/test_ignore.yml +4 -1
  46. data/test/integration/test_ignore2.yml +1 -4
  47. data/test/integration/test_image2local.yml +3 -5
  48. data/test/integration/test_svnlog.yml +2 -1
  49. data/test/integration/test_tumblr2local.yml +3 -3
  50. metadata +43 -22
  51. data/utils/auto_discovery.rb +0 -18
  52. data/utils/opml_parser.rb +0 -247
data/utils/opml_parser.rb DELETED
@@ -1,247 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # -*- coding: utf-8 -*-
3
-
4
- require 'rexml/document'
5
- require 'rexml/parsers/pullparser'
6
-
7
- module OPML
8
- def self::unnormalize(text)
9
- text.gsub(/&(\w+);/) {
10
- x = $1
11
- case x
12
- when 'lt'
13
- '<'
14
- when 'gt'
15
- '>'
16
- when 'quot'
17
- '"'
18
- when 'amp'
19
- '&'
20
- when 'apos'
21
- "'"
22
- when /^\#(\d+)$/
23
- [$1.to_i].pack("U")
24
- when /^\#x([0-9a-f]+)$/i
25
- [$1.hex].pack("U")
26
- else
27
- raise "unnormalize error '#{x}'"
28
- end
29
- }
30
- end
31
-
32
- module DOM
33
- class Element
34
- include Enumerable
35
-
36
- def initialize
37
- @attr = {}
38
- @parent = nil
39
- @children = []
40
- end
41
- attr_accessor :parent
42
- attr_reader :attr, :children
43
-
44
- def each
45
- yield self
46
- @children.each {|c|
47
- c.each {|x|
48
- yield x
49
- }
50
- }
51
- end
52
-
53
- def <<(elem)
54
- elem.parent = self if elem.respond_to? :parent=
55
- @children << elem
56
- self
57
- end
58
-
59
- def [](n)
60
- if n.is_a? String
61
- @attr[n]
62
- else
63
- @children[n]
64
- end
65
- end
66
-
67
- def []=(k,v)
68
- if k.is_a? String
69
- @attr[k] = v
70
- else
71
- @children[k] = v
72
- end
73
- end
74
-
75
- def text
76
- @attr['text']
77
- end
78
-
79
- def type
80
- @attr['type']
81
- end
82
-
83
- def is_comment?
84
- @attr['isComment']=='true'
85
- end
86
-
87
- def is_breaakpoint?
88
- @attr['isBreakpoint']=='true'
89
- end
90
- end # Element
91
-
92
- class OPML < Element
93
- def head
94
- @children.find {|x| x.is_a? Head }
95
- end
96
-
97
- def body
98
- @children.find {|x| x.is_a? Body }
99
- end
100
- end
101
-
102
- class Head < Element
103
- end
104
-
105
- class Body < Element
106
- def outline
107
- @children.find {|x| x.is_a? Outline }
108
- end
109
- end
110
-
111
- class Outline < Element
112
- def method_missing(name,*arg,&block)
113
- name = name.to_s
114
- case name
115
- when /^[a-z][0-9a-zA-Z_]*$/
116
- key = name.gsub(/_([a-z])/) {|x| ".#{$1.upcase}" }
117
- @attr[key]
118
- else
119
- raise NoMethodError
120
- end
121
- end
122
- end
123
- end # Model
124
-
125
- class Parser
126
- def initialize(port)
127
- @p = REXML::Parsers::PullParser.new(port)
128
- @opml = nil
129
- end
130
-
131
- def parse_tree
132
- root = cur = nil
133
- while event=@p.pull
134
- case event.event_type
135
- when :xmldecl
136
- encoding = event[1]
137
- when :start_element
138
- case event[0]
139
- when "opml"
140
- root = cur = DOM::OPML.new
141
- when "head"
142
- e = DOM::Head.new
143
- cur << e
144
- cur = e
145
- when "body"
146
- e = DOM::Body.new
147
- cur << e
148
- cur = e
149
- when "outline"
150
- e = DOM::Outline.new
151
- cur << e
152
- cur = e
153
- else
154
- cur['.' + event[0]] = read_text
155
- end
156
- event[1].each {|k,v|
157
- cur[k] = OPML::unnormalize(v)
158
- }
159
- when :end_element
160
- cur = cur.parent
161
- when :text
162
- when :cdata
163
- when :start_doctype
164
- when :end_doctype,:comment
165
- when :end_document
166
- break
167
- else
168
- p event.event_type
169
- p event
170
- raise "unknown event"
171
- end
172
- end # while
173
- root
174
- end # parse_tree
175
-
176
- def each_outline
177
- root = cur = nil
178
- while event=@p.pull
179
- case event.event_type
180
- when :xmldecl
181
- encoding = event[1]
182
- when :start_element
183
- case event[0]
184
- when "opml"
185
- root = cur = DOM::OPML.new
186
- when "head"
187
- e = DOM::Head.new
188
- cur << e
189
- cur = e
190
- when "body"
191
- e = DOM::Body.new
192
- cur << e
193
- cur = e
194
- when "outline"
195
- e = DOM::Outline.new
196
- # cur << e
197
- cur = e
198
- else
199
- cur['_' + event[0]] = read_text
200
- end
201
- event[1].each {|k,v|
202
- cur[k] = OPML::unnormalize(v)
203
- }
204
- if event[0]=="outline"
205
- yield root, cur
206
- end
207
- when :end_element
208
- cur = cur.parent if cur.kind_of? DOM::Element
209
- when :text
210
- when :cdata
211
- when :start_doctype
212
- when :end_doctype,:comment
213
- when :end_document
214
- break
215
- else
216
- p event.event_type
217
- p event
218
- raise "unknown event"
219
- end
220
- end # while
221
- end # each_outline
222
-
223
- def read_text
224
- text = ""
225
- while event = @p.pull
226
- case event.event_type
227
- when :end_element
228
- break
229
- when :text
230
- text << OPML::unnormalize(event[0])
231
- when :cdata
232
- text << event[0]
233
- else
234
- raise
235
- end
236
- end
237
- text
238
- end
239
- end # Parser
240
- end # OPML
241
-
242
- if __FILE__ == $0
243
- parser = OPML::Parser.new(File.read('opml.xml'))
244
- parser.each_outline {|opml, o|
245
- puts "#{o.xmlUrl}"
246
- }
247
- end