sinator 3.1.1 → 5.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a63710b6c5c35b11d696ace428df494205183305b61132365338db6f1d344f6
4
- data.tar.gz: 3b315314240dfaac92b1da348b0ab2b1120e24b1aa55ecc1c0b7a15f68177c79
3
+ metadata.gz: a2bc45395774e1370062fdc1c56712f803a4d4e92a32e5bb3a3be2da4e25ef66
4
+ data.tar.gz: 954389971a148a660729f80566c942e772bf06ead1c8f03eb0f0702db3f7a7df
5
5
  SHA512:
6
- metadata.gz: 186a2afb345abb59708dfcf5405b972a68ce5c94c03ebd66cf3da14ffad313797c00c8a8a618c6d17b4cd289fa809b6c7ba230213cf4091429821c9174da0062
7
- data.tar.gz: a0c896ca5bfff3d17c9d87882494296b91acc2b9000b34311ce8b55240a9ff93d8261e2a58c33d976ff99711a89a5cbff0a9711070d54261f124125b76f577d2
6
+ metadata.gz: c287f519efd361772f14668ec487955638e72d2f6cc05963b893a3eaedd47affd0ef14e25672dceaad37e074224e59cc619bfab1ca9e7b031c91c7213eb0547d
7
+ data.tar.gz: b58d463dd12544ea9c322bd45cbcc12bc89f9ad9cdaaad88e58bc7c6404b351a042486d17d39a5ed5fc1557ec75dff7fe0fcf0913565066490dc3fc0d7078968
data/.github/FUNDING.yml CHANGED
@@ -3,7 +3,7 @@
3
3
  github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4
4
  patreon: # Replace with a single Patreon username
5
5
  open_collective: # Replace with a single Open Collective username
6
- ko_fi: kuntoaji
6
+ ko_fi: kaklabs
7
7
  tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8
8
  community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
9
  liberapay: # Replace with a single Liberapay username
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ 5.0.0:
2
+ * Support Ruby 4. Ruby 3.3.1 and newer are still supported
3
+ * Generated app: upgrade to Sinatra 4.2, Rack 3, Puma 8.1, Sprockets 4.4, and Sequel 5.110
4
+ * Generated app: replace encrypted_cookie with rack-session encrypted cookies in config.ru. The secret comes from the SESSION_SECRET environment variable
5
+ * Generated app: replace uglifier with terser, and sass/sassc with sassc-embedded (Dart Sass)
6
+ * Generated app: replace tux with `rake console` (IRB)
7
+ * Generated app: remove `daemonize` from the Puma production config, because Puma 5 and newer do not support it
8
+
9
+ 4.0.0:
10
+ * Drop support for older Ruby versions, only support Ruby 3.3.1 and newer
11
+
1
12
  3.1.1:
2
13
  * Update Ruby gems
3
14
 
