automatic 13.2.0 → 13.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/Gemfile +2 -2
  2. data/README.md +15 -3
  3. data/Rakefile +1 -1
  4. data/VERSION +1 -1
  5. data/automatic.gemspec +3 -5
  6. data/bin/automatic +104 -15
  7. data/doc/ChangeLog +9 -0
  8. data/doc/PLUGINS +4 -1
  9. data/doc/PLUGINS.ja +4 -1
  10. data/doc/README +27 -31
  11. data/doc/README.ja +24 -28
  12. data/lib/automatic/feed_parser.rb +1 -1
  13. data/lib/automatic.rb +3 -3
  14. data/plugins/filter/absolute_uri.rb +11 -10
  15. data/plugins/filter/full_feed.rb +16 -14
  16. data/plugins/filter/ignore.rb +18 -16
  17. data/plugins/filter/image.rb +14 -18
  18. data/plugins/filter/image_source.rb +11 -10
  19. data/plugins/filter/tumblr_resize.rb +11 -10
  20. data/plugins/notify/ikachan.rb +4 -4
  21. data/plugins/publish/google_calendar.rb +1 -1
  22. data/plugins/publish/hatena_bookmark.rb +15 -4
  23. data/plugins/publish/instapaper.rb +12 -3
  24. data/plugins/store/target_link.rb +1 -1
  25. data/plugins/subscription/feed.rb +1 -1
  26. data/plugins/subscription/google_reader_star.rb +9 -6
  27. data/plugins/subscription/link.rb +13 -12
  28. data/plugins/subscription/tumblr.rb +13 -12
  29. data/plugins/subscription/twitter.rb +19 -18
  30. data/script/build +14 -12
  31. data/spec/lib/automatic_spec.rb +3 -3
  32. data/spec/plugins/filter/full_feed_spec.rb +88 -5
  33. data/spec/plugins/filter/ignore_spec.rb +2 -1
  34. data/spec/plugins/filter/sort_spec.rb +1 -1
  35. data/spec/plugins/publish/hatena_bookmark_spec.rb +63 -1
  36. data/spec/plugins/publish/instapaper_spec.rb +18 -6
  37. data/spec/plugins/store/target_link_spec.rb +3 -3
  38. data/spec/plugins/subscription/feed_spec.rb +1 -1
  39. data/spec/plugins/subscription/google_reader_star_spec.rb +30 -1
  40. data/spec/plugins/subscription/link_spec.rb +1 -1
  41. data/spec/plugins/subscription/tumblr_spec.rb +1 -1
  42. data/spec/plugins/subscription/twitter_spec.rb +1 -1
  43. data/spec/spec_helper.rb +13 -3
  44. data/test/integration/test_googlestar.yml +13 -0
  45. metadata +2 -5
  46. data/bin/automatic-config +0 -111
  47. data/script/bootstrap +0 -117
@@ -2,7 +2,7 @@
2
2
  # Name:: Automatic::Plugin::Filter::FullFeed
3
3
  # Author:: 774 <http://id774.net>
4
4
  # Created:: Jan 24, 2013
5
- # Updated:: Jan 24, 2013
5
+ # Updated:: Mar 24, 2013
6
6
  # Copyright:: 774 Copyright (c) 2013
7
7
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
8
8
 
@@ -11,7 +11,7 @@ require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
11
11
  require 'filter/full_feed'
12
12
 
13
13
  describe Automatic::Plugin::FilterFullFeed do
14
- context "It should be asc sorted" do
14
+ context "It should be matched by siteinfo" do
15
15
  subject {
16
16
  Automatic::Plugin::FilterFullFeed.new(
17
17
  {
@@ -19,8 +19,8 @@ describe Automatic::Plugin::FilterFullFeed do
19
19
  },
20
20
  AutomaticSpec.generate_pipeline {
21
21
  feed {
22
- item "http://matome.naver.jp/odai/2129948007339738701/2129948085139809603", "",
23
- "",
22
+ item "http://matome.naver.jp/odai/2129948007339738701/2129948085139809603", "hoge",
23
+ "fuga",
24
24
  "Mon, 07 Mar 2011 15:54:11 +0900"
25
25
  }})}
26
26
 
