komponent 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/.travis.yml +1 -0
- data/CHANGELOG.md +8 -2
- data/README.md +8 -0
- data/komponent.gemspec +1 -1
- data/lib/generators/component/component_generator.rb +47 -0
- data/lib/komponent/komponent_helper.rb +1 -1
- data/lib/komponent/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83a583b1f8468d26403f19dfdd6113e3dd0f10be
|
4
|
+
data.tar.gz: f2a0d993bdc7349b0b7c1370df7758b618664f09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d07b311a6fc9fd55ce0bfa06f08991b48498db7361bfa59da47e90b0a49c098378b965049fa5be51f622e000f41b9238b280eb0b0ae7673da37a47999e9d38e
|
7
|
+
data.tar.gz: fe2e28f5cc9ff5f55c591e0d0680c8d8741e3892d68c47c9307f05dde502471c47442831e7c7801767e10abb4d511b87ad9959255bd6c0e277b4ced1af180da4
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
## Upcoming release
|
4
4
|
|
5
|
+
**Enhancements:**
|
6
|
+
- Custom destroy for the component generator: you can now safely run `rails d component button`
|
7
|
+
|
8
|
+
**Bug fixes:**
|
9
|
+
- Fix crash when `nil` is passed to a component
|
10
|
+
|
11
|
+
## v1.1.2 (2018-02-13)
|
12
|
+
|
5
13
|
**Enhancements:**
|
6
14
|
- Support for Stimulus 1.0
|
7
15
|
- `import`s are now sorted alphabetically every time you run the component generator
|
@@ -34,7 +42,6 @@ imported in JavaScript files
|
|
34
42
|
## v1.0.0 (2018-01-01)
|
35
43
|
|
36
44
|
**Enhancements:**
|
37
|
-
|
38
45
|
- Components namespacing
|
39
46
|
- Implement basic features
|
40
47
|
- Implement `render_partial` helper
|
@@ -42,7 +49,6 @@ imported in JavaScript files
|
|
42
49
|
## v1.0.0.pre.2 (2017-12-09)
|
43
50
|
|
44
51
|
**Enhancements:**
|
45
|
-
|
46
52
|
- Lazy-load helpers and configuration
|
47
53
|
- Add an install generator (`rails g komponent:install`)
|
48
54
|
- Standardize components name (underscore for all except css classes are dasherized)
|
data/README.md
CHANGED
@@ -27,6 +27,7 @@ This gem has been inspired by our Rails development practices at [Ouvrages](http
|
|
27
27
|
- [Namespacing components](#namespacing-components)
|
28
28
|
- [Stimulus integration](#stimulus-integration)
|
29
29
|
- [Internationalization](#internationalization)
|
30
|
+
- [Available locales configuration](#available-locales-configuration)
|
30
31
|
- [Configuration](#configuration)
|
31
32
|
- [Change default root path](#change-default-root-path)
|
32
33
|
- [Default options for the generators](#default-options-for-the-generators)
|
@@ -259,6 +260,13 @@ fr:
|
|
259
260
|
external_link: "lien externe"
|
260
261
|
```
|
261
262
|
|
263
|
+
#### Available locales configuration
|
264
|
+
|
265
|
+
You can whitelist the locales you use by setting this into an initializer, as explained in the ["official guide"](http://guides.rubyonrails.org/i18n.html#configure-the-i18n-module):
|
266
|
+
```ruby
|
267
|
+
I18n.available_locales = [:en, :fr]
|
268
|
+
```
|
269
|
+
|
262
270
|
### Configuration
|
263
271
|
|
264
272
|
#### Default options for the generators
|
data/komponent.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
-
f.match(%r{^(test|spec|features)/})
|
17
|
+
f.match(%r{^(test|spec|features|fixtures)/})
|
18
18
|
end
|
19
19
|
spec.bindir = "exe"
|
20
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
@@ -64,6 +64,37 @@ class ComponentGenerator < Rails::Generators::NamedBase
|
|
64
64
|
sort_lines_alphabetically!(base_path + "index.js")
|
65
65
|
end
|
66
66
|
|
67
|
+
def clear_component
|
68
|
+
return unless destroying?
|
69
|
+
|
70
|
+
base_path = default_path + "components"
|
71
|
+
base_path_dup = base_path.dup
|
72
|
+
|
73
|
+
paths = split_name[0..-2].map do |split|
|
74
|
+
base_path_dup += split
|
75
|
+
[base_path_dup, split]
|
76
|
+
end
|
77
|
+
|
78
|
+
paths.reverse.each do |(path, split)|
|
79
|
+
FileUtils.rm_rf(component_path)
|
80
|
+
|
81
|
+
Dir.chdir(path)
|
82
|
+
directories = Dir.glob("*").select do |entry|
|
83
|
+
File.directory?(entry)
|
84
|
+
end
|
85
|
+
|
86
|
+
if directories.size == 0
|
87
|
+
FileUtils.rm_rf(path)
|
88
|
+
remove_line!(base_path + "index.js", split)
|
89
|
+
else
|
90
|
+
remove_line!(path + "index.js", component_name)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
FileUtils.rm_rf(component_path)
|
95
|
+
remove_line!(base_path + "index.js", component_name)
|
96
|
+
end
|
97
|
+
|
67
98
|
protected
|
68
99
|
|
69
100
|
def template_prefix
|
@@ -154,4 +185,20 @@ class ComponentGenerator < Rails::Generators::NamedBase
|
|
154
185
|
end
|
155
186
|
end
|
156
187
|
end
|
188
|
+
|
189
|
+
def remove_line!(path, component_name)
|
190
|
+
lines = File.readlines(path).map do |line|
|
191
|
+
line unless line =~ /#{component_name}/
|
192
|
+
end.compact
|
193
|
+
|
194
|
+
File.open(path, "w") do |f|
|
195
|
+
lines.each do |line|
|
196
|
+
f.write(line)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def destroying?
|
202
|
+
self.behavior == :revoke
|
203
|
+
end
|
157
204
|
end
|
@@ -37,7 +37,7 @@ module KomponentHelper
|
|
37
37
|
end
|
38
38
|
|
39
39
|
locals.each do |name, value|
|
40
|
-
instance_variable_set(:"@#{name}", locals[name]
|
40
|
+
instance_variable_set(:"@#{name}", locals[name])
|
41
41
|
end
|
42
42
|
|
43
43
|
instance_variable_set(:"@block_given_to_component", block)
|
data/lib/komponent/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ouvrages
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aruba
|