sinatra-scaffold 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 883999ffd637e6d03bbe1e9e935637b1e52618bacce8e8f38d2a2bb682fc4ff6
4
+ data.tar.gz: ef5429ea137c387f8b282143ab17088c6bedf7acbcef19f13e33c88a655cb8b8
5
+ SHA512:
6
+ metadata.gz: b2c908960db471de3b446628ae45dc770c566bc029b0853c5b345ded512035d53ee5c93a826e88e11a823aac9e425a7ade391044c6d6bd3b13be977498c1ac69
7
+ data.tar.gz: 5967b5fba83756ae2fd97d4c00a3c23322dc362f2a003b58337103ccc3f9cddbf4b374bd155217ca7c3e579ab3c2a0d36c86c44640dd7610f32bf2149b2607a6
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2024-08-16
4
+
5
+ - Initial release
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ [INSERT CONTACT METHOD].
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # SinatraScaffold
2
+
3
+ A scaffold cli for the Sinatra web gem.
4
+
5
+ ## Installation
6
+
7
+ Globally install
8
+ ```sh
9
+ gem install sinatra-scaffold
10
+ ```
11
+
12
+ Project install
13
+ ```sh
14
+ bundle add sinatra-scaffold
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```sh
20
+ sinatra-scaffold new my_app
21
+ ```
22
+
23
+ ## Development
24
+
25
+ Install the dependencies
26
+ ```sh
27
+ bundle install
28
+ ```
29
+
30
+ Build and install gem locally
31
+
32
+ ```sh
33
+ gem build sinatra-scaffold.gemspec && gem install ./sinatra-scaffold-0.1.0.gem
34
+ ```
35
+
36
+ Run lint
37
+ ```sh
38
+ bundle exec rake standard:fix
39
+ ```
40
+
41
+ ## Contributing
42
+
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/joaoGabriel55/sinatra-scaffold. 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/joaoGabriel55/sinatra-scaffold/blob/main/CODE_OF_CONDUCT.md).
44
+
45
+ ## License
46
+
47
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
48
+
49
+ ## Code of Conduct
50
+
51
+ Everyone interacting in the SinatraScaffold project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/joaoGabriel55/sinatra-scaffold/blob/main/CODE_OF_CONDUCT.md).
data/bin/console ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "sinatra-scaffold"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ require "irb"
11
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ lib = File.expand_path('../../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ require 'sinatra_scaffold'
6
+
7
+ SinatraScaffold::CLI.start
@@ -0,0 +1,185 @@
1
+ require "thor"
2
+ require "fileutils"
3
+
4
+ module SinatraScaffold
5
+ class CLI < Thor
6
+ desc "new APP_NAME", "Create a new Sinatra application with a basic scaffold"
7
+ def new(app_name)
8
+ create_directory_structure(app_name)
9
+ create_main_files(app_name)
10
+ puts "Sinatra application #{app_name} created successfully!"
11
+ end
12
+
13
+ private
14
+
15
+ def create_directory_structure(app_name)
16
+ directories = [
17
+ "#{app_name}/app",
18
+ "#{app_name}/app/routes",
19
+ "#{app_name}/spec",
20
+ "#{app_name}/spec/requests"
21
+ ]
22
+
23
+ directories.each do |dir|
24
+ FileUtils.mkdir_p(dir)
25
+ end
26
+ end
27
+
28
+ def create_main_files(app_name)
29
+ File.write("#{app_name}/config.ru", <<~RUBY)
30
+ require "./app"
31
+
32
+ run Sinatra::Application
33
+ RUBY
34
+
35
+ File.write("#{app_name}/app/routes/users_routes.rb", <<~RUBY)
36
+ require "sinatra/base"
37
+
38
+ get "/users" do
39
+ ["User 1", "User 2"].to_json
40
+ end
41
+ RUBY
42
+
43
+ File.write("#{app_name}/server.rb", <<~RUBY)
44
+ require "sinatra"
45
+ require "sinatra/base"
46
+ require "dotenv"
47
+
48
+ Dotenv.load
49
+
50
+ set :bind, "0.0.0.0"
51
+ set :default_content_type, :json
52
+
53
+ require "./app/routes/users_routes"
54
+
55
+ get "/health-check" do
56
+ {status: "ok"}.to_json
57
+ end
58
+ RUBY
59
+
60
+ File.write("#{app_name}/.gitignore", <<~RUBY)
61
+ .env
62
+ RUBY
63
+
64
+ File.write("#{app_name}/spec/spec_helper.rb", <<~RUBY)
65
+ # frozen_string_literal: true
66
+
67
+ ENV["RACK_ENV"] = "test"
68
+
69
+ require "rubygems"
70
+ require "bundler"
71
+
72
+ require_relative "../server"
73
+
74
+ Bundler.require(:default) # load all the default gems
75
+ Bundler.require(Sinatra::Base.environment) # load all the environment specific gems
76
+
77
+ Dotenv.load
78
+
79
+ def app
80
+ Sinatra::Application
81
+ end
82
+
83
+ RSpec.configure do |config|
84
+ config.include Rack::Test::Methods
85
+ config.expect_with :rspec do |expectations|
86
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
87
+ end
88
+ config.mock_with :rspec do |mocks|
89
+ mocks.verify_partial_doubles = true
90
+ end
91
+ config.filter_run :focus
92
+ config.run_all_when_everything_filtered = true
93
+ config.disable_monkey_patching!
94
+ config.warnings = true
95
+ config.default_formatter = "doc" if config.files_to_run.one?
96
+ config.profile_examples = 10
97
+ config.order = :random
98
+ Kernel.srand config.seed
99
+ end
100
+ RUBY
101
+
102
+ File.write("#{app_name}/spec/requests/users_spec.rb", <<~RUBY)
103
+ require "spec_helper"
104
+
105
+ RSpec.describe "GET /users" do
106
+ it "returns a list of users" do
107
+ get "/users"
108
+
109
+ expect(last_response).to be_ok
110
+ expect(last_response.body).to eq(["User 1", "User 2"].to_json)
111
+ end
112
+ end
113
+ RUBY
114
+
115
+ File.write("#{app_name}/spec/requests/health_check_spec.rb", <<~RUBY)
116
+ require "spec_helper"
117
+
118
+ RSpec.describe "GET /health-check" do
119
+ it "returns ok" do
120
+ get "/health-check"
121
+
122
+ expect(last_response).to be_ok
123
+ expect(last_response.body).to eq({status: "ok"}.to_json)
124
+ end
125
+ end
126
+ RUBY
127
+
128
+ File.write("#{app_name}/Gemfile", <<~RUBY)
129
+ source "https://rubygems.org"
130
+
131
+ gem "sinatra"
132
+ gem "dotenv"
133
+ gem "rake"
134
+
135
+ group :test do
136
+ gem "rack-test"
137
+ gem "rspec"
138
+ end
139
+
140
+ group :development, :test do
141
+ gem "pry"
142
+ gem "standard"
143
+ end
144
+ RUBY
145
+
146
+ File.write("#{app_name}/Rakefile", <<~RUBY)
147
+ require "rspec/core/rake_task"
148
+
149
+ RSpec::Core::RakeTask.new(:spec)
150
+
151
+ require "standard/rake"
152
+
153
+ task default: %i[spec standard]
154
+ RUBY
155
+
156
+ File.write("#{app_name}/README.md", <<~RUBY)
157
+ # #{app_name}
158
+
159
+ My Sinatra application
160
+
161
+ ## Running
162
+ Run:
163
+ ```sh
164
+ ruby server.rb
165
+ ```
166
+
167
+ ## Testing
168
+ Run:
169
+ ```sh
170
+ bundle exec rspec
171
+ bundle exec rspec [file-or-directory-path]
172
+ ```
173
+
174
+ ## Lint
175
+ ```sh
176
+ bundle exec rake standard
177
+ ```
178
+ Lint and fix with:
179
+ ```sh
180
+ bundle exec rake standard:fix
181
+ ```
182
+ RUBY
183
+ end
184
+ end
185
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SinatraScaffold
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "sinatra_scaffold/cli"
4
+ require "sinatra_scaffold/version"
5
+
6
+ module SinatraScaffold
7
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sinatra-scaffold
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - joaoGabriel55
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-08-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: standard
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '13.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '13.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: thor
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
69
+ description: Ruby gem to make more easy the getting start of web app development with
70
+ Sinatra gem
71
+ email:
72
+ - joaoGabriel55
73
+ executables:
74
+ - sinatra-scaffold
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - CHANGELOG.md
79
+ - CODE_OF_CONDUCT.md
80
+ - README.md
81
+ - bin/console
82
+ - bin/setup
83
+ - bin/sinatra-scaffold
84
+ - lib/sinatra_scaffold.rb
85
+ - lib/sinatra_scaffold/cli.rb
86
+ - lib/sinatra_scaffold/version.rb
87
+ homepage: https://github.com/joaoGabriel55/sinatra-scaffold
88
+ licenses:
89
+ - MIT
90
+ metadata:
91
+ homepage_uri: https://github.com/joaoGabriel55/sinatra-scaffold
92
+ source_code_uri: https://github.com/joaoGabriel55/sinatra-scaffold
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: 3.0.0
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubygems_version: 3.4.1
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: Scaffold for Sinatra applications
112
+ test_files: []