cyborg 0.5.23 → 0.5.24

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: f39879ff4f3fd4e28316d8e646c36b2ac90701f3
4
- data.tar.gz: 4157d506118a428fbefae2f92ab69dc30d0c66fd
3
+ metadata.gz: 68cf19f866d0d344943d3d4844e0329bce1e52f2
4
+ data.tar.gz: 01126b6a0e25132737e68be1799fc3cbc8a5fe0a
5
5
  SHA512:
6
- metadata.gz: 37d029410fe756af1105607637bd13204781aefc738c70b7ceb681319f6e40df6c83f1c00400d3d9af491b6babb7b82e0163d405207781e08963d932ebcf9195
7
- data.tar.gz: 037765fbc3c3f3a45120d1aeac7f1b002c6cb5a930f2e62078ce97dcd4240770a9d702110730bd71a30a4e8a8944fd6e962ca29367e5409c9d21b0eaf3693f58
6
+ metadata.gz: 8b865ce911bec5cb84129cf9f48877bd43355ac7a666af16987bb8be422fa5d48256777b9071affba1c89a9a25d2bcdfb914f1d43a84a3928c221bec3235722c
7
+ data.tar.gz: 638361f7f4520e682211cb09a75393af11919e960eb620e69b2aadfaea128a62152b049c4f09a207a037ac7b8f6b259ece2b2bcd2458c9c5bef5d9c080c12b9f
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_runtime_dependency 'sass', '~> 3.4'
22
- spec.add_runtime_dependency 'esvg', '~> 3.2'
22
+ spec.add_runtime_dependency 'esvg', '~> 4.0'
23
23
  spec.add_runtime_dependency 'listen', '~> 3.0.0'
24
24
  spec.add_runtime_dependency 'block_helpers', '~> 0.3'
25
25
  spec.add_runtime_dependency 'colorize', '~> 0.8'
@@ -0,0 +1,14 @@
1
+ require 'esvg'
2
+
3
+ module Esvg
4
+ module Helpers
5
+
6
+ def use_svg(name, options={})
7
+ if esvg_files.exist?(name, options[:fallback])
8
+ esvg_files.use(name, options).html_safe
9
+ elsif Cyborg.plugin.svgs.icons.exist?(name, options[:fallback])
10
+ Cyborg.plugin.svgs.use(name, options).html_safe
11
+ end
12
+ end
13
+ end
14
+ end
@@ -56,26 +56,27 @@ module Cyborg
56
56
  STDERR.puts msg.to_s.colorize(:red)
57
57
  end
58
58
 
59
- # Determine if an NPM module is installed by checking paths with `npm ls`
59
+ # Determine if an NPM module is installed by checking paths with `npm bin`
60
60
  # Returns path to binary if installed
61
- def find_node_module(cmd)
62
- response = Open3.capture3("npm ls #{cmd}")
63
-
64
- # Look in local `./node_modules` path.
65
- # Be sure stderr is empty (the second argument returned by capture3)
66
- if response[1].empty?
67
- "$(npm bin)/#{cmd}"
68
-
69
- # Check global module path
70
- elsif Open3.capture3("npm ls -g #{cmd}")[1].empty?
71
- cmd
61
+ def find_node_module(cmd)
62
+ require 'open3'
63
+ (@modules ||= {})[cmd] ||= begin
64
+
65
+ local = "$(npm bin)/#{cmd}"
66
+ global = "$(npm -g bin)/#{cmd}"
67
+
68
+ if Open3.capture3(local)[2].success?
69
+ local
70
+ elsif Open3.capture3(global)[2].success?
71
+ global
72
72
  end
73
+
73
74
  end
75
+ end
74
76
 
75
77
  def npm_command(cmd)
76
78
  cmd = cmd.split(' ')
77
- path = find_node_module(cmd.shift)
78
- if path
79
+ if path = find_node_module(cmd.shift)
79
80
  system "#{path} #{cmd.join(' ')}"
80
81
  end
81
82
  end
@@ -3,18 +3,23 @@ module Cyborg
3
3
  class Svgs < AssetType
4
4
 
5
5
  def initialize(plugin, path)
6
- require 'esvg'
6
+
7
+ require 'cyborg/esvg'
8
+
7
9
  @plugin = plugin
8
10
  @base = path
9
11
 
10
- @svg = Esvg.new({
12
+ @svg = Esvg::SVG.new({
11
13
  config_file: File.join(plugin.root, 'config', 'esvg.yml'),
12
- path: path,
13
- tmp_path: Cyborg.rails_path('tmp/cache/assets'),
14
- js_path: File.join(plugin.paths[:javascripts], '_icons.js'),
15
- js_build_version: plugin.version,
16
- js_build_dir: plugin.destination,
17
- optimize: true
14
+ source: path,
15
+ assets: plugin.paths[:javascripts],
16
+ version: plugin.version,
17
+ build: plugin.destination,
18
+ temp: Cyborg.rails_path('tmp/cache/assets'),
19
+ filename: '_icons.js',
20
+ compress: Cyborg.production?,
21
+ optimize: true,
22
+ print: false
18
23
  })
19
24
 
20
25
  end
@@ -35,6 +40,10 @@ module Cyborg
35
40
  .sub(plugin.root+'/','') # writtent to public dir
36
41
  end
37
42
 
43
+ def use(*args)
44
+ icons.use(*args)
45
+ end
46
+
38
47
  def build_paths
39
48
  @svg.build_paths.map { |file| file.sub("-#{plugin.version}",'') }
40
49
  end
@@ -44,13 +53,10 @@ module Cyborg
44
53
  begin
45
54
  @svg.read_files
46
55
 
47
- return if @svg.files.empty?
56
+ return if @svg.svgs.empty?
48
57
 
49
- if files = @svg.write
58
+ if files = @svg.build
50
59
  files.each do |file|
51
- if file.start_with?(plugin.destination)
52
- compress(file)
53
- end
54
60
  puts build_success(file)
55
61
  end
56
62
  else
@@ -1,3 +1,3 @@
1
1
  module Cyborg
2
- VERSION = "0.5.23"
2
+ VERSION = "0.5.24"
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.5.23
4
+ version: 0.5.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mathis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-04 00:00:00.000000000 Z
11
+ date: 2017-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sass
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '3.2'
33
+ version: '4.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '3.2'
40
+ version: '4.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: listen
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -193,6 +193,7 @@ files:
193
193
  - lib/cyborg/command/help.rb
194
194
  - lib/cyborg/command/npm.rb
195
195
  - lib/cyborg/command/scaffold.rb
196
+ - lib/cyborg/esvg.rb
196
197
  - lib/cyborg/helpers/asset_helpers.rb
197
198
  - lib/cyborg/helpers/layout_helpers.rb
198
199
  - lib/cyborg/middleware.rb