frankly 0.2.3 → 0.2.5

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: 55072e2189a10b13cd3beca25cc58d0aed428099f250d2533f3690e9ac44e7d0
4
+ data.tar.gz: 346209309426c1496898246056fcebbd23a07820947ec060982a1049b5017805
5
5
  SHA512:
6
- metadata.gz: 06cd91c94c621288f7f2ee5df4840c8e20b9bcfb25964fecd9c450ac7b609e4a485c9c948586a5ba43dc459d9e4997a76b19ad735a7b47b9580cf5ef51e4b867
7
- data.tar.gz: 1353cf106c8ab649ce7a4dba097a92081aeb5bdedd7939195fe2e00782efc5858b118b736e32dcfd07834035943c17d459ee6677bd1d8077c5df78c8493b086d
6
+ metadata.gz: e022caa9ec66a23734a3f6577dbf38220143ff2c74822ad2541c9f775458b06b84cefbe7ccb6b893d549310af4307f037916506e10da73762139a00fe92bcc8a
7
+ data.tar.gz: 2b89f270e32860808ead382424c2b2b670531bf1a3e327526b4a2447348729ef6d4a72a2847906456bc0cfebbe72e9e8575407528a4a054e717e201a598f0126
@@ -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,15 +32,48 @@ 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
56
64
  bundle install
57
65
  bundle exec rackup
66
+ bundle exec bin/console
58
67
  ```
59
68
 
60
- Open http://localhost:9292.
69
+ Open [http://localhost:9292](http://localhost:9292).
70
+
71
+ ## Troubleshooting
72
+
73
+ - PostgreSQL not running:
74
+ - Start Postgres and set `DATABASE_URL`, then run `bundle exec rake db:create db:migrate`.
75
+ - Port already in use (`9292`):
76
+ - Run on another port, e.g. `bundle exec rackup -p 9393`.
61
77
 
62
78
  ## Development (this gem)
63
79
 
@@ -66,19 +82,6 @@ bin/setup
66
82
  bundle exec rspec
67
83
  ```
68
84
 
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
85
  ## License
83
86
 
84
87
  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,12 +52,17 @@ 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
+ copy_file "bin/console", "#{@app_path}/bin/console"
56
+ template "README.md.tt", "#{@app_path}/README.md"
54
57
  template "Gemfile.tt", "#{@app_path}/Gemfile"
55
58
  template "gitignore.tt", "#{@app_path}/.gitignore"
59
+ copy_file ".rspec", "#{@app_path}/.rspec"
60
+ copy_file "spec/spec_helper.rb", "#{@app_path}/spec/spec_helper.rb"
61
+ copy_file "spec/requests/app_spec.rb", "#{@app_path}/spec/requests/app_spec.rb"
56
62
  copy_file "public/css/application.css", "#{@app_path}/public/css/application.css"
57
63
  copy_file "public/js/application.js", "#{@app_path}/public/js/application.js"
58
64
  copy_file "public/favicon.ico", "#{@app_path}/public/favicon.ico"
65
+ chmod "#{@app_path}/bin/console", 0o755
59
66
  end
60
67
 
61
68
  def initialize_git_repo
@@ -70,13 +77,26 @@ module Frankly
70
77
  inside(@app_path) { run("bundle install") }
71
78
  end
72
79
 
80
+ def print_next_steps
81
+ say "\nNext steps:"
82
+ say " cd #{@app_path}"
83
+ say " bundle install#{options[:bundle] ? ' (already run because you passed --bundle)' : ''}"
84
+ say " bundle exec rackup"
85
+ say " bundle exec bin/console"
86
+ say " Set DATABASE_URL in your environment (or use the defaults in config/database.rb)."
87
+ say " Database setup is required for persistence (create DB and run migrations)."
88
+ end
89
+
73
90
  private
74
91
 
75
92
  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?
93
+ raw_name = name.to_s.strip
94
+ raise Thor::Error, "APP_NAME cannot be blank" if raw_name.empty?
95
+ unless raw_name.match?(/\A[a-zA-Z0-9][a-zA-Z0-9_-]*\z/)
96
+ raise Thor::Error, "APP_NAME may only include letters, numbers, hyphens, and underscores"
97
+ end
78
98
 
79
- cleaned
99
+ raw_name.downcase
80
100
  end
81
101
  end
82
102
  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.5"
5
5
  end
data/templates/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --require spec_helper
2
+ --format documentation
@@ -0,0 +1,40 @@
1
+ # <%= @app_path %>
2
+
3
+ Generated by `frankly`.
4
+
5
+ ## Quickstart
6
+
7
+ ```sh
8
+ bundle install
9
+ bundle exec rackup
10
+ bundle exec bin/console
11
+ ```
12
+
13
+ Open http://localhost:9292.
14
+
15
+ ## Database
16
+
17
+ This app uses PostgreSQL via ActiveRecord.
18
+
19
+ Environment variables:
20
+
21
+ - `RACK_ENV` (default: `development`)
22
+ - `DATABASE_URL` (default: `postgres://localhost/<%= @db_name %>_<rack_env>`)
23
+
24
+ Example:
25
+
26
+ ```sh
27
+ DATABASE_URL=postgres://localhost/<%= @db_name %>_development bundle exec rackup
28
+ ```
29
+
30
+ Create the database and run migrations before relying on persistence:
31
+
32
+ ```sh
33
+ bundle exec rake db:create db:migrate
34
+ ```
35
+
36
+ ## Tests
37
+
38
+ ```sh
39
+ bundle exec rspec
40
+ ```
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
5
+ require "bundler/setup"
6
+ require_relative "../config/environment"
7
+
8
+ begin
9
+ require "pry"
10
+ Pry.start
11
+ rescue LoadError
12
+ require "irb"
13
+ IRB.start(__FILE__)
14
+ end
@@ -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.5
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
@@ -118,18 +118,20 @@ files:
118
118
  - templates/app/views/.gitkeep
119
119
  - templates/app/views/index.erb
120
120
  - templates/app/views/layout.erb
121
+ - templates/bin/console
121
122
  - templates/config.ru
122
123
  - templates/config/database.rb
123
124
  - templates/config/environment.rb
124
125
  - templates/db/migrate/.gitkeep
125
126
  - templates/db/seeds.rb
126
127
  - templates/gitignore.tt
127
- - templates/public/.DS_Store
128
128
  - templates/public/css/application.css
129
129
  - templates/public/css/normalize.css
130
130
  - templates/public/favicon.ico
131
131
  - templates/public/js/.gitkeep
132
132
  - templates/public/js/application.js
133
+ - templates/spec/requests/app_spec.rb
134
+ - templates/spec/spec_helper.rb
133
135
  homepage: https://github.com/kenrett/frankly
134
136
  licenses:
135
137
  - 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