Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
executable file
·
141 lines (133 loc) · 3.79 KB

File metadata and controls

executable file
·
141 lines (133 loc) · 3.79 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# Name:: Automatic::Ruby
# Author:: 774 <http://id774.net>
# Created:: Feb 18, 2012
# Updated:: Feb 21, 2014
# Copyright:: Copyright (c) 2012-2014 Automatic Ruby Developers.
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
root_dir = File.expand_path("..", File.dirname(__FILE__))
$:.unshift root_dir
$:.unshift root_dir + '/lib'
require 'automatic'
require 'rubygems'
require 'optparse'
require 'fileutils'
require 'feedbag'
require 'pp'
recipe_path = ""
def abort_with_usage(subcommand, message)
top_filename = File.basename($0)
abort("Usage: #{top_filename} #{subcommand} #{message}")
end
subparsers = {
'scaffold' => lambda {|argv|
Dir::entries(root_dir + '/plugins').sort.each {|path|
dir = (File.expand_path('~/.automatic/plugins/' + path))
unless File.exist?(dir)
FileUtils.mkdir_p(dir)
puts "Creating #{dir}"
end
}
dir = (File.expand_path('~/.automatic/assets'))
unless File.exist?(dir)
FileUtils.mkdir_p(dir)
FileUtils.cp_r(root_dir + '/assets/siteinfo', dir + '/siteinfo')
puts "Creating #{dir}"
end
dir = (File.expand_path('~/.automatic/config'))
unless File.exist?(dir)
FileUtils.mkdir_p(dir)
FileUtils.cp_r(root_dir + '/config', dir + '/example')
puts "Creating #{dir}"
end
dir = (File.expand_path('~/.automatic/db'))
unless File.exist?(dir)
FileUtils.mkdir_p(dir)
puts "Creating #{dir}"
end
},
'unscaffold' => lambda {|argv|
dir = (File.expand_path('~/.automatic'))
if File.directory?(dir)
puts "Removing #{dir}"
FileUtils.rm_r(dir)
end
},
'autodiscovery' => lambda {|argv|
url = argv.shift || abort_with_usage("autodiscovery", "<url>")
pp Feedbag.find(url)
},
'feedparser' => lambda {|argv|
require 'automatic/feed_parser'
url = argv.shift || abort_with_usage("feedparser", "<url>")
rss_results = Automatic::FeedParser.get_url(url)
pp rss_results
},
'inspect' => lambda {|argv|
require 'automatic/feed_parser'
url = argv.shift || abort_with_usage("inspect", "<url>")
feeds = Feedbag.find(url)
pp feeds
rss_results = Automatic::FeedParser.get_url(feeds.pop)
pp rss_results
},
'opmlparser' => lambda {|argv|
require 'automatic/opml'
path = argv.shift
if path.nil?
abort_with_usage("opmlparser", "<opml path>")
end
parser = Automatic::OPML::Parser.new(File.read(path))
parser.each_outline {|opml, o|
puts "#{o.xmlUrl}"
}
},
'log' => lambda {|argv|
require 'automatic/log'
level = argv.shift || abort_with_usage("log", "<level> <message>")
message = ARGV.shift
Automatic::Log.puts(level, message)
}
}
parser = OptionParser.new {|parser|
parser.version = Automatic.const_get(:VERSION)
parser.banner = "Automatic #{parser.version}
Usage: automatic [options] [subcommand]"
parser.separator "SubCommands:"
subparsers.keys.each {|key|
parser.separator " " + key
}
#{subparsers.keys.join(", ")}"
parser.separator "Options:"
parser.on('-c', '--config FILE', String,
"recipe YAML file"){|c| recipe_path = c}
parser.on('-h', '--help', "show this message") {
puts parser
exit 1
}
}
begin
Automatic::Log.puts("info", "Loading #{recipe_path}") unless recipe_path.empty?
parser.parse!
rescue OptionParser::ParseError => err
$stderr.puts err.message
$stderr.puts parser.help
exit 2
end
unless recipe_path.to_s.empty?
recipe = Automatic::Recipe.new(recipe_path)
Automatic.run(:recipe => recipe,
:root_dir => root_dir)
else
parser.order!(ARGV)
unless ARGV.empty?
Hash.new {|h, k|
puts "No such subcommand: #{k}"
exit 1
}.update(subparsers)[ARGV.shift].call(ARGV)
else
puts parser
exit 1
end
end
Morty Proxy This is a proxified and sanitized view of the page, visit original site.