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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8be8c78e209edaa778911fe6eb792394e33b58f0
4
- data.tar.gz: cc0cb8ae86a6ce4b68a851bcf8593ea38e2823a9
3
+ metadata.gz: 07256e2ad9fe07490476d23e2c00d348d78a8f7e
4
+ data.tar.gz: e46a29def80e707128522a6190d069c6704ba78b
5
5
  SHA512:
6
- metadata.gz: aa46ffe222014a8c92e0cd4eda081b68106cb7ebf80646686751031ec2c9e9f369f910a759cee589a53b867997de1ded3d52e224b22932bdd67c711fd7c1910c
7
- data.tar.gz: c92d05d34c5f00cc2ba96f5a1bf96907bf0ab5fbcf1fe0f59a2d3ebc02dde3faf2ffffd46b8585bd7dce87f66f15a249d5c0b5d7f5b39558bf0e149457a58091
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 == 'help'
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] == 'new'
28
+ if %w(n new).include? options[:command]
29
29
  options[:name] = next_arg
30
30
 
31
- opts.on("-f", "--force", "overwrite existing files") do |val|
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] == 'npm'
37
- options[:cli_path] = next_arg || Dir.pwd
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", "build javascripts") do |val|
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", "build css") do |val|
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", "build svg") do |val|
51
+ opts.on("-s", "--svg", "Build svg") do |val|
50
52
  options[:select_assets] = true
51
53
  options[:svg] = true
52
54
  end
@@ -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"
@@ -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 'npm'
15
- from_root { NPM.setup }
16
- when 'build'
17
- from_root { Cyborg.dispatch(:build, options) }
18
- when 'watch'
19
- from_root { Cyborg.dispatch(:watch, options) }
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
- def load_rails
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)
@@ -6,45 +6,49 @@ module Cyborg
6
6
  if command.nil?
7
7
  <<-HERE
8
8
  Commands:
9
- #{commands.values.join("\n ")}
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[command.to_sym]
16
- "\nUsage: #{commands[command.to_sym]}\n\nOptions:\n"
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 commands
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 new
31
- "cyborg new project_name # Create a new Cyborg based project"
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 npm
35
- "cyborg npm [path] # Add NPM dependencies (path: dir with package.json, defaults to '.')"
34
+ def new
35
+ "new <project_name> # Create a new Cyborg project"
36
36
  end
37
37
 
38
38
  def build
39
- "cyborg build [options] # Build assets"
39
+ "build [options] # Build assets"
40
40
  end
41
41
 
42
42
  def watch
43
- "cyborg watch [options] # Build assets when files change"
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
- "cyborg help [command] # Show help for a specific command"
51
+ "help [command] # Show help for a specific command"
48
52
  end
49
53
  end
50
54
  end
@@ -1,3 +1,3 @@
1
1
  module Cyborg
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cyborg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mathis