data/CLAUDE.md ADDED
@@ -0,0 +1,34 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project
6
+
7
+ Sinator is a Ruby gem and CLI (`sinator`) that generates a Sinatra application skeleton, optionally with PostgreSQL + Sequel ORM (`-d`). Requires Ruby >= 3.3.1.
8
+
9
+ ## Commands
10
+
11
+ - Install deps: `bundle install`
12
+ - Run all tests: `bundle exec rspec`
13
+ - Run one file: `bundle exec rspec spec/sinator/generator_spec.rb`
14
+ - Run one example: `bundle exec rspec spec/sinator/generator_spec.rb:<line>`
15
+ - Run the CLI locally: `ruby -Ilib bin/sinator -n my_app [-t target/dir] [-d]`
16
+ - Build the gem: `gem build sinator.gemspec`
17
+
18
+ There is no Rakefile or linter in this repo. The gemspec uses `git ls-files` for its file list, so new files must be tracked in git to ship in the gem.
19
+
20
+ ## Architecture
21
+
22
+ - `bin/sinator` -> `Sinator::Command.parse(ARGV)` (`lib/sinator/command.rb`): OptionParser handles `-n/--name`, `-t/--target`, `-d/--database`, `-v`, `-h`. With a name, `Command.run` calls the generator steps in order: `generate_app`, `generate_rakefile`, `generate_gemfile`, `generate_bundle_config`, `generate_puma_config`.
23
+ - `Sinator::Generator` (`lib/sinator/generator.rb`) works in two ways on `lib/sinator/templates/`:
24
+ - Static files (`assets`, `config`, `public`, `app`, and `db` only with `-d`) are copied as-is by `copy_templates`. Without `-d`, `config/database.yml` is deleted after copying. With `-d`, an empty `app/models` directory is also created, and `Rakefile.erb` adds a `db:migrate` task.
25
+ - `generate_app` must run first: it calls `copy_templates`, which creates the directories (`config/puma`, `app/routes`) that the later steps write into.
26
+ - `*.erb` templates (`app.erb`, `Rakefile.erb`, `Gemfile.erb`, `config.ru.erb`, `app/routes/home.erb`, `config/puma/*.erb`) render with the generator's `binding`, so they read `@app_name`, `@app_class_name` (CamelCase of the snake_case name), and `@with_database`. Copied `.erb` sources are removed after rendering.
27
+ - Note: `app/views/*.erb` are Sinatra views for the generated app, not generator templates. They are copied verbatim.
28
+ - The generated app is a modular Sinatra app: `<app_name>.rb` defines the app class, routes go in `app/routes/*.rb` by reopening that class, and it runs with `bundle exec puma`.
29
+
30
+ ## Tests
31
+
32
+ - Specs generate real apps into `/tmp/sinator`, `/tmp/sinator_with_db` (generator spec), and `/tmp/my_app` (command spec), and delete them around each example. Examples run in random order, with SimpleCov enabled.
33
+ - Rendered ERB output is compared byte-for-byte against `spec/fixtures/*.txt` through `Helper::Generator#expect_file_eq` in `spec/helpers/generator.rb`. Templates that change with `-d` (`app`, `gemfile`, `rakefile`) have `with_db/` and `without_db/` fixtures; the others have one shared fixture. When you change an ERB template, update the matching fixture.
34
+ - The generated `config.ru` adds the session middleware with `ENV.fetch('SESSION_SECRET')`. It is in `config.ru`, not in `app.erb`, so rake tasks (which load the app class) run without the secret.
data/Gemfile.lock CHANGED
@@ -1,41 +1,35 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sinator (3.1.0)
4
+ sinator (5.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- diff-lcs (1.2.5)
10
- docile (1.3.2)
11
- json (2.3.1)
12
- rspec (3.2.0)
13
- rspec-core (~> 3.2.0)
14
- rspec-expectations (~> 3.2.0)
15
- rspec-mocks (~> 3.2.0)
16
- rspec-core (3.2.3)
17
- rspec-support (~> 3.2.0)
18
- rspec-expectations (3.2.1)
9
+ diff-lcs (1.6.2)
10
+ rspec (3.13.2)
11
+ rspec-core (~> 3.13.0)
12
+ rspec-expectations (~> 3.13.0)
13
+ rspec-mocks (~> 3.13.0)
14
+ rspec-core (3.13.7)
15
+ rspec-support (~> 3.13.0)
16
+ rspec-expectations (3.13.6)
19
17
  diff-lcs (>= 1.2.0, < 2.0)
20
- rspec-support (~> 3.2.0)
21
- rspec-mocks (3.2.1)
18
+ rspec-support (~> 3.13.0)
19
+ rspec-mocks (3.13.9)
22
20
  diff-lcs (>= 1.2.0, < 2.0)
23
- rspec-support (~> 3.2.0)
24
- rspec-support (3.2.2)
25
- simplecov (0.17.0)
26
- docile (~> 1.1)
27
- json (>= 1.8, < 3)
28
- simplecov-html (~> 0.10.0)
29
- simplecov-html (0.10.2)
21
+ rspec-support (~> 3.13.0)
22
+ rspec-support (3.13.8)
23
+ simplecov (1.3.2)
30
24
 
31
25
  PLATFORMS
32
26
  ruby
33
27
 
34
28
  DEPENDENCIES
35
- bundler (~> 1.7)
36
- rspec (= 3.2.0)
29
+ bundler
30
+ rspec
37
31
  simplecov
38
32
  sinator!
39
33
 
40
34
  BUNDLED WITH
41
- 1.17.2
35
+ 4.1.0
data/README.md CHANGED
@@ -43,6 +43,13 @@ Generate app in current directory with database. `-d` option will generate app w
43
43
  ```
44
44
  sinator -n my_app -d
45
45
  ```
46
+ Set the session secret. The web server does not start without it. The secret must be at least 64 bytes.
47
+ For production, load the secret from a secrets manager, such as AWS Secrets Manager or SSM Parameter Store. Do not commit it.
48
+
49
+ ```
50
+ export SESSION_SECRET=$(ruby -rsecurerandom -e 'puts SecureRandom.hex(64)')
51
+ ```
52
+
46
53
  Run web server on localhost.
47
54
 
48
55
  ```
@@ -52,7 +59,13 @@ bundle exec puma
52
59
  Run application console / interactive mode / IRB.
53
60
 
54
61
  ```
55
- bundle exec tux
62
+ bundle exec rake console
63
+ ```
64
+
65
+ Precompile assets for production. This needs a JavaScript runtime, such as Node.js.
66
+
67
+ ```
68
+ RACK_ENV=production bundle exec rake assets:precompile
56
69
  ```
57
70
 
58
71
  ### Example Usage
@@ -125,6 +138,6 @@ See [github.com/kuntoaji/todo_sinator](https://github.com/kuntoaji/todo_sinator)
125
138
  </form>
126
139
  ```
127
140
 
128
- 11. run the server `bundle exec puma`
141
+ 11. set `SESSION_SECRET` (see above) and run the server `bundle exec puma`
129
142
  12. open url `localhost:9292/artists`
130
143
  13. Enjoy! :)
