cyborg 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/cyborg +11 -9
- data/lib/cyborg.rb +0 -51
- data/lib/cyborg/command.rb +38 -12
- data/lib/cyborg/command/help.rb +22 -18
- data/lib/cyborg/version.rb +1 -1
- 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: 07256e2ad9fe07490476d23e2c00d348d78a8f7e
|
4
|
+
data.tar.gz: e46a29def80e707128522a6190d069c6704ba78b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f0d968eae626ade7d658a0d72b31cce7d563362548f433c1474244b7ebf265b5d583f3ae2fea887a2c103e8757568bf73afdaea26738a2615a24df7f210ce4f
|
7
|
+
data.tar.gz: 77706d396805e4dada36d0cc3283ddaf9fd7f0224f565a3750bf4fc6a341704eb4bd1e58c3a13ccbad4b0cf12111e90cd86e39cbefe0b9c145e07459eb8d3729
|
data/bin/cyborg
CHANGED
@@ -15,7 +15,7 @@ end
|
|
15
15
|
|
16
16
|
OptionParser.new do |opts|
|
17
17
|
|
18
|
-
options[:help] = ARGV.shift if ARGV.first
|
18
|
+
options[:help] = ARGV.shift if %w(help h).include?(ARGV.first)
|
19
19
|
|
20
20
|
if ARGV.empty?
|
21
21
|
options[:help] = 'help' # show help as default subcommand
|
@@ -25,28 +25,30 @@ OptionParser.new do |opts|
|
|
25
25
|
|
26
26
|
opts.banner = Cyborg::Help.banner(options[:command])
|
27
27
|
|
28
|
-
if options[:command]
|
28
|
+
if %w(n new).include? options[:command]
|
29
29
|
options[:name] = next_arg
|
30
30
|
|
31
|
-
opts.on("-f", "--force", "
|
31
|
+
opts.on("-f", "--force", "Overwrite existing files") do |val|
|
32
32
|
options[:force] = true
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
if options[:command]
|
37
|
-
|
36
|
+
if %w(s server).include? options[:command]
|
37
|
+
opts.on("-w", "--watch", "Watch assets") do |val|
|
38
|
+
options[:watch] = true
|
39
|
+
end
|
38
40
|
end
|
39
41
|
|
40
|
-
if %w(build watch server).include? options[:command]
|
41
|
-
opts.on("-j", "--js", "
|
42
|
+
if %w(b w s build watch server).include? options[:command]
|
43
|
+
opts.on("-j", "--js", "Build javascripts") do |val|
|
42
44
|
options[:select_assets] = true
|
43
45
|
options[:js] = true
|
44
46
|
end
|
45
|
-
opts.on("-c", "--css", "
|
47
|
+
opts.on("-c", "--css", "Build css") do |val|
|
46
48
|
options[:select_assets] = true
|
47
49
|
options[:css] = true
|
48
50
|
end
|
49
|
-
opts.on("-s", "--svg", "
|
51
|
+
opts.on("-s", "--svg", "Build svg") do |val|
|
50
52
|
options[:select_assets] = true
|
51
53
|
options[:svg] = true
|
52
54
|
end
|
data/lib/cyborg.rb
CHANGED
@@ -26,60 +26,9 @@ module Cyborg
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def patch_rails
|
29
|
-
load_rake_tasks
|
30
29
|
load_helpers
|
31
30
|
end
|
32
31
|
|
33
|
-
def dispatch(command, *args)
|
34
|
-
@threads = []
|
35
|
-
send(command, *args)
|
36
|
-
@threads.each { |thr| thr.join }
|
37
|
-
end
|
38
|
-
|
39
|
-
def build(options={})
|
40
|
-
puts 'Building…'
|
41
|
-
require File.join(Dir.pwd, rails_path, 'config/application')
|
42
|
-
@threads.concat plugin.build(options)
|
43
|
-
end
|
44
|
-
|
45
|
-
def watch(options={})
|
46
|
-
build(options)
|
47
|
-
require 'listen'
|
48
|
-
|
49
|
-
trap("SIGINT") {
|
50
|
-
puts "\nCyborg watcher stopped. Have a nice day!"
|
51
|
-
exit!
|
52
|
-
}
|
53
|
-
|
54
|
-
@threads.concat plugin.watch(options)
|
55
|
-
end
|
56
|
-
|
57
|
-
def server(options={})
|
58
|
-
@threads << Thread.new { Cyborg::Command.from_rails 'rails server' }
|
59
|
-
watch(options)
|
60
|
-
end
|
61
|
-
|
62
|
-
def load_rake_tasks
|
63
|
-
plugin.engine.rake_tasks do
|
64
|
-
namespace :cyborg do
|
65
|
-
desc "Cyborg build task"
|
66
|
-
task :build do
|
67
|
-
Cyborg.dispatch(:build)
|
68
|
-
end
|
69
|
-
|
70
|
-
desc "Watch assets for build"
|
71
|
-
task :watch do
|
72
|
-
Cyborg.dispatch(:watch)
|
73
|
-
end
|
74
|
-
|
75
|
-
desc "Start rails and watch assets for build"
|
76
|
-
task :server do
|
77
|
-
Cyborg.dispatch(:server)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
32
|
def load_helpers
|
84
33
|
require "cyborg/helpers/asset_helpers"
|
85
34
|
require "cyborg/helpers/layout_helpers"
|
data/lib/cyborg/command.rb
CHANGED
@@ -9,25 +9,51 @@ module Cyborg
|
|
9
9
|
def run(options)
|
10
10
|
|
11
11
|
case options[:command]
|
12
|
-
when 'new'
|
12
|
+
when 'new', 'n'
|
13
13
|
Scaffold.new(options[:name])
|
14
|
-
when '
|
15
|
-
from_root {
|
16
|
-
when '
|
17
|
-
from_root {
|
18
|
-
when '
|
19
|
-
from_root {
|
20
|
-
when 'server'
|
21
|
-
from_root { Cyborg.dispatch(:server, options) }
|
22
|
-
when 'rails'
|
23
|
-
from_rails "rails s"
|
14
|
+
when 'build', 'b'
|
15
|
+
from_root { dispatch(:build, options) }
|
16
|
+
when 'watch', 'w'
|
17
|
+
from_root { dispatch(:watch, options) }
|
18
|
+
when 'server', 's'
|
19
|
+
from_root { dispatch(:server, options) }
|
24
20
|
else
|
25
21
|
puts "Command `#{options[:command]}` not recognized"
|
26
22
|
end
|
27
23
|
end
|
28
24
|
|
29
|
-
|
25
|
+
# Handles running threaded commands
|
26
|
+
#
|
27
|
+
def dispatch(command, *args)
|
28
|
+
@threads = []
|
29
|
+
send(command, *args)
|
30
|
+
@threads.each { |thr| thr.join }
|
31
|
+
end
|
32
|
+
|
33
|
+
# Build assets
|
34
|
+
def build(options={})
|
35
|
+
puts 'Building…'
|
30
36
|
require File.join(Dir.pwd, Cyborg.rails_path, 'config/application')
|
37
|
+
@threads.concat Cyborg.plugin.build(options)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Watch assets for changes and build
|
41
|
+
def watch(options={})
|
42
|
+
build(options)
|
43
|
+
require 'listen'
|
44
|
+
|
45
|
+
trap("SIGINT") {
|
46
|
+
puts "\nCyborg watcher stopped. Have a nice day!"
|
47
|
+
exit!
|
48
|
+
}
|
49
|
+
|
50
|
+
@threads.concat Cyborg.plugin.watch(options)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Run rails server and watch assets
|
54
|
+
def server(options={})
|
55
|
+
@threads << Thread.new { from_rails 'rails server' }
|
56
|
+
watch(options) if options[:watch]
|
31
57
|
end
|
32
58
|
|
33
59
|
def from_rails(command=nil, &blk)
|
data/lib/cyborg/command/help.rb
CHANGED
@@ -6,45 +6,49 @@ module Cyborg
|
|
6
6
|
if command.nil?
|
7
7
|
<<-HERE
|
8
8
|
Commands:
|
9
|
-
#{commands.
|
9
|
+
#{command_list.map{|c| commands(c.to_sym) }.join("\n ")}
|
10
10
|
|
11
11
|
For help with a specific command, run `cyborg help command`
|
12
12
|
|
13
13
|
Options:
|
14
14
|
HERE
|
15
|
-
elsif commands
|
16
|
-
"\nUsage
|
15
|
+
elsif commands(command.to_sym)
|
16
|
+
"\nUsage:\n cyborg #{commands(command.to_sym)}\n\nOptions:\n"
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
21
|
-
|
22
|
-
new: new,
|
23
|
-
npm: npm,
|
24
|
-
build: build,
|
25
|
-
watch: watch,
|
26
|
-
help: help
|
27
|
-
}
|
20
|
+
def command_list
|
21
|
+
%w(new build watch server help)
|
28
22
|
end
|
29
23
|
|
30
|
-
def
|
31
|
-
|
24
|
+
def commands(command)
|
25
|
+
case command
|
26
|
+
when :new, :n; new
|
27
|
+
when :build, :b; build
|
28
|
+
when :watch, :w; watch
|
29
|
+
when :server, :s; server
|
30
|
+
when :help, :h; help
|
31
|
+
end
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
35
|
-
"
|
34
|
+
def new
|
35
|
+
"new <project_name> # Create a new Cyborg project"
|
36
36
|
end
|
37
37
|
|
38
38
|
def build
|
39
|
-
"
|
39
|
+
"build [options] # Build assets"
|
40
40
|
end
|
41
41
|
|
42
42
|
def watch
|
43
|
-
"
|
43
|
+
"watch [options] # Build assets when files change"
|
44
|
+
end
|
45
|
+
|
46
|
+
def server
|
47
|
+
"server [options] # Serve documentation site"
|
44
48
|
end
|
45
49
|
|
46
50
|
def help
|
47
|
-
"
|
51
|
+
"help [command] # Show help for a specific command"
|
48
52
|
end
|
49
53
|
end
|
50
54
|
end
|
data/lib/cyborg/version.rb
CHANGED