seiya 0.0.7 → 0.0.7.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.
- checksums.yaml +4 -4
- data/lib/seiya/contrib/commands/crawl.rb +29 -9
- data/lib/seiya/task.rb +4 -0
- data/lib/seiya/version.rb +1 -1
- data/lib/seiya.rb +40 -16
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9964852e3ba6851acdab2537d026e800d0b6c24f
|
|
4
|
+
data.tar.gz: da4abe61167d4688170eb5ba35994d39457d80c5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 123eed1fdbe3d0c4f7280f8b565a93c43f57cddd40be0404245bc512edb4eb24997e7e19c47884296dba674c8116a87ee68fb6af84eccddc665708b7494b2bfb
|
|
7
|
+
data.tar.gz: 2bc95f18d099db390bc3ee8c45f4a5e09ec9571a659c7a596c327c531d04cf32e23f8c6203a4fbb675e86fc14c2b6188a2a9cefdf8580f554ac1c20f20a48f5d
|
|
@@ -18,19 +18,22 @@ Run a task
|
|
|
18
18
|
Options
|
|
19
19
|
=======
|
|
20
20
|
--help, -h show this help message and exit
|
|
21
|
-
-a NAME=VALUE set task argument (may be repeated)
|
|
21
|
+
-a NAME=VALUE set task argument (may be repeated)
|
|
22
|
+
--list, -l show task list in this project'
|
|
22
23
|
end
|
|
23
24
|
|
|
24
|
-
def
|
|
25
|
-
|
|
25
|
+
def print_task_list
|
|
26
|
+
task_list = Seiya.tasks.map do |k, v|
|
|
27
|
+
'%-14s%-30s' % [k, v]
|
|
28
|
+
end.join("\n")
|
|
29
|
+
puts "Task list
|
|
30
|
+
=========
|
|
26
31
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
exit!
|
|
31
|
-
end
|
|
32
|
-
task_class = Seiya.get_task_class task_name
|
|
32
|
+
#{task_list}
|
|
33
|
+
"
|
|
34
|
+
end
|
|
33
35
|
|
|
36
|
+
def run(*args)
|
|
34
37
|
options = {}
|
|
35
38
|
OptionParser.new do |opts|
|
|
36
39
|
opts.banner = 'Usage: seiya [options]'
|
|
@@ -39,8 +42,25 @@ Options
|
|
|
39
42
|
options[:args] = [] unless options[:args]
|
|
40
43
|
options[:args] << a
|
|
41
44
|
end
|
|
45
|
+
|
|
46
|
+
opts.on '-l', '--list', 'list tasks' do |l|
|
|
47
|
+
options[:list] = l
|
|
48
|
+
end
|
|
42
49
|
end.parse!
|
|
43
50
|
|
|
51
|
+
if options[:list]
|
|
52
|
+
print_task_list
|
|
53
|
+
exit 0
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
task_name = args.shift
|
|
57
|
+
if task_name.nil?
|
|
58
|
+
puts 'Need a task_name'
|
|
59
|
+
exit!
|
|
60
|
+
end
|
|
61
|
+
task_class = Seiya.get_task_class task_name
|
|
62
|
+
|
|
63
|
+
|
|
44
64
|
_args = options[:args] ? options[:args] : []
|
|
45
65
|
|
|
46
66
|
task = task_class.new *_args
|
data/lib/seiya/task.rb
CHANGED
data/lib/seiya/version.rb
CHANGED
data/lib/seiya.rb
CHANGED
|
@@ -34,6 +34,18 @@ module Seiya
|
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
+
def get_klasses(const_path, super_clazz = Object)
|
|
38
|
+
require_str, const_str = const_path.split '|'
|
|
39
|
+
_module = get_const require_str, const_str
|
|
40
|
+
|
|
41
|
+
_module.constants.select do |c|
|
|
42
|
+
const = _module.const_get(c)
|
|
43
|
+
const.is_a? Class and const < super_clazz
|
|
44
|
+
end.map do |c|
|
|
45
|
+
_module.const_get c
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
37
49
|
def extend_load_path(path)
|
|
38
50
|
Dir.foreach path do |f|
|
|
39
51
|
unless %w(. ..).include? f
|
|
@@ -80,18 +92,27 @@ module Seiya
|
|
|
80
92
|
# ignored
|
|
81
93
|
end
|
|
82
94
|
|
|
83
|
-
@commands = commands.map do |
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const = _module.const_get(c)
|
|
88
|
-
const.is_a? Class and const < Command
|
|
89
|
-
end
|
|
90
|
-
clazz_symbols.map do |c|
|
|
91
|
-
clazz = _module.const_get c
|
|
92
|
-
[clazz.name.underscore.split('/').last.to_sym, clazz.new]
|
|
95
|
+
@commands = commands.map do |const_path|
|
|
96
|
+
klasses = get_klasses(const_path, Command)
|
|
97
|
+
klasses.map do |klass|
|
|
98
|
+
[klass.name.underscore.split('/').last.to_sym, klass.new]
|
|
93
99
|
end
|
|
94
100
|
end.flatten(1).to_h
|
|
101
|
+
|
|
102
|
+
task_klasses = get_klasses('tasks|Tasks', Task)
|
|
103
|
+
@task_klasses = task_klasses.map do |klass|
|
|
104
|
+
[klass.name.underscore.split('/').last.to_sym, klass]
|
|
105
|
+
end.to_h
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def tasks
|
|
109
|
+
if @task_klasses.nil?
|
|
110
|
+
setup
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
@task_klasses.map do |k, v|
|
|
114
|
+
[k, v.summary]
|
|
115
|
+
end.to_h
|
|
95
116
|
end
|
|
96
117
|
|
|
97
118
|
def run_command(command, *args)
|
|
@@ -129,14 +150,17 @@ Use "seiya <command> -h" to see more info about a command
|
|
|
129
150
|
end
|
|
130
151
|
|
|
131
152
|
def get_task_class(task_name)
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
153
|
+
if @task_klasses.nil?
|
|
154
|
+
setup
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
task_name = task_name.to_sym
|
|
158
|
+
unless @task_klasses.key? task_name
|
|
159
|
+
puts "Task #{task_name} does not exist!"
|
|
138
160
|
exit!
|
|
139
161
|
end
|
|
162
|
+
|
|
163
|
+
@task_klasses[task_name]
|
|
140
164
|
end
|
|
141
165
|
|
|
142
166
|
def gen_project_file(project_name)
|