Skip to content

Commit 574f213

Browse files
committed
170 Implement unscaffold subcommand for automatic-config, show message when loading recipe, fix CI problem
1 parent 86dc07d commit 574f213

File tree

3 files changed

+29
-20
lines changed

3 files changed

+29
-20
lines changed

bin/automatic-config

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ $:.unshift root_dir + '/lib'
1313
require 'automatic'
1414
require 'rubygems'
1515
require 'optparse'
16+
require 'fileutils'
17+
require 'feedbag'
18+
require 'pp'
1619

1720
parser = OptionParser.new { |opt|
1821
}
@@ -25,7 +28,6 @@ end
2528

2629
subparsers = {
2730
'scaffold' => lambda { |argv|
28-
require 'fileutils'
2931
Dir::entries(root_dir + '/plugins').sort.each { |path|
3032
dir = (File.expand_path('~/.automatic/plugins/' + path))
3133
unless File.exist?(dir)
@@ -46,39 +48,42 @@ subparsers = {
4648
puts "Create Directory #{dir}"
4749
end
4850
},
51+
'unscaffold' => lambda { |argv|
52+
dir = (File.expand_path('~/.automatic'))
53+
if File.directory?(dir)
54+
puts "Remove Directory #{dir}"
55+
FileUtils.rm_r(dir)
56+
end
57+
},
4958
'autodiscovery' => lambda { |argv|
50-
require 'pp'
51-
require 'feedbag'
5259
url = argv.shift || abort_with_usage("autodiscovery", "<url>")
5360
pp Feedbag.find(url)
5461
},
55-
'opmlparser' => lambda { |argv|
56-
require 'automatic/opml'
57-
path = argv.shift
58-
if path.nil?
59-
abort_with_usage("opmlparser", "<opml path>")
60-
end
61-
parser = Automatic::OPML::Parser.new(File.read(path))
62-
parser.each_outline {|opml, o|
63-
puts "#{o.xmlUrl}"
64-
}
65-
},
6662
'feedparser' => lambda { |argv|
67-
require 'pp'
6863
require 'automatic/feed_parser'
6964
url = argv.shift || abort_with_usage("feedparser", "<url>")
7065
rss_results = Automatic::FeedParser.get_rss(url)
7166
pp rss_results
7267
},
7368
'inspect' => lambda { |argv|
7469
require 'automatic/feed_parser'
75-
require 'feedbag'
7670
url = argv.shift || abort_with_usage("inspect", "<url>")
7771
feeds = Feedbag.find(url)
7872
pp feeds
7973
rss_results = Automatic::FeedParser.get_rss(feeds.pop)
8074
pp rss_results
8175
},
76+
'opmlparser' => lambda { |argv|
77+
require 'automatic/opml'
78+
pathh = argv.shift
79+
if path.nil?
80+
abort_with_usage("opmlparser", "<opml path>")
81+
end
82+
parser = Automatic::OPML::Parser.new(File.read(path))
83+
parser.each_outline {|opml, o|
84+
puts "#{o.xmlUrl}"
85+
}
86+
},
8287
'log' => lambda { |argv|
8388
require 'automatic/log'
8489
level = argv.shift || abort_with_usage("log", "<level> <message>")

lib/automatic/recipe.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ def initialize(path = "")
1818

1919
def load_recipe(path)
2020
dir = File.join((File.expand_path('~/.automatic/config/')), path)
21-
if File.exist?(dir)
22-
path = dir
23-
end
21+
path = dir if File.exist?(dir)
22+
Automatic::Log.puts("info", "Loading: #{path}")
2423
@procedure = Hashie::Mash.new(YAML.load(File.read(path)))
2524
end
2625

script/build

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,13 @@ test_config() {
4444
$RACK_ROOT/bin/automatic-config $*
4545
}
4646

47-
added_tests() {
47+
test_scaffold() {
4848
test_config scaffold
49+
test_config unscaffold
50+
}
51+
52+
added_tests() {
53+
test -f $HOME/.automatic || test_scaffold
4954
test_config autodiscovery http://blog.id774.net/blogs/
5055
test_config opmlparser "$RACK_ROOT/test/fixtures/sampleOPML.xml"
5156
test_config feedparser http://blog.id774.net/blogs/feed/ > /dev/null

0 commit comments

Comments
 (0)