frankly 0.2.2 → 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: 93bc4a74b8e4c574817e4e8cd0de16112b5c6d152fcc39dfbb641d34c9cb9f6f
4
- data.tar.gz: 58589529b0b9450e534e1018fe75ef07bc708c095abca661d832fb7e7c84d4dd
3
+ metadata.gz: fe3e14e6b7eaca34d9ce4bfbb3b8ecd42ee953945747ea7d2cdb29e968b5cb4e
4
+ data.tar.gz: 5d03218e4e887f6a4830ab7050f1131c8a56fa5725802e26661f5849b7a0da90
5
5
  SHA512:
6
- metadata.gz: 95420fbfd186664fc392594e6ea60a4a460aaed358678f08ac86af854818524c22eae51830df580309e2a437370c70feb3dd8f935fd65e7b66e66fb877254e32
7
- data.tar.gz: a96eb3ff588b6cb6e8a111f7c634d0d4ceafb64856c86cd459f6ab78ac590f60ac8ac032fdbf896c8127dc4a4167e5f417147ac7b762ab20115dc56a06b1fa4c
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
 
@@ -18,13 +18,11 @@ gem install frankly
18
18
 
19
19
  ## Usage
20
20
 
21
- Generate a new app:
22
-
23
21
  ```sh
24
22
  frankly my_app
25
23
  ```
26
24
 
27
- ### Options
25
+ Common options:
28
26
 
29
27
  ```sh
30
28
  frankly my_app --bundle
@@ -34,7 +32,32 @@ frankly my_app --skip-git
34
32
  - `--bundle`: runs `bundle install` in the generated app
35
33
  - `--skip-git`: skips `git init`
36
34
 
37
- ## 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
38
61
 
39
62
  ```sh
40
63
  cd my_app
@@ -42,7 +65,14 @@ bundle install
42
65
  bundle exec rackup
43
66
  ```
44
67
 
45
- 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`.
46
76
 
47
77
  ## Development (this gem)
48
78
 
@@ -51,19 +81,6 @@ bin/setup
51
81
  bundle exec rspec
52
82
  ```
53
83
 
54
- ## Release
55
-
56
- ```sh
57
- bundle exec rake build
58
- bundle exec rake install
59
- bundle exec rake release
60
- ```
61
-
62
- ## Contributing
63
-
64
- Issues and pull requests are welcome at:
65
- https://github.com/kenrett/frankly
66
-
67
84
  ## License
68
85
 
69
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/bin/frankly CHANGED
@@ -1,10 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
- require 'rubygems'
3
- require 'bundler/setup'
4
- require 'frankly'
2
+ require "rubygems"
3
+ require "bundler/setup"
4
+ require "frankly"
5
5
 
6
6
  begin
7
- require 'frankly/cli'
7
+ puts Frankly::Banner::ASCII_ART
8
+ require "frankly/cli"
8
9
  Frankly::CLI.start
9
10
  rescue Interrupt => e
10
11
  puts "\nQuitting..."
data/frankly.gemspec CHANGED
@@ -3,6 +3,7 @@
3
3
  lib = File.expand_path("lib", __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require "frankly/version"
6
+ require "frankly/banner"
6
7
 
7
8
  Gem::Specification.new do |spec|
8
9
  spec.name = "frankly"
@@ -15,20 +16,8 @@ Gem::Specification.new do |spec|
15
16
  spec.homepage = "https://github.com/kenrett/frankly"
16
17
  spec.license = "MIT"
17
18
  spec.required_ruby_version = ">= 3.1"
18
- spec.post_install_message = <<-PIC
19
- .
20
- .---------.'---.
21
- '. : .'
22
- '. .::: .' The Chairman
23
- '.'::'.' of the Board
24
- '||' has arrived.
25
- ||
26
- ||
27
- ||
28
- ---====---
29
- PIC
19
+ spec.post_install_message = Frankly::Banner::ASCII_ART
30
20
 
31
- spec.metadata["homepage_uri"] = spec.homepage
32
21
  spec.metadata["source_code_uri"] = spec.homepage
33
22
 
34
23
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.start_with?("spec/") }
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Frankly
4
+ module Banner
5
+ ASCII_ART = <<~ART
6
+ .
7
+ .---------.'---.
8
+ '. : .'
9
+ '. .::: .' The Chairman
10
+ '.'::'.' of the Board
11
+ '||' has arrived.
12
+ ||
13
+ ||
14
+ ||
15
+ ---====---
16
+ ART
17
+ end
18
+ end
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.2"
4
+ VERSION = "0.2.4"
5
5
  end
data/lib/frankly.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "frankly/version"
2
+ require "frankly/banner"
2
3
  require "frankly/cli"
3
4
 
4
5
  module Frankly
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.2
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
@@ -102,13 +102,14 @@ files:
102
102
  - bin/setup
103
103
  - frankly.gemspec
104
104
  - lib/frankly.rb
105
+ - lib/frankly/banner.rb
105
106
  - lib/frankly/cli.rb
106
107
  - lib/frankly/version.rb
108
+ - templates/.rspec
107
109
  - templates/Gemfile.tt
108
- - templates/README.md
110
+ - templates/README.md.tt
109
111
  - templates/Rakefile
110
112
  - templates/app.rb
111
- - templates/app/.DS_Store
112
113
  - templates/app/controllers/.gitkeep
113
114
  - templates/app/helpers/.gitkeep
114
115
  - templates/app/helpers/README.md
@@ -123,29 +124,29 @@ files:
123
124
  - templates/db/migrate/.gitkeep
124
125
  - templates/db/seeds.rb
125
126
  - templates/gitignore.tt
126
- - templates/public/.DS_Store
127
127
  - templates/public/css/application.css
128
128
  - templates/public/css/normalize.css
129
129
  - templates/public/favicon.ico
130
130
  - templates/public/js/.gitkeep
131
131
  - templates/public/js/application.js
132
+ - templates/spec/requests/app_spec.rb
133
+ - templates/spec/spec_helper.rb
132
134
  homepage: https://github.com/kenrett/frankly
133
135
  licenses:
134
136
  - MIT
135
137
  metadata:
136
- homepage_uri: https://github.com/kenrett/frankly
137
138
  source_code_uri: https://github.com/kenrett/frankly
138
139
  post_install_message: |2
139
- .
140
- .---------.'---.
141
- '. : .'
142
- '. .::: .' The Chairman
143
- '.'::'.' of the Board
144
- '||' has arrived.
145
- ||
146
- ||
147
- ||
148
- ---====---
140
+ .
141
+ .---------.'---.
142
+ '. : .'
143
+ '. .::: .' The Chairman
144
+ '.'::'.' of the Board
145
+ '||' has arrived.
146
+ ||
147
+ ||
148
+ ||
149
+ ---====---
149
150
  rdoc_options: []
150
151
  require_paths:
151
152
  - lib
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