@@ -52,7 +52,7 @@ module Sinator
52
52
  generator.generate_puma_config
53
53
 
54
54
  msg = "#{args[:name]} is successfully generated"
55
- msg << " in #{args[:target]}" if args[:target]
55
+ msg += " in #{args[:target]}" if args[:target]
56
56
 
57
57
  msg
58
58
  end
@@ -1,5 +1,4 @@
1
1
  require 'fileutils'
2
- require 'securerandom'
3
2
  require 'erb'
4
3
  require_relative 'version'
5
4
 
@@ -24,7 +23,7 @@ module Sinator
24
23
 
25
24
  def generate_rakefile
26
25
  gemfile = File.read File.expand_path("../templates/Rakefile.erb", __FILE__)
27
- erb = ERB.new gemfile, 0, '-'
26
+ erb = ERB.new gemfile, trim_mode: '-'
28
27
 
29
28
  File.open "#{@destination}/Rakefile", "w" do |f|
30
29
  f.write erb.result(binding)
@@ -33,7 +32,7 @@ module Sinator
33
32
 
34
33
  def generate_gemfile
35
34
  gemfile = File.read File.expand_path("../templates/Gemfile.erb", __FILE__)
36
- erb = ERB.new gemfile, 0, '-'
35
+ erb = ERB.new gemfile, trim_mode: '-'
37
36
 
38
37
  File.open "#{@destination}/Gemfile", "w" do |f|
39
38
  f.write erb.result(binding)
@@ -53,12 +52,12 @@ module Sinator
53
52
  puma_development = File.read File.expand_path("../templates/config/puma/development.erb", __FILE__)
54
53
  puma_production = File.read File.expand_path("../templates/config/puma/production.erb", __FILE__)
55
54
 
56
- erb = ERB.new puma_development, 0, '-'
55
+ erb = ERB.new puma_development, trim_mode: '-'
57
56
  File.open "#{@destination}/config/puma/development.rb", "w" do |f|
58
57
  f.write erb.result(binding)
59
58
  end
60
59
 
61
- erb = ERB.new puma_production, 0, '-'
60
+ erb = ERB.new puma_production, trim_mode: '-'
62
61
  File.open "#{@destination}/config/puma/production.rb", "w" do |f|
63
62
  f.write erb.result(binding)
64
63
  end
@@ -68,14 +67,14 @@ module Sinator
68
67
  def generate_app
69
68
  copy_templates
70
69
  app = File.read File.expand_path("../templates/app.erb", __FILE__)
71
- erb = ERB.new app, 0, '-'
70
+ erb = ERB.new app, trim_mode: '-'
72
71
 
73
72
  File.open "#{@destination}/#{@app_name}.rb", "w" do |f|
74
73
  f.write erb.result(binding)
75
74
  end
76
75
 
77
76
  route = File.read File.expand_path("../templates/app/routes/home.erb", __FILE__)
78
- erb = ERB.new route, 0, '-'
77
+ erb = ERB.new route, trim_mode: '-'
79
78
 
