forked from id774/automaticruby
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathREADME
More file actions
511 lines (378 loc) · 10.3 KB
/
README
File metadata and controls
511 lines (378 loc) · 10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
automaticruby
Name
Automatic Ruby - Ruby framework for the general-purpose automatic processing
Syntax
$ automatic
Specify the start of any recipe
$ automatic -c <recipe>
To view the version number
$ automatic -v
Description
This is a general-purpose automatic processing
ruby framework which can extend the functionality
by plug-ins.
============
Installation
============
[Stable]
$ gem install automatic
$ automatic scaffold
(Make ~/.automatic on your home directory.)
$ automatic -c ~/.automatic/config/example/feed2console.yml
(This process will be output my blog feed to your terminal.)
[Development]
$ git clone git://github.com/automaticruby/automaticruby.git
$ cd automaticruby
$ bundle install --path vendor/gems
$ bin/automatic scaffold
$ bin/automatic -c ~/.automatic/config/example/feed2console.yml
(The same as above.)
===========
Get Started
===========
Create of any recipe (see below).
$ automatic -c your_recipe.yml
-c option to run with the manual. If there is no problem
to automate, register it to cron.
If you specify the-c argument of a simple file name, load
the file located in ~ /.automatic/config. If not exist,
load file as specified in the path.
If ~/.automatic/db exists, plug-ins save the file to this
directory.
If ~/.automatic/plugins exists, the plug-ins be loaded
as well.
This is the easy recipe to simply output blog's feed to
only console. It can be used to check the operation of
this software.
$ automatic -c ~/.automatic/config/example/feed2console.yml
=======
Recipes
=======
Automatic Ruby parses configuration file that was written
in the form of YAML which including variety of information
of associated plug-ins.
This YAML file is called "Recipe".
You can use -c option for specify a file name.
[Example]
$ automatic -c your_recipe.yml
=====================
How to write a Recipe
=====================
The Recipe has an implicit naming convention.
[Syntax]
plugins:
- module: MODULE_NAME
config:
VARIABLES
The following is a example.
plugins:
- module: SubscriptionFeed
config:
feeds:
- http://reretlet.tumblr.com/rss
- module: StorePermalink
config:
db: tumblr.db
- module: FilterImage
- module: FilterTumblrResize
- module: StoreFile
config:
path: /Users/yourname/Desktop/
interval: 1
In the case of sample this recipe.
1. Subscribe to RSS feeds of Tumblr by SubScriptionFeed.
2. Save permalink to database by StorePermalink.
3. Specify the URL of the image by FilterImage and FilterTumblrResize.
4. Downloading image file of Tumblr by StoreFile.
Showing another example as follows.
plugins:
- module: SubscriptionFeed
config:
feeds:
- http://example.com/rss2
- http://hogefuga.com/feed
- module: FilterIgnore
config:
link:
- hoge
- fuga
- module: StorePermalink
config:
db: permalink.db
- module: PublishHatenaBookmark
config:
username: your_hatena_id
password: your_password
interval: 5
In the case of sample this recipe.
1. Subscribe to 2 RSS feeds by SubScriptionFeed.
2. Feed ignore the keyword by FilterIgnore.
3. Save permalink to database by StorePermalink.
4. Social Bookmarking by PublishHatenaBookmark.
(Hatena Bookmark is a most popular social bookmark service
in Japan.)
These have been realized by a combination of plug-ins
a series of processes.
In this way, by simply writing to the recipe and
configuration information for plug-ins, free processing can
be achieved by a combination of multiple plug-ins.
The possibility of infinite depending on the combination
of plug-ins can be realized.
All depending on whether you make a plug-in looks like!
=======
Plug-in
=======
Plug-ins from the plugins directory (see below) will be loaded.
If ~ /.automatic/plugins exists, is loaded into them as well.
Put your own plug-ins in your home directory.
(How to make the plug-in will be described later.)
You can automatically generate a sub-directory for your own plug-ins
with the following command.
$ automatic scaffold
(For a description of automatic subcommands will be described later.)
============================
Directory and file structure
============================
.
|
+-+ bin
| |
| +-- automatic
| The main file for run.
|
+-- config
|
| Describe the recipe information in the form of yaml.
| They called in the argument -c option of Automatic Ruby.
| If you write a new recipe, locate it in the config directory.
|
|
+-+ plugins
| |
| +-- subscription
| | Plug-ins to subscribe to feeds.
| |
| +-- customfeed
| | Plug-ins to generate a custom feed.
| |
| +-- filter
| | Plug-ins to filter the information.
| |
| +-- store
| | Plug-ins to store the information to internally.
| |
| +-- notify
| | Plug-ins to notify the information.
| |
| +-- publish
| Plug-ins to send information to external.
|
| If you write a new plug-in, locate it in the plugins directory.
|
|
+-+ lib
| |
| +-- automatic.rb
| | To the definition of automatic module.
| |
| +-+ automatic
| |
| +-- environment.rb
| | Read the environmental information.
| |
| +-- pipeline.rb
| | To use an object called a pipeline
| | sequentially processing plug-ins in recipes.
| |
| +-- feed_parser.rb
| | To parse the feed.
| |
| +-- log.rb
| | To output logs.
| |
| +-- recipe.rb
| Read a recipes.
|
+-- db
|
| If ~/.automatic/db not exist, save db file here.
|
+-- assets
|
| There are some files that needed in a plug-ins.
| If ~/.automatic/assets exist, takes precedence it.
|
+-+ script
| |
| +-- build
| Run Integration Test that carried out on CI.
|
+-- spec
| Directory for unit tests (Use RSpec).
|
+-+ test
| |
| +-- fixtures
| | Fixtures for test.
| |
| +-- integration
| Directory for the Integration Test.
|
+-+ vendor
| |
| +-- gems
| Bundle installed gem packages.
|
+---+ doc
|
+-- COPYING
| The license for this software.
|
+-- ChangeLog
| Update history.
|
+-- PLUGINS
| Documentation for plug-ins.
|
+-- README
This document.
===========
Development
===========
Repository
https://github.com/automaticruby/automaticruby
Issues
https://github.com/automaticruby/automaticruby/issues
RubyForge
http://rubyforge.org/projects/automatic/
RubyGems.org
https://rubygems.org/gems/automatic
CI
http://jenkins.id774.net/jenkins/
===========
How to Join
===========
1. Fork the repository.
2. Write new plugin or existing code improvement.
3. Send pull request!
After that, we will give you the right to commit for a quick fix finely.
===========
Coding Rule
===========
Coding standards should be completed in 1 file.
Remove trailing spaces.
{} is recommended than do end (To avoid end end end,,).
RDoc Header is written by creator of the file.
Write tests with RSPec.
Aim at 100% coverage.
===================
Automatic::Pipeline
===================
This framework sequentially analyze a plug-ins on yaml recipe.
At this time, pipeline passed instantance as an argument. And then,
pipeline backs again as the return value.
Code is as follows.
pipeline = []
recipe.each_plugin {|plugin|
mod = plugin.module
load_plugin(mod)
klass = Automatic::Plugin.const_get(mod)
pipeline = klass.new(plugin.config, pipeline).run
}
In this iteration, sequential processing can be realized.
This mechanism called "Automatic::Pipeline".
The contents of the pipeline is the array of the feeds.
=============================
Implementation of the plug-in
=============================
Plug-in is loaded by the constructor of YAML.load
Class is recieved the array of hashes as the instance
variable of pipelines object.
Example implementation of the constructor that is recommended
is as follows.
def initialize(config, pipeline=[])
@config = config
@pipeline = pipeline
end
Run an instance method is called automatically. The return value
is on the instance variable @pipeline. And then, be handed over
to the next plug-in in the recipe.
@pipeline's data format should be combined. If the preceding
plug-in will return an RSS feed, you need to write handle the
RSS feed. If the one will return as HTML, you need to write
code to handle HTML.
=========
Unit Test
=========
Unit testing is performed in RSpec.
Test of the plug-in, pass the pipeline which will be the argument,
to check the return value.
============
Binding Test
============
To combine more than one recipe under the test/integration.
Put the recipe for the binding test.
Before you check-in to the repository, run following
command with ruby 1.9.
$ script/build
By this, all RSpec tests and binding tests will be conducted.
You can check-in to the repository after all test successed.
Otherwise, CI will fail.
======================
Continuous Integration
======================
CI is performed in Jenkins.
http://jenkins.id774.net/jenkins/
===========================
Description of the plug-ins
===========================
See doc/PLUGINS.
===========
SubCommands
===========
automatic has the auxiliary tool in subcommands.
[Syntax]
$ automatic
Show help and list of sub-command.
$ automatic scaffold
Make ~/.automatic directory in your home directory.
This operation makes 'plugins', 'db', 'config', 'assets' directories.
These takes precedence the origin directory.
$ automatic unscaffold
Delete ~/.automatic directory.
$ automatic autodiscovery <url>
Return the URL of the feed of target detected by auto discovery.
(ex.)
$ automatic autodiscovery http://blog.id774.net/post
["http://blog.id774.net/post/feed/", "http://blog.id774.net/post/comments/feed/"]
$ automatic opmlparser <opml path>
Output the URLs to parse the OPML file.
(ex.)
$ automatic opmlparser opml.xml > feeds.txt
$ automatic feedparser <url>
Return the contents to parse the feed.
$ automatic inspect <url>
Return the URL of the feed of target detected by auto discovery.
Return the contents to parse the first feed further.
This inspects verify the target subscriptionable.
$ automatic log <level> <message>
Output log messages in the form of Automatic Ruby.
==============
Update History
==============
See doc/ChangeLog.
====
TODO
====
Refer to the issues of github.
https://github.com/automaticruby/automaticruby/issues
===========
Environment
===========
After Ruby 1.9.
Depend on the packages that described in Gemfile.
=====
Notes
=====
To avoid excessive scraping, use in the bounds of common sense.
This software licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.