rails-webpack 0.2.2 → 0.3.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
  SHA1:
3
- metadata.gz: e0b2d0dafa314889b0a1fbd53025d50ca94b1c88
4
- data.tar.gz: 44a151a2207a72a7549e59bb552d562ac28dad87
3
+ metadata.gz: 5cd84d06a8e21c28240655adba24c58aa657fd0f
4
+ data.tar.gz: 536271021f15f5814aad07ed9ba194d2d34a159f
5
5
  SHA512:
6
- metadata.gz: 56cd80fdd03af4d86606f70d37e9c048dbb9cc384248a16c681e311323131d795029d0e3ba6547182924db5cd3d55f08dc507185196238d1da19a054804d99d7
7
- data.tar.gz: a5e13f0998f223068d49ffc7fb10fead2bd9a35f839bb01463c99dc914bee6b8cfa04e37148344871216d3b31dd30b554a28d6b3c7ff2e164cf4bf8366ac57f1
6
+ metadata.gz: 39d903f9036af2ed7f4ec5f07f12aea3fe7c831cb75f07bcfc872aea822707c53b356f3343403919c521283d1e855aa9ae42cb9d1fa37bfc5cee811b9523f84e
7
+ data.tar.gz: 6cad5b06cf8f1e3a36c57cf9dc0d1bafbe5035ba8d970238a45e7db8a032d3327bdf40b1027ed187a99c7e67c16cfcc9ee697e079f085e62e40840ba9c0ca83b
@@ -2,7 +2,5 @@ Description:
2
2
  Explain the generator
3
3
 
4
4
  Example:
5
- rails generate install Thing
6
-
7
- This will create:
8
- what/will/it/create
5
+ rails generate webpack:config
6
+ rails generate webpack:install
@@ -1,16 +1,2 @@
1
- require 'settingslogic'
2
-
3
- class WebpackConfig < Settingslogic
4
- source Rails.root.join('config', 'webpack.yml')
5
-
6
- def npm_configured?(key)
7
- keys.include?('npm') && npm.keys.include?(key.to_s)
8
- end
9
-
10
- def bower_configured?(key)
11
- keys.include?('bower') && bower.keys.include?(key.to_s)
12
- end
13
- end
14
-
15
1
  Rails.application.config.assets.paths << Rails.root.join('app', 'assets', 'compiled')