80
79
  File.open "#{@destination}/app/routes/home.rb", "w" do |f|
81
80
  f.write erb.result(binding)
@@ -1,16 +1,15 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'sinatra', '~> 2.2'
4
- gem 'sinatra-contrib', '~> 2.2', require: false
5
- gem 'encrypted_cookie', '0.1.0'
6
- gem 'rack_csrf', '~> 2.6', require: 'rack/csrf'
7
- gem 'puma', '~> 5.6'
8
- gem 'tux', '~> 0.3', require: false
9
- gem 'uglifier', '~> 4.2', require: false
10
- gem 'sass', '~> 3.7', require: false
11
- gem 'sassc', '~> 2.4', require: false
12
- gem 'sprockets', '~> 4.0'
3
+ gem 'sinatra', '~> 4.2'
4
+ gem 'sinatra-contrib', '~> 4.2', require: false
5
+ gem 'rack-session', '~> 2.1'
6
+ gem 'rack_csrf', '~> 2.7', require: 'rack/csrf'
7
+ gem 'puma', '~> 8.1'
8
+ gem 'irb', require: false
9
+ gem 'terser', '~> 1.2', require: false
10
+ gem 'sassc-embedded', '~> 1.80', require: false
11
+ gem 'sprockets', '~> 4.4'
13
12
  <% if @with_database -%>
14
- gem 'sequel', '>= 5'
15
- gem 'sequel_pg', '>= 1.15', require: 'sequel'
13
+ gem 'sequel', '~> 5.110'
14
+ gem 'sequel_pg', '~> 1.20', require: 'sequel'
16
15
  <% end -%>
@@ -13,6 +13,14 @@ namespace :assets do
13
13
  FileUtils.rm_rf("#{<%= @app_class_name %>.public_folder}/assets")
14
14
  end
15
15
  end
16
+
17
+ desc "Start an IRB console with the app loaded"
18
+ task :console do
19
+ require 'irb'
20
+ require_relative 'config/application'
21
+ ARGV.clear
22
+ IRB.start
23
+ end
16
24
  <% if @with_database %>
17
25
  namespace :db do
18
26
  desc "Run migrations"
@@ -1,8 +1,5 @@
1
1
  <%= "require 'yaml'\n\n" if @with_database -%>
2
2
  class <%= @app_class_name %> < Sinatra::Application
3
- use Rack::Session::EncryptedCookie,
4
- secret: '<%= SecureRandom.hex 32 %>'
5
-
6
3
  set :app_file, __FILE__
7
4
  set :server, :puma
8
5
  set :views, Proc.new { File.join(root, "app/views") }
@@ -43,8 +40,9 @@ class <%= @app_class_name %> < Sinatra::Application
43
40
  # Serve assets via Nginx or Apache
44
41
  disable :static
45
42
 
46
- assets.js_compressor = :uglify
47
- assets.css_compressor = :sass
43
+ require 'terser'
44
+ assets.js_compressor = Terser.new
45
+ assets.css_compressor = :sassc
48
46
  Sequel.connect YAML.load_file(File.expand_path("../config/database.yml", __FILE__))['production']
49
47
  end
50
48
  <% else -%>
@@ -64,8 +62,9 @@ class <%= @app_class_name %> < Sinatra::Application
64
62
  # Serve assets via Nginx or Apache
65
63
  disable :static
66
64
 
67
- assets.js_compressor = :uglify
68
- assets.css_compressor = :sass
65
+ require 'terser'
66
+ assets.js_compressor = Terser.new
67
+ assets.css_compressor = :sassc
69
68
  end
70
69
  <% end -%>
71
70
  end
@@ -5,7 +5,6 @@ ctl_socket = '/path/to/shared/tmp/sockets/pumactl.sock'
5
5
  state_path '/path/to/shared/tmp/sockets/puma.state'
6
6
  stdout_redirect '/path/to/shared/log/stdout.log', '/path/to/shared/log/stderr.log'
7
7
  activate_control_app 'unix:///path/to/shared/tmp/sockets/pumactl.sock'
8
- daemonize
9
8
  quiet
10
9
 
11
10
  threads 5, 5
@@ -2,4 +2,10 @@ require File.expand_path('../config/boot.rb', __FILE__)
2
2
  require Sinator::ROOT + '/<%= @app_name %>'
3
3
  require Sinator::ROOT + '/config/application'