@@ -31,7 +31,7 @@ describe Automatic::Plugin::FilterFullFeed do
31
31
  subject.instance_variable_get(:@pipeline)[0].items[0].link.
32
32
  should == "http://matome.naver.jp/odai/2129948007339738701/2129948085139809603"
33
33
  subject.instance_variable_get(:@pipeline)[0].items[0].description.
34
- should == ""
34
+ should == "fuga"
35
35
 
36
36
  subject.run
37
37
 
@@ -45,4 +45,87 @@ describe Automatic::Plugin::FilterFullFeed do
45
45
  end
46
46
  end
47
47
 
48
+ context "It should be not matched by siteinfo" do
49
+ subject {
50
+ Automatic::Plugin::FilterFullFeed.new(
51
+ {
52
+ 'siteinfo' => "items_all.json"
53
+ },
54
+ AutomaticSpec.generate_pipeline {
55
+ feed {
56
+ item "http://id774.net", "aaaaaa",
57
+ "bbbbbb",
58
+ "Mon, 07 Mar 2011 15:54:11 +0900"
59
+ }})}
60
+
61
+ describe "#run" do
62
+ its(:run) { should have(1).feeds }
63
+
64
+ specify {
65
+ subject.instance_variable_get(:@pipeline)[0].items[0].link.
66
+ should == "http://id774.net"
67
+ subject.instance_variable_get(:@pipeline)[0].items[0].description.
68
+ should == "bbbbbb"
69
+
70
+ subject.run
71
+
72
+ subject.instance_variable_get(:@pipeline)[0].items[0].link.
73
+ should == "http://id774.net"
74
+ subject.instance_variable_get(:@pipeline)[0].items[0].description.
75
+ should == "bbbbbb"
76
+ }
77
+ end
78
+ end
79
+
80
+ context "It should be not matched by siteinfo with local dir" do
81
+ subject {
82
+ Automatic::Plugin::FilterFullFeed.new(
83
+ {
84
+ 'siteinfo' => "items_all.json"
85
+ },
86
+ AutomaticSpec.generate_pipeline {
87
+ feed {
88
+ item "http://id774.net", "cccc",
89
+ "ddddd",
90
+ "Mon, 07 Mar 2011 15:54:11 +0900"
91
+ }})}
92
+
93
+ describe "#run" do
94
+ def cleanup_dir
95
+ root_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", ".."))
96
+ dir = (File.expand_path('~/.automatic/assets/siteinfo'))
97
+ if File.directory?(dir)
98
+ puts "Removing #{dir}"
99
+ FileUtils.rm_r(dir)
100
+ end
101
+ return dir, root_dir
102
+ end
103
+
104
+ before do
105
+ dir, root_dir = cleanup_dir
106
+ FileUtils.mkdir_p(dir)
107
+ FileUtils.cp_r(root_dir + '/assets/siteinfo/items_all.json', dir)
108
+ end
109
+
110
+ its(:run) { should have(1).feeds }
111
+
112
+ specify {
113
+ subject.instance_variable_get(:@pipeline)[0].items[0].link.
114
+ should == "http://id774.net"
115
+ subject.instance_variable_get(:@pipeline)[0].items[0].description.
116
+ should == "ddddd"
117
+
118
+ subject.run
119
+
120
+ subject.instance_variable_get(:@pipeline)[0].items[0].link.
121
+ should == "http://id774.net"
122
+ subject.instance_variable_get(:@pipeline)[0].items[0].description.
123
+ should == "ddddd"
124
+ }
125
+
126
+ after do
127
+ cleanup_dir
128
+ end
129
+ end
130
+ end
48
131
  end
@@ -2,7 +2,7 @@
2
2
  # Name:: Automatic::Plugin::Filter::Ignore
3
3
  # Author:: 774 <http://id774.net>
4
4
  # Updated:: Jan 19, 2013
5
- # Copyright:: 774 Copyright (c) 2012
5
+ # Copyright:: 774 Copyright (c) 2012-2013
6
6
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
7
7
 
8
8
  require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
@@ -144,6 +144,7 @@ describe Automatic::Plugin::FilterIgnore do
144
144
  'description' => ["bbb"],
145
145
  },
