mvc_one 0.1.0.pre.rc1

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: 83b06832bc6afc138ec694b723c2bc13f2f39827fb46770d7773a3048d91c42f
4
+ data.tar.gz: bd99db661af0cede4f3f65ecbca91ac20c9d933cb8f3ab52ee2a03649d0d4068
5
+ SHA512:
6
+ metadata.gz: d84541b370a67866d35f88f52988d5245a705ad78cc7591bc88637237d58b1e96fafb29ec3e430bbe084c9df83c86675b557018cd5549fb8390eeabf04d93034
7
+ data.tar.gz: 2faed9bd7a152d766c09c1c157da12f7ea35142d8edbe1e4e6176277c31e6a268ec03bb999693b669daf9c9b4cc84803cdda200ae069d26eca33db9c41045f5c
data/.idea/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Editor-based HTTP Client requests
5
+ /httpRequests/
6
+ # Datasource local storage ignored files
7
+ /dataSources/
8
+ /dataSources.local.xml
data/.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/mvc_one.iml" filepath="$PROJECT_DIR$/.idea/mvc_one.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
data/.idea/mvc_one.iml ADDED
@@ -0,0 +1,76 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="ModuleRunConfigurationManager">
4
+ <shared />
5
+ </component>
6
+ <component name="NewModuleRootManager">
7
+ <content url="file://$MODULE_DIR$">
8
+ <sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
9
+ <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
10
+ <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
11
+ </content>
12
+ <orderEntry type="jdk" jdkName="RVM: ruby-2.7.4 [global]" jdkType="RUBY_SDK" />
13
+ <orderEntry type="sourceFolder" forTests="false" />
14
+ <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, RVM: ruby-2.7.4 [global]) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v2.4.7, RVM: ruby-2.7.4 [global]) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.5.0, RVM: ruby-2.7.4 [global]) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="json (v2.6.3, RVM: ruby-2.7.4 [global]) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="parallel (v1.22.1, RVM: ruby-2.7.4 [global]) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="parser (v3.2.1.0, RVM: ruby-2.7.4 [global]) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, RVM: ruby-2.7.4 [global]) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, RVM: ruby-2.7.4 [global]) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.7.0, RVM: ruby-2.7.4 [global]) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.5, RVM: ruby-2.7.4 [global]) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v3.12.0, RVM: ruby-2.7.4 [global]) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.12.1, RVM: ruby-2.7.4 [global]) [gem]" level="application" />
26
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.12.2, RVM: ruby-2.7.4 [global]) [gem]" level="application" />
27
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.12.3, RVM: ruby-2.7.4 [global]) [gem]" level="application" />
28
+ <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.12.0, RVM: ruby-2.7.4 [global]) [gem]" level="application" />
29
+ <orderEntry type="library" scope="PROVIDED" name="rubocop (v1.46.0, RVM: ruby-2.7.4 [global]) [gem]" level="application" />
30
+ <orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.26.0, RVM: ruby-2.7.4 [global]) [gem]" level="application" />
31
+ <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.11.0, RVM: ruby-2.7.4 [global]) [gem]" level="application" />
32
+ <orderEntry type="library" scope="PROVIDED" name="thor (v1.2.1, RVM: ruby-2.7.4 [global]) [gem]" level="application" />
33
+ <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.4.2, RVM: ruby-2.7.4 [global]) [gem]" level="application" />
34
+ </component>
35
+ <component name="RakeTasksCache">
36
+ <option name="myRootTask">
37
+ <RakeTaskImpl id="rake">
38
+ <subtasks>
39
+ <RakeTaskImpl description="Build mvc_one-0.1.0.gem into the pkg directory" fullCommand="build" id="build" />
40
+ <RakeTaskImpl id="build">
41
+ <subtasks>
42
+ <RakeTaskImpl description="Generate SHA512 checksum if mvc_one-0.1.0.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
43
+ </subtasks>
44
+ </RakeTaskImpl>
45
+ <RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
46
+ <RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
47
+ <RakeTaskImpl description="Build and install mvc_one-0.1.0.gem into system gems" fullCommand="install" id="install" />
48
+ <RakeTaskImpl id="install">
49
+ <subtasks>
50
+ <RakeTaskImpl description="Build and install mvc_one-0.1.0.gem into system gems without network access" fullCommand="install:local" id="local" />
51
+ </subtasks>
52
+ </RakeTaskImpl>
53
+ <RakeTaskImpl description="Create tag v0.1.0 and build and push mvc_one-0.1.0.gem to rubygems.org" fullCommand="release[remote]" id="release[remote]" />
54
+ <RakeTaskImpl description="Run RuboCop" fullCommand="rubocop" id="rubocop" />
55
+ <RakeTaskImpl id="rubocop">
56
+ <subtasks>
57
+ <RakeTaskImpl description="Autocorrect RuboCop offenses (only when it's safe)" fullCommand="rubocop:autocorrect" id="autocorrect" />
58
+ <RakeTaskImpl description="Autocorrect RuboCop offenses (safe and unsafe)" fullCommand="rubocop:autocorrect_all" id="autocorrect_all" />
59
+ <RakeTaskImpl description="" fullCommand="rubocop:auto_correct" id="auto_correct" />
60
+ </subtasks>
61
+ </RakeTaskImpl>
62
+ <RakeTaskImpl description="Run RSpec code examples" fullCommand="spec" id="spec" />
63
+ <RakeTaskImpl description="" fullCommand="default" id="default" />
64
+ <RakeTaskImpl description="" fullCommand="release" id="release" />
65
+ <RakeTaskImpl id="release">
66
+ <subtasks>
67
+ <RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
68
+ <RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
69
+ <RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
70
+ </subtasks>
71
+ </RakeTaskImpl>
72
+ </subtasks>
73
+ </RakeTaskImpl>
74
+ </option>
75
+ </component>
76
+ </module>
data/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-02-23
4
+ ## [0.1.0] - 2023-03-02 RC 1
5
+
6
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at evgeniisendziuk@taxdome.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in mvc_one.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,59 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ mvc_one (0.1.0.pre.rc1)
5
+ thor
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ diff-lcs (1.5.0)
12
+ json (2.6.3)
13
+ parallel (1.22.1)
14
+ parser (3.2.1.0)
15
+ ast (~> 2.4.1)
16
+ rainbow (3.1.1)
17
+ rake (13.0.6)
18
+ regexp_parser (2.7.0)
19
+ rexml (3.2.5)
20
+ rspec (3.12.0)
21
+ rspec-core (~> 3.12.0)
22
+ rspec-expectations (~> 3.12.0)
23
+ rspec-mocks (~> 3.12.0)
24
+ rspec-core (3.12.1)
25
+ rspec-support (~> 3.12.0)
26
+ rspec-expectations (3.12.2)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.12.0)
29
+ rspec-mocks (3.12.3)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.12.0)
32
+ rspec-support (3.12.0)
33
+ rubocop (1.46.0)
34
+ json (~> 2.3)
35
+ parallel (~> 1.10)
36
+ parser (>= 3.2.0.0)
37
+ rainbow (>= 2.2.2, < 4.0)
38
+ regexp_parser (>= 1.8, < 3.0)
39
+ rexml (>= 3.2.5, < 4.0)
40
+ rubocop-ast (>= 1.26.0, < 2.0)
41
+ ruby-progressbar (~> 1.7)
42
+ unicode-display_width (>= 2.4.0, < 3.0)
43
+ rubocop-ast (1.26.0)
44
+ parser (>= 3.2.1.0)
45
+ ruby-progressbar (1.11.0)
46
+ thor (1.2.1)
47
+ unicode-display_width (2.4.2)
48
+
49
+ PLATFORMS
50
+ x86_64-darwin-20
51
+
52
+ DEPENDENCIES
53
+ mvc_one!
54
+ rake (~> 13.0)
55
+ rspec (~> 3.0)
56
+ rubocop (~> 1.21)
57
+
58
+ BUNDLED WITH
59
+ 2.4.7
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Evgenii Sendziuk
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,39 @@
1
+ # MvcOne
2
+
3
+ TODO: Delete this and the text below, and describe your gem
4
+
5
+ Welcome to your new gem! 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 `lib/mvc_one`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ ## Installation
8
+
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
14
+
15
+ If bundler is not being used to manage dependencies, install the gem by executing:
16
+
17
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Development
24
+
25
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
+
27
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which 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).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/mvc_one. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/mvc_one/blob/main/CODE_OF_CONDUCT.md).
32
+
33
+ ## License
34
+
35
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
36
+
37
+ ## Code of Conduct
38
+
39
+ Everyone interacting in the MvcOne project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/mvc_one/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/exe/mvc_one ADDED
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env ruby
2
+ require 'thor'
3
+ require 'erb'
4
+ require 'pry'
5
+
6
+ module MvcOne
7
+ class MyCLI < Thor
8
+ desc "new PROJECT_NAME", "Generate new application"
9
+ def new(name)
10
+ puts "Generating #{name}"
11
+ project_template(name)
12
+ end
13
+
14
+ desc "generate controller/model/view/contract name", "Generate new controller/model/view."
15
+ def generate(layer, layer_name)
16
+ case layer
17
+ when 'controller'
18
+ puts "Generating controller #{layer_name}"
19
+ generate_controller layer_name
20
+ when 'model'
21
+ puts "Generating model #{layer_name}"
22
+ generate_model layer_name
23
+ when 'view' then puts "Generating view #{layer_name}"
24
+ when 'contract' then puts "Generating contract #{layer_name}"
25
+ else
26
+ raise ArgumentError, "Undefined generator for #{layer}"
27
+ end
28
+ end
29
+
30
+ private
31
+
32
+ def generate_controller(name)
33
+ raise Error, 'cd into your project repository' unless Dir.exists? 'app/controllers'
34
+ file_name = "app/controllers/#{name}_controller.rb"
35
+ template = ERB.new(File.read('../templates/app/controller_template.erb'))
36
+ File.write(file_name, template.result(binding))
37
+ end
38
+
39
+ def generate_model(name)
40
+ raise Error, 'cd into your project repository' unless Dir.exists? 'app/models'
41
+ file_name = "app/models/#{name}.rb"
42
+ template = ERB.new(File.read('../templates/app/model_template.erb'))
43
+ File.write(file_name, template.result(binding))
44
+ end
45
+
46
+ def project_template(name)
47
+ name_normalized = name.downcase.gsub(/\s/, '_')
48
+ make_default_dirs(name_normalized)
49
+ make_default_files(name_normalized)
50
+ template = ERB.new <<-EOF
51
+ class ApplicationController
52
+ def name
53
+ <%= name %>
54
+ end
55
+ end
56
+ EOF
57
+ template.result(binding)
58
+ end
59
+
60
+ def make_default_files(name_normalized)
61
+ config_ru = ERB.new(File.read('templates/general/config_ru.erb'))
62
+ File.write "#{name_normalized}/config.ru", config_ru.result(binding)
63
+
64
+ rakefile = ERB.new(File.read('templates/general/rakefile.erb'))
65
+ File.write "#{name_normalized}/Rakefile", rakefile.result(binding)
66
+
67
+ application_rb = ERB.new(File.read('templates/general/application_rb.erb'))
68
+ File.write "#{name_normalized}/application.rb", config_ru.result(binding)
69
+
70
+ routes_rb = ERB.new(File.read('templates/config/routes_rb.erb'))
71
+ File.write "#{name_normalized}/app/config/routes.rb", routes_rb.result(binding)
72
+
73
+ database_yml = ERB.new(File.read('templates/general/database_yml.erb'))
74
+ File.write "#{name_normalized}/config/database.yml", database_yml.result(binding)
75
+
76
+ secrets_yml = ERB.new(File.read('templates/general/secrets_yml.erb'))
77
+ File.write "#{name_normalized}/config/secrets.yml", secrets_yml.result(binding)
78
+ end
79
+
80
+ def make_default_dirs(root_dir_name)
81
+ raise Error, "Project directory already exists: #{root_dir_name}" if Dir.exists? root_dir_name
82
+
83
+ Dir.mkdir(root_dir_name)
84
+
85
+ %w[app config db].each do |dir_name|
86
+ Dir.mkdir("#{root_dir_name}/#{dir_name}")
87
+ end
88
+ Dir.mkdir("#{root_dir_name}/db/migrations")
89
+
90
+ %w[controllers models views contracts config].each do |dir_name|
91
+ Dir.mkdir("#{root_dir_name}/app/#{dir_name}")
92
+ end
93
+ end
94
+ end
95
+ end
96
+
97
+
98
+ MvcOne::MyCLI.start(ARGV)
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MvcOne
4
+ VERSION = "0.1.0-rc1"
5
+ end
data/lib/mvc_one.rb ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "mvc_one/version"
4
+
5
+ module MvcOne
6
+ class Error < StandardError; end
7
+ # Your code goes here...
8
+ end
data/mvc_one.gemspec ADDED
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/mvc_one/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "mvc_one"
7
+ spec.version = MvcOne::VERSION
8
+ spec.authors = ["Evgenii Sendziuk"]
9
+ spec.email = ["evgeniisendziuk@taxdome.com"]
10
+
11
+ spec.summary = "Simple mvc framework, not for production purposes"
12
+ spec.description = "Simple mvc framework, not for production purposes"
13
+ spec.license = "MIT"
14
+ spec.required_ruby_version = ">= 2.6.0"
15
+
16
+
17
+ spec.metadata["source_code_uri"] = "https://github.com/senzpo/mvc_one.git"
18
+ spec.metadata["changelog_uri"] = "https://github.com/senzpo/mvc_one.git"
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(__dir__) do
23
+ `git ls-files -z`.split("\x0").reject do |f|
24
+ (File.expand_path(f) == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
25
+ end
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ # Uncomment to register a new dependency of your gem
32
+ spec.add_dependency "thor"
33
+
34
+ # For more information and examples about making a new gem, check out our
35
+ # guide at: https://bundler.io/guides/creating_gem.html
36
+ end
data/sig/mvc_one.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module MvcOne
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Controller for <%= name.capitalize%>
4
+ class <%= name.capitalize%>Controller < ApplicationController
5
+ def index
6
+ projects = <%= name.capitalize%>Repository.all
7
+ # serialize here
8
+ end
9
+
10
+ def create
11
+ contract = <%= name.capitalize%>Contract.new.call(request_params)
12
+ if contract.failure?
13
+ return render(
14
+ code: 422, body: contract.errors.to_h.to_json,
15
+ headers: { 'content-type' => 'application/json' }
16
+ )
17
+ end
18
+
19
+ <%= name%> = <%= name.capitalize%>Repository.create(contract.to_h)
20
+ render code: 201, body: <%= name%>.to_h.to_json, headers: { 'content-type' => 'application/json' }
21
+ end
22
+
23
+ def update
24
+ contract = <%= name.capitalize%>Contract.new.call(request_params)
25
+ if contract.success?
26
+ <%= name.capitalize%>Repository.update(params[:id], contract.to_h)
27
+
28
+ head 204
29
+ else
30
+ render code: 422, body: contract.errors
31
+ end
32
+ rescue ApplicationRepository::NotFoundRecord
33
+ head 404
34
+ end
35
+
36
+ def delete
37
+ <%= name.capitalize%>Repository.delete(params[:id])
38
+
39
+ head 204
40
+ rescue ApplicationRepository::NotFoundRecord
41
+ head 404
42
+ end
43
+
44
+ def show
45
+ <%= name%> = <%= name%>Repository.find(id: params[:id])
46
+ #serialize here
47
+ rescue ApplicationRepository::NotFoundRecord
48
+ head 404
49
+ end
50
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class <%= name.capitalize%> < ApplicationModel
4
+ attribute? :id, Types::Coercible::Integer.optional.meta(info: 'Uniq ID')
5
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ lambda do
4
+ # Example
5
+ # get '/api/v1/users', to: 'api#v1#users#index'
6
+ # get '/api/v1/users/:id', to: 'api#v1#users#show'
7
+ # patch '/api/v1/users/:id', to: 'api#v1#users#update'
8
+ # delete '/api/v1/users/:id', to: 'api#v1#users#delete'
9
+ # post '/api/v1/users', to: 'api#v1#users#create'
10
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+
5
+ # Rack friendly launcher for project
6
+ class Application
7
+ # Main application config
8
+ class Config
9
+ def self.env
10
+ ENV.fetch('APP_ENV', 'development')
11
+ end
12
+
13
+ def self.test?
14
+ env == 'test'
15
+ end
16
+
17
+ def self.secrets
18
+ YAML.load_file('config/secrets.yml')[Application::Config.env]
19
+ end
20
+ end
21
+
22
+ def initialize
23
+ @router = RegexpRouter.new(File.join(File.dirname(__FILE__), 'app', 'config', 'routes.rb'))
24
+ end
25
+
26
+ def self.launch
27
+ Rack::Builder.new do |builder|
28
+ builder.use Rack::Session::Cookie, domain: 'localhost', path: '/', expire_after: 3600 * 24,
29
+ secret: Application::Config.secrets['session_cookie']
30
+ builder.run Application.new
31
+ end
32
+ end
33
+
34
+ def call(env)
35
+ request = Rack::Request.new(env)
36
+ result = @router.resolve(request.path, request.request_method)
37
+ controller = result.controller.new(env, result.params, request)
38
+ controller.resolve(result.action)
39
+ end
40
+ end
41
+
42
+ # Dir[File.join(File.dirname(__FILE__), 'lib', '**', '*.rb')].each { |file| require file }
43
+ Dir[File.join(File.dirname(__FILE__), 'app', '**', '*.rb')].each { |file| require file }
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ require 'securerandom'
6
+
7
+ Bundler.require
8
+
9
+ require './application'
10
+
11
+ use Rack::Reloader, 0
12
+ run Application.launch
@@ -0,0 +1,12 @@
1
+ development:
2
+ db:
3
+ name: '<%= name_normalized%>.db'
4
+ adapter: 'sqlite'
5
+ connection_line: 'sqlite://db/<%= name_normalized%>.db'
6
+ path: './db/<%= name_normalized%>.db'
7
+ test:
8
+ db:
9
+ name: '<%= name_normalized%>.db'
10
+ adapter: 'sqlite'
11
+ connection_line: 'sqlite://db/test_<%= name_normalized%>.db'
12
+ path: './db/test_<%= name_normalized%>.db'
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler'
4
+
5
+ Bundler.require
6
+
7
+ require './application'
8
+
9
+ task :default do
10
+ puts 'Hello from default task!'
11
+ end
12
+
13
+ namespace :db do
14
+ # http://sequel.jeremyevans.net/documentation.html
15
+ desc 'Create database'
16
+ task :create do
17
+ SQLite3::Database.open(ApplicationRepository.db_config['db']['path'])
18
+ end
19
+
20
+ desc 'Drop database'
21
+ task :drop do
22
+ File.delete(ApplicationRepository.db_config['db']['path'])
23
+ end
24
+
25
+ desc 'Migrate database'
26
+ task :migrate do
27
+ Sequel.extension :migration
28
+ Sequel::Migrator.run(ApplicationRepository::DB, 'db/migrations')
29
+ end
30
+
31
+ desc 'Rollback database'
32
+ task :rollback do
33
+ Sequel.extension :migration
34
+ steps = ENV['STEPS'].nil? ? 1 : ENV['STEPS'].to_i
35
+ Sequel::Migrator.run(ApplicationRepository::DB, 'db/migrations', relative: steps * -1)
36
+ end
37
+ end
38
+
39
+ namespace :app do
40
+ desc 'Run controllers test'
41
+ task :console do
42
+ require 'rubygems'
43
+ require 'bundler'
44
+ require 'securerandom'
45
+ require 'irb'
46
+
47
+ Bundler.require
48
+
49
+ require './application'
50
+
51
+ ARGV.clear
52
+ IRB.start
53
+ end
54
+ end
55
+
56
+ namespace :test do
57
+ require 'rake'
58
+ require 'rspec/core/rake_task'
59
+
60
+ desc 'Run all test'
61
+ task :all do
62
+ RSpec::Core::RakeTask.new(:spec) do |t|
63
+ t.pattern = 'spec/**/*_spec.rb'
64
+ end
65
+ Rake::Task['spec'].execute
66
+ end
67
+
68
+ desc 'Run controllers test'
69
+ task :controllers do
70
+ RSpec::Core::RakeTask.new(:spec) do |t|
71
+ t.pattern = 'spec/controllers/**/*_spec.rb'
72
+ end
73
+ Rake::Task['spec'].execute
74
+ end
75
+ end
@@ -0,0 +1,4 @@
1
+ development:
2
+ session_cookie: ""
3
+ test:
4
+ session_cookie: ""
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mvc_one
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.pre.rc1
5
+ platform: ruby
6
+ authors:
7
+ - Evgenii Sendziuk
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-03-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Simple mvc framework, not for production purposes
28
+ email:
29
+ - evgeniisendziuk@taxdome.com
30
+ executables:
31
+ - mvc_one
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".idea/.gitignore"
36
+ - ".idea/modules.xml"
37
+ - ".idea/mvc_one.iml"
38
+ - ".idea/vcs.xml"
39
+ - ".rspec"
40
+ - ".rubocop.yml"
41
+ - CHANGELOG.md
42
+ - CODE_OF_CONDUCT.md
43
+ - Gemfile
44
+ - Gemfile.lock
45
+ - LICENSE.txt
46
+ - README.md
47
+ - Rakefile
48
+ - exe/mvc_one
49
+ - lib/mvc_one.rb
50
+ - lib/mvc_one/version.rb
51
+ - mvc_one.gemspec
52
+ - sig/mvc_one.rbs
53
+ - templates/app/controller_template.erb
54
+ - templates/app/model_template.erb
55
+ - templates/config/routes_rb.erb
56
+ - templates/general/application_rb.erb
57
+ - templates/general/config_ru.erb
58
+ - templates/general/database_yml.erb
59
+ - templates/general/rakefile.erb
60
+ - templates/general/secrets_yml.erb
61
+ homepage:
62
+ licenses:
63
+ - MIT
64
+ metadata:
65
+ source_code_uri: https://github.com/senzpo/mvc_one.git
66
+ changelog_uri: https://github.com/senzpo/mvc_one.git
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 2.6.0
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">"
79
+ - !ruby/object:Gem::Version
80
+ version: 1.3.1
81
+ requirements: []
82
+ rubygems_version: 3.1.6
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: Simple mvc framework, not for production purposes
86
+ test_files: []