4
4
 
5
+ use Rack::Session::Cookie,
6
+ secrets: ENV.fetch('SESSION_SECRET'),
7
+ same_site: :lax,
8
+ httponly: true,
9
+ secure: ENV['RACK_ENV'] == 'production'
10
+
5
11
  run <%= @app_class_name %>
@@ -1,3 +1,3 @@
1
1
  module Sinator
2
- VERSION = '3.1.1'
2
+ VERSION = '5.0.0'
3
3
  end
data/sinator.gemspec CHANGED
@@ -14,8 +14,8 @@ Gem::Specification.new do |s|
14
14
  s.homepage = 'http://github.com/kuntoaji/sinator'
15
15
  s.license = 'MIT'
16
16
 
17
- s.required_ruby_version = '>= 2.1'
18
- s.add_development_dependency 'bundler', '~> 1.7'
19
- s.add_development_dependency 'rspec', '3.2.0'
17
+ s.required_ruby_version = '>= 3.3.1'
18
+ s.add_development_dependency 'bundler'
19
+ s.add_development_dependency 'rspec'
20
20
  s.add_development_dependency 'simplecov'
21
21
  end
@@ -5,7 +5,6 @@ ctl_socket = '/path/to/shared/tmp/sockets/pumactl.sock'
5
5
  state_path '/path/to/shared/tmp/sockets/puma.state'
6
6
  stdout_redirect '/path/to/shared/log/stdout.log', '/path/to/shared/log/stderr.log'
7
7
  activate_control_app 'unix:///path/to/shared/tmp/sockets/pumactl.sock'
8
- daemonize
9
8
  quiet
10
9
 
11
10
  threads 5, 5
@@ -2,4 +2,10 @@ require File.expand_path('../config/boot.rb', __FILE__)
2
2
  require Sinator::ROOT + '/my_app'
3
3
  require Sinator::ROOT + '/config/application'
4
4
 
5
+ use Rack::Session::Cookie,
6
+ secrets: ENV.fetch('SESSION_SECRET'),
7
+ same_site: :lax,
8
+ httponly: true,
9
+ secure: ENV['RACK_ENV'] == 'production'
10
+
5
11
  run MyApp
@@ -1,9 +1,6 @@
1
1
  require 'yaml'
2
2
 
3
3
  class MyApp < Sinatra::Application
4
- use Rack::Session::EncryptedCookie,
5
- secret: 'supersecretcookiefromgenerator'
6
-
7
4
  set :app_file, __FILE__
8
5
  set :server, :puma
9
6
  set :views, Proc.new { File.join(root, "app/views") }
@@ -43,8 +40,9 @@ class MyApp < Sinatra::Application
43
40
  # Serve assets via Nginx or Apache
44
41
  disable :static
45
42
 
46
- assets.js_compressor = :uglify
47
- assets.css_compressor = :sass
43
+ require 'terser'
44
+ assets.js_compressor = Terser.new
45
+ assets.css_compressor = :sassc
48
46
  Sequel.connect YAML.load_file(File.expand_path("../config/database.yml", __FILE__))['production']
49
47
  end
50
48
  end
@@ -1,14 +1,13 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'sinatra', '~> 2.2'
4
- gem 'sinatra-contrib', '~> 2.2', require: false
5
- gem 'encrypted_cookie', '0.1.0'
6
- gem 'rack_csrf', '~> 2.6', require: 'rack/csrf'
7
- gem 'puma', '~> 5.6'
8
- gem 'tux', '~> 0.3', require: false
9
- gem 'uglifier', '~> 4.2', require: false
10
- gem 'sass', '~> 3.7', require: false
11
- gem 'sassc', '~> 2.4', require: false
12
- gem 'sprockets', '~> 4.0'
13
- gem 'sequel', '>= 5'
14
- gem 'sequel_pg', '>= 1.15', require: 'sequel'
3
+ gem 'sinatra', '~> 4.2'
4
+ gem 'sinatra-contrib', '~> 4.2', require: false
5
+ gem 'rack-session', '~> 2.1'
6
+ gem 'rack_csrf', '~> 2.7', require: 'rack/csrf'
7
+ gem 'puma', '~> 8.1'
8
+ gem 'irb', require: false
9
+ gem 'terser', '~> 1.2', require: false
10
+ gem 'sassc-embedded', '~> 1.80', require: false
11
+ gem 'sprockets', '~> 4.4'
12
+ gem 'sequel', '~> 5.110'
13
+ gem 'sequel_pg', '~> 1.20', require: 'sequel'
@@ -14,6 +14,14 @@ namespace :assets do
14
14
  end
