komponent 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rubocop.yml +5 -1
- data/.travis.yml +28 -2
- data/CHANGELOG.md +12 -0
- data/Gemfile +11 -0
- data/README.md +1 -1
- data/Rakefile +24 -1
- data/bin/console +1 -0
- data/gemfiles/Gemfile-rails.4.2.x +8 -0
- data/gemfiles/Gemfile-rails.5.0.x +8 -0
- data/gemfiles/Gemfile-rails.5.1.x +8 -0
- data/gemfiles/Gemfile-rails.5.2.x +8 -0
- data/komponent.gemspec +8 -7
- data/lib/generators/component/component_generator.rb +3 -1
- data/lib/generators/component/templates/js.erb +3 -1
- data/lib/generators/komponent/install_generator.rb +28 -5
- data/lib/komponent.rb +2 -0
- data/lib/komponent/core/component_helper.rb +2 -0
- data/lib/komponent/core/component_path_resolver.rb +2 -0
- data/lib/komponent/core/translation.rb +2 -0
- data/lib/komponent/komponent_helper.rb +4 -0
- data/lib/komponent/railtie.rb +2 -8
- data/lib/komponent/version.rb +3 -1
- metadata +22 -60
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c0aadad91b23804da8724b26704c6bb481f2869
|
4
|
+
data.tar.gz: 5ef9c5fb02bf7f6f7e53c2ea0397f1724dfa6116
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ade22af3b7e1b13484f8e0d3b35648e6c35bbbd1393d71c399b25648655a05524dd2fc5d36c40beb89177cb9b2634e093ba596f200b9b0664f6cf7571618117a
|
7
|
+
data.tar.gz: 3a8d50d8c461372f1d8f3edde97651cd352213d48fb6d40c26518d3a2041150c7593112e3c07a4b76b0c4329a01eb7aa0d74bcf8daf3b6edde88e557239b40ad
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.
|
2
|
+
TargetRubyVersion: 2.2
|
3
3
|
DisabledByDefault: true
|
4
4
|
Exclude:
|
5
5
|
- 'node_modules/**/*'
|
@@ -33,6 +33,10 @@ Style/MethodCallWithoutArgsParentheses:
|
|
33
33
|
Style/MethodDefParentheses:
|
34
34
|
Enabled: true
|
35
35
|
|
36
|
+
Style/FrozenStringLiteralComment:
|
37
|
+
Enabled: true
|
38
|
+
EnforcedStyle: always
|
39
|
+
|
36
40
|
Naming/ConstantName:
|
37
41
|
Enabled: true
|
38
42
|
|
data/.travis.yml
CHANGED
@@ -1,7 +1,33 @@
|
|
1
|
-
sudo: false
|
2
1
|
language: ruby
|
2
|
+
sudo: false
|
3
|
+
|
4
|
+
before_install:
|
5
|
+
- gem update --system
|
6
|
+
|
3
7
|
rvm:
|
8
|
+
- 2.2
|
9
|
+
- 2.3
|
4
10
|
- 2.4
|
11
|
+
- 2.5
|
12
|
+
- ruby-head
|
13
|
+
|
14
|
+
gemfile:
|
15
|
+
- Gemfile-rails.4.2.x
|
16
|
+
- Gemfile-rails.5.0.x
|
17
|
+
- Gemfile-rails.5.1.x
|
18
|
+
- Gemfile-rails.5.2.x
|
19
|
+
|
20
|
+
cache:
|
21
|
+
bundler: true
|
22
|
+
yarn: true
|
23
|
+
|
24
|
+
install:
|
25
|
+
- bundle install
|
26
|
+
- nvm install node
|
27
|
+
- node -v
|
28
|
+
- npm i -g yarn
|
29
|
+
- yarn
|
30
|
+
|
5
31
|
script:
|
6
32
|
- bundle exec rubocop
|
7
|
-
- bundle exec
|
33
|
+
- bundle exec rake test
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,18 @@
|
|
2
2
|
|
3
3
|
## Upcoming release
|
4
4
|
|
5
|
+
## v1.1.4 (2018-03-05)
|
6
|
+
|
7
|
+
**Enhancements:**
|
8
|
+
|
9
|
+
- Added `frozen_string_literal` option to optimize performance
|
10
|
+
- Removed useless `autoload_paths` config definition (it was not taken into account)
|
11
|
+
- Install generator can be ran several times in order to enable features
|
12
|
+
- Autoloading is now appended to `config/application.rb` when you run `rails g komponent:install`
|
13
|
+
- Make all locals passed to `component` helper available through `properties` helper method
|
14
|
+
|
15
|
+
## v1.1.3 (2018-02-22)
|
16
|
+
|
5
17
|
**Enhancements:**
|
6
18
|
- Custom destroy for the component generator: you can now safely run `rails d component button`
|
7
19
|
|
data/Gemfile
CHANGED
@@ -1,6 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source "https://rubygems.org"
|
2
4
|
|
3
5
|
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
4
6
|
|
5
7
|
# Specify your gem's dependencies in komponent.gemspec
|
6
8
|
gemspec
|
9
|
+
|
10
|
+
gem "rails"
|
11
|
+
gem "rake", ">= 11.1"
|
12
|
+
gem "rubocop", require: false
|
13
|
+
|
14
|
+
group :test do
|
15
|
+
gem "aruba"
|
16
|
+
gem "cucumber"
|
17
|
+
end
|
data/README.md
CHANGED
@@ -93,7 +93,7 @@ Check [Webpacker documentation](https://github.com/rails/webpacker) for further
|
|
93
93
|
|
94
94
|
### Passing variables
|
95
95
|
|
96
|
-
You can pass `locals` to the helper. They are accessible within the component partial, as instance variables.
|
96
|
+
You can pass `locals` to the helper. They are accessible within the component partial, as instance variables. Additionally, the entire `locals` hash is made available through a `properties` helper method.
|
97
97
|
|
98
98
|
```slim
|
99
99
|
/ app/views/pages/home.html.slim
|
data/Rakefile
CHANGED
@@ -1,2 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "bundler/gem_tasks"
|
2
|
-
|
4
|
+
require "rake/testtask"
|
5
|
+
require 'cucumber'
|
6
|
+
require 'cucumber/rake/task'
|
7
|
+
|
8
|
+
namespace :test do
|
9
|
+
task all: [:unit, :cucumber]
|
10
|
+
|
11
|
+
Rake::TestTask.new(:unit) do |t|
|
12
|
+
t.libs << "test"
|
13
|
+
t.libs << "lib"
|
14
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
15
|
+
t.verbose = true
|
16
|
+
end
|
17
|
+
|
18
|
+
Cucumber::Rake::Task.new(:cucumber) do |t|
|
19
|
+
t.cucumber_opts = "--format pretty"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
task test: 'test:all'
|
24
|
+
|
25
|
+
task default: :test
|
data/bin/console
CHANGED
data/komponent.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
lib = File.expand_path("../lib", __FILE__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require "komponent/version"
|
@@ -20,12 +22,11 @@ Gem::Specification.new do |spec|
|
|
20
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
23
|
spec.require_paths = ["lib"]
|
22
24
|
|
23
|
-
spec.
|
24
|
-
spec.add_development_dependency "bundler", "~> 1.15"
|
25
|
-
spec.add_development_dependency "cucumber"
|
26
|
-
spec.add_development_dependency "rails", ">= 5.0"
|
27
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
-
spec.add_development_dependency "rubocop", '~> 0.52.1'
|
25
|
+
spec.required_ruby_version = '>= 2.2.0'
|
29
26
|
|
30
|
-
spec.
|
27
|
+
spec.add_dependency "activesupport", ">= 4.2"
|
28
|
+
spec.add_dependency "railties", ">= 4.2"
|
29
|
+
spec.add_dependency "webpacker", ">= 3.0.0"
|
30
|
+
|
31
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
31
32
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class ComponentGenerator < Rails::Generators::NamedBase
|
2
4
|
source_root File.expand_path('../templates', __FILE__)
|
3
5
|
|
@@ -177,7 +179,7 @@ class ComponentGenerator < Rails::Generators::NamedBase
|
|
177
179
|
|
178
180
|
return if lines.empty?
|
179
181
|
|
180
|
-
lines = lines.sort
|
182
|
+
lines = lines.uniq.sort
|
181
183
|
|
182
184
|
File.open(path, "w") do |f|
|
183
185
|
lines.each do |line|
|
@@ -1,8 +1,10 @@
|
|
1
|
-
import "./<%= name_with_namespace %>.<%= stylesheet_engine %>";
|
2
1
|
<%- if stimulus? -%>
|
3
2
|
import application from "stimulus_application";
|
4
3
|
import { definitionsFromContext } from "stimulus/webpack-helpers";
|
4
|
+
import "./<%= name_with_namespace %>.<%= stylesheet_engine %>";
|
5
5
|
|
6
6
|
const context = require.context('./', true, /_controller\.js$/);
|
7
7
|
application.load(definitionsFromContext(context));
|
8
|
+
<%- else -%>
|
9
|
+
import "./<%= name_with_namespace %>.<%= stylesheet_engine %>";
|
8
10
|
<%- end -%>
|
@@ -1,15 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Komponent
|
2
4
|
module Generators
|
3
5
|
class InstallGenerator < Rails::Generators::Base
|
4
6
|
class_option :stimulus, type: :boolean, default: false
|
5
7
|
|
6
8
|
def check_webpacker_dependency
|
9
|
+
return if komponent_already_installed?
|
10
|
+
|
7
11
|
unless File.exist?(webpacker_configuration_file) and File.directory?(webpacker_default_structure)
|
8
12
|
raise Thor::Error, dependencies_not_met_error_message
|
9
13
|
end
|
10
14
|
end
|
11
15
|
|
12
16
|
def create_root_directory
|
17
|
+
return if File.directory?(komponent_root_directory)
|
18
|
+
|
13
19
|
empty_directory(komponent_root_directory)
|
14
20
|
end
|
15
21
|
|
@@ -18,18 +24,29 @@ module Komponent
|
|
18
24
|
end
|
19
25
|
|
20
26
|
def move_webpacker_default_structure
|
27
|
+
return if File.directory?(komponent_root_directory)
|
28
|
+
|
21
29
|
run("mv #{webpacker_default_structure}/* #{komponent_root_directory}")
|
22
30
|
end
|
23
31
|
|
24
32
|
def create_komponent_default_structure
|
33
|
+
return if File.exist?(components_directory.join("index.js"))
|
34
|
+
|
25
35
|
empty_directory(components_directory)
|
26
36
|
create_file(components_directory.join("index.js"))
|
27
37
|
end
|
28
38
|
|
29
39
|
def create_stimulus_file
|
40
|
+
return if File.exist?(stimulus_application_path)
|
41
|
+
|
30
42
|
create_file(stimulus_application_path, stimulus? ? stimulus_application_template : "")
|
31
43
|
end
|
32
44
|
|
45
|
+
def append_to_application_configuration
|
46
|
+
application "config.autoload_paths << config.root.join('#{relative_path_from_rails}/components')"
|
47
|
+
application "config.i18n.load_path += Dir[config.root.join('#{relative_path_from_rails}/components/**/*.yml')]"
|
48
|
+
end
|
49
|
+
|
33
50
|
def append_to_application_pack
|
34
51
|
append_to_file(application_pack_path, "import 'components';")
|
35
52
|
end
|
@@ -45,11 +62,13 @@ module Komponent
|
|
45
62
|
protected
|
46
63
|
|
47
64
|
def stimulus_application_template
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
65
|
+
<<-JAVASCRIPT
|
66
|
+
import { Application } from "stimulus";
|
67
|
+
|
68
|
+
const application = Application.start();
|
69
|
+
|
70
|
+
export default application;
|
71
|
+
JAVASCRIPT
|
53
72
|
end
|
54
73
|
|
55
74
|
def stimulus_application_path
|
@@ -76,6 +95,10 @@ module Komponent
|
|
76
95
|
Rails.root.join("app", "javascript")
|
77
96
|
end
|
78
97
|
|
98
|
+
def komponent_already_installed?
|
99
|
+
File.directory?(relative_path_from_rails)
|
100
|
+
end
|
101
|
+
|
79
102
|
def dependencies_not_met_error_message
|
80
103
|
"Seems you don't have webpacker installed in your project. Please install webpacker, and follow instructions at https://github.com/rails/webpacker"
|
81
104
|
end
|
data/lib/komponent.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module KomponentHelper
|
2
4
|
def component(component, locals = {}, &block)
|
3
5
|
component_path = Komponent::ComponentPathResolver.new.resolve(component)
|
@@ -40,6 +42,8 @@ module KomponentHelper
|
|
40
42
|
instance_variable_set(:"@#{name}", locals[name])
|
41
43
|
end
|
42
44
|
|
45
|
+
define_singleton_method(:properties) { locals }
|
46
|
+
|
43
47
|
instance_variable_set(:"@block_given_to_component", block)
|
44
48
|
end
|
45
49
|
|
data/lib/komponent/railtie.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'webpacker'
|
2
4
|
require 'komponent/core/component_helper'
|
3
5
|
require 'komponent/core/translation'
|
@@ -29,14 +31,6 @@ module Komponent
|
|
29
31
|
app.config.komponent.root
|
30
32
|
)
|
31
33
|
end
|
32
|
-
|
33
|
-
ActiveSupport.on_load :i18n do
|
34
|
-
I18n.load_path.concat(
|
35
|
-
Dir["#{app.config.komponent.root}/components/**/*.yml"]
|
36
|
-
)
|
37
|
-
end
|
38
|
-
|
39
|
-
app.config.autoload_paths += [app.config.komponent.root]
|
40
34
|
end
|
41
35
|
end
|
42
36
|
end
|
data/lib/komponent/version.rb
CHANGED
metadata
CHANGED
@@ -1,113 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: komponent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ouvrages
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
type: :
|
19
|
+
version: '4.2'
|
20
|
+
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: bundler
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.15'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1.15'
|
26
|
+
version: '4.2'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
28
|
+
name: railties
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
31
|
- - ">="
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
48
|
-
type: :
|
33
|
+
version: '4.2'
|
34
|
+
type: :runtime
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
38
|
- - ">="
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
40
|
+
version: '4.2'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
42
|
+
name: webpacker
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
45
|
- - ">="
|
60
46
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
62
|
-
type: :
|
47
|
+
version: 3.0.0
|
48
|
+
type: :runtime
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
52
|
- - ">="
|
67
53
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rake
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '10.0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '10.0'
|
54
|
+
version: 3.0.0
|
83
55
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
56
|
+
name: bundler
|
85
57
|
requirement: !ruby/object:Gem::Requirement
|
86
58
|
requirements:
|
87
59
|
- - "~>"
|
88
60
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
61
|
+
version: '1.15'
|
90
62
|
type: :development
|
91
63
|
prerelease: false
|
92
64
|
version_requirements: !ruby/object:Gem::Requirement
|
93
65
|
requirements:
|
94
66
|
- - "~>"
|
95
67
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: webpacker
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 3.0.0
|
104
|
-
type: :runtime
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: 3.0.0
|
68
|
+
version: '1.15'
|
111
69
|
description: An opinionated way of organizing front-end code in Ruby on Rails, based
|
112
70
|
on components
|
113
71
|
email:
|
@@ -127,6 +85,10 @@ files:
|
|
127
85
|
- Rakefile
|
128
86
|
- bin/console
|
129
87
|
- bin/setup
|
88
|
+
- gemfiles/Gemfile-rails.4.2.x
|
89
|
+
- gemfiles/Gemfile-rails.5.0.x
|
90
|
+
- gemfiles/Gemfile-rails.5.1.x
|
91
|
+
- gemfiles/Gemfile-rails.5.2.x
|
130
92
|
- komponent.gemspec
|
131
93
|
- lib/generators/component/USAGE
|
132
94
|
- lib/generators/component/component_generator.rb
|
@@ -164,7 +126,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
164
126
|
requirements:
|
165
127
|
- - ">="
|
166
128
|
- !ruby/object:Gem::Version
|
167
|
-
version:
|
129
|
+
version: 2.2.0
|
168
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
131
|
requirements:
|
170
132
|
- - ">="
|