146
146
  AutomaticSpec.generate_pipeline {
147
+ # url, title, description, pubDate, author, source, enclosure
147
148
  feed {
148
149
  item "http://hogefuga.com", "",
149
150
  "aaabbbccc"
@@ -3,7 +3,7 @@
3
3
  # Author:: 774 <http://id774.net>
4
4
  # Created:: Mar 23, 2012
5
5
  # Updated:: Jan 23, 2013
6
- # Copyright:: 774 Copyright (c) 2012
6
+ # Copyright:: 774 Copyright (c) 2012-2013
7
7
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
8
8
 
9
9
  require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
@@ -1,3 +1,11 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Name:: Automatic::Plugin::Publish::HatenaBookmark
3
+ # Author:: 774 <http://id774.net>
4
+ # Created:: Feb 22, 2012
5
+ # Updated:: Mar 7, 2013
6
+ # Copyright:: 774 Copyright (c) 2012-2013
7
+ # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
8
+
1
9
  require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
2
10
 
3
11
  require 'publish/hatena_bookmark'
@@ -12,7 +20,61 @@ describe Automatic::Plugin::PublishHatenaBookmark do
12
20
  )
13
21
  }
14
22
 
15
- it "should post the link in the feed" do
23
+ it "should post the link with prefix 'http' in the feed" do
24
+ hb = mock("hb")
25
+ hb.should_receive(:post).with("http://github.com", nil)
26
+ subject.instance_variable_set(:@hb, hb)
27
+ subject.run.should have(1).feed
28
+ end
29
+ end
30
+
31
+ describe Automatic::Plugin::PublishHatenaBookmark do
32
+ subject {
33
+ Automatic::Plugin::PublishHatenaBookmark.new(
34
+ {"username" => "user", "password" => "pswd"},
35
+ AutomaticSpec.generate_pipeline{
36
+ feed { item "//github.com" }
37
+ }
38
+ )
39
+ }
40
+
41
+ it "should post the link with prefix '//...' in the feed" do
42
+ hb = mock("hb")
43
+ hb.should_receive(:post).with("http://github.com", nil)
44
+ subject.instance_variable_set(:@hb, hb)
45
+ subject.run.should have(1).feed
46
+ end
47
+ end
48
+
49
+ describe Automatic::Plugin::PublishHatenaBookmark do
50
+ subject {
51
+ Automatic::Plugin::PublishHatenaBookmark.new(
52
+ {"username" => "user", "password" => "pswd"},
53
+ AutomaticSpec.generate_pipeline{
54
+ feed { item "https://github.com" }
55
+ }
56
+ )
57
+ }
58
+
59
+ it "should post the link with prefix 'https' in the feed" do
60
+ hb = mock("hb")
61
+ hb.should_receive(:post).with("https://github.com", nil)
62
+ subject.instance_variable_set(:@hb, hb)
63
+ subject.run.should have(1).feed
64
+ end
65
+ end
66
+
67
+ describe Automatic::Plugin::PublishHatenaBookmark do
68
+ subject {
69
+ Automatic::Plugin::PublishHatenaBookmark.new(
70
+ {"username" => "user", "password" => "pswd"},
71
+ AutomaticSpec.generate_pipeline{
72
+ feed { item "github.com" }
73
+ }
74
+ )
75
+ }
76
+
77
+ it "should post the link with others in the feed" do
16
78
  hb = mock("hb")
17
79
  hb.should_receive(:post).with("http://github.com", nil)
18
80
  subject.instance_variable_set(:@hb, hb)
@@ -1,8 +1,9 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Name:: Automatic::Plugin::Publish::Instapaper
3
3
  # Author:: soramugi <http://soramugi.net>
4
+ # 774 <http://id774.net>
4
5
  # Created:: Feb 9, 2013
5
- # Updated:: Feb 9, 2013
6
+ # Updated:: Mar 22, 2013
6
7
  # Copyright:: soramugi Copyright (c) 2013
7
8
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
8
9
 
@@ -13,7 +14,11 @@ require 'publish/instapaper'
13
14
  describe Automatic::Plugin::PublishInstapaper do