15
15
  end
16
16
 
17
+ desc "Start an IRB console with the app loaded"
18
+ task :console do
19
+ require 'irb'
20
+ require_relative 'config/application'
21
+ ARGV.clear
22
+ IRB.start
23
+ end
24
+
17
25
  namespace :db do
18
26
  desc "Run migrations"
19
27
  task :migrate, [:version] do |t, args|
@@ -1,7 +1,4 @@
1
1
  class MyApp < Sinatra::Application
2
- use Rack::Session::EncryptedCookie,
3
- secret: 'supersecretcookiefromgenerator'
4
-
5
2
  set :app_file, __FILE__
6
3
  set :server, :puma
7
4
  set :views, Proc.new { File.join(root, "app/views") }
@@ -25,7 +22,8 @@ class MyApp < Sinatra::Application
25
22
  # Serve assets via Nginx or Apache
26
23
  disable :static
27
24
 
28
- assets.js_compressor = :uglify
29
- assets.css_compressor = :sass
25
+ require 'terser'
26
+ assets.js_compressor = Terser.new
27
+ assets.css_compressor = :sassc
30
28
  end
31
29
  end
@@ -1,12 +1,11 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'sinatra', '~> 2.2'
4
- gem 'sinatra-contrib', '~> 2.2', require: false
5
- gem 'encrypted_cookie', '0.1.0'
6
- gem 'rack_csrf', '~> 2.6', require: 'rack/csrf'
7
- gem 'puma', '~> 5.6'
8
- gem 'tux', '~> 0.3', require: false
9
- gem 'uglifier', '~> 4.2', require: false
10
- gem 'sass', '~> 3.7', require: false
11
- gem 'sassc', '~> 2.4', require: false
12
- gem 'sprockets', '~> 4.0'
3
+ gem 'sinatra', '~> 4.2'
4
+ gem 'sinatra-contrib', '~> 4.2', require: false
5
+ gem 'rack-session', '~> 2.1'
6
+ gem 'rack_csrf', '~> 2.7', require: 'rack/csrf'
7
+ gem 'puma', '~> 8.1'
8
+ gem 'irb', require: false
9
+ gem 'terser', '~> 1.2', require: false
10
+ gem 'sassc-embedded', '~> 1.80', require: false
11
+ gem 'sprockets', '~> 4.4'
@@ -13,3 +13,11 @@ namespace :assets do
13
13
  FileUtils.rm_rf("#{MyApp.public_folder}/assets")
14
14
  end
15
15
  end
16
+
17
+ desc "Start an IRB console with the app loaded"
18
+ task :console do
19
+ require 'irb'
20
+ require_relative 'config/application'
21
+ ARGV.clear
22
+ IRB.start
23
+ end
@@ -4,7 +4,7 @@ module Helper
4
4
  file_content = File.read(file)
5
5
  expected_file_content = File.read(expected_file)
6
6
 
7
- expect(File.exists?(file)).to be_truthy
7
+ expect(File.exist?(file)).to be_truthy
8
8
  expect(file_content).to eq(expected_file_content)
9
9
  end
10
10
 
@@ -21,25 +21,25 @@ module Helper
21
21
  layout = "#{target_dir}/app/views/layout.erb"
22
22
  home_index = "#{target_dir}/app/views/home/index.erb"
23
23
 
