amber_extension_generator 0.0.5 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +69 -12
- data/banner.png +0 -0
- data/lib/amber_extension_generator/cli/gem_generator.rb +84 -45
- data/lib/amber_extension_generator/templates/.rubocop.yml +185 -0
- data/lib/amber_extension_generator/templates/README.md.erb +135 -0
- data/lib/amber_extension_generator/templates/amber_banner.png +0 -0
- data/lib/amber_extension_generator/templates/{components.rb → lib/components.rb} +0 -0
- data/lib/amber_extension_generator/templates/lib/generators/install_generator.rb.erb +36 -0
- data/lib/amber_extension_generator/templates/{railtie.rb.erb → lib/railtie.rb.erb} +0 -0
- data/lib/amber_extension_generator/version.rb +1 -1
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a14f864e671f06c059e8da1b34aafc3bcc03becea62e08f03faeeddc6ea1b92
|
4
|
+
data.tar.gz: 99ad7389987ca1bcbb9d8c122f838dcc3996f0f8601548d3e3003057a67e1c46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a39ed56ba680b27642c735d5862094f90993cb2f47bbe0b29659c14618711ba0cd424a688b8e944a8977b4b0ac4a503cb341cdb8efdd59f7f68824e31d5e5516
|
7
|
+
data.tar.gz: c694b24121dd28737eb87038d10540730cdc17d6714fa62baa84df2f12d7f215906975f31f72d9f8d1dccf1ee9984262166bff65e11bcdf418bd8d84f8abf020
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,36 +2,93 @@
|
|
2
2
|
[![CI badge](https://github.com/amber-ruby/amber_extension_generator/actions/workflows/ci_ruby.yml/badge.svg)](https://github.com/amber-ruby/amber_extension_generator/actions/workflows/ci_ruby.yml)
|
3
3
|
[![Coverage Badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/Verseth/82fd98743c74c8c36a9b04c9e325755e/raw/197794be336cde2bdaa3bccec99ebfc4660a3186/amber_extension_generator__heads_main.json)](https://github.com/amber-ruby/amber_extension_generator/actions/workflows/ci_ruby.yml)
|
4
4
|
|
5
|
-
|
5
|
+
<img src="banner.png" width="500px" style="margin-bottom: 2rem;"/>
|
6
6
|
|
7
|
-
|
7
|
+
# AmberExtensionGenerator
|
8
8
|
|
9
|
-
|
9
|
+
This library serves as a generator of [amber_component](https://github.com/amber-ruby/amber_component) component packs or extensions.
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
13
|
-
|
13
|
+
```sh
|
14
|
+
$ gem install amber_extension_generator
|
15
|
+
```
|
16
|
+
|
17
|
+
## Usage
|
14
18
|
|
15
|
-
|
19
|
+
You can generate a new component pack like so
|
16
20
|
|
17
|
-
|
21
|
+
```sh
|
22
|
+
$ amber_extension_generator my_library_name
|
23
|
+
```
|
18
24
|
|
19
|
-
|
25
|
+
This will create a new gem in `my_library_name` named `my_library_name`.
|
26
|
+
It has all the information on how to use it and develop it in its `README.md`.
|
20
27
|
|
21
|
-
|
28
|
+
It is generated with a dummy Rails app configured to hot-reload the gem.
|
29
|
+
This makes it possible to incredibly easy test your components in practice.
|
30
|
+
|
31
|
+
There is a custom test suite which makes it extremely easy to unit test components
|
32
|
+
by querying the generated HTML with special assertions.
|
22
33
|
|
23
|
-
|
34
|
+
More details can be found at [amber_component](https://github.com/amber-ruby/amber_component).
|
24
35
|
|
25
36
|
## Development
|
26
37
|
|
27
|
-
|
38
|
+
### Setup
|
39
|
+
|
40
|
+
To setup this gem for development you should run the setup script.
|
41
|
+
This should install all dependencies and make the gem ready.
|
42
|
+
|
43
|
+
```sh
|
44
|
+
$ bin/setup
|
45
|
+
```
|
46
|
+
|
47
|
+
### Console
|
48
|
+
|
49
|
+
To make development and experimenting easier there is a script
|
50
|
+
that lets you access an IRB with this entire gem preloaded.
|
51
|
+
|
52
|
+
```sh
|
53
|
+
$ bin/console
|
54
|
+
```
|
55
|
+
|
56
|
+
### Tests
|
28
57
|
|
29
|
-
|
58
|
+
You can run all tests like this.
|
59
|
+
|
60
|
+
```sh
|
61
|
+
$ bundle exec rake test
|
62
|
+
```
|
63
|
+
|
64
|
+
### Release
|
65
|
+
|
66
|
+
To release a new version, update the version number in `version.rb`, and then run
|
67
|
+
|
68
|
+
```sh
|
69
|
+
$ bundle exec rake release
|
70
|
+
```
|
71
|
+
|
72
|
+
This will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
73
|
+
|
74
|
+
### Local installation
|
75
|
+
|
76
|
+
To install this gem onto your local machine, run
|
77
|
+
|
78
|
+
```sh
|
79
|
+
$ bundle exec rake install
|
80
|
+
```
|
30
81
|
|
31
82
|
## Contributing
|
32
83
|
|
33
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
84
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/amber-ruby/amber_extension_generator.
|
34
85
|
|
35
86
|
## License
|
36
87
|
|
37
88
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
89
|
+
|
90
|
+
## Acknowledgement
|
91
|
+
|
92
|
+
This component pack generator is powered by [amber_component](https://github.com/amber-ruby/amber_component).
|
93
|
+
|
94
|
+
[<img src="banner.png" width="200px" style="margin-bottom: 2rem;"/>](https://github.com/amber-ruby/amber_component)
|
data/banner.png
ADDED
Binary file
|
@@ -12,7 +12,7 @@ using ::Rainbow
|
|
12
12
|
module ::AmberExtensionGenerator
|
13
13
|
module CLI
|
14
14
|
# Generates a new extension gem
|
15
|
-
class GemGenerator
|
15
|
+
class GemGenerator # rubocop:disable Metrics/ClassLength
|
16
16
|
class << self
|
17
17
|
# @param args [::AmberExtensionGenerator::CLI::Args]
|
18
18
|
# @return [void]
|
@@ -38,7 +38,7 @@ module ::AmberExtensionGenerator
|
|
38
38
|
|
39
39
|
# @return [void]
|
40
40
|
def generate_amber_gem
|
41
|
-
::CLI::UI::Frame.open 'Create gem', color: :green do
|
41
|
+
::CLI::UI::Frame.open 'Create gem', color: :green do
|
42
42
|
::CLI::UI::Frame.open 'Generate gem with bundler' do
|
43
43
|
syscall "bundle gem #{root_path} --linter=rubocop --ci=github --test=minitest", input: "y\n"
|
44
44
|
end
|
@@ -46,8 +46,8 @@ module ::AmberExtensionGenerator
|
|
46
46
|
::CLI::UI::Frame.open 'Patch gem' do
|
47
47
|
template 'components/base_component.rb.erb', gem_entry_folder_path / 'components' / 'base_component.rb'
|
48
48
|
|
49
|
-
copy 'components.rb', gem_entry_folder_path / 'components.rb'
|
50
|
-
template 'railtie.rb.erb', gem_entry_folder_path / 'railtie.rb'
|
49
|
+
copy 'lib/components.rb', gem_entry_folder_path / 'components.rb'
|
50
|
+
template 'lib/railtie.rb.erb', gem_entry_folder_path / 'railtie.rb'
|
51
51
|
|
52
52
|
substitute gem_entry_file_path, /^end/, <<~RUBY.chomp
|
53
53
|
end
|
@@ -62,47 +62,74 @@ module ::AmberExtensionGenerator
|
|
62
62
|
#{root_module_name}::ROOT_PATH = ::Pathname.new ::File.expand_path('#{relative_path_to_root}', __dir__)
|
63
63
|
RUBY
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
template 'bin/generate.erb', 'bin/generate'
|
68
|
-
template 'bin/dev.erb', 'bin/dev'
|
69
|
-
make_executable 'bin/generate'
|
70
|
-
make_executable 'bin/dev'
|
71
|
-
|
72
|
-
make_dir 'assets/stylesheets'
|
73
|
-
template 'assets/stylesheets/main.scss.erb', main_stylesheet_path
|
74
|
-
copy 'assets/stylesheets/components.scss', stylesheet_dir_path / 'components.scss'
|
75
|
-
|
76
|
-
make_dir 'templates'
|
77
|
-
copy 'templates/component.rb.tt'
|
78
|
-
copy 'templates/style.scss.tt'
|
79
|
-
copy 'templates/view.html.erb.tt'
|
80
|
-
copy 'templates/component_test.rb.tt'
|
81
|
-
|
82
|
-
substitute "#{gem_name}.gemspec", /^end/, <<~RUBY.chomp
|
83
|
-
# ignore the dummy Rails app when building the gem
|
84
|
-
spec.files.reject! { _1.match(/^#{rails_dummy_path}/) }
|
85
|
-
spec.add_dependency 'amber_component'
|
86
|
-
spec.add_development_dependency 'thor'
|
87
|
-
spec.add_development_dependency 'sassc'
|
88
|
-
end
|
89
|
-
RUBY
|
65
|
+
template 'lib/generators/install_generator.rb.erb',
|
66
|
+
::Pathname.new('lib') / 'generators' / gem_name_path / 'install_generator.rb'
|
90
67
|
|
91
|
-
copy '
|
92
|
-
|
93
|
-
|
94
|
-
move gem_test_folder_path.parent / "test_#{inner_module_name}.rb",
|
95
|
-
gem_test_folder_path.parent / "#{inner_module_name}_test.rb"
|
68
|
+
copy '.rubocop.yml'
|
69
|
+
template 'README.md.erb', 'README.md'
|
70
|
+
copy 'amber_banner.png'
|
96
71
|
|
97
|
-
|
98
|
-
|
72
|
+
generate_scripts
|
73
|
+
generate_assets
|
74
|
+
copy_templates
|
75
|
+
patch_gemspec
|
76
|
+
configure_tests
|
99
77
|
end
|
100
78
|
end
|
101
79
|
end
|
102
80
|
|
103
81
|
# @return [void]
|
104
|
-
def
|
105
|
-
|
82
|
+
def generate_scripts
|
83
|
+
template 'bin/generate.erb', 'bin/generate'
|
84
|
+
template 'bin/dev.erb', 'bin/dev'
|
85
|
+
make_executable 'bin/generate'
|
86
|
+
make_executable 'bin/dev'
|
87
|
+
end
|
88
|
+
|
89
|
+
# @return [void]
|
90
|
+
def generate_assets
|
91
|
+
make_dir 'assets/stylesheets'
|
92
|
+
template 'assets/stylesheets/main.scss.erb', main_stylesheet_path
|
93
|
+
copy 'assets/stylesheets/components.scss', stylesheet_dir_path / 'components.scss'
|
94
|
+
end
|
95
|
+
|
96
|
+
# @return [void]
|
97
|
+
def copy_templates
|
98
|
+
make_dir 'templates'
|
99
|
+
copy 'templates/component.rb.tt'
|
100
|
+
copy 'templates/style.scss.tt'
|
101
|
+
copy 'templates/view.html.erb.tt'
|
102
|
+
copy 'templates/component_test.rb.tt'
|
103
|
+
end
|
104
|
+
|
105
|
+
# @return [void]
|
106
|
+
def patch_gemspec
|
107
|
+
substitute "#{gem_name}.gemspec", /^end/, <<~RUBY.chomp
|
108
|
+
# ignore the dummy Rails app when building the gem
|
109
|
+
spec.files.reject! { _1.match(/^#{rails_dummy_path}/) }
|
110
|
+
spec.add_dependency 'amber_component', '~> #{VERSION}'
|
111
|
+
spec.add_development_dependency 'thor'
|
112
|
+
spec.add_development_dependency 'sassc'
|
113
|
+
spec.add_development_dependency 'capybara'
|
114
|
+
end
|
115
|
+
RUBY
|
116
|
+
end
|
117
|
+
|
118
|
+
# @return [void]
|
119
|
+
def configure_tests
|
120
|
+
copy 'test/component_test_case.rb'
|
121
|
+
substitute 'Rakefile', /test_\*\.rb/, '*_test.rb'
|
122
|
+
inner_module_name = gem_name.split('-').last
|
123
|
+
move gem_test_folder_path.parent / "test_#{inner_module_name}.rb",
|
124
|
+
gem_test_folder_path.parent / "#{inner_module_name}_test.rb"
|
125
|
+
|
126
|
+
append 'test/test_helper.rb',
|
127
|
+
"require_relative 'component_test_case'\n"
|
128
|
+
end
|
129
|
+
|
130
|
+
# @return [void]
|
131
|
+
def generate_rails_dummy_app # rubocop:disable Metrics/MethodLength
|
132
|
+
::CLI::UI::Frame.open 'Rails dummy app', color: :magenta do # rubocop:disable Metrics/BlockLength
|
106
133
|
unless syscall? 'gem list -i rails'
|
107
134
|
::CLI::UI::Frame.open 'Install Rails' do
|
108
135
|
syscall 'gem install rails'
|
@@ -123,6 +150,10 @@ module ::AmberExtensionGenerator
|
|
123
150
|
move rails_dummy_path / 'app' / 'assets' / 'stylesheets' / 'application.css',
|
124
151
|
rails_dummy_path / 'app' / 'assets' / 'stylesheets' / 'application.scss'
|
125
152
|
|
153
|
+
append rails_dummy_path / 'app' / 'assets' / 'stylesheets' / 'application.scss', <<~SCSS
|
154
|
+
@import "#{gem_name_path}";
|
155
|
+
SCSS
|
156
|
+
elsif exist?(rails_dummy_path / 'app' / 'assets' / 'stylesheets' / 'application.scss')
|
126
157
|
append rails_dummy_path / 'app' / 'assets' / 'stylesheets' / 'application.scss', <<~SCSS
|
127
158
|
@import "#{gem_name_path}";
|
128
159
|
SCSS
|
@@ -198,6 +229,11 @@ module ::AmberExtensionGenerator
|
|
198
229
|
@gem_name_path ||= ::Pathname.new gem_name.gsub('-', '/')
|
199
230
|
end
|
200
231
|
|
232
|
+
# @return [String]
|
233
|
+
def gem_name_rake
|
234
|
+
gem_name.gsub('-', ':')
|
235
|
+
end
|
236
|
+
|
201
237
|
# Name of the generated gem.
|
202
238
|
#
|
203
239
|
# @return [String]
|
@@ -205,6 +241,13 @@ module ::AmberExtensionGenerator
|
|
205
241
|
@gem_name ||= root_path.basename.to_s
|
206
242
|
end
|
207
243
|
|
244
|
+
# Name of the root module of the generated gem.
|
245
|
+
#
|
246
|
+
# @return [String]
|
247
|
+
def root_module_name
|
248
|
+
@root_module_name ||= camelize(gem_name_path)
|
249
|
+
end
|
250
|
+
|
208
251
|
# Relative path to the stylesheet directory of the generated gem.
|
209
252
|
#
|
210
253
|
# @return [Pathname]
|
@@ -231,6 +274,9 @@ module ::AmberExtensionGenerator
|
|
231
274
|
@args.gem_path
|
232
275
|
end
|
233
276
|
|
277
|
+
# Path to the Rails template used to generate
|
278
|
+
# the dummy development app in the generated gem.
|
279
|
+
#
|
234
280
|
# @return [Pathname]
|
235
281
|
def rails_template_path
|
236
282
|
ROOT_GEM_PATH / 'lib' / 'dummy_rails_app_template.rb'
|
@@ -378,13 +424,6 @@ module ::AmberExtensionGenerator
|
|
378
424
|
::File.open(path, 'a') { _1.write(content) }
|
379
425
|
end
|
380
426
|
|
381
|
-
# Name of the root module of the generated gem.
|
382
|
-
#
|
383
|
-
# @return [String]
|
384
|
-
def root_module_name
|
385
|
-
camelize(gem_name_path)
|
386
|
-
end
|
387
|
-
|
388
427
|
# @param string [String]
|
389
428
|
# @param uppercase_first_letter [Boolean]
|
390
429
|
# @return [String]
|
@@ -0,0 +1,185 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.7
|
3
|
+
SuggestExtensions: false
|
4
|
+
EnabledByDefault: true
|
5
|
+
Exclude:
|
6
|
+
- 'bin/*'
|
7
|
+
- 'vendor/bundle/**/*'
|
8
|
+
- 'spec/**/*'
|
9
|
+
- 'test/**/*'
|
10
|
+
- 'dummy_app/**/*'
|
11
|
+
|
12
|
+
Style/ClassMethodsDefinitions:
|
13
|
+
EnforcedStyle: self_class
|
14
|
+
|
15
|
+
Style/StringLiterals:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Layout/RedundantLineBreak:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Layout/EmptyLinesAroundExceptionHandlingKeywords:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Layout/EmptyLinesAroundBlockBody:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
Layout/EmptyLines:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
Layout/EmptyLinesAroundClassBody:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
Layout/EmptyLinesAroundModuleBody:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
Layout/HashAlignment:
|
37
|
+
Enabled: false
|
38
|
+
|
39
|
+
Metrics/AbcSize:
|
40
|
+
Enabled: false
|
41
|
+
|
42
|
+
Metrics/MethodLength:
|
43
|
+
Max: 30
|
44
|
+
|
45
|
+
Metrics/ClassLength:
|
46
|
+
Max: 200
|
47
|
+
|
48
|
+
Metrics/CyclomaticComplexity:
|
49
|
+
Max: 12
|
50
|
+
|
51
|
+
Style/Alias:
|
52
|
+
Enabled: false
|
53
|
+
|
54
|
+
Style/DisableCopsWithinSourceCodeDirective:
|
55
|
+
Enabled: false
|
56
|
+
|
57
|
+
Layout/ExtraSpacing:
|
58
|
+
Enabled: false
|
59
|
+
|
60
|
+
Layout/SingleLineBlockChain:
|
61
|
+
Enabled: false
|
62
|
+
|
63
|
+
Metrics/PerceivedComplexity:
|
64
|
+
Max: 12
|
65
|
+
|
66
|
+
Layout/ClassStructure:
|
67
|
+
Enabled: false
|
68
|
+
|
69
|
+
Style/OpenStructUse:
|
70
|
+
Enabled: true
|
71
|
+
|
72
|
+
Style/MethodCalledOnDoEndBlock:
|
73
|
+
Enabled: true
|
74
|
+
|
75
|
+
Style/LambdaCall:
|
76
|
+
Enabled: false
|
77
|
+
|
78
|
+
Style/OptionHash:
|
79
|
+
Enabled: false
|
80
|
+
|
81
|
+
Style/QuotedSymbols:
|
82
|
+
Enabled: true
|
83
|
+
|
84
|
+
Style/ReturnNil:
|
85
|
+
Enabled: true
|
86
|
+
EnforcedStyle: return
|
87
|
+
|
88
|
+
Style/ArrayCoercion:
|
89
|
+
Enabled: true
|
90
|
+
|
91
|
+
Style/AutoResourceCleanup:
|
92
|
+
Enabled: true
|
93
|
+
|
94
|
+
Style/StringChars:
|
95
|
+
Enabled: true
|
96
|
+
|
97
|
+
Style/TopLevelMethodDefinition:
|
98
|
+
Enabled: true
|
99
|
+
|
100
|
+
Style/RedundantArgument:
|
101
|
+
Enabled: true
|
102
|
+
|
103
|
+
Lint/MissingSuper:
|
104
|
+
Enabled: false
|
105
|
+
|
106
|
+
Style/Documentation:
|
107
|
+
Enabled: true
|
108
|
+
|
109
|
+
Style/ClassAndModuleChildren:
|
110
|
+
Enabled: false
|
111
|
+
|
112
|
+
Naming/BlockForwarding:
|
113
|
+
Enabled: true
|
114
|
+
|
115
|
+
Style/ImplicitRuntimeError:
|
116
|
+
Enabled: false
|
117
|
+
|
118
|
+
Style/InPatternThen:
|
119
|
+
Enabled: true
|
120
|
+
|
121
|
+
Style/MethodCallWithArgsParentheses:
|
122
|
+
Enabled: false
|
123
|
+
|
124
|
+
Style/ModuleFunction:
|
125
|
+
EnforcedStyle: extend_self
|
126
|
+
|
127
|
+
Style/MissingElse:
|
128
|
+
Enabled: false
|
129
|
+
|
130
|
+
Lint/NumberConversion:
|
131
|
+
Enabled: false
|
132
|
+
|
133
|
+
Lint/ConstantResolution:
|
134
|
+
Enabled: false
|
135
|
+
|
136
|
+
Style/RescueStandardError:
|
137
|
+
Enabled: false
|
138
|
+
|
139
|
+
Style/FormatStringToken:
|
140
|
+
Enabled: false
|
141
|
+
|
142
|
+
Style/FormatString:
|
143
|
+
Enabled: false
|
144
|
+
|
145
|
+
Style/DocumentationMethod:
|
146
|
+
Enabled: false
|
147
|
+
|
148
|
+
Style/Copyright:
|
149
|
+
Enabled: false
|
150
|
+
|
151
|
+
Style/StringHashKeys:
|
152
|
+
Enabled: false
|
153
|
+
|
154
|
+
Style/InlineComment:
|
155
|
+
Enabled: false
|
156
|
+
|
157
|
+
Layout/FirstHashElementLineBreak:
|
158
|
+
Enabled: false
|
159
|
+
|
160
|
+
Layout/FirstMethodArgumentLineBreak:
|
161
|
+
Enabled: false
|
162
|
+
|
163
|
+
Style/ConstantVisibility:
|
164
|
+
Enabled: false
|
165
|
+
|
166
|
+
Layout/FirstArrayElementLineBreak:
|
167
|
+
Enabled: false
|
168
|
+
|
169
|
+
Layout/MultilineMethodArgumentLineBreaks:
|
170
|
+
Enabled: false
|
171
|
+
|
172
|
+
Layout/MultilineAssignmentLayout:
|
173
|
+
Enabled: false
|
174
|
+
|
175
|
+
Bundler/GemComment:
|
176
|
+
Enabled: false
|
177
|
+
|
178
|
+
Bundler/GemVersion:
|
179
|
+
Enabled: false
|
180
|
+
|
181
|
+
Layout/LineLength:
|
182
|
+
Max: 120
|
183
|
+
|
184
|
+
Style/IfUnlessModifier:
|
185
|
+
Enabled: false
|
@@ -0,0 +1,135 @@
|
|
1
|
+
# <%= root_module_name %>
|
2
|
+
|
3
|
+
Welcome to your [amber_component](https://github.com/amber-ruby/amber_component/) component pack! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `<%= gem_entry_folder_path %>`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Install the gem and add to the application's Gemfile by executing:
|
10
|
+
|
11
|
+
```sh
|
12
|
+
$ bundle add <%= gem_name %>
|
13
|
+
```
|
14
|
+
|
15
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
|
+
|
17
|
+
```sh
|
18
|
+
$ gem install <%= gem_name %>
|
19
|
+
```
|
20
|
+
|
21
|
+
Afterwards you need to import this gem's SCSS stylesheet like so:
|
22
|
+
|
23
|
+
```scss
|
24
|
+
@import "<%= gem_name_path %>";
|
25
|
+
```
|
26
|
+
|
27
|
+
If you're using Rails, that line should be appended to `app/assets/stylesheets/application.scss`.
|
28
|
+
|
29
|
+
There is a generator that does it for you.
|
30
|
+
|
31
|
+
```sh
|
32
|
+
bin/rails generate <%= gem_name_rake %>:install
|
33
|
+
```
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
TODO: Write usage instructions here
|
38
|
+
|
39
|
+
## Development
|
40
|
+
|
41
|
+
### Setup
|
42
|
+
|
43
|
+
To setup this gem for development you should run the setup script.
|
44
|
+
This should install all dependencies and make the gem ready.
|
45
|
+
|
46
|
+
```sh
|
47
|
+
$ bin/setup
|
48
|
+
```
|
49
|
+
|
50
|
+
### Console
|
51
|
+
|
52
|
+
To make development and experimenting easier there is a script
|
53
|
+
that lets you access an IRB with this entire gem preloaded.
|
54
|
+
|
55
|
+
```sh
|
56
|
+
$ bin/console
|
57
|
+
```
|
58
|
+
|
59
|
+
### Development app
|
60
|
+
|
61
|
+
There is a dummy Rails app in `dummy_app` which has this gem installed and configured
|
62
|
+
for hot-reloading. You don't have to restart the server when you make changes to your gem,
|
63
|
+
it will reload automatically.
|
64
|
+
|
65
|
+
You can start it by running
|
66
|
+
|
67
|
+
```sh
|
68
|
+
$ bin/dev
|
69
|
+
```
|
70
|
+
|
71
|
+
You can use it to experiment with your components.
|
72
|
+
|
73
|
+
### Generating new components
|
74
|
+
|
75
|
+
You can generate new component by running
|
76
|
+
|
77
|
+
```sh
|
78
|
+
$ bin/generate component button
|
79
|
+
```
|
80
|
+
|
81
|
+
This will create a few files:
|
82
|
+
- the logic/mini controller of your component `<%= gem_entry_folder_path %>/components/button_component.rb` containing `<%= root_module_name %>::ButtonComponent`
|
83
|
+
- your component's template/view `<%= gem_entry_folder_path %>/components/button_component/view.html.erb`
|
84
|
+
- your component's stylesheet `<%= gem_entry_folder_path %>/components/button_component/style.scss`
|
85
|
+
- your component's test file `<%= gem_test_folder_path %>/components/button_component_test.rb`
|
86
|
+
|
87
|
+
The stylesheet of your new component will be automatically imported
|
88
|
+
in `assets/stylesheets/<%= gem_name_path %>/components.scss`.
|
89
|
+
|
90
|
+
More details on how these components work can be found at [amber_component](https://github.com/amber-ruby/amber_component).
|
91
|
+
|
92
|
+
### Tests
|
93
|
+
|
94
|
+
You can run all tests like this.
|
95
|
+
|
96
|
+
```sh
|
97
|
+
$ bundle exec rake test
|
98
|
+
```
|
99
|
+
|
100
|
+
You can unit test your components using the custom test suite which provides
|
101
|
+
handy assertions for the HTML rendered by your component.
|
102
|
+
More details can be found at [amber_component](https://github.com/amber-ruby/amber_component).
|
103
|
+
|
104
|
+
### Release
|
105
|
+
|
106
|
+
To release a new version, update the version number in `version.rb`, and then run
|
107
|
+
|
108
|
+
```sh
|
109
|
+
$ bundle exec rake release
|
110
|
+
```
|
111
|
+
|
112
|
+
This will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
113
|
+
|
114
|
+
### Local installation
|
115
|
+
|
116
|
+
To install this gem onto your local machine, run
|
117
|
+
|
118
|
+
```sh
|
119
|
+
$ bundle exec rake install
|
120
|
+
```
|
121
|
+
|
122
|
+
## Contributing
|
123
|
+
|
124
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/<%= gem_name %>.
|
125
|
+
|
126
|
+
## License
|
127
|
+
|
128
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
129
|
+
|
130
|
+
## Acknowledgement
|
131
|
+
|
132
|
+
This component pack is powered by [amber_component](https://github.com/amber-ruby/amber_component) and has been generated with [amber_extension_generator](https://github.com/amber-ruby/amber_extension_generator).
|
133
|
+
|
134
|
+
[<img src="amber_banner.png" width="200px" style="margin-bottom: 2rem;"/>](https://github.com/amber-ruby/amber_component)
|
135
|
+
|
Binary file
|
File without changes
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
module <%= root_module_name %>
|
6
|
+
module Generators
|
7
|
+
# A Rails generator which installs the
|
8
|
+
# library in a Rails project.
|
9
|
+
class InstallGenerator < ::Rails::Generators::Base
|
10
|
+
desc 'Install the <%= gem_name %> gem'
|
11
|
+
|
12
|
+
def install
|
13
|
+
uncomment_lines 'Gemfile', /sassc-rails/
|
14
|
+
|
15
|
+
if ::File.exist? 'app/assets/stylesheets/application.css.scss'
|
16
|
+
::FileUtils.move 'app/assets/stylesheets/application.css.scss', 'app/assets/stylesheets/application.scss'
|
17
|
+
end
|
18
|
+
|
19
|
+
if ::File.exist? 'app/assets/stylesheets/application.css.sass'
|
20
|
+
::FileUtils.move 'app/assets/stylesheets/application.css.sass', 'app/assets/stylesheets/application.sass'
|
21
|
+
end
|
22
|
+
|
23
|
+
if ::File.exist? 'app/assets/stylesheets/application.css'
|
24
|
+
::FileUtils.move 'app/assets/stylesheets/application.css', 'app/assets/stylesheets/application.scss'
|
25
|
+
end
|
26
|
+
|
27
|
+
if ::File.exist? 'app/assets/stylesheets/application.scss'
|
28
|
+
append_file 'app/assets/stylesheets/application.scss', %(@import "<%= gem_name_path %>";\n)
|
29
|
+
elsif ::File.exist? 'app/assets/stylesheets/application.sass'
|
30
|
+
append_file 'app/assets/stylesheets/application.sass', %(@import "<%= gem_name_path %>"\n)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amber_extension_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruby-Amber
|
@@ -76,20 +76,25 @@ files:
|
|
76
76
|
- README.md
|
77
77
|
- Rakefile
|
78
78
|
- amber_extension_generator.gemspec
|
79
|
+
- banner.png
|
79
80
|
- exe/amber_extension_generator
|
80
81
|
- lib/amber_extension_generator.rb
|
81
82
|
- lib/amber_extension_generator/cli.rb
|
82
83
|
- lib/amber_extension_generator/cli/args.rb
|
83
84
|
- lib/amber_extension_generator/cli/gem_generator.rb
|
84
85
|
- lib/amber_extension_generator/gem_name.rb
|
86
|
+
- lib/amber_extension_generator/templates/.rubocop.yml
|
87
|
+
- lib/amber_extension_generator/templates/README.md.erb
|
88
|
+
- lib/amber_extension_generator/templates/amber_banner.png
|
85
89
|
- lib/amber_extension_generator/templates/assets/stylesheets/components.scss
|
86
90
|
- lib/amber_extension_generator/templates/assets/stylesheets/main.scss.erb
|
87
91
|
- lib/amber_extension_generator/templates/bin/dev.erb
|
88
92
|
- lib/amber_extension_generator/templates/bin/generate.erb
|
89
|
-
- lib/amber_extension_generator/templates/components.rb
|
90
93
|
- lib/amber_extension_generator/templates/components/base_component.rb.erb
|
94
|
+
- lib/amber_extension_generator/templates/lib/components.rb
|
95
|
+
- lib/amber_extension_generator/templates/lib/generators/install_generator.rb.erb
|
96
|
+
- lib/amber_extension_generator/templates/lib/railtie.rb.erb
|
91
97
|
- lib/amber_extension_generator/templates/rails_dummy/Gemfile.erb
|
92
|
-
- lib/amber_extension_generator/templates/railtie.rb.erb
|
93
98
|
- lib/amber_extension_generator/templates/templates/component.rb.tt
|
94
99
|
- lib/amber_extension_generator/templates/templates/component_test.rb.tt
|
95
100
|
- lib/amber_extension_generator/templates/templates/style.scss.tt
|