16
- Rails.application.config.webpack = WebpackConfig
2
+ Rails.application.config.webpack = Rails::Webpack::Config
@@ -0,0 +1,28 @@
1
+ module Rails::Webpack::Actions
2
+ def dependencies(&block)
3
+ collections = Rails::Webpack::DependencyCollection.new Rails::Webpack::Config
4
+ collections.instance_eval &block
5
+ processor = collections.processor
6
+
7
+ processor.process([
8
+ {
9
+ matcher: 'bower.dependencies',
10
+ category: :bower,
11
+ text: 'dependencies'
12
+ },
13
+ {
14
+ matcher: 'npm.dependencies',
15
+ category: :npm,
16
+ text: 'dependencies'
17
+ },
18
+ {
19
+ matcher: 'npm.develop_dependencies',
20
+ category: :npm_develop,
21
+ text: 'develop_dependencies'
22
+ }
23
+ ])
24
+
25
+ log :webpack, 'config/webpack.yml'
26
+ processor.flush
27
+ end
28
+ end
@@ -0,0 +1,13 @@
1
+ require 'settingslogic'
2
+
3
+ class Rails::Webpack::Config < Settingslogic
4
+ source Rails.root.join('config', 'webpack.yml')
5
+
6
+ def npm_configured?(key)
7
+ keys.include?('npm') && npm.keys.include?(key.to_s)
8
+ end
9
+
10
+ def bower_configured?(key)
11
+ keys.include?('bower') && bower.keys.include?(key.to_s)
12
+ end
13
+ end
@@ -0,0 +1,60 @@
1
+ require 'rails/generators/actions'
2
+
3
+ class Rails::Webpack::DependencyCollection
4
+ include Rails::Generators::Actions
5
+
6
+ VALID_CATEGORY = [:bower, :npm, :npm_develop]
7
+
8
+ class << self
9
+ def collection_name_from(category)
10
+ "#{category.to_s}_deps"
11
+ end
12
+ end
13
+
14
+ VALID_CATEGORY.each do |category|
15
+ attr_reader collection_name_from(category).to_sym
16
+ define_method category do |name, version_spec|
17
+ add category, name, version_spec
18
+ end
19
+ end
20
+
21
+ def initialize(config)
22
+ @config, @file = config, config.source.to_s
23
+ @bower_deps = normalize @config.bower.dependencies
24
+ @npm_deps = normalize @config.npm.dependencies
25
+ @npm_develop_deps = normalize @config.npm.develop_dependencies
26
+ end
27
+
28
+ def add(category, name, version_spec)
29
+ deps = get(category)
30
+ deps << {'name' => name, 'version' => version_spec}
31
+ deps.uniq!
32
+ end
33
+
34
+ def yamlize(category)
35
+ get(category).to_yaml.lines[1..-1].map(&:rstrip).join("\n").gsub('"', "'").gsub /^/, (' ' * 4)
36
+ end
37
+
38
+ def processor
39
+ Rails::Webpack::Processor.new(@file, self)
40
+ end
41
+
42
+ private
43
+ def normalize(hashes)
44
+ hashes.map {|d| {}.merge d}
45
+ end
46
+
47
+ def get(category)
48
+ sanitize! category
49
+ send collection_name_from(category)
50
+ end
51
+
52
+ def sanitize!(category)
53
+ error = "The specified category is invalid. valid categories are in [#{VALID_CATEGORY.to_s}]"
54
+ raise error unless VALID_CATEGORY.include?(category)
55
+ end
56
+
57
+ def collection_name_from(category)
58
+ self.class.collection_name_from(category)
59
+ end
60
+ end
@@ -0,0 +1,53 @@
1
+ class Rails::Webpack::Processor
2
+ def initialize(file, collections)
3
+ @contents = File.read(file).lines.map(&:rstrip)
4
+ @file = file
5
+ @collections = collections
6
+ @generated = []
7
+ @scope = []
8
+ @depth = 0
9
+ @indent = ' ' * 2
10
+ end
11
+
12
+ def process(config_list)
13
+ @contents.each do |line|
14
+ next if comments(line)
15
+ @depth = line.match(/(^(#{@indent}){0,})/)[1].length / @indent.length
16
+ @scope[@depth] = line.split(':').first.strip
17
+ @fullname = @scope[0, @depth + 1].join('.')
18
+ next if process_configs(config_list)
19
+ @generated << line
20
+ end
21
+ end
22
+
23
+ def flush
24
+ File.write @file, @generated.join("\n")
25
+ end
26
+
27
+ private
28
+ def process_configs(config_list)
29
+ config_list.each do |config|
30
+ return true if process_line(config)
31
+ end
32
+ false
33
+ end
34
+
35
+ def process_line(config)
36
+ return false unless @fullname.start_with? config[:matcher]
37
+ return true unless @depth == (config[:matcher].split('.').length - 1)
38
+ replace(config)
39
+ true
40
+ end
41
+
42
+ def comments(line)
43
+ return false unless line.match(/^\s*#/)
44
+ @generated << line
45
+ true
46
+ end
47
+
48
+ def replace(config)
49
+ deps = @collections.yamlize(config[:category])
50
+ @generated << " #{config[:text]}:#{' []' if deps.blank?}"
51
+ @generated << deps unless deps.blank?
52
+ end
53
+ end
@@ -1,5 +1,5 @@
1
1
  module Rails
2
2
  module Webpack
3
- VERSION = '0.2.2'
3
+ VERSION = '0.3.1'
4
4
  end
5
5
  end
data/lib/rails/webpack.rb CHANGED
@@ -2,5 +2,9 @@ module Rails
2
2
  module Webpack
3
3
  require 'rails/webpack/version'
4
4
  require 'rails/webpack/railtie'
5
+ autoload :DependencyCollection, 'rails/webpack/dependency_collection'
6
+ autoload :Processor, 'rails/webpack/processor'
7
+ autoload :Config, 'rails/webpack/config'
8
+ autoload :Actions, 'rails/webpack/actions'
5
9
  end
6
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-webpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeong, Jiung
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-19 00:00:00.000000000 Z
11
+ date: 2015-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -50,15 +50,13 @@ dependencies:
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
52
  version: 2.0.9
53
- description: Rails Plugin fro webpack support
53
+ description: Rails Plugin for webpack support
54
54
  email:
55
55
  - ethernuiel@sanultari.com
56
56
  executables: []
57
57
  extensions: []
58
58
  extra_rdoc_files: []
59
59
  files:
60
- - MIT-LICENSE
61
- - README.rdoc
62
60
  - Rakefile
63
61
  - lib/generators/webpack/USAGE
64
62
  - lib/generators/webpack/config_generator.rb
@@ -71,6 +69,10 @@ files:
71
69
  - lib/generators/webpack/templates/webpack.yml.erb
72
70
  - lib/rails-webpack.rb
73
71
  - lib/rails/webpack.rb
72
+ - lib/rails/webpack/actions.rb
73
+ - lib/rails/webpack/config.rb
74
+ - lib/rails/webpack/dependency_collection.rb
75
+ - lib/rails/webpack/processor.rb
74
76
  - lib/rails/webpack/railtie.rb
75
77
  - lib/rails/webpack/version.rb
76
78
  - lib/tasks/files/src/page.common.coffee
@@ -86,7 +88,7 @@ files:
86
88
  - lib/tasks/templates/gulpfile.js.erb
87
89
  - lib/tasks/templates/package.json.erb
88
90
  - lib/tasks/webpack.rake
89
- homepage: https://bitbucket.org/amamcloud/rails-webpack
91
+ homepage: https://github.com/astral1/rails-webpack
90
92
  licenses:
91
93
  - MIT
92
94
  metadata: {}
@@ -106,8 +108,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
108
  version: '0'
107
109
  requirements: []
108
110
  rubyforge_project:
109
- rubygems_version: 2.4.6
111
+ rubygems_version: 2.4.3
110
112
  signing_key:
111
113
  specification_version: 4
112
- summary: Rails Plugin fro webpack support
114
+ summary: Rails Plugin for webpack support
113
115
  test_files: []
data/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright 2015 Jeong, Jiung
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc DELETED
@@ -1,3 +0,0 @@
1
- = RailsWebpackSupport
2
-
3
- This project rocks and uses MIT-LICENSE.