24
- expect(File.exists?(config_dir)).to eq(expected_value)
25
- expect(File.exists?("#{config_dir}/boot.rb")).to eq(expected_value)
26
- expect(File.exists?("#{config_dir}/application.rb")).to eq(expected_value)
27
- expect(File.exists?(assets_dir)).to eq(expected_value)
28
- expect(File.exists?(public_dir)).to eq(expected_value)
29
-
30
- expect(Dir.exists?(app_dir)).to eq(expected_value)
31
- expect(Dir.exists?(routes_dir)).to eq(expected_value)
32
- expect(Dir.exists?(views_dir)).to eq(expected_value)
33
- expect(File.exists?(layout)).to eq(expected_value)
34
- expect(File.exists?(home_index)).to eq(expected_value)
24
+ expect(File.exist?(config_dir)).to eq(expected_value)
25
+ expect(File.exist?("#{config_dir}/boot.rb")).to eq(expected_value)
26
+ expect(File.exist?("#{config_dir}/application.rb")).to eq(expected_value)
27
+ expect(File.exist?(assets_dir)).to eq(expected_value)
28
+ expect(File.exist?(public_dir)).to eq(expected_value)
29
+
30
+ expect(Dir.exist?(app_dir)).to eq(expected_value)
31
+ expect(Dir.exist?(routes_dir)).to eq(expected_value)
32
+ expect(Dir.exist?(views_dir)).to eq(expected_value)
33
+ expect(File.exist?(layout)).to eq(expected_value)
34
+ expect(File.exist?(home_index)).to eq(expected_value)
35
35
  end
36
36
 
37
37
  def expected_generated_files_with_db(target_dir, expected_value)
38
38
  sample_migration = "#{target_dir}/db/migrations/000_example.rb"
39
39
 
40
- expect(Dir.exists?("#{target_dir}/app/models")).to eq(expected_value)
41
- expect(File.exists?("#{target_dir}/config/database.yml")).to eq(expected_value)
42
- expect(File.exists?(sample_migration)).to eq(expected_value)
40
+ expect(Dir.exist?("#{target_dir}/app/models")).to eq(expected_value)
41
+ expect(File.exist?("#{target_dir}/config/database.yml")).to eq(expected_value)
42
+ expect(File.exist?(sample_migration)).to eq(expected_value)
43
43
  end
44
44
 
45
45
  end
@@ -3,17 +3,17 @@ require_relative '../../lib/sinator/command'
3
3
  describe Sinator::Command do
4
4
 
5
5
  describe "parse" do
6
- def remove_existing_app_if_exists
7
- FileUtils.rm_r "my_app" if Dir.exists?("my_app")
8
- FileUtils.rm_r "/tmp/my_app" if Dir.exists?("/tmp/my_app")
6
+ def remove_existing_app_if_exist
7
+ FileUtils.rm_r "my_app" if Dir.exist?("my_app")
8
+ FileUtils.rm_r "/tmp/my_app" if Dir.exist?("/tmp/my_app")
9
9
  end
10
10
 
11
11
  before do
12
- remove_existing_app_if_exists
12
+ remove_existing_app_if_exist
13
13
  end
14
14
 
15
15
  after :all do
16
- remove_existing_app_if_exists
16
+ remove_existing_app_if_exist
17
17
  end
18
18
 
19
19
  it "has --help option" do
@@ -39,14 +39,14 @@ describe Sinator::Command do
39
39
  app = Sinator::Command.parse %w(-n my_app --target /tmp)
40
40
 
41
41
  expect(app).to include "my_app is successfully generated in /tmp"
42
- expect(Dir.exists?("/tmp/my_app")).to be_truthy
42
+ expect(Dir.exist?("/tmp/my_app")).to be_truthy
43
43
  end
44
44
 
45
45
  it "has --database option" do
46
46
  app = Sinator::Command.parse %w(-n my_app --target /tmp -d)
47
47
 
48
48
  expect(app).to include "my_app is successfully generated in /tmp"
49
- expect(Dir.exists?("/tmp/my_app/db")).to be_truthy
49
+ expect(Dir.exist?("/tmp/my_app/db")).to be_truthy
50
50
  end
51
51
 
52
52
  context "when has no --name option and only --target option" do
@@ -14,13 +14,13 @@ describe Sinator::Generator do
14
14
  @dest_with_db = "#{@dest}_with_db"
15
15
  @app = "my_app"
16
16
 
17
- FileUtils.rm_r @dest if Dir.exists?(@dest)
18
- FileUtils.rm_r @dest_with_db if Dir.exists?(@dest_with_db)
17
+ FileUtils.rm_r @dest if Dir.exist?(@dest)
18
+ FileUtils.rm_r @dest_with_db if Dir.exist?(@dest_with_db)
19
19
  end
20
20
 
21
21
  after do
22
- FileUtils.rm_r @dest if Dir.exists?(@dest)
23
- FileUtils.rm_r @dest_with_db if Dir.exists?(@dest_with_db)
22
+ FileUtils.rm_r @dest if Dir.exist?(@dest)
23
+ FileUtils.rm_r @dest_with_db if Dir.exist?(@dest_with_db)
24
24
  end
