frankly 0.1.6 → 0.2.1
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/README.md +48 -14
- data/bin/console +11 -11
- data/frankly.gemspec +25 -32
- data/lib/frankly/cli.rb +45 -27
- data/lib/frankly/version.rb +3 -1
- data/templates/Gemfile.tt +17 -22
- data/templates/README.md +37 -19
- data/templates/Rakefile +153 -117
- data/templates/app/views/index.erb +2 -0
- data/templates/app/views/layout.erb +13 -21
- data/templates/app.rb +23 -0
- data/templates/config/database.rb +27 -37
- data/templates/config/environment.rb +12 -39
- data/templates/config.ru +3 -4
- data/templates/gitignore.tt +7 -0
- data/templates/public/css/application.css +26 -0
- data/templates/public/js/application.js +1 -7
- metadata +34 -47
- data/spec/frankly_spec.rb +0 -44
- data/spec/spec_helper.rb +0 -32
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 256f2dbb88d9b111151d44696cb90572e4038079e48636bac595b987ba9cd6d5
|
|
4
|
+
data.tar.gz: 6b4901cee23b0c43d7ff1d7e7f719f6b38f71a1e000dce72ea4cec06429b2d8f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4d3fad1677f0a62c1d0405c92dcc95823413aa5ccbc77c4bac20e21a8feca788bc8c124705720fa8139ebf453eac7482ed82bae79a0278fd01f74262afb5172f
|
|
7
|
+
data.tar.gz: 26cb2665936482d1aef4088ef689344baa4b1f7ef3818da98fa2cd2f2d1e98ba4144d92c5fc3c6187e24c39257cd0ffec938cec9d7b96570010cbf53a59d54d8
|
data/README.md
CHANGED
|
@@ -1,35 +1,69 @@
|
|
|
1
1
|
# Frankly
|
|
2
|
-

