frankly 0.2.3 → 0.2.4

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: ec34b9f3424166a083d2a66f867231d933b2aadaa59f0c5cd05d5ef9f0cc99f0
4
- data.tar.gz: 70e164681f51d310b3c9316f59af12e328342eb41733592bea9f1e4c4da53b1b
3
+ metadata.gz: fe3e14e6b7eaca34d9ce4bfbb3b8ecd42ee953945747ea7d2cdb29e968b5cb4e
4
+ data.tar.gz: 5d03218e4e887f6a4830ab7050f1131c8a56fa5725802e26661f5849b7a0da90
5
5
  SHA512:
6
- metadata.gz: 06cd91c94c621288f7f2ee5df4840c8e20b9bcfb25964fecd9c450ac7b609e4a485c9c948586a5ba43dc459d9e4997a76b19ad735a7b47b9580cf5ef51e4b867
7
- data.tar.gz: 1353cf106c8ab649ce7a4dba097a92081aeb5bdedd7939195fe2e00782efc5858b118b736e32dcfd07834035943c17d459ee6677bd1d8077c5df78c8493b086d
6
+ metadata.gz: 67fd2432d06b7846926d09794e661362d04b51901789d267bd43370377f5598c90f2e736a454cb7483b3fb98eeff36f594d2133b78e4f14c4781f2a97a76dd72
7
+ data.tar.gz: 788e5b29b4ff3a5ea7eba2b4a5c7fe051a51623a0860c02ca5cf9233b5cd1be579c99f505a035abf4e6eaf2fddec556f14c4cb62a85f30c75440a8b5c725c35a
@@ -0,0 +1,26 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ fail-fast: false
12
+ matrix:
13
+ ruby: ["3.1", "3.2", "3.3"]
14
+
15
+ steps:
16
+ - name: Checkout
17
+ uses: actions/checkout@v4
18
+
19
+ - name: Set up Ruby
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby }}
23
+ bundler-cache: true
24
+
25
+ - name: Run specs
26
+ run: bundle exec rspec
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Frankly
2
2
 
3
- `frankly` is a Sinatra starter generator.
3
+ `frankly` is a small Thor-based Sinatra scaffold generator.
4
4
 
5
- It creates a PostgreSQL + ActiveRecord app scaffold with a modern Sinatra setup.
5
+ It creates a PostgreSQL + ActiveRecord app with a minimal RSpec setup.
6
6
 
7
7
  ## Requirements
8
8
 
@@ -16,30 +16,13 @@ It creates a PostgreSQL + ActiveRecord app scaffold with a modern Sinatra setup.
16
16
  gem install frankly
17
17
  ```
18
18
 
19
- Install and runtime banner:
20
-
21
- ```text
22
- .
23
- .---------.'---.
24
- '. : .'
25
- '. .::: .' The Chairman
26
- '.'::'.' of the Board
27
- '||' has arrived.
28
- ||
29
- ||
30
- ||
31
- ---====---
32
- ```
33
-
34
19
  ## Usage
35
20
 
36
- Generate a new app:
37
-
38
21
  ```sh
39
22
  frankly my_app
40
23
  ```
41
24
 
42
- ### Options
25
+ Common options:
43
26
 
44
27
  ```sh
45
28
  frankly my_app --bundle
@@ -49,7 +32,32 @@ frankly my_app --skip-git
49
32
  - `--bundle`: runs `bundle install` in the generated app
50
33
  - `--skip-git`: skips `git init`
51
34
 
52
- ## Generated app quickstart
35
+ ## What It Generates
36
+
37
+ ```text
38
+ my_app/
39
+ app.rb
40
+ config.ru
41
+ Gemfile
42
+ Rakefile
43
+ config/
44
+ environment.rb
45
+ database.rb
46
+ app/views/
47
+ layout.erb
48
+ index.erb
49
+ spec/
50
+ spec_helper.rb
51
+ requests/app_spec.rb
52
+ ```
53
+
54
+ ## Name and DB Naming Behavior
55
+
56
+ - The generated folder keeps your requested name (downcased), including hyphens.
57
+ - Default database names are PostgreSQL-friendly and use underscores.
58
+ - Example: `frankly my-app` creates `my-app/`, with default DB names like `my_app_development`.
59
+
60
+ ## Generated App Quickstart
53
61
 
54
62
  ```sh
55
63
  cd my_app
@@ -57,7 +65,14 @@ bundle install
57
65
  bundle exec rackup
58
66
  ```
59
67
 