14
15
  subject {
15
16
  Automatic::Plugin::PublishInstapaper.new(
16
- {"email" => "email@example.com", "password" => "pswd"},
17
+ { 'email' => "email@example.com",
18
+ 'password' => "pswd",
19
+ 'interval' => 5,
20
+ 'retry' => 5
21
+ },
17
22
  AutomaticSpec.generate_pipeline{
18
23
  feed { item "http://github.com" }
19
24
  }
@@ -31,11 +36,18 @@ end
31
36
  describe Automatic::Plugin::Instapaper do
32
37
  describe "#add" do
33
38
  subject {
34
- Automatic::Plugin::Instapaper.new("email@example.com", "pswd")
39
+ Automatic::Plugin::Instapaper.new(
40
+ { 'email' => "email@example.com",
41
+ 'password' => "pswd",
42
+ 'interval' => 5,
43
+ 'retry' => 5
44
+ }
45
+ )
35
46
  }
36
- url = "http://www.google.com"
37
- title = "automatic test"
38
- description = "automatic test"
47
+
48
+ url = "http://www.google.com"
49
+ title = "automatic test"
50
+ description = "automatic test"
39
51
 
40
52
  specify {
41
53
  res = stub("res")
@@ -3,8 +3,8 @@
3
3
  # Author:: kzgs
4
4
  # 774 <http://id774.net>
5
5
  # Created:: Mar 4, 2012
6
- # Updated:: Feb 9, 2013
7
- # Copyright:: kzgs Copyright (c) 2012
6
+ # Updated:: Apr 3, 2013
7
+ # Copyright:: kzgs Copyright (c) 2012-2013
8
8
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
9
9
 
10
10
  require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
@@ -19,7 +19,7 @@ describe Automatic::Plugin::StoreTargetLink do
19
19
  instance = Automatic::Plugin::StoreTargetLink.new(
20
20
  { "path" => dir },
21
21
  AutomaticSpec.generate_pipeline {
22
- feed { item "http://digithoughts.com/rss" }
22
+ feed { item "http://id774.net/test/store/rss" }
23
23
  }
24
24
  )
25
25
  instance.run.should have(1).feed
@@ -2,7 +2,7 @@
2
2
  # Name:: Automatic::Plugin::Subscription::Feed
3
3
  # Author:: 774 <http://id774.net>
4
4
  # Updated:: Feb 8, 2013
5
- # Copyright:: 774 Copyright (c) 2012
5
+ # Copyright:: 774 Copyright (c) 2012-2013
6
6
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
7
7
 
8
8
  require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
@@ -1,8 +1,9 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Name:: Automatic::Plugin::Subscription::GoogleReaderStar
3
3
  # Author:: soramugi <http://soramugi.net>
4
+ # 774 <http://id774.net>
4
5
  # Created:: Feb 10, 2013
5
- # Updated:: Feb 10, 2013
6
+ # Updated:: Feb 17, 2013
6
7
  # Copyright:: soramugi Copyright (c) 2013
7
8
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
8
9
 
@@ -42,4 +43,32 @@ describe Automatic::Plugin::SubscriptionGoogleReaderStar do
42
43
 
43
44
  its(:run) { should have(1).feed }
44
45
  end
46
+
47
+ context "with retry to feeds whose valid URL" do
48
+ subject {
49
+ Automatic::Plugin::SubscriptionGoogleReaderStar.new(
50
+ { 'feeds' => [
51
+ "http://www.google.com/reader/public/atom/user%2F00482198897189159802%2Fstate%2Fcom.google%2Fstarred"],
52
+ 'retry' => 3,
53
+ 'interval' => 5
54
+ }
55
+ )
56
+ }
57
+
58
+ its(:run) { should have(1).feed }
59
+ end
60
+
61
+ context "with retry to feeds whose invalid URL" do
62
+ subject {
63
+ Automatic::Plugin::SubscriptionGoogleReaderStar.new(
64
+ { 'feeds' => ["invalid_url"],
65
+ 'retry' => 1,
66
+ 'interval' => 1
67
+ }
68
+ )
69
+ }
70
+
71
+ its(:run) { should be_empty }
72
+ end
73
+
45
74
  end
@@ -3,7 +3,7 @@
3
3
  # Author:: 774 <http://id774.net>
4
4
  # Created:: Sep 18, 2012
5
5
  # Updated:: Feb 8, 2013
6
- # Copyright:: 774 Copyright (c) 2012
6
+ # Copyright:: 774 Copyright (c) 2012-2013
7
7
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
8
8
 
9
9
  require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
@@ -3,7 +3,7 @@
3
3
  # Author:: 774 <http://id774.net>
4
4
  # Created:: Oct 16, 2012
5
5
  # Updated:: Feb 8, 2013
6
- # Copyright:: 774 Copyright (c) 2012
6
+ # Copyright:: 774 Copyright (c) 2012-2013
7
7
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
8
8
 
9
9
  require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
@@ -3,7 +3,7 @@
3
3
  # Author:: 774 <http://id774.net>
4
4
  # Created:: Sep 10, 2012
5
5
  # Updated:: Feb 8, 2013
6
- # Copyright:: 774 Copyright (c) 2012
6
+ # Copyright:: 774 Copyright (c) 2012-2013
7
7
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
8
8
 
9
9
  require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Name:: Automatic::Spec
3
- # Updated:: Sep 18, 2012
3
+ # Updated:: Mar 14, 2013
4
4
 
5
5
  APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), ".."))