|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
`frankly` is a Sinatra starter generator.
|
|
4
|
+
|
|
5
|
+
It creates a PostgreSQL + ActiveRecord app scaffold with a modern Sinatra setup.
|
|
6
|
+
|
|
7
|
+
## Requirements
|
|
8
|
+
|
|
9
|
+
- Ruby 3.1+
|
|
10
|
+
- PostgreSQL
|
|
11
|
+
- Bundler
|
|
5
12
|
|
|
6
13
|
## Installation
|
|
7
14
|
|
|
8
|
-
|
|
15
|
+
```sh
|
|
16
|
+
gem install frankly
|
|
17
|
+
```
|
|
9
18
|
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
Generate a new app:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
frankly my_app
|
|
10
25
|
```
|
|
11
|
-
|
|
26
|
+
|
|
27
|
+
### Options
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
frankly my_app --bundle
|
|
31
|
+
frankly my_app --skip-git
|
|
12
32
|
```
|
|
13
33
|
|
|
14
|
-
|
|
34
|
+
- `--bundle`: runs `bundle install` in the generated app
|
|
35
|
+
- `--skip-git`: skips `git init`
|
|
15
36
|
|
|
16
|
-
|
|
37
|
+
## Generated app quickstart
|
|
17
38
|
|
|
18
|
-
|
|
39
|
+
```sh
|
|
40
|
+
cd my_app
|
|
41
|
+
bundle install
|
|
42
|
+
bundle exec rackup
|
|
43
|
+
```
|
|
19
44
|
|
|
20
|
-
|
|
45
|
+
Open http://localhost:9292.
|
|
21
46
|
|
|
22
|
-
## Development
|
|
47
|
+
## Development (this gem)
|
|
23
48
|
|
|
24
|
-
|
|
49
|
+
```sh
|
|
50
|
+
bin/setup
|
|
51
|
+
bundle exec rspec
|
|
52
|
+
```
|
|
25
53
|
|
|
26
|
-
|
|
54
|
+
## Release
|
|
27
55
|
|
|
28
|
-
|
|
56
|
+
```sh
|
|
57
|
+
bundle exec rake build
|
|
58
|
+
bundle exec rake install
|
|
59
|
+
bundle exec rake release
|
|
60
|
+
```
|
|
29
61
|
|
|
30
|
-
|
|
62
|
+
## Contributing
|
|
31
63
|
|
|
64
|
+
Issues and pull requests are welcome at:
|
|
65
|
+
https://github.com/kenrett/frankly
|
|
32
66
|
|
|
33
67
|
## License
|
|
34
68
|
|
|
35
|
-
|
|
69
|
+
MIT. See [LICENSE.txt](LICENSE.txt).
|
data/bin/console
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
4
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
|
3
5
|
require "bundler/setup"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
require "irb"
|
|
14
|
-
IRB.start
|
|
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
|
data/frankly.gemspec
CHANGED
|
@@ -1,40 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
|
-
require
|
|
5
|
+
require "frankly/version"
|
|
4
6
|
|
|
5
7
|
Gem::Specification.new do |spec|
|
|
6
|
-
spec.name
|
|
7
|
-
spec.version
|
|
8
|
-
spec.authors
|
|
9
|
-
spec.email
|
|
10
|
-
|
|
11
|
-
spec.summary
|
|
12
|
-
spec.
|
|
13
|
-
spec.homepage
|
|
14
|
-
spec.
|
|
15
|
-
spec.
|
|
16
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
17
|
-
spec.test_files = spec.files.grep(%r{^(spec)/})
|
|
18
|
-
spec.require_paths = ["lib"]
|
|
8
|
+
spec.name = "frankly"
|
|
9
|
+
spec.version = Frankly::VERSION
|
|
10
|
+
spec.authors = ["Ken Rettberg"]
|
|
11
|
+
spec.email = ["kenrettberg@gmail.com"]
|
|
12
|
+
|
|
13
|
+
spec.summary = "Opinionated Sinatra app skeleton generator"
|
|
14
|
+
spec.description = "Generate a modern Sinatra + ActiveRecord starter app with sensible defaults."
|
|
15
|
+
spec.homepage = "https://github.com/kenrett/frankly"
|
|
16
|
+
spec.license = "MIT"
|
|
17
|
+
spec.required_ruby_version = ">= 3.1"
|
|
19
18
|
|
|
20
|
-
spec.
|
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
20
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
'.'::'.' of the Board
|
|
27
|
-
'||' has arrived.
|
|
28
|
-
||
|
|
29
|
-
||
|
|
30
|
-
||
|
|
31
|
-
---====---
|
|
32
|
-
PIC
|
|
22
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.start_with?("spec/") }
|
|
23
|
+
spec.bindir = "bin"
|
|
24
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
25
|
+
spec.require_paths = ["lib"]
|
|
33
26
|
|
|
34
|
-
|
|
35
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
|
36
|
-
spec.add_development_dependency "rspec"
|
|
37
|
-
spec.add_development_dependency "pry-byebug", "~> 3.4"
|
|
27
|
+
spec.add_dependency "thor", "~> 1.3"
|
|
38
28
|
|
|
39
|
-
|
|
29
|
+
spec.add_development_dependency "bundler", ">= 2.4"
|
|
30
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
|
31
|
+
spec.add_development_dependency "rspec", "~> 3.13"
|
|
32
|
+
spec.add_development_dependency "pry-byebug", "~> 3.10"
|
|
40
33
|
end
|
data/lib/frankly/cli.rb
CHANGED
|
@@ -1,66 +1,84 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
require
|
|
4
|
-
require
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "fileutils"
|
|
4
|
+
require "pathname"
|
|
5
|
+
require "thor"
|
|
6
|
+
require "thor/group"
|
|
5
7
|
|
|
6
8
|
module Frankly
|
|
7
9
|
class CLI < Thor::Group
|
|
8
10
|
include Thor::Actions
|
|
9
11
|
|
|
12
|
+
class_option :bundle, type: :boolean, default: false, desc: "Run bundle install after generation"
|
|
13
|
+
class_option :skip_git, type: :boolean, default: false, desc: "Skip git init"
|
|
14
|
+
|
|
15
|
+
desc "Creates a new Sinatra application"
|
|
16
|
+
argument :name, type: :string, desc: "The name of the new application"
|
|
17
|
+
|
|
10
18
|
def self.source_root
|
|
11
|
-
File.expand_path(
|
|
19
|
+
File.expand_path("../../templates", __dir__)
|
|
12
20
|
end
|
|
13
21
|
|
|
14
|
-
|
|
15
|
-
|
|
22
|
+
def self.exit_on_failure?
|
|
23
|
+
true
|
|
24
|
+
end
|
|
16
25
|
|
|
17
26
|
def setup
|
|
18
|
-
@app_path =
|
|
27
|
+
@app_path = sanitized_app_path
|
|
19
28
|
end
|
|
20
29
|
|
|
21
30
|
def create_app_scaffold
|
|
22
|
-
|
|
23
|
-
|
|
31
|
+
raise Thor::Error, "Directory '#{@app_path}' already exists" if File.exist?(@app_path)
|
|
32
|
+
|
|
33
|
+
empty_directory @app_path
|
|
34
|
+
empty_directory "#{@app_path}/app/controllers"
|
|
35
|
+
empty_directory "#{@app_path}/app/helpers"
|
|
36
|
+
empty_directory "#{@app_path}/app/models"
|
|
37
|
+
empty_directory "#{@app_path}/db/migrate"
|
|
24
38
|
create_file "#{@app_path}/app/controllers/.gitkeep"
|
|
25
|
-
create_file "#{@app_path}/app/views/.gitkeep"
|
|
26
39
|
create_file "#{@app_path}/app/helpers/.gitkeep"
|
|
27
|
-
create_file "#{@app_path}/
|
|
40
|
+
create_file "#{@app_path}/app/models/.gitkeep"
|
|
28
41
|
create_file "#{@app_path}/db/migrate/.gitkeep"
|
|
29
|
-
create_file "#{@app_path}/public/css/.gitkeep"
|
|
30
|
-
create_file "#{@app_path}/public/js/.gitkeep"
|
|
31
42
|
end
|
|
32
43
|
|
|
33
44
|
def copy_templates
|
|
34
45
|
copy_file "app/views/layout.erb", "#{@app_path}/app/views/layout.erb"
|
|
46
|
+
copy_file "app/views/index.erb", "#{@app_path}/app/views/index.erb"
|
|
47
|
+
copy_file "app.rb", "#{@app_path}/app.rb"
|
|
35
48
|
copy_file "config.ru", "#{@app_path}/config.ru"
|
|
36
49
|
copy_file "Rakefile", "#{@app_path}/Rakefile"
|
|
37
50
|
copy_file "config/database.rb", "#{@app_path}/config/database.rb"
|
|
38
51
|
copy_file "config/environment.rb", "#{@app_path}/config/environment.rb"
|
|
39
52
|
copy_file "db/seeds.rb", "#{@app_path}/db/seeds.rb"
|
|
40
53
|
copy_file "README.md", "#{@app_path}/README.md"
|
|
41
|
-
|
|
54
|
+
template "Gemfile.tt", "#{@app_path}/Gemfile"
|
|
55
|
+
template "gitignore.tt", "#{@app_path}/.gitignore"
|
|
42
56
|
copy_file "public/css/application.css", "#{@app_path}/public/css/application.css"
|
|
43
|
-
copy_file "public/css/normalize.css", "#{@app_path}/public/css/normalize.css"
|
|
44
57
|
copy_file "public/js/application.js", "#{@app_path}/public/js/application.js"
|
|
45
58
|
copy_file "public/favicon.ico", "#{@app_path}/public/favicon.ico"
|
|
46
59
|
end
|
|
47
60
|
|
|
48
61
|
def initialize_git_repo
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
end
|
|
62
|
+
return if options[:skip_git]
|
|
63
|
+
|
|
64
|
+
inside(@app_path) { run("git init .") }
|
|
53
65
|
end
|
|
54
66
|
|
|
55
67
|
def install_dependencies
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
68
|
+
return unless options[:bundle]
|
|
69
|
+
|
|
70
|
+
inside(@app_path) { run("bundle install") }
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
private
|
|
74
|
+
|
|
75
|
+
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?
|
|
78
|
+
|
|
79
|
+
cleaned
|
|
60
80
|
end
|
|
61
81
|
end
|
|
62
82
|
end
|
|
63
83
|
|
|
64
|
-
if
|
|
65
|
-
cli = Frankly::CLI.start
|
|
66
|
-
end
|
|
84
|
+
Frankly::CLI.start if $PROGRAM_NAME == __FILE__
|
data/lib/frankly/version.rb
CHANGED
data/templates/Gemfile.tt
CHANGED
|
@@ -1,28 +1,23 @@
|
|
|
1
|
-
source
|
|
1
|
+
source "https://rubygems.org"
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
gem 'pg'
|
|
3
|
+
ruby ">= 3.1"
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
gem
|
|
8
|
-
gem
|
|
5
|
+
gem "sinatra", "~> 3.1"
|
|
6
|
+
gem "sinatra-activerecord", "~> 2.0"
|
|
7
|
+
gem "sinatra-contrib", "~> 3.1"
|
|
8
|
+
gem "ostruct"
|
|
9
|
+
gem "pg", "~> 1.5"
|
|
10
|
+
gem "puma", "~> 6.0"
|
|
11
|
+
gem "rake", "~> 13.0"
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
gem
|
|
12
|
-
|
|
13
|
-
gem 'rake'
|
|
14
|
-
|
|
15
|
-
gem 'shotgun', '~>0.9.1'
|
|
16
|
-
|
|
17
|
-
group :test do
|
|
18
|
-
gem 'shoulda-matchers'
|
|
19
|
-
gem 'rack-test'
|
|
20
|
-
gem 'rspec', '~>3.0'
|
|
21
|
-
gem 'capybara'
|
|
13
|
+
group :development do
|
|
14
|
+
gem "pry-byebug", "~> 3.10"
|
|
15
|
+
gem "rerun", "~> 0.14"
|
|
22
16
|
end
|
|
23
17
|
|
|
24
|
-
group :test
|
|
25
|
-
gem
|
|
26
|
-
gem
|
|
27
|
-
gem
|
|
18
|
+
group :test do
|
|
19
|
+
gem "capybara", "~> 3.40"
|
|
20
|
+
gem "rack-test", "~> 2.1"
|
|
21
|
+
gem "rspec", "~> 3.13"
|
|
22
|
+
gem "shoulda-matchers", "~> 6.4"
|
|
28
23
|
end
|
data/templates/README.md
CHANGED
|
@@ -1,30 +1,48 @@
|
|
|
1
|
-
|
|
1
|
+
# Sinatra App
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
The Sinatra Skeleton:
|
|
3
|
+
Generated by `frankly`.
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
2. Demonstrates a reasonable set of practices around building Sinatra applications.
|
|
8
|
-
3. Eases the transition to Rails for Dev Bootcamp students
|
|
5
|
+
## Requirements
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
- Ruby 3.1+
|
|
8
|
+
- PostgreSQL
|
|
9
|
+
- Bundler
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
2. `shotgun config.ru`
|
|
14
|
-
|
|
15
|
-
As needed, create models & migrations with the `rake` tasks:
|
|
11
|
+
## Quickstart
|
|
16
12
|
|
|
13
|
+
```sh
|
|
14
|
+
bundle install
|
|
15
|
+
bundle exec rackup
|
|
17
16
|
```
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
|
|
18
|
+
Open http://localhost:9292.
|
|
19
|
+
|
|
20
|
+
## Development reload
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
bundle exec rerun -- rackup
|
|
20
24
|
```
|
|
21
25
|
|
|
22
|
-
|
|
26
|
+
## Database
|
|
27
|
+
|
|
28
|
+
The template uses PostgreSQL via ActiveRecord.
|
|
23
29
|
|
|
24
|
-
|
|
30
|
+
Environment variables:
|
|
25
31
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
3. Code review an open pull request!
|
|
32
|
+
- `RACK_ENV` (default: `development`)
|
|
33
|
+
- `DATABASE_URL` (default: `postgres://localhost/<app_name>_<rack_env>`)
|
|
29
34
|
|
|
30
|
-
|
|
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/Rakefile
CHANGED
|
@@ -1,154 +1,190 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "fileutils"
|
|
5
|
+
require "active_support/inflector"
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
unless defined?(Rails)
|
|
8
|
+
module Rails
|
|
9
|
+
class AppConfig
|
|
10
|
+
def load_database_yaml
|
|
11
|
+
{}
|
|
12
|
+
end
|
|
7
13
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
unless ENV.has_key?('NAME')
|
|
12
|
-
raise "Must specificy model name, e.g., rake generate:model NAME=User"
|
|
14
|
+
def paths
|
|
15
|
+
{ "db" => ["db"] }
|
|
16
|
+
end
|
|
13
17
|
end
|
|
14
18
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
class AppShim
|
|
20
|
+
def config
|
|
21
|
+
@config ||= AppConfig.new
|
|
22
|
+
end
|
|
18
23
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
def paths
|
|
25
|
+
{ "db/migrate" => ["db/migrate"] }
|
|
26
|
+
end
|
|
22
27
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
class #{model_name} < ActiveRecord::Base
|
|
27
|
-
# Remember to create a migration!
|
|
28
|
-
end
|
|
29
|
-
EOF
|
|
28
|
+
def migration_railties
|
|
29
|
+
[]
|
|
30
|
+
end
|
|
30
31
|
end
|
|
31
|
-
end
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
task :migration do
|
|
35
|
-
unless ENV.has_key?('NAME')
|
|
36
|
-
raise "Must specificy migration name, e.g., rake generate:migration NAME=create_tasks"
|
|
37
|
-
end
|
|
33
|
+
module_function
|
|
38
34
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
def env
|
|
36
|
+
ENV.fetch("RACK_ENV", "development")
|
|
37
|
+
end
|
|
42
38
|
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
def application
|
|
40
|
+
@application ||= AppShim.new
|
|
45
41
|
end
|
|
46
42
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
f.write(<<-EOF.strip_heredoc)
|
|
50
|
-
class #{name} < ActiveRecord::Migration[5.2]
|
|
51
|
-
def change
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
EOF
|
|
43
|
+
def root
|
|
44
|
+
Dir.pwd
|
|
55
45
|
end
|
|
56
46
|
end
|
|
47
|
+
end
|
|
57
48
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
unless ENV.has_key?('NAME')
|
|
61
|
-
raise "Must specificy migration name, e.g., rake generate:spec NAME=user"
|
|
62
|
-
end
|
|
49
|
+
require "sinatra/activerecord/rake"
|
|
50
|
+
require_relative "app"
|
|
63
51
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
52
|
+
begin
|
|
53
|
+
require "rspec/core/rake_task"
|
|
54
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
55
|
+
rescue LoadError
|
|
56
|
+
end
|
|
67
57
|
|
|
68
|
-
|
|
69
|
-
raise "ERROR: File '#{path}' already exists"
|
|
70
|
-
end
|
|
58
|
+
task default: :spec
|
|
71
59
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
require 'spec_helper'
|
|
76
|
-
describe #{name} do
|
|
77
|
-
pending "add some examples to (or delete) #{__FILE__}"
|
|
78
|
-
end
|
|
79
|
-
EOF
|
|
80
|
-
end
|
|
60
|
+
if ARGV.first.to_s.start_with?("generate:")
|
|
61
|
+
ARGV[1..].to_a.each do |arg|
|
|
62
|
+
task(arg.to_sym) unless Rake::Task.task_defined?(arg)
|
|
81
63
|
end
|
|
64
|
+
end
|
|
82
65
|
|
|
66
|
+
def positional_arg_for(task_name, index = 0)
|
|
67
|
+
tasks = Rake.application.top_level_tasks
|
|
68
|
+
position = tasks.index(task_name)
|
|
69
|
+
return nil unless position
|
|
70
|
+
|
|
71
|
+
tasks[position + 1 + index]
|
|
83
72
|
end
|
|
84
73
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
74
|
+
def positional_args_for(task_name, from_index: 0)
|
|
75
|
+
tasks = Rake.application.top_level_tasks
|
|
76
|
+
position = tasks.index(task_name)
|
|
77
|
+
return [] unless position
|
|
88
78
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
puts "Creating development and test databases if they don't exist..."
|
|
92
|
-
system("createdb #{APP_NAME}_development && createdb #{APP_NAME}_test")
|
|
93
|
-
end
|
|
79
|
+
tasks[(position + 1 + from_index)..].to_a
|
|
80
|
+
end
|
|
94
81
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
82
|
+
namespace :generate do
|
|
83
|
+
desc "Generate a model Usage: rake generate:model User name:string age:integer"
|
|
84
|
+
task :model, [:name] do |_task, args|
|
|
85
|
+
model_name = args[:name].presence || positional_arg_for("generate:model")
|
|
86
|
+
model_name = model_name.to_s.strip
|
|
87
|
+
abort "Model name is required. Example: rake generate:model User" if model_name.empty?
|
|
100
88
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if
|
|
106
|
-
|
|
107
|
-
ENV["SCOPE"].blank? || (ENV["SCOPE"] == migration.scope)
|
|
108
|
-
end
|
|
89
|
+
class_name = model_name.camelize
|
|
90
|
+
file_name = model_name.underscore
|
|
91
|
+
model_path = File.join("app", "models", "#{file_name}.rb")
|
|
92
|
+
|
|
93
|
+
if File.exist?(model_path)
|
|
94
|
+
puts "Model exists: #{model_path}"
|
|
109
95
|
else
|
|
110
|
-
|
|
96
|
+
FileUtils.mkdir_p(File.dirname(model_path))
|
|
97
|
+
File.write(model_path, <<~RUBY)
|
|
98
|
+
# frozen_string_literal: true
|
|
99
|
+
|
|
100
|
+
class #{class_name} < ActiveRecord::Base
|
|
101
|
+
end
|
|
102
|
+
RUBY
|
|
103
|
+
puts "Created #{model_path}"
|
|
111
104
|
end
|
|
112
|
-
end
|
|
113
105
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
106
|
+
attrs = positional_args_for("generate:model", from_index: 1).map(&:strip).reject(&:empty?)
|
|
107
|
+
next if attrs.empty?
|
|
108
|
+
|
|
109
|
+
migration_name = "create_#{class_name.tableize}"
|
|
110
|
+
migration_class = migration_name.camelize
|
|
111
|
+
timestamp = Time.now.utc.strftime("%Y%m%d%H%M%S")
|
|
112
|
+
migration_path = File.join("db", "migrate", "#{timestamp}_#{migration_name}.rb")
|
|
113
|
+
|
|
114
|
+
columns = attrs.map do |attr|
|
|
115
|
+
column_name, column_type = attr.split(":", 2)
|
|
116
|
+
next if column_name.to_s.strip.empty? || column_type.to_s.strip.empty?
|
|
117
|
+
" t.#{column_type} :#{column_name}"
|
|
118
|
+
end.compact
|
|
119
|
+
|
|
120
|
+
migration_version = "#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"
|
|
121
|
+
FileUtils.mkdir_p(File.dirname(migration_path))
|
|
122
|
+
File.write(migration_path, <<~RUBY)
|
|
123
|
+
class #{migration_class} < ActiveRecord::Migration[#{migration_version}]
|
|
124
|
+
def change
|
|
125
|
+
create_table :#{class_name.tableize} do |t|
|
|
126
|
+
#{columns.join("\n")}
|
|
127
|
+
|
|
128
|
+
t.timestamps
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
RUBY
|
|
120
133
|
|
|
121
|
-
|
|
122
|
-
task :seed do
|
|
123
|
-
require APP_ROOT.join('db', 'seeds.rb')
|
|
134
|
+
puts "Created #{migration_path}"
|
|
124
135
|
end
|
|
125
136
|
|
|
126
|
-
desc "
|
|
127
|
-
task :
|
|
128
|
-
|
|
129
|
-
|
|
137
|
+
desc "Generate a controller + index view Usage: rake generate:controller Users"
|
|
138
|
+
task :controller, [:name] do |_task, args|
|
|
139
|
+
controller_name = args[:name].presence || positional_arg_for("generate:controller")
|
|
140
|
+
controller_name = controller_name.to_s.strip
|
|
141
|
+
abort "Controller name is required. Example: rake generate:controller Users" if controller_name.empty?
|
|
130
142
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
system "rake db:migrate RACK_ENV=test"
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
end
|
|
143
|
+
base_name = controller_name.underscore
|
|
144
|
+
base_name = base_name.delete_suffix("_controller")
|
|
145
|
+
plural_name = base_name.pluralize
|
|
138
146
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
end
|
|
147
|
+
controller_path = File.join("app", "controllers", "#{plural_name}_controller.rb")
|
|
148
|
+
view_dir = File.join("app", "views", plural_name)
|
|
149
|
+
view_path = File.join(view_dir, "index.erb")
|
|
143
150
|
|
|
151
|
+
if File.exist?(controller_path)
|
|
152
|
+
puts "Controller exists: #{controller_path}"
|
|
153
|
+
else
|
|
154
|
+
FileUtils.mkdir_p(File.dirname(controller_path))
|
|
155
|
+
File.write(controller_path, <<~RUBY)
|
|
156
|
+
# frozen_string_literal: true
|
|
144
157
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
#
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
end
|
|
158
|
+
class App < Sinatra::Base
|
|
159
|
+
get "/#{plural_name}" do
|
|
160
|
+
erb :\"#{plural_name}/index\"
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
RUBY
|
|
164
|
+
puts "Created #{controller_path}"
|
|
165
|
+
end
|
|
153
166
|
|
|
154
|
-
|
|
167
|
+
if File.exist?(view_path)
|
|
168
|
+
puts "View exists: #{view_path}"
|
|
169
|
+
else
|
|
170
|
+
FileUtils.mkdir_p(view_dir)
|
|
171
|
+
File.write(view_path, "<h1>#{plural_name.humanize}</h1>\n")
|
|
172
|
+
puts "Created #{view_path}"
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
desc "Generate model + controller Usage: rake generate:resource User name:string"
|
|
177
|
+
task :resource, [:name] do |_task, args|
|
|
178
|
+
resource_name = args[:name].presence || positional_arg_for("generate:resource")
|
|
179
|
+
resource_name = resource_name.to_s.strip
|
|
180
|
+
abort "Resource name is required. Example: rake generate:resource User" if resource_name.empty?
|
|
181
|
+
|
|
182
|
+
attrs = positional_args_for("generate:resource", from_index: 1).map(&:strip).reject(&:empty?)
|
|
183
|
+
original_tasks = Rake.application.top_level_tasks.dup
|
|
184
|
+
Rake.application.instance_variable_set(:@top_level_tasks, ["generate:model", resource_name, *attrs])
|
|
185
|
+
Rake::Task["generate:model"].invoke(resource_name)
|
|
186
|
+
Rake::Task["generate:controller"].invoke(resource_name.pluralize)
|
|
187
|
+
ensure
|
|
188
|
+
Rake.application.instance_variable_set(:@top_level_tasks, original_tasks) if defined?(original_tasks)
|
|
189
|
+
end
|
|
190
|
+
end
|
|
@@ -1,23 +1,15 @@
|
|
|
1
|
-
<!
|
|
1
|
+
<!doctype html>
|
|
2
2
|
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
|
|
16
|
-
<script src="/js/application.js"></script>
|
|
17
|
-
|
|
18
|
-
<title></title>
|
|
19
|
-
</head>
|
|
20
|
-
<body>
|
|
21
|
-
<%= yield %>
|
|
22
|
-
</body>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title><%= @app_name || "Sinatra App" %></title>
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
7
|
+
<link rel="stylesheet" href="/css/application.css">
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<main class="container">
|
|
11
|
+
<%= yield %>
|
|
12
|
+
</main>
|
|
13
|
+
<script src="/js/application.js"></script>
|
|
14
|
+
</body>
|
|
23
15
|
</html>
|
data/templates/app.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "sinatra/base"
|
|
4
|
+
require_relative "config/environment"
|
|
5
|
+
|
|
6
|
+
class App < Sinatra::Base
|
|
7
|
+
configure do
|
|
8
|
+
set :root, APP_ROOT.to_s
|
|
9
|
+
set :public_folder, APP_ROOT.join("public").to_s
|
|
10
|
+
set :views, APP_ROOT.join("app", "views").to_s
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
configure :development do
|
|
14
|
+
register Sinatra::Reloader
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
get "/" do
|
|
18
|
+
@app_name = APP_NAME
|
|
19
|
+
erb :index
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
run! if app_file == $PROGRAM_NAME
|
|
23
|
+
end
|
|
@@ -1,42 +1,32 @@
|
|
|
1
|
-
#
|
|
2
|
-
if Sinatra::Application.development?
|
|
3
|
-
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
|
4
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
#
|
|
9
|
-
# We have to do this in case we have models that inherit from each other.
|
|
10
|
-
# If model Student inherits from model Person and app/models/student.rb is
|
|
11
|
-
# required first, it will throw an error saying "Person" is undefined.
|
|
12
|
-
#
|
|
13
|
-
# With this lazy-loading technique, Ruby will try to load app/models/person.rb
|
|
14
|
-
# the first time it sees "Person" and will only throw an exception if
|
|
15
|
-
# that file doesn't define the Person class.
|
|
16
|
-
#
|
|
17
|
-
# See http://www.rubyinside.com/ruby-techniques-revealed-autoload-1652.html
|
|
18
|
-
Dir[APP_ROOT.join('app', 'models', '*.rb')].each do |model_file|
|
|
19
|
-
filename = File.basename(model_file).gsub('.rb', '')
|
|
20
|
-
autoload ActiveSupport::Inflector.camelize(filename), model_file
|
|
21
|
-
end
|
|
3
|
+
require "logger"
|
|
4
|
+
require "uri"
|
|
22
5
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
db = URI.parse(ENV['DATABASE_URL'] || "postgres://localhost/#{APP_NAME}_#{Sinatra::Application.environment}")
|
|
6
|
+
rack_env = ENV.fetch("RACK_ENV", "development")
|
|
7
|
+
ActiveRecord::Base.logger = Logger.new($stdout) if rack_env == "development"
|
|
26
8
|
|
|
27
|
-
|
|
9
|
+
build_db_config = lambda do |env_name|
|
|
10
|
+
database_url = ENV.fetch("DATABASE_URL", "postgres://localhost/#{APP_NAME}_#{env_name}")
|
|
11
|
+
uri = URI.parse(database_url)
|
|
12
|
+
database_name = uri.path.sub(%r{^/}, "")
|
|
13
|
+
adapter = uri.scheme == "postgres" ? "postgresql" : uri.scheme
|
|
14
|
+
|
|
15
|
+
{
|
|
16
|
+
adapter: adapter,
|
|
17
|
+
host: uri.host,
|
|
18
|
+
port: uri.port,
|
|
19
|
+
username: uri.user,
|
|
20
|
+
password: uri.password,
|
|
21
|
+
database: database_name,
|
|
22
|
+
encoding: "utf8"
|
|
23
|
+
}.compact
|
|
24
|
+
end
|
|
28
25
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
ActiveRecord::Base.configurations = {
|
|
27
|
+
"development" => build_db_config.call("development"),
|
|
28
|
+
"test" => build_db_config.call("test"),
|
|
29
|
+
"production" => build_db_config.call("production")
|
|
30
|
+
}
|
|
33
31
|
|
|
34
|
-
ActiveRecord::Base.establish_connection(
|
|
35
|
-
:adapter => db.scheme == 'postgres' ? 'postgresql' : db.scheme,
|
|
36
|
-
:host => db.host,
|
|
37
|
-
:port => db.port,
|
|
38
|
-
:username => db.user,
|
|
39
|
-
:password => db.password,
|
|
40
|
-
:database => DB_NAME,
|
|
41
|
-
:encoding => 'utf8'
|
|
42
|
-
)
|
|
32
|
+
ActiveRecord::Base.establish_connection(rack_env.to_sym)
|
|
@@ -1,46 +1,19 @@
|
|
|
1
|
-
#
|
|
2
|
-
# See: http://gembundler.com/bundler_setup.html
|
|
3
|
-
# http://stackoverflow.com/questions/7243486/why-do-you-need-require-bundler-setup
|
|
4
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
|
1
|
+
# frozen_string_literal: true
|
|
5
2
|
|
|
6
|
-
|
|
3
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
|
4
|
+
require "bundler/setup"
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
require 'rubygems'
|
|
6
|
+
require "pathname"
|
|
10
7
|
|
|
11
|
-
require
|
|
12
|
-
require
|
|
13
|
-
|
|
14
|
-
require 'pg'
|
|
15
|
-
require 'active_record'
|
|
16
|
-
require 'logger'
|
|
17
|
-
|
|
18
|
-
require 'sinatra'
|
|
19
|
-
require "sinatra/reloader" if development?
|
|
20
|
-
|
|
21
|
-
require 'erb'
|
|
22
|
-
require 'pry-byebug'
|
|
23
|
-
|
|
24
|
-
# Some helper constants for path-centric logic
|
|
25
|
-
APP_ROOT = Pathname.new(File.expand_path('../../', __FILE__))
|
|
8
|
+
require "active_record"
|
|
9
|
+
require "erb"
|
|
10
|
+
require "sinatra/reloader"
|
|
26
11
|
|
|
12
|
+
APP_ROOT = Pathname.new(File.expand_path("..", __dir__))
|
|
27
13
|
APP_NAME = APP_ROOT.basename.to_s
|
|
28
14
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
set :root, APP_ROOT.to_path
|
|
33
|
-
# See: http://www.sinatrarb.com/faq.html#sessions
|
|
34
|
-
enable :sessions
|
|
35
|
-
set :session_secret, ENV['SESSION_SECRET'] || 'this is a secret shhhhh'
|
|
36
|
-
|
|
37
|
-
# Set the views to
|
|
38
|
-
set :views, File.join(Sinatra::Application.root, "app", "views")
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# Set up the controllers and helpers
|
|
42
|
-
Dir[APP_ROOT.join('app', 'controllers', '*.rb')].each { |file| require file }
|
|
43
|
-
Dir[APP_ROOT.join('app', 'helpers', '*.rb')].each { |file| require file }
|
|
15
|
+
Dir[APP_ROOT.join("app", "helpers", "*.rb")].sort.each { |file| require file }
|
|
16
|
+
Dir[APP_ROOT.join("app", "controllers", "*.rb")].sort.each { |file| require file }
|
|
17
|
+
Dir[APP_ROOT.join("app", "models", "*.rb")].sort.each { |file| require file }
|
|
44
18
|
|
|
45
|
-
|
|
46
|
-
require APP_ROOT.join('config', 'database')
|
|
19
|
+
require APP_ROOT.join("config", "database")
|
data/templates/config.ru
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
* {
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
body {
|
|
10
|
+
margin: 0;
|
|
11
|
+
color: #1f2937;
|
|
12
|
+
background: radial-gradient(circle at top, #f8fafc, #eef2ff 50%, #e5e7eb 100%);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.container {
|
|
16
|
+
max-width: 44rem;
|
|
17
|
+
margin: 3rem auto;
|
|
18
|
+
padding: 2.25rem;
|
|
19
|
+
border: 1px solid #d1d5db;
|
|
20
|
+
border-radius: 1rem;
|
|
21
|
+
background: rgba(255, 255, 255, 0.92);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
h1 {
|
|
25
|
+
margin-top: 0;
|
|
26
|
+
}
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// This is called after the document has loaded in its entirety
|
|
3
|
-
// This guarantees that any elements we bind to will exist on the page
|
|
4
|
-
// when we try to bind to them
|
|
5
|
-
|
|
6
|
-
// See: http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
|
|
7
|
-
});
|
|
1
|
+
console.log("Frankly generated app loaded.");
|
metadata
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: frankly
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ken Rettberg
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
13
|
+
name: thor
|
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
|
16
15
|
requirements:
|
|
17
16
|
- - "~>"
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
18
|
version: '1.3'
|
|
20
|
-
type: :
|
|
19
|
+
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
@@ -25,63 +24,64 @@ dependencies:
|
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
25
|
version: '1.3'
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
27
|
+
name: bundler
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
30
29
|
requirements:
|
|
31
|
-
- - "
|
|
30
|
+
- - ">="
|
|
32
31
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
32
|
+
version: '2.4'
|
|
34
33
|
type: :development
|
|
35
34
|
prerelease: false
|
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
36
|
requirements:
|
|
38
|
-
- - "
|
|
37
|
+
- - ">="
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
39
|
+
version: '2.4'
|
|
41
40
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
41
|
+
name: rake
|
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
|
44
43
|
requirements:
|
|
45
|
-
- - "
|
|
44
|
+
- - "~>"
|
|
46
45
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '0'
|
|
46
|
+
version: '13.0'
|
|
48
47
|
type: :development
|
|
49
48
|
prerelease: false
|
|
50
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
50
|
requirements:
|
|
52
|
-
- - "
|
|
51
|
+
- - "~>"
|
|
53
52
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '0'
|
|
53
|
+
version: '13.0'
|
|
55
54
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
55
|
+
name: rspec
|
|
57
56
|
requirement: !ruby/object:Gem::Requirement
|
|
58
57
|
requirements:
|
|
59
58
|
- - "~>"
|
|
60
59
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '3.
|
|
60
|
+
version: '3.13'
|
|
62
61
|
type: :development
|
|
63
62
|
prerelease: false
|
|
64
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
64
|
requirements:
|
|
66
65
|
- - "~>"
|
|
67
66
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '3.
|
|
67
|
+
version: '3.13'
|
|
69
68
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
69
|
+
name: pry-byebug
|
|
71
70
|
requirement: !ruby/object:Gem::Requirement
|
|
72
71
|
requirements:
|
|
73
72
|
- - "~>"
|
|
74
73
|
- !ruby/object:Gem::Version
|
|
75
|
-
version:
|
|
76
|
-
type: :
|
|
74
|
+
version: '3.10'
|
|
75
|
+
type: :development
|
|
77
76
|
prerelease: false
|
|
78
77
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
78
|
requirements:
|
|
80
79
|
- - "~>"
|
|
81
80
|
- !ruby/object:Gem::Version
|
|
82
|
-
version:
|
|
83
|
-
description:
|
|
84
|
-
email:
|
|
81
|
+
version: '3.10'
|
|
82
|
+
description: Generate a modern Sinatra + ActiveRecord starter app with sensible defaults.
|
|
83
|
+
email:
|
|
84
|
+
- kenrettberg@gmail.com
|
|
85
85
|
executables:
|
|
86
86
|
- console
|
|
87
87
|
- frankly
|
|
@@ -104,11 +104,10 @@ files:
|
|
|
104
104
|
- lib/frankly.rb
|
|
105
105
|
- lib/frankly/cli.rb
|
|
106
106
|
- lib/frankly/version.rb
|
|
107
|
-
- spec/frankly_spec.rb
|
|
108
|
-
- spec/spec_helper.rb
|
|
109
107
|
- templates/Gemfile.tt
|
|
110
108
|
- templates/README.md
|
|
111
109
|
- templates/Rakefile
|
|
110
|
+
- templates/app.rb
|
|
112
111
|
- templates/app/.DS_Store
|
|
113
112
|
- templates/app/controllers/.gitkeep
|
|
114
113
|
- templates/app/helpers/.gitkeep
|
|
@@ -116,12 +115,14 @@ files:
|
|
|
116
115
|
- templates/app/models/.gitkeep
|
|
117
116
|
- templates/app/models/README.md
|
|
118
117
|
- templates/app/views/.gitkeep
|
|
118
|
+
- templates/app/views/index.erb
|
|
119
119
|
- templates/app/views/layout.erb
|
|
120
120
|
- templates/config.ru
|
|
121
121
|
- templates/config/database.rb
|
|
122
122
|
- templates/config/environment.rb
|
|
123
123
|
- templates/db/migrate/.gitkeep
|
|
124
124
|
- templates/db/seeds.rb
|
|
125
|
+
- templates/gitignore.tt
|
|
125
126
|
- templates/public/.DS_Store
|
|
126
127
|
- templates/public/css/application.css
|
|
127
128
|
- templates/public/css/normalize.css
|
|
@@ -131,19 +132,9 @@ files:
|
|
|
131
132
|
homepage: https://github.com/kenrett/frankly
|
|
132
133
|
licenses:
|
|
133
134
|
- MIT
|
|
134
|
-
metadata:
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
.
|
|
138
|
-
.---------.'---.
|
|
139
|
-
'. : .'
|
|
140
|
-
'. .::: .' The Chairman
|
|
141
|
-
'.'::'.' of the Board
|
|
142
|
-
'||' has arrived.
|
|
143
|
-
||
|
|
144
|
-
||
|
|
145
|
-
||
|
|
146
|
-
---====---
|
|
135
|
+
metadata:
|
|
136
|
+
homepage_uri: https://github.com/kenrett/frankly
|
|
137
|
+
source_code_uri: https://github.com/kenrett/frankly
|
|
147
138
|
rdoc_options: []
|
|
148
139
|
require_paths:
|
|
149
140
|
- lib
|
|
@@ -151,18 +142,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
151
142
|
requirements:
|
|
152
143
|
- - ">="
|
|
153
144
|
- !ruby/object:Gem::Version
|
|
154
|
-
version: '
|
|
145
|
+
version: '3.1'
|
|
155
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
147
|
requirements:
|
|
157
148
|
- - ">="
|
|
158
149
|
- !ruby/object:Gem::Version
|
|
159
150
|
version: '0'
|
|
160
151
|
requirements: []
|
|
161
|
-
|
|
162
|
-
rubygems_version: 2.7.3
|
|
163
|
-
signing_key:
|
|
152
|
+
rubygems_version: 4.0.7
|
|
164
153
|
specification_version: 4
|
|
165
|
-
summary:
|
|
166
|
-
test_files:
|
|
167
|
-
- spec/frankly_spec.rb
|
|
168
|
-
- spec/spec_helper.rb
|
|
154
|
+
summary: Opinionated Sinatra app skeleton generator
|
|
155
|
+
test_files: []
|
data/spec/frankly_spec.rb
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
require "tmpdir"
|
|
3
|
-
require "logger"
|
|
4
|
-
|
|
5
|
-
describe Frankly do
|
|
6
|
-
it "has a version number" do
|
|
7
|
-
expect(Frankly::VERSION).not_to be nil
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
context "when generating a new skeleton" do
|
|
11
|
-
before(:all) do
|
|
12
|
-
@templates_path = "#{File.dirname(__FILE__)}/../lib/sinatra_generator/templates"
|
|
13
|
-
@tmp_dir = Dir.mktmpdir
|
|
14
|
-
Dir.chdir @tmp_dir
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it "creates a temporary directory" do
|
|
18
|
-
expect(@tmp_dir).to_not be nil
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it "builds a new app" do
|
|
22
|
-
Frankly::CLI.start ["test_app"]
|
|
23
|
-
|
|
24
|
-
expect(File.directory?('test_app')).to be true
|
|
25
|
-
|
|
26
|
-
Dir.chdir 'test_app' do
|
|
27
|
-
expect(File.exist?('config.ru')).to be true
|
|
28
|
-
expect(File.exist?('Gemfile')).to be true
|
|
29
|
-
expect(File.exist?('Rakefile')).to be true
|
|
30
|
-
expect(File.exist?('README.md')).to be true
|
|
31
|
-
expect(File.directory?('app')).to be true
|
|
32
|
-
expect(File.directory?('config')).to be true
|
|
33
|
-
expect(File.directory?('db')).to be true
|
|
34
|
-
expect(File.directory?('public')).to be true
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
after(:all) do
|
|
39
|
-
Dir.chdir('..')
|
|
40
|
-
FileUtils.rm_rf @tmp_dir
|
|
41
|
-
expect(File.directory?(@tmp_dir)).to be false
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
data/spec/spec_helper.rb
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
|
2
|
-
require "frankly"
|
|
3
|
-
require "pry-byebug"
|
|
4
|
-
|
|
5
|
-
#### TODO Figure out how to silence the rubygems (Or prevent it from
|
|
6
|
-
# bundling at all) The solution below only silence the generating
|
|
7
|
-
# files part
|
|
8
|
-
#
|
|
9
|
-
# Borrowed from https://gist.github.com/adamstegman/926858
|
|
10
|
-
#
|
|
11
|
-
# RSpec.configure do |config|
|
|
12
|
-
# config.before(:all) { silence_output }
|
|
13
|
-
# config.after(:all) { enable_output }
|
|
14
|
-
# end
|
|
15
|
-
#
|
|
16
|
-
# # Redirects stderr and stdout to /dev/null.
|
|
17
|
-
# def silence_output
|
|
18
|
-
# @orig_stderr = $stderr
|
|
19
|
-
# @orig_stdout = $stdout
|
|
20
|
-
#
|
|
21
|
-
# # redirect stderr and stdout to /dev/null
|
|
22
|
-
# $stderr = File.new('/dev/null', 'w')
|
|
23
|
-
# $stdout = File.new('/dev/null', 'w')
|
|
24
|
-
# end
|
|
25
|
-
#
|
|
26
|
-
# # Replace stdout and stderr so anything else is output correctly.
|
|
27
|
-
# def enable_output
|
|
28
|
-
# $stderr = @orig_stderr
|
|
29
|
-
# $stdout = @orig_stdout
|
|
30
|
-
# @orig_stderr = nil
|
|
31
|
-
# @orig_stdout = nil
|
|
32
|
-
# end
|