bower_vendor 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: 2b417d3edd915d7fde1d0881d3beda3307c347e6782e42a5d440dd0479578304
4
- data.tar.gz: 4dd3926b2c96f3ba301f34b0b3cf3d223f30b2a4c181ad10a62f29a5b7bbcc1d
3
+ metadata.gz: ae8df14c3a4d96a011ea97afacbb840302295cf7ccad308ba7c85c2e54bbc102
4
+ data.tar.gz: 7023fd813d12928fc16e54b1a5be7e05cb6475f07af0ce5c1a46c48b9275950d
5
5
  SHA512:
6
- metadata.gz: 57d05d4bd63b24fc08baac65304a22902b10cb0d810c842c7eabc942e53d9877efe8e1ec26b632449cf72510702cca4cc1440586f49de00cc660791ac2282fe5
7
- data.tar.gz: 669245594777c50b5c18cc1721a488ea6e4b1848af9a05691b5718b55ce5e1f9c0bd9d57682b342325f11d273b036cea61a8fea6097523b7fd41b46f9b47f399
6
+ metadata.gz: 2b57c087bf946edd1e96a8213ac99a9973da50afe983ef1ce4f8b5778ee687a22f1a47ba6d519953bdd787312516389bf56ed345be1f308da7e06a0e1c41bccb
7
+ data.tar.gz: 3ad422ffec81f6bff8c73d15cbdbfa0f98f9cf0969402d30b5a4e907c45dac9b9eacbbac111be31afb21646f8ed3f1347442b429e7d5ff8a4dfceb24c5fca546
@@ -3,14 +3,18 @@ class BowerVendor::Base
3
3
  end
4
4
 
5
5
  def vendors
6
- @vendors ||= load_vendors
7
- validate_vendors
6
+ @vendors ||= load_vendors.delete_if { |vendor, vendor_data| !accept_vendor?(vendor, vendor_data) }
7
+ validate_vendors(@vendors)
8
8
  @vendors
9
9
  end
10
10
 
11
- def validate_vendors
11
+ def accept_vendor?(vendor, vendor_data)
12
+ !vendor_data['yarn']
13
+ end
14
+
15
+ def validate_vendors(vendors)
12
16
  # validate resources
13
- @vendors.each do |vendor_key, vendor|
17
+ vendors.each do |vendor_key, vendor|
14
18
  raise "VERSION MISSING: #{vendor_key}: #{vendor.inspect}" unless vendor['version']
15
19
  puts "WARN: ASSETS MISSING: #{vendor_key}: #{vendor.inspect}" unless vendor['assets']
16
20
  end
@@ -29,8 +33,8 @@ class BowerVendor::Base
29
33
  end
30
34
  end
31
35
 
32
- def full_asset_key_src_dir(asset_key)
33
- "#{self.work_dir}/bower_components/#{asset_key}"
36
+ def full_vendor_src_dir(vendor)
37
+ "#{self.work_dir}/bower_components/#{vendor}"
34
38
  end
35
39
 
36
40
  def work_dir
@@ -1,19 +1,19 @@
1
1
  class BowerVendor::Copy < BowerVendor::Base
2
2
  def execute
3
- vendors.each do |asset_key, asset_data|
4
- src_dir = full_asset_key_src_dir(asset_key)
3
+ vendors.each do |vendor, asset_data|
4
+ src_dir = full_vendor_src_dir(vendor)
5
5
  msg 0, "processing: #{src_dir}"
6
6
 
7
- run_build_scripts(asset_key, asset_data, 1)
8
- copy_assets(asset_key, asset_data, 1)
7
+ run_build_scripts(vendor, asset_data, 1)
8
+ copy_assets(vendor, asset_data, 1)
9
9
  end
10
10
  end
11
11
 
12
- def run_build_scripts(asset_key, asset_data, level)
12
+ def run_build_scripts(vendor, asset_data, level)
13
13
  scripts = (asset_data['build'] || [])
14
14
  return if scripts.empty?
15
15
 
16
- src_dir = full_asset_key_src_dir(asset_key)
16
+ src_dir = full_vendor_src_dir(vendor)
17
17
 
18
18
  msg level, "building..."
19
19
  scripts.each do |cmd|
@@ -27,12 +27,12 @@ class BowerVendor::Copy < BowerVendor::Base
27
27
  end
28
28
  end
29
29
 
30
- def copy_assets(asset_key, asset_data, level)
31
- msg level, "copying: #{asset_key}..."
32
- copy_asset(asset_key, asset_data, asset_data['assets'], '', level + 1)
30
+ def copy_assets(vendor, asset_data, level)
31
+ msg level, "copying: #{vendor}..."
32
+ copy_asset(vendor, asset_data, asset_data['assets'], '', level + 1)
33
33
  end
34
34
 
35
- def copy_asset(asset_key, asset_data, assets, target_path = '', level)
35
+ def copy_asset(vendor, asset_data, assets, target_path = '', level)
36
36
  assets ||= []
37
37
  if assets.empty?
38
38
  msg level, "WARN: ASSETS MISSING"
@@ -42,7 +42,7 @@ class BowerVendor::Copy < BowerVendor::Base
42
42
  if asset.is_a? Hash
43
43
  sub_asset = asset.keys.first
44
44
  sub_target_path = target_path.empty? ? sub_asset : target_path + '/' + sub_asset