25
25
 
26
26
  it "sets app_name" do
@@ -32,9 +32,9 @@ describe Sinator::Generator do
32
32
  end
33
33
 
34
34
  it "has default destination path app_name" do
35
- FileUtils.rm_r @app if Dir.exists?(@app)
35
+ FileUtils.rm_r @app if Dir.exist?(@app)
36
36
  expect(Sinator::Generator.new(@app).destination).to eq File.expand_path(@app)
37
- FileUtils.rm_r @app if Dir.exists?(@app)
37
+ FileUtils.rm_r @app if Dir.exist?(@app)
38
38
  end
39
39
 
40
40
  it "sets new destination path even if it's not exist yet" do
@@ -97,8 +97,8 @@ describe Sinator::Generator do
97
97
  generated_file = "#{target_dir}/app/routes/home.rb"
98
98
  expected_file = File.expand_path("../../fixtures/app_routes_home.txt", __FILE__)
99
99
 
100
- expect(File.exists?(erb_file)).to be_falsey
101
- expect(File.exists?(generated_file)).to be_truthy
100
+ expect(File.exist?(erb_file)).to be_falsey
101
+ expect(File.exist?(generated_file)).to be_truthy
102
102
  expect_file_eq(generated_file, expected_file)
103
103
  end
104
104
 
@@ -116,9 +116,6 @@ describe Sinator::Generator do
116
116
  end
117
117
 
118
118
  describe "app file" do
119
- let(:secret) { "supersecretcookiefromgenerator" }
120
- before { allow(SecureRandom).to receive(:hex).with(32).and_return(secret) }
121
-
122
119
  it "generates <app_name>.rb, public dir, and app dir" do
123
120
  generator.generate_app
124
121
 
@@ -144,9 +141,6 @@ describe Sinator::Generator do
144
141
  end
145
142
 
146
143
  describe "app file" do
147
- let(:secret) { "supersecretcookiefromgenerator" }
148
- before { allow(SecureRandom).to receive(:hex).with(32).and_return(secret) }
149
-
150
144
  it "has sequel database connector" do
151
145
  generator_with_db.generate_app
152
146
 
metadata CHANGED
@@ -1,43 +1,42 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinator
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kunto Aji Kristianto
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-05-14 00:00:00.000000000 Z
10
+ date: 2026-11-29 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: bundler
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - "~>"
16
+ - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: '1.7'
18
+ version: '0'
20
19
  type: :development
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
- - - "~>"
23
+ - - ">="
25
24
  - !ruby/object:Gem::Version
26
- version: '1.7'
25
+ version: '0'
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: rspec
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
- - - '='
30
+ - - ">="
32
31
  - !ruby/object:Gem::Version
33
- version: 3.2.0
32
+ version: '0'
34
33
  type: :development
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
- - - '='
37
+ - - ">="
39
38
  - !ruby/object:Gem::Version
40
- version: 3.2.0
39
+ version: '0'
41
40
  - !ruby/object:Gem::Dependency
42
41
  name: simplecov
43
42
  requirement: !ruby/object:Gem::Requirement
@@ -63,6 +62,7 @@ files:
63
62
  - ".gitignore"
64
63
  - ".rspec"
65
64
  - CHANGELOG.md
65
+ - CLAUDE.md
66
66
  - Gemfile
67
67
  - Gemfile.lock
68
68
  - LICENSE.txt
@@ -119,7 +119,6 @@ homepage: http://github.com/kuntoaji/sinator
119
119
  licenses:
120
120
  - MIT
121
121
  metadata: {}
122
- post_install_message:
123
122
  rdoc_options: []
124
123
  require_paths:
125
124
  - lib
@@ -127,15 +126,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
127
126
  requirements:
128
127
  - - ">="
129
128
  - !ruby/object:Gem::Version
130
- version: '2.1'
129
+ version: 3.3.1
131
130
  required_rubygems_version: !ruby/object:Gem::Requirement
132
131
  requirements:
133
132
  - - ">="
134
133
  - !ruby/object:Gem::Version
135
134
  version: '0'
136
135
  requirements: []
137
- rubygems_version: 3.3.7
138
- signing_key:
136
+ rubygems_version: 4.0.20
139
137
  specification_version: 4
140
138
  summary: Sinatra application generator
141
139
  test_files: []