flame_app_generator 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d84774abfa166f8a221a8af59ec007a4b3edd2398f9498261c855ea3e9656d90
4
+ data.tar.gz: 504e40670137ef53eac00efc95d49ebf54980a79fda02f828ad01d225470bf8e
5
+ SHA512:
6
+ metadata.gz: f3dc8ab12f7b9d33fabee02e63f5ad2fdd456692b44dd7f71e6cea6ed0ec0ce0338c9116a3e2ac5c7a9070711ec37602a33ac1ce17270ed8084add5dcc8f8971
7
+ data.tar.gz: 5e442c6b64d76d2706c67ea7c00737238e9f077f416701d5799ec0a24df17de34974844150df2938d5832c516cfa204829d13940a27754aab5326debf1e9a36d
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Changelog
2
+
3
+ ## Unreleased
4
+
5
+ ## 0.1.0 (2023-11-06)
6
+
7
+ * Initial release.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Alexander Popov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,106 @@
1
+ # Flame App Generator
2
+
3
+ [![Cirrus CI - Base Branch Build Status](https://img.shields.io/cirrus/github/AlexWayfer/flame_app_generator?style=flat-square)](https://cirrus-ci.com/github/AlexWayfer/flame_app_generator)
4
+ [![Codecov branch](https://img.shields.io/codecov/c/github/AlexWayfer/flame_app_generator/main.svg?style=flat-square)](https://codecov.io/gh/AlexWayfer/flame_app_generator)
5
+ [![Code Climate](https://img.shields.io/codeclimate/maintainability/AlexWayfer/flame_app_generator.svg?style=flat-square)](https://codeclimate.com/github/AlexWayfer/flame_app_generator)
6
+ [![Depfu](https://img.shields.io/depfu/AlexWayfer/flame_app_generator?style=flat-square)](https://depfu.com/repos/github/AlexWayfer/flame_app_generator)
7
+ [![license](https://img.shields.io/github/license/AlexWayfer/flame_app_generator.svg?style=flat-square)](LICENSE.txt)
8
+ [![Gem](https://img.shields.io/gem/v/flame_app_generator.svg?style=flat-square)](https://rubygems.org/gems/flame_app_generator)
9
+
10
+ Gem for new [Flame](https://github.com/AlexWayfer/flame) web applications generation.
11
+
12
+ It was created for myself, but you can suggest options for generation to adopt it for your usage.
13
+
14
+ ## Installation
15
+
16
+ Install it globally:
17
+
18
+ ```shell
19
+ gem install flame_app_generator
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ ### With local template
25
+
26
+ ```sh
27
+ flame_app_generator name_of_a_new_app path/to/template
28
+ ```
29
+
30
+ ### With GitHub template
31
+
32
+ ```sh
33
+ flame_app_generator name_of_a_new_app template_github_org/template_github_repo --git
34
+ ```
35
+
36
+ Be aware: `flame_app_generator` uses `template/` directory from the GitHub repo, not the root one.
37
+
38
+ ### With custom project name
39
+
40
+ It can be used instead of camelized app name, for example:
41
+
42
+ ```sh
43
+ flame_app_generator foobar path/to/template --project-name=FooBar
44
+ ```
45
+
46
+ ### With custom domain
47
+
48
+ It can be used instead of default `.com` domain, for example:
49
+
50
+ ```sh
51
+ flame_app_generator foobar path/to/template --domain=foo-bar.dev
52
+ ```
53
+
54
+ ## Template creation
55
+
56
+ Example of gem template you can see at [AlexWayfer/flame_app_template](https://github.com/AlexWayfer/flame_app_template).
57
+
58
+ Available paths:
59
+
60
+ | Path part | Example of source | Example of result |
61
+ | ---------- | ----------------- | ----------------- |
62
+ | `app_name` | `app_name.rb` | `foo_bar.rb` |
63
+
64
+ Any `*.erb` file will be rendered via [ERB](https://ruby-doc.org/stdlib/libdoc/erb/rdoc/ERB.html);
65
+ if you want an `*.erb` file as result — name it as `*.erb.erb` (even if there are no tags).
66
+
67
+ Available variables:
68
+
69
+ | Variable | Example of result | Default |
70
+ | ------------------- | ------------------ | ------------------------------- |
71
+ | `name`, `app_name` | `foo_bar` | _required_ |
72
+ | `module_name` | `FooBar` | camelized app name |
73
+ | `short_module_name` | `FB` | upcased chars from module name |
74
+ | `domain_name` | `foobar.com` | downcased module name + `.com` |
75
+ | `indentation` | `tabs` or `spaces` | `tabs` (it's easier to convert) |
76
+
77
+ By default indentation is `tabs`, but if a template spaces-indented — option will not affect.
78
+ So, this option only for tabs-indented templates.
79
+
80
+ ### Git templates
81
+
82
+ You can create public git-templates and then guide users to call
83
+ `flame_app_generator app_name your_org/your_repo --git`,
84
+ but be aware that `flame_app_generator` will look for template inside `template/` directory
85
+ to allow you having out-of-template README, specs (for the template itself), anything else.
86
+
87
+ ## Development
88
+
89
+ After checking out the repo, run `bundle install` to install dependencies.
90
+
91
+ Then, run `bundle exec rspec` to run the tests.
92
+
93
+ To install this gem onto your local machine, run `toys gem install`.
94
+
95
+ To release a new version, run `toys gem release %version%`.
96
+ See how it works [here](https://github.com/AlexWayfer/gem_toys#release).
97
+
98
+ ## Contributing
99
+
100
+ Bug reports and pull requests are welcome
101
+ on [GitHub](https://github.com/AlexWayfer/flame_app_generator).
102
+
103
+ ## License
104
+
105
+ The gem is available as open source under the terms of the
106
+ [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # frozen_string_literal: true
4
+
5
+ require_relative '../lib/flame_app_generator/command'
6
+
7
+ FlameAppGenerator::Command.run
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'gorilla_patch/blank'
4
+
5
+ ## For internal templates usage
6
+ require 'date'
7
+ require 'securerandom'
8
+
9
+ module FlameAppGenerator
10
+ class Command < ProjectGenerator::Command
11
+ module ProcessFiles
12
+ ## Class for a single object which should be a scope in render
13
+ class RenderVariables < ProjectGenerator::Command::ProcessFiles::RenderVariables
14
+ using GorillaPatch::Inflections
15
+
16
+ attr_reader :module_name, :domain_name
17
+
18
+ alias app_name name
19
+
20
+ def initialize(name, project_name, domain, indentation)
21
+ super name, indentation
22
+
23
+ @module_name = project_name || app_name.camelize
24
+
25
+ @domain_name = domain || "#{@module_name.downcase}.com"
26
+ end
27
+
28
+ undef_method :path
29
+
30
+ memoize def short_module_name
31
+ module_name.split(/([[:upper:]][[:lower:]]*)/).map! { |s| s[0] }.join
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'process_files/render_variables'
4
+
5
+ module FlameAppGenerator
6
+ class Command < ProjectGenerator::Command
7
+ ## Private instance methods for processing template files (copying, renaming, rendering)
8
+ module ProcessFiles
9
+ RENAME_FILES_PLACEHOLDERS = {
10
+ name: 'app_name'
11
+ }.freeze
12
+
13
+ private
14
+
15
+ def initialize_render_variables
16
+ self.class::RenderVariables.new name, project_name, domain, indentation
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler'
4
+ require 'project_generator'
5
+
6
+ require_relative 'command/process_files'
7
+
8
+ ## https://github.com/mdub/clamp#allowing-options-after-parameters
9
+ Clamp.allow_options_after_parameters = true
10
+
11
+ module FlameAppGenerator
12
+ ## Main CLI command for Flame App Generator
13
+ class Command < ProjectGenerator::Command
14
+ include ProcessFiles
15
+
16
+ parameter 'NAME', 'name of a new application'
17
+ parameter 'TEMPLATE', 'template path of a new app'
18
+
19
+ option ['-d', '--domain'], 'NAME', 'domain name for configuration'
20
+ option ['-p', '--project-name'], 'NAME', 'project name for code and configuration'
21
+
22
+ def execute
23
+ check_target_directory
24
+
25
+ refine_template_parameter if git?
26
+
27
+ process_files
28
+
29
+ clean_dirs
30
+
31
+ initialize_git
32
+
33
+ setup_project
34
+
35
+ FileUtils.rm_r @git_tmp_dir if git?
36
+
37
+ done
38
+ end
39
+
40
+ private
41
+
42
+ def clean_dirs
43
+ puts 'Clean directories...'
44
+
45
+ FileUtils.rm Dir.glob('**/.keep', File::FNM_DOTMATCH)
46
+ end
47
+
48
+ def setup_project
49
+ puts 'Setup project...'
50
+
51
+ Dir.chdir name do
52
+ Bundler.with_unbundled_env do
53
+ system 'exe/setup.sh'
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FlameAppGenerator
4
+ VERSION = '0.1.0'
5
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flame_app_generator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Popov
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-11-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gorilla_patch
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: project_generator
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.3.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.3.0
41
+ description: 'Generator for Flame web applications.
42
+
43
+ '
44
+ email:
45
+ - alex.wayfer@gmail.com
46
+ executables:
47
+ - flame_app_generator
48
+ extensions: []
49
+ extra_rdoc_files: []
50
+ files:
51
+ - CHANGELOG.md
52
+ - LICENSE.txt
53
+ - README.md
54
+ - exe/flame_app_generator
55
+ - lib/flame_app_generator/command.rb
56
+ - lib/flame_app_generator/command/process_files.rb
57
+ - lib/flame_app_generator/command/process_files/render_variables.rb
58
+ - lib/flame_app_generator/version.rb
59
+ homepage: https://github.com/AlexWayfer/flame_app_generator
60
+ licenses:
61
+ - MIT
62
+ metadata:
63
+ rubygems_mfa_required: 'true'
64
+ bug_tracker_uri: https://github.com/AlexWayfer/flame_app_generator/issues
65
+ changelog_uri: https://github.com/AlexWayfer/flame_app_generator/blob/v0.1.0/CHANGELOG.md
66
+ homepage_uri: https://github.com/AlexWayfer/flame_app_generator
67
+ source_code_uri: https://github.com/AlexWayfer/flame_app_generator
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '3.0'
77
+ - - "<"
78
+ - !ruby/object:Gem::Version
79
+ version: '4'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubygems_version: 3.4.21
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: Generator for Flame web applications
90
+ test_files: []