6
6
  $LOAD_PATH.unshift APP_ROOT
@@ -28,7 +28,7 @@ require 'lib/automatic'
28
28
  # in ./support/ and its subdirectories.
29
29
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
30
30
 
31
- unless /^1\.9\./ =~ RUBY_VERSION
31
+ if /^1\.8\./ =~ RUBY_VERSION
32
32
  require 'rspec'
33
33
  end
34
34
 
@@ -83,12 +83,22 @@ module AutomaticSpec
83
83
  rss
84
84
  end
85
85
 
86
- def item(url, title="", description="", date="")
86
+ def item(url,
87
+ title="",
88
+ description="",
89
+ date="",
90
+ author="",
91
+ source="",
92
+ enclosure=""
93
+ )
87
94
  i = RSS::Rss::Channel::Item.new
88
95
  i.link = url
89
96
  i.title = title unless title.blank?
90
97
  i.instance_variable_set(:@description, description)
91
98
  i.pubDate = date unless date.blank?
99
+ i.author = author unless author.blank?
100
+ i.source = source unless source.blank?
101
+ i.enclosure = enclosure unless enclosure.blank?
92
102
  @channel.items << i
93
103
  end
94
104
  end
@@ -11,6 +11,19 @@ plugins:
11
11
  feeds:
12
12
  - http://www.google.com/reader/public/atom/user%2F00482198897189159802%2Fstate%2Fcom.google%2Fstarred
13
13
 
14
+ - module: SubscriptionGoogleReaderStar
15
+ config:
16
+ feeds:
17
+ - http://www.google.com/reader/public/atom/user%2F00482198897189159802%2Fstate%2Fcom.google%2Fstarred
18
+ internal: 1
19
+
20
+ - module: SubscriptionGoogleReaderStar
21
+ config:
22
+ feeds:
23
+ - http://www.google.com/reader/public/atom/user%2F00482198897189159802%2Fstate%2Fcom.google%2Fstarred
24
+ internal: 5
25
+ retry: 5
26
+
14
27
  - module: StorePermalink
15
28
  config:
16
29
  db: test_googlestar.db
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: automatic
3
3
  version: !ruby/object:Gem::Version
4
- version: 13.2.0
4
+ version: 13.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-13 00:00:00.000000000 Z
12
+ date: 2013-04-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sqlite3
@@ -207,7 +207,6 @@ description: Ruby General Automation Framework
207
207
  email: idnanashi@gmail.com
208
208
  executables:
209
209
  - automatic
210
- - automatic-config
211
210
  extensions: []
212
211
  extra_rdoc_files:
213
212
  - README.md
@@ -219,7 +218,6 @@ files:
219
218
  - assets/siteinfo/items_all.json
220
219
  - automatic.gemspec
221
220
  - bin/automatic
222
- - bin/automatic-config
223
221
  - config/feed2console.yml
224
222
  - db/.gitkeep
225
223
  - doc/AUTHORS
@@ -260,7 +258,6 @@ files:
260
258
  - plugins/subscription/link.rb
261
259
  - plugins/subscription/tumblr.rb
262
260
  - plugins/subscription/twitter.rb
263
- - script/bootstrap
264
261
  - script/build
265
262
  - spec/fixtures/sampleRecipe.yml
266
263
  - spec/lib/automatic/pipeline_spec.rb
