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 +4 -4
- data/.github/workflows/ci.yml +26 -0
- data/README.md +37 -20
- data/bin/console +1 -1
- data/bin/frankly +5 -4
- data/frankly.gemspec +2 -13
- data/lib/frankly/banner.rb +18 -0
- data/lib/frankly/cli.rb +21 -4
- data/lib/frankly/version.rb +1 -1
- data/lib/frankly.rb +1 -0
- data/templates/.rspec +2 -0
- data/templates/README.md.tt +39 -0
- data/templates/config/database.rb +1 -1
- data/templates/config/environment.rb +1 -0
- data/templates/spec/requests/app_spec.rb +16 -0
- data/templates/spec/spec_helper.rb +12 -0
- metadata +17 -16
- data/.travis.yml +0 -6
- data/templates/README.md +0 -48
- data/templates/app/.DS_Store +0 -0
- data/templates/public/.DS_Store +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fe3e14e6b7eaca34d9ce4bfbb3b8ecd42ee953945747ea7d2cdb29e968b5cb4e
|
|
4
|
+
data.tar.gz: 5d03218e4e887f6a4830ab7050f1131c8a56fa5725802e26661f5849b7a0da90
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
3
|
+
`frankly` is a small Thor-based Sinatra scaffold generator.
|
|
4
4
|
|
|
5
|
-
It creates a PostgreSQL + ActiveRecord app
|
|
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
|
-
|
|
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
|
-
##
|
|
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
data/bin/frankly
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
-
require
|
|
3
|
-
require
|
|
4
|
-
require
|
|
2
|
+
require "rubygems"
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "frankly"
|
|
5
5
|
|
|
6
6
|
begin
|
|
7
|
-
|
|
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 =
|
|
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/") }
|
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
|
-
|
|
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
|
-
|
|
77
|
-
raise Thor::Error, "APP_NAME
|
|
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
|
-
|
|
96
|
+
raw_name.downcase
|
|
80
97
|
end
|
|
81
98
|
end
|
|
82
99
|
end
|
data/lib/frankly/version.rb
CHANGED
data/lib/frankly.rb
CHANGED
data/templates/.rspec
ADDED
|
@@ -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/#{
|
|
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
|
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.
|
|
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
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
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
|
-
```
|
data/templates/app/.DS_Store
DELETED
|
Binary file
|
data/templates/public/.DS_Store
DELETED
|
Binary file
|