cyborg 0.2.0 → 0.3.0

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: de1ffb656fd08f1bc6ce7993f13df4f0d40a8055
4
- data.tar.gz: 14313e29b7ae7968042e0027a8498d9953cd2d39
3
+ metadata.gz: 8d2f44ea7c9403815f3e2e5e02ba3804bdf1e4e1
4
+ data.tar.gz: 9d74c36a6640a2410c1365040a0b43dd1d873cf7
5
5
  SHA512:
6
- metadata.gz: 8d55c4eacd4a0e75d6462776143c8e221a9e570b76d2fb05af9a54658fd17019b47e805f6020f4f681835f38767ead191606a66afc3c6d513576cc04f8de6db1
7
- data.tar.gz: 844bce677e103e3e487ba0c6adeadb5815ac675f066fc4ac71f6ae55908d408a8b9ce52cac666ff6005afc68d17c7b32540bdcd38edee38358d9ba593e75bf3a
6
+ metadata.gz: a43f7b67340a52f143d2cd8bfe03391465faf139d449913d14082b05cdb6cb76f0006dcd935ba8a760619708e7572139b8ed7ef22222463489ea8770b06d953c
7
+ data.tar.gz: 01af22afd859ca34cff2e6c9637555ae56431a09794bb1176805f8bbb35165d5d22fea38944139fcdbc67673154b55ab381840da1b1f749bb8b1f0f0b5189d9e
data/bin/cyborg CHANGED
@@ -62,6 +62,9 @@ OptionParser.new do |opts|
62
62
  opts.on("-p", "--production", "Build assets as with production mode.") do |val|
63
63
  options[:production] = true
64
64
  end
65
+ opts.on("-C", "--clean", "Remove cache files before build.") do |val|
66
+ options[:clean] = true
67
+ end
65
68
  end
66
69
 
67
70
  opts.on("-v", "--version", "Print version") do |version|
@@ -78,20 +81,4 @@ OptionParser.new do |opts|
78
81
  end
79
82
  end.parse!
80
83
 
81
- if options[:version]
82
- puts "Cyborg version #{Cyborg::VERSION}"
83
- elsif options[:help]
84
-
85
- if options[:help]
86
- puts "Cyborg version #{Cyborg::VERSION}\n\n"
87
- puts options[:help]
88
-
89
- # Use this if commands get long
90
- #IO.popen("less", "w") do |f|
91
- #f.puts "Cyborg version #{Cyborg::VERSION}"
92
- #f.puts options[:help]
93
- #end
94
- end
95
- else
96
- Cyborg::Command.run(options)
97
- end
84
+ Cyborg::Command.run(options)
@@ -18,6 +18,13 @@ module Cyborg
18
18
  from_root { dispatch(:watch, options) }
19
19
  when 'server', 's'
20
20
  from_root { dispatch(:server, options) }
21
+ when 'clean', 'c'
22
+ from_root { clean }
23
+ when 'help', 'h'
24
+ version
25
+ puts options[:help]
26
+ when 'version'
27
+ version
21
28
  when 'gem:build'
22
29
  from_root { gem_build }
23
30
  when 'gem:install'
@@ -27,6 +34,10 @@ module Cyborg
27
34
  end
28
35
  end
29
36
 
37
+ def version
38
+ puts "Cyborg version #{Cyborg::VERSION}\n\n"
39
+ end
40
+
30
41
  def production?
31
42
  @production == true
32
43
  end
@@ -46,6 +57,15 @@ module Cyborg
46
57
  system "bundle exec rake release"
47
58
  end
48
59
 
60
+ def require_rails
61
+ require File.join(Dir.pwd, Cyborg.rails_path('config/application'))
62
+ end
63
+
64
+ def clean
65
+ require_rails
66
+ Cyborg.plugin.clean
67
+ end
68
+
49
69
  # Handles running threaded commands
50
70
  #
51
71
  def dispatch(command, *args)
@@ -57,7 +77,7 @@ module Cyborg
57
77
  # Build assets
58
78
  def build(options={})
59
79
  puts Cyborg.production? ? 'Building for production…' : 'Building…'
