sinator 4.0.0 → 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: f34ecbbb94d95a5d18092e7dbc30f56f6632aae85e4ade0ac61631aa0a60d2dc
4
- data.tar.gz: 6b5f6611754632defcd5e1b1067f4a926c31993a5df12fc212f9ca357f12bea6
3
+ metadata.gz: a2bc45395774e1370062fdc1c56712f803a4d4e92a32e5bb3a3be2da4e25ef66
4
+ data.tar.gz: 954389971a148a660729f80566c942e772bf06ead1c8f03eb0f0702db3f7a7df
5
5
  SHA512:
6
- metadata.gz: ee06d661c2a157dbf45de4aac82103d428c908fba751cbf7a24f3ef4cc374ea9a3f995a622ca67c01bbba8f66462eedca2b3d6685f17628649facc5f5ed91158
7
- data.tar.gz: dce8a9f162b42745f6e02ff0d2e4cc71d89ce9d215fec6c8a57f1756a69ba840893f326ba2d1fe2d5a01879aeca6e8704a7f39aacb7736eb9abee056ee8e3cac
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,11 @@
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
+
1
9
  4.0.0:
2
10
  * Drop support for older Ruby versions, only support Ruby 3.3.1 and newer
3
11
 
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,32 +1,26 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sinator (3.1.1)
4
+ sinator (5.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- diff-lcs (1.5.1)
10
- docile (1.4.1)
11
- rspec (3.13.0)
9
+ diff-lcs (1.6.2)
10
+ rspec (3.13.2)
12
11
  rspec-core (~> 3.13.0)
13
12
  rspec-expectations (~> 3.13.0)
14
13
  rspec-mocks (~> 3.13.0)
15
- rspec-core (3.13.2)
14
+ rspec-core (3.13.7)
16
15
  rspec-support (~> 3.13.0)
17
- rspec-expectations (3.13.3)
16
+ rspec-expectations (3.13.6)
18
17
  diff-lcs (>= 1.2.0, < 2.0)
19
18
  rspec-support (~> 3.13.0)
20
- rspec-mocks (3.13.2)
19
+ rspec-mocks (3.13.9)
21
20
  diff-lcs (>= 1.2.0, < 2.0)
22
21
  rspec-support (~> 3.13.0)
23
- rspec-support (3.13.2)
24
- simplecov (0.22.0)
25
- docile (~> 1.1)
26
- simplecov-html (~> 0.11)
27
- simplecov_json_formatter (~> 0.1)
28
- simplecov-html (0.13.1)
29
- simplecov_json_formatter (0.1.4)
22
+ rspec-support (3.13.8)
23
+ simplecov (1.3.2)
30
24
 
31
25
  PLATFORMS
32
26
  ruby
@@ -38,4 +32,4 @@ DEPENDENCIES
38
32
  sinator!
39
33
 
40
34
  BUNDLED WITH
41
- 2.5.23
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
 
@@ -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 = '4.0.0'
2
+ VERSION = '5.0.0'
3
3
  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
@@ -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,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinator
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
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: 2024-12-11 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
@@ -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
@@ -134,8 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
133
  - !ruby/object:Gem::Version
135
134
  version: '0'
136
135
  requirements: []
137
- rubygems_version: 3.5.16
138
- signing_key:
136
+ rubygems_version: 4.0.20
139
137
  specification_version: 4
140
138
  summary: Sinatra application generator
141
139
  test_files: []