60
- Open http://localhost:9292.
68
+ Open [http://localhost:9292](http://localhost:9292).
69
+
70
+ ## Troubleshooting
71
+
72
+ - PostgreSQL not running:
73
+ - Start Postgres and set `DATABASE_URL`, then run `bundle exec rake db:create db:migrate`.
74
+ - Port already in use (`9292`):
75
+ - Run on another port, e.g. `bundle exec rackup -p 9393`.
61
76
 
62
77
  ## Development (this gem)
63
78
 
@@ -66,19 +81,6 @@ bin/setup
66
81
  bundle exec rspec
67
82
  ```
68
83
 
69
- ## Release
70
-
71
- ```sh
72
- bundle exec rake build
73
- bundle exec rake install
74
- bundle exec rake release
75
- ```
76
-
77
- ## Contributing
78
-
79
- Issues and pull requests are welcome at:
80
- https://github.com/kenrett/frankly
81
-
82
84
  ## License
83
85
 
84
86
  MIT. See [LICENSE.txt](LICENSE.txt).
data/bin/console CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
5
5
  require "bundler/setup"
6
- require_relative "../config/environment"
6
+ require "frankly"
7
7
 
8
8
  begin
9
9
  require "pry"
data/lib/frankly/cli.rb CHANGED
@@ -25,6 +25,7 @@ module Frankly
25
25
 
26
26
  def setup
27
27
  @app_path = sanitized_app_path
28
+ @db_name = @app_path.tr("-", "_")
28
29
  end
29
30
 
30
31
  def create_app_scaffold
@@ -35,6 +36,7 @@ module Frankly
35
36
  empty_directory "#{@app_path}/app/helpers"
36
37
  empty_directory "#{@app_path}/app/models"
37
38
  empty_directory "#{@app_path}/db/migrate"
39
+ empty_directory "#{@app_path}/spec/requests"
38
40
  create_file "#{@app_path}/app/controllers/.gitkeep"
39
41
  create_file "#{@app_path}/app/helpers/.gitkeep"
40
42
  create_file "#{@app_path}/app/models/.gitkeep"
@@ -50,9 +52,12 @@ module Frankly
50
52
  copy_file "config/database.rb", "#{@app_path}/config/database.rb"
51
53
  copy_file "config/environment.rb", "#{@app_path}/config/environment.rb"
52
54
  copy_file "db/seeds.rb", "#{@app_path}/db/seeds.rb"
53
- copy_file "README.md", "#{@app_path}/README.md"
55
+ template "README.md.tt", "#{@app_path}/README.md"
54
56
  template "Gemfile.tt", "#{@app_path}/Gemfile"
55
57
  template "gitignore.tt", "#{@app_path}/.gitignore"
58
+ copy_file ".rspec", "#{@app_path}/.rspec"
59
+ copy_file "spec/spec_helper.rb", "#{@app_path}/spec/spec_helper.rb"
60
+ copy_file "spec/requests/app_spec.rb", "#{@app_path}/spec/requests/app_spec.rb"
56
61
  copy_file "public/css/application.css", "#{@app_path}/public/css/application.css"
57
62
  copy_file "public/js/application.js", "#{@app_path}/public/js/application.js"
58
63
  copy_file "public/favicon.ico", "#{@app_path}/public/favicon.ico"
@@ -70,13 +75,25 @@ module Frankly
70
75
  inside(@app_path) { run("bundle install") }
71
76
  end
72
77
 
78
+ def print_next_steps
79
+ say "\nNext steps:"
80
+ say " cd #{@app_path}"
81
+ say " bundle install#{options[:bundle] ? ' (already run because you passed --bundle)' : ''}"
82
+ say " bundle exec rackup"
83
+ say " Set DATABASE_URL in your environment (or use the defaults in config/database.rb)."
84
+ say " Database setup is required for persistence (create DB and run migrations)."
85
+ end
86
+
73
87
  private
74
88
 
75
89
  def sanitized_app_path
76
- cleaned = name.to_s.strip.downcase.gsub(/[^a-z0-9_-]/, "")
77
- raise Thor::Error, "APP_NAME must include at least one letter or number" if cleaned.empty?
90
+ raw_name = name.to_s.strip
91
+ raise Thor::Error, "APP_NAME cannot be blank" if raw_name.empty?
92
+ unless raw_name.match?(/\A[a-zA-Z0-9][a-zA-Z0-9_-]*\z/)
93
+ raise Thor::Error, "APP_NAME may only include letters, numbers, hyphens, and underscores"
94
+ end
78
95
 
79
- cleaned
96
+ raw_name.downcase
80
97
  end
81
98
  end
82
99
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Frankly
4
- VERSION = "0.2.3"
4
+ VERSION = "0.2.4"
5
5
  end
data/templates/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --require spec_helper
2
+ --format documentation
@@ -0,0 +1,39 @@
1
+ # <%= @app_path %>
2
+
3
+ Generated by `frankly`.
4
+
5
+ ## Quickstart
6
+
7
+ ```sh
8
+ bundle install
9
+ bundle exec rackup
10
+ ```
11
+
12
+ Open http://localhost:9292.
13
+
14
+ ## Database
15
+
16
+ This app uses PostgreSQL via ActiveRecord.
17
+
18
+ Environment variables:
19
+
20
+ - `RACK_ENV` (default: `development`)
21
+ - `DATABASE_URL` (default: `postgres://localhost/<%= @db_name %>_<rack_env>`)
22
+
23
+ Example:
24
+
25
+ ```sh
26
+ DATABASE_URL=postgres://localhost/<%= @db_name %>_development bundle exec rackup
27
+ ```
28
+
29
+ Create the database and run migrations before relying on persistence:
30
+
31
+ ```sh
32
+ bundle exec rake db:create db:migrate
33
+ ```
34
+
35
+ ## Tests
36
+
37
+ ```sh
38
+ bundle exec rspec
39
+ ```
@@ -7,7 +7,7 @@ rack_env = ENV.fetch("RACK_ENV", "development")
7
7
  ActiveRecord::Base.logger = Logger.new($stdout) if rack_env == "development"
8
8
 
9
9
  build_db_config = lambda do |env_name|
10
- database_url = ENV.fetch("DATABASE_URL", "postgres://localhost/#{APP_NAME}_#{env_name}")
10
+ database_url = ENV.fetch("DATABASE_URL", "postgres://localhost/#{DB_NAME}_#{env_name}")
11
11
  uri = URI.parse(database_url)
12
12
  database_name = uri.path.sub(%r{^/}, "")
13
13
  adapter = uri.scheme == "postgres" ? "postgresql" : uri.scheme
@@ -11,6 +11,7 @@ require "sinatra/reloader"
11
11
 
12
12
  APP_ROOT = Pathname.new(File.expand_path("..", __dir__))
13
13
  APP_NAME = APP_ROOT.basename.to_s
14
+ DB_NAME = APP_NAME.tr("-", "_")
14
15
 
15
16
  Dir[APP_ROOT.join("app", "helpers", "*.rb")].sort.each { |file| require file }
16
17
  Dir[APP_ROOT.join("app", "controllers", "*.rb")].sort.each { |file| require file }
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ RSpec.describe "GET /" do
6
+ def app
7
+ App
8
+ end
9
+
10
+ it "returns 200 with the default home page content" do
11
+ get "/"
12
+
13
+ expect(last_response.status).to eq(200)
14
+ expect(last_response.body).to include("Frankly, it works.")
15
+ end
16
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ ENV["RACK_ENV"] = "test"
4
+
5
+ require "rack/test"
6
+ require "rspec"
7
+
8
+ require_relative "../app"
9
+
10
+ RSpec.configure do |config|
11
+ config.include Rack::Test::Methods
12
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frankly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Rettberg
@@ -89,9 +89,9 @@ executables:
89
89
  extensions: []
90
90
  extra_rdoc_files: []
91
91
  files:
92
+ - ".github/workflows/ci.yml"
92
93
  - ".gitignore"
93
94
  - ".rspec"
94
- - ".travis.yml"
95
95
  - CODE_OF_CONDUCT.md
96
96
  - Gemfile
97
97
  - LICENSE.txt
@@ -105,11 +105,11 @@ files:
105
105
  - lib/frankly/banner.rb
106
106
  - lib/frankly/cli.rb
107
107
  - lib/frankly/version.rb
108
+ - templates/.rspec
108
109
  - templates/Gemfile.tt
109
- - templates/README.md
110
+ - templates/README.md.tt
110
111
  - templates/Rakefile
111
112
  - templates/app.rb
112
- - templates/app/.DS_Store
113
113
  - templates/app/controllers/.gitkeep
114
114
  - templates/app/helpers/.gitkeep
115
115
  - templates/app/helpers/README.md
@@ -124,12 +124,13 @@ files:
124
124
  - templates/db/migrate/.gitkeep
125
125
  - templates/db/seeds.rb
126
126
  - templates/gitignore.tt
127
- - templates/public/.DS_Store
128
127
  - templates/public/css/application.css
129
128
  - templates/public/css/normalize.css
130
129
  - templates/public/favicon.ico
131
130
  - templates/public/js/.gitkeep
132
131
  - templates/public/js/application.js
132
+ - templates/spec/requests/app_spec.rb
133
+ - templates/spec/spec_helper.rb
133
134
  homepage: https://github.com/kenrett/frankly
134
135
  licenses:
135
136
  - MIT
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.3.1
6
- before_install: gem install bundler -v 1.13.6
data/templates/README.md DELETED
@@ -1,48 +0,0 @@
1
- # Sinatra App
2
-
3
- Generated by `frankly`.
4
-
5
- ## Requirements
6
-
7
- - Ruby 3.1+
8
- - PostgreSQL
9
- - Bundler
10
-
11
- ## Quickstart
12
-
13
- ```sh
14
- bundle install
15
- bundle exec rackup
16
- ```
17
-
18
- Open http://localhost:9292.
19
-
20
- ## Development reload
21
-
22
- ```sh
23
- bundle exec rerun -- rackup
24
- ```
25
-
26
- ## Database
27
-
28
- The template uses PostgreSQL via ActiveRecord.
29
-
30
- Environment variables:
31
-
32
- - `RACK_ENV` (default: `development`)
33
- - `DATABASE_URL` (default: `postgres://localhost/<app_name>_<rack_env>`)
34
-
35
- Examples:
36
-
37
- ```sh
38
- RACK_ENV=test bundle exec rake spec
39
- DATABASE_URL=postgres://localhost/my_app_development bundle exec rackup
40
- ```
41
-
42
- ## Common tasks
43
-
44
- ```sh
45
- bundle exec rake spec
46
- bundle exec rake db:migrate
47
- bundle exec rake db:rollback
48
- ```
Binary file
Binary file