45
- copy_asset(asset_key, asset_data, asset[sub_asset], sub_target_path, level + 1)
45
+ copy_asset(vendor, asset_data, asset[sub_asset], sub_target_path, level + 1)
46
46
  else
47
47
  msg level, asset
48
48
 
@@ -50,18 +50,18 @@ class BowerVendor::Copy < BowerVendor::Base
50
50
  raise "VERSION MISSING: #{asset_data.inspect}" if version.empty?
51
51
 
52
52
  asset_path = asset.gsub("{{VERSION}}", version)
53
- src = "#{full_asset_key_src_dir(asset_key)}/#{asset_path}"
53
+ src = "#{full_vendor_src_dir(vendor)}/#{asset_path}"
54
54
 
55
55
  files = Dir[src].sort!
56
56
  raise "NOT_FOUND: #{src}" if files.empty?
57
57
  files.each do |src_path|
58
- copy_src_file asset_key, asset_data, asset, src_path, target_path, level + 1
58
+ copy_src_file vendor, asset_data, asset, src_path, target_path, level + 1
59
59
  end
60
60
  end
61
61
  end
62
62
  end
63
63
 
64
- def copy_src_file(asset_key, asset_data, orig_path, full_src_file, target_path, level)
64
+ def copy_src_file(vendor, asset_data, orig_path, full_src_file, target_path, level)
65
65
  if !File.exist? full_src_file
66
66
  raise "NOT_FOUND: #{full_src_file}"
67
67
  end
@@ -74,7 +74,7 @@ class BowerVendor::Copy < BowerVendor::Base
74
74
  base_dst_dir = self.dst_dirs[ext]
75
75
  raise "NOT_FOUND_EXT: #{ext}" unless base_dst_dir
76
76
 
77
- dst_dir = "#{base_dst_dir}/#{asset_key}-#{version}"
77
+ dst_dir = "#{base_dst_dir}/#{vendor}-#{version}"
78
78
  dst_dir = "#{dst_dir}/#{target_path}" unless target_path.empty?
79
79
  full_dst_file = "#{dst_dir}/#{dst_file}"
80
80
 
@@ -1,3 +1,3 @@
1
1
  module BowerVendor
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -1,24 +1,25 @@
1
1
  class BowerVendor::Yarn < BowerVendor::Copy
2
- def full_asset_key_src_dir(asset_key)
3
- "node_modules/#{asset_key}"
2
+ def full_vendor_src_dir(vendor)
3
+ "node_modules/#{vendor}"
4
4
  end
5
5
 
6
- def validate_vendors
7
- # nothing
6
+ def accept_vendor?(vendor, vendor_data)
7
+ vendor_data['yarn']
8
8
  end
9
9
 
10
10
  def load_vendors
11
11
  versions = load_vendor_versions
12
12
 
13
- vendors = YAML.load_file 'vendor_yarn.yml'
13
+ vendors_data = YAML.load_file 'vendor.yml'
14
+ vendors_data.delete_if { |vendor, vendor_data| !accept_vendor?(vendor, vendor_data) }
14
15
 
15
- vendors.each do |vendor, vendor_data|
16
+ vendors_data.each do |vendor, vendor_data|
16
17
  version = versions[vendor]
17
18
  raise "YARN: missing vendor: #{vendor}" unless version
18
19
  vendor_data['version'] = version
19
20
  end
20
21
 
21
- vendors
22
+ vendors_data
22
23
  end
23
24
 
24
25
  def load_vendor_versions
data/vendor.yml CHANGED
@@ -21,3 +21,33 @@ test_3:
21
21
  version: test3
22
22
  assets:
23
23
  - index.jpg
24
+
25
+ bootstrap:
26
+ yarn: true
27
+ assets:
28
+ - scss/*.scss
29
+ - mixins:
30
+ - scss/mixins/*.scss
31
+ - utilities:
32
+ - scss/utilities/*.scss
33
+ - js/dist/*.js
34
+
35
+ jquery:
36
+ yarn: true
37
+ assets:
38
+ - dist/jquery.js
39
+
40
+ lodash:
41
+ yarn: true
42
+ assets:
43
+ - lodash.js
44
+
45
+ url.js:
46
+ yarn: true
47
+ assets:
48
+ - url.js
49
+
50
+ vue:
51
+ yarn: true
52
+ assets:
53
+ - dist/vue.js
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bower_vendor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - kari
@@ -99,7 +99,6 @@ files:
99
99
  - test/test1.js
100
100
  - test/test2.js
101
101
  - vendor.yml
102
- - vendor_yarn.yml
103
102
  - yarn.lock
104
103
  homepage: https://github.com/kikonen/bower_vendor
105
104
  licenses:
data/vendor_yarn.yml DELETED
@@ -1,24 +0,0 @@
1
- bootstrap:
2
- assets:
3
- - scss/*.scss
4
- - mixins:
5
- - scss/mixins/*.scss
6
- - utilities:
7
- - scss/utilities/*.scss
8
- - js/dist/*.js
9
-
10
- jquery:
11
- assets:
12
- - dist/jquery.js
13
-
14
- lodash:
15
- assets:
16
- - lodash.js
17
-
18
- url.js:
19
- assets:
20
- - url.js
21
-
22
- vue:
23
- assets:
24
- - dist/vue.js