lite-component 1.0.2 → 1.0.3

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: 2317e34463be37b1dac9715d6b64ce4f73734bfb920439b09005b9c2d7acb3ab
4
- data.tar.gz: 8d4ec71562044fe13088330a4f6167c53f3897e0014a7fdb4cdc38fe382c1f44
3
+ metadata.gz: e363087100ee78c9e7a154815680d42707467ff16f9f77606c8cfecf4e7afe7a
4
+ data.tar.gz: fefd80fb36d4fd2e35e533258fb27434c18e78841f0c5d3ebd5f4cb83b58efa6
5
5
  SHA512:
6
- metadata.gz: 86007d8751ecd87d26e1dfa2c40f9c861d67baaf2f765e7b2eb3cbdf1d7c1a6f826db0bc8b23cef40c4a02347b00884687070b8dab6ba63ed7cb00be23f9fbdb
7
- data.tar.gz: 0a711732df4639a31705d37ec88e396a93c0f55574661b3fcce8ff431ac4b00829f1c16c1b93672bf2099b3de833550152e40defbc9e5b0b74c8afb09c031f62
6
+ metadata.gz: 4cceae23254cf5e0e80693929580910a6c798a6201f03280504700a81381dfecb71f2eb5c322b76c98aa5e06ec6ce1b83583c8a8cdf2ed8efa32725f44df0404
7
+ data.tar.gz: 0ad326b891c245dc231f15b366f33f11a7196a7c7d2190abdcb8fa297086ab35ac042a8abd427e496ca22bd07a63b0069150a8a61bc6e1426d84a169b6068ac6
data/.rubocop.yml CHANGED
@@ -12,14 +12,16 @@ Layout/EmptyLinesAroundClassBody:
12
12
  EnforcedStyle: empty_lines_except_namespace
13
13
  Layout/EmptyLinesAroundModuleBody:
14
14
  EnforcedStyle: empty_lines_except_namespace
15
+ Layout/LineLength:
16
+ Max: 100
15
17
  Metrics/BlockLength:
16
18
  Enabled: false
17
19
  Metrics/ClassLength:
18
20
  Enabled: false
19
- Metrics/LineLength:
20
- Max: 100
21
21
  Naming/FileName:
22
22
  Enabled: false
23
+ Naming/MemoizedInstanceVariableName:
24
+ Enabled: false
23
25
  RSpec/ExampleLength:
24
26
  Enabled: false
25
27
  RSpec/MultipleExpectations:
data/CHANGELOG.md CHANGED
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.0.3] - 2019-12-20
10
+ ### Changed
11
+ - Reworked component generator
12
+
9
13
  ## [1.0.2] - 2019-12-19
10
14
  ### Changed
11
15
  - Rewrite the internals of component building and rendering
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lite-component (1.0.2)
4
+ lite-component (1.0.3)
5
5
  rails (>= 5.1.0)
6
6
 
7
7
  GEM
@@ -5,37 +5,53 @@ require 'rails/generators'
5
5
  module Rails
6
6
  class ComponentGenerator < Rails::Generators::NamedBase
7
7
 
8
+ source_root File.expand_path('../templates', __FILE__)
9
+ check_class_collision suffix: 'Component'
10
+
8
11
  class_option :skip_erb, type: :boolean, default: false
9
12
  class_option :skip_css, type: :boolean, default: false
10
13
  class_option :skip_js, type: :boolean, default: false
11
14
 
12
- source_root File.expand_path('../templates', __FILE__)
13
- check_class_collision suffix: 'Component'
14
-
15
- def create_component_file
16
- template('install.rb.erb', "app/components/#{name}_component.rb")
15
+ def copy_components
16
+ path = File.join('app', 'components', class_path, "#{file_name}_component.rb")
17
+ empty_directory('app/components')
18
+ template('component.rb.tt', path)
17
19
  end
18
20
 
19
- def create_erb_file
21
+ def create_erbs
20
22
  return if options['skip_erb']
21
23
 
22
- name_parts = name.split('/')
23
- file_parts = name_parts[0..-2]
24
- file_parts << "_#{name_parts.last}.html.erb"
25
-
26
- create_file("app/views/components/#{file_parts.join('/')}")
24
+ path = File.join('app', 'views', 'components', class_path, "_#{file_name}.html.erb")
25
+ empty_directory('app/views')
26
+ create_file(path)
27
27
  end
28
28
 
29
- def copy_javascript_file
29
+ def copy_javascripts
30
30
  return if options['skip_js']
31
31
 
32
- copy_file('install.js', "app/assets/javascripts/components/#{name}.js")
32
+ path = File.join('app', 'assets', 'javascripts', 'components', class_path, "#{file_name}.js")
33
+ empty_directory('app/assets')
34
+ template('component.js', path)
33
35
  end
34
36
 
35
- def copy_stylesheet_file
37
+ # rubocop:disable Layout/LineLength
38
+ def copy_stylesheets
36
39
  return if options['skip_css']
37
40
 
38
- copy_file('install.scss', "app/assets/stylesheets/components/#{name}.scss")
41
+ path = File.join('app', 'assets', 'stylesheets', 'components', class_path, "#{file_name}.scss")
42
+ empty_directory('app/assets')
43
+ template('component.scss', path)
44
+ end
45
+ # rubocop:enable Layout/LineLength
46
+
47
+ private
48
+
49
+ def file_name
50
+ @_file_name ||= remove_possible_suffix(super)
51
+ end
52
+
53
+ def remove_possible_suffix(name)
54
+ name.sub(/_?component$/i, '')
39
55
  end
40
56
 
41
57
  end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ <% module_namespacing do -%>
4
+ class <%= class_name %>Command < <%= ApplicationComponent.to_s rescue 'Lite::Component::Base' %>
5
+ end
6
+ <% end -%>
@@ -3,7 +3,7 @@
3
3
  module Lite
4
4
  module Component
5
5
 
6
- VERSION ||= '1.0.2'
6
+ VERSION ||= '1.0.3'
7
7
 
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lite-component
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-19 00:00:00.000000000 Z
11
+ date: 2019-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -161,9 +161,9 @@ files:
161
161
  - bin/setup
162
162
  - lib/generators/rails/USAGE
163
163
  - lib/generators/rails/component_generator.rb
164
- - lib/generators/rails/templates/install.js
165
- - lib/generators/rails/templates/install.rb.erb
166
- - lib/generators/rails/templates/install.scss
164
+ - lib/generators/rails/templates/component.js
165
+ - lib/generators/rails/templates/component.rb.tt
166
+ - lib/generators/rails/templates/component.scss
167
167
  - lib/lite/component.rb
168
168
  - lib/lite/component/base.rb
169
169
  - lib/lite/component/collection.rb
@@ -1,2 +0,0 @@
1
- class <%= name.classify %>Component < <%= ApplicationComponent.to_s rescue 'Lite::Component::Base' %>
2
- end