data/bin/automatic-config DELETED
@@ -1,111 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # -*- coding: utf-8 -*-
3
- # Name:: Automatic::Ruby
4
- # Author:: kzgs
5
- # 774 <http://id774.net>
6
- # Created:: Mar 11, 2012
7
- # Updated:: Jan 24, 2013
8
- # Copyright:: kzgs Copyright (c) 2012-2013
9
- # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
10
-
11
- root_dir = File.expand_path("..", File.dirname(__FILE__))
12
- $:.unshift root_dir + '/lib'
13
-
14
- require 'automatic'
15
- require 'rubygems'
16
- require 'optparse'
17
- require 'fileutils'
18
- require 'feedbag'
19
- require 'pp'
20
-
21
- parser = OptionParser.new { |opt|
22
- }
23
- parser.version = Automatic.const_get(:VERSION)
24
-
25
- def abort_with_usage(subcommand, message)
26
- top_filename = File.basename($0)
27
- abort("Usage: #{top_filename} #{subcommand} #{message}")
28
- end
29
-
30
- subparsers = {
31
- 'scaffold' => lambda { |argv|
32
- Dir::entries(root_dir + '/plugins').sort.each { |path|
33
- dir = (File.expand_path('~/.automatic/plugins/' + path))
34
- unless File.exist?(dir)
35
- FileUtils.mkdir_p(dir)
36
- puts "Creating #{dir}"
37
- end
38
- }
39
- dir = (File.expand_path('~/.automatic/assets'))
40
- unless File.exist?(dir)
41
- FileUtils.mkdir_p(dir)
42
- FileUtils.cp_r(root_dir + '/assets/siteinfo', dir + '/siteinfo')
43
- puts "Creating #{dir}"
44
- end
45
- dir = (File.expand_path('~/.automatic/config'))
46
- unless File.exist?(dir)
47
- FileUtils.mkdir_p(dir)
48
- FileUtils.cp_r(root_dir + '/config', dir + '/example')
49
- puts "Creating #{dir}"
50
- end
51
- dir = (File.expand_path('~/.automatic/db'))
52
- unless File.exist?(dir)
53
- FileUtils.mkdir_p(dir)
54
- puts "Creating #{dir}"
55
- end
56
- },
57
- 'unscaffold' => lambda { |argv|
58
- dir = (File.expand_path('~/.automatic'))
59
- if File.directory?(dir)
60
- puts "Removing #{dir}"
61
- FileUtils.rm_r(dir)
62
- end
63
- },
64
- 'autodiscovery' => lambda { |argv|
65
- url = argv.shift || abort_with_usage("autodiscovery", "<url>")
66
- pp Feedbag.find(url)
67
- },
68
- 'feedparser' => lambda { |argv|
69
- require 'automatic/feed_parser'
70
- url = argv.shift || abort_with_usage("feedparser", "<url>")
71
- rss_results = Automatic::FeedParser.get(url)
72
- pp rss_results
73
- },
74
- 'inspect' => lambda { |argv|
75
- require 'automatic/feed_parser'
76
- url = argv.shift || abort_with_usage("inspect", "<url>")
77
- feeds = Feedbag.find(url)
78
- pp feeds
79
- rss_results = Automatic::FeedParser.get(feeds.pop)
80
- pp rss_results
81
- },
82
- 'opmlparser' => lambda { |argv|
83
- require 'automatic/opml'
84
- path = argv.shift
85
- if path.nil?
86
- abort_with_usage("opmlparser", "<opml path>")
87
- end
88
- parser = Automatic::OPML::Parser.new(File.read(path))
89
- parser.each_outline {|opml, o|
90
- puts "#{o.xmlUrl}"
91
- }
92
- },
93
- 'log' => lambda { |argv|
94
- require 'automatic/log'
95
- level = argv.shift || abort_with_usage("log", "<level> <message>")
96
- message = ARGV.shift
97
- Automatic::Log.puts(level, message)
98
- }
99
- }
100
-
101
- parser.order!(ARGV)
102
-
103
- if ARGV.empty?
104
- puts "Available commands: #{subparsers.keys.join(", ")}"
105
- exit 1
106
- end
107
-
108
- Hash.new { |h, k|
109
- puts "No such subcommand: #{k}"
110
- exit 1
111
- }.update(subparsers)[ARGV.shift].call(ARGV)