60
- require File.join(Dir.pwd, Cyborg.rails_path('config/application'))
80
+ require_rails
61
81
  @threads.concat Cyborg.plugin.build(options)
62
82
  end
63
83
 
@@ -27,6 +27,7 @@ Options:
27
27
  when 'build', 'b'; build
28
28
  when 'watch', 'w'; watch
29
29
  when 'server', 's'; server
30
+ when 'clean', 'c'; clean
30
31
  when 'help', 'h'; help
31
32
  when 'gem:build'; gem_build
32
33
  when 'gem:install'; gem_install
@@ -50,6 +51,10 @@ Options:
50
51
  "server [options] # Serve documentation site"
51
52
  end
52
53
 
54
+ def clean
55
+ "clean # Remove cache files"
56
+ end
57
+
53
58
  def help
54
59
  "help [command] # Show help for a specific command"
55
60
  end
@@ -92,6 +92,12 @@ module Cyborg
92
92
  assets(options).map(&:watch)
93
93
  end
94
94
 
95
+ def clean
96
+ FileUtils.rm_rf(Cyborg.rails_path('tmp/cache/'))
97
+ FileUtils.rm_rf('.sass-cache')
98
+ FileUtils.rm_rf(Cyborg.rails_path('.sass-cache'))
99
+ end
100
+
95
101
  def config(options)
96
102
  options = {
97
103
  production_asset_root: "/assets/#{name}",
@@ -9,20 +9,45 @@ module Cyborg
9
9
  javascript_include_tag(args)
10
10
  end
11
11
 
12
+ def cache_file(name=nil)
13
+ Cyborg.rails_path("tmp/cache/assets/.browserify-cache-#{name}.json")
14
+ end
15
+
12
16
  def build
17
+ files = find_files
18
+ FileUtils.mkdir_p(File.dirname(cache_file)) if !files.empty?
19
+
13
20
  if Open3.capture3("npm ls browserify-incremental")[1].empty?
14
- find_files.each do |file|
15
- dest = destination(file).sub(/\.js$/,'')
16
- cmd = "browserifyinc --cachefile #{Cyborg.rails_path("tmp/cache/assets/.browserify-cache.json")} #{file} -t babelify --standalone #{plugin.name} -o #{dest}.js -d"
17
- cmd += " -p [ minifyify --map #{url(file).sub(/\.js$/,'')}.map.json --output #{dest}.map.json ]" if plugin.maps? || Cyborg.production?
18
- system cmd
19
- compress(destination(file))
21
+ files.each do |file|
22
+ system build_command(file)
23
+
24
+ if Cyborg.production?
25
+ compress(destination(file))
26
+ end
27
+
20
28
  puts build_msg(file)
21
29
  end
22
30
  else
23
31
  abort "JS BUILD FAILED: browserifyinc NPM module not found.\n" << "Please add browserifyinc to your package.json and run `npm install`"
24
32
  end
25
33
  end
34
+
35
+ def build_command(file)
36
+ dest = destination(file).sub(/\.js$/,'')
37
+ options = " -t babelify --standalone #{plugin.name} -o #{dest}.js -d"
38
+
39
+ cmd = if Cyborg.production?
40
+ "browserify #{file} #{options}"
41
+ else
42
+ "browserifyinc --cachefile #{cache_file(File.basename(dest))} #{file} #{options}"
43
+ end
44
+
45
+ if Cyborg.production? || plugin.maps?
46
+ cmd += " -p [ minifyify --map #{url(file).sub(/\.js$/,'')}.map.json --output #{dest}.map.json ]"
47
+ end
48
+
49
+ cmd
50
+ end
26
51
  end
27
52
  end
28
53
  end
@@ -9,7 +9,7 @@ module Cyborg
9
9
  def asset_tag(*args)
10
10
  stylesheet_link_tag(args)
11
11
  end
12
-
12
+
13
13
  def build(ext=nil)
14
14
  files = find_files
15
15
  files = files.reject {|f| !f.match(/\.#{ext}/) } if ext
@@ -1,3 +1,3 @@
1
1
  module Cyborg
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cyborg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mathis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-25 00:00:00.000000000 Z
11
+ date: 2016-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sass