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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f8bd4c6d54dc267c2c76c3acda425e4d9e43e7278cdacd11e35c379723a0ce2
4
- data.tar.gz: 9a214222eda89b2edd17e1650a1b2213fba965a337cc2fa09e7991250d5afa2b
3
+ metadata.gz: 256f2dbb88d9b111151d44696cb90572e4038079e48636bac595b987ba9cd6d5
4
+ data.tar.gz: 6b4901cee23b0c43d7ff1d7e7f719f6b38f71a1e000dce72ea4cec06429b2d8f
5
5
  SHA512:
6
- metadata.gz: d9a73f8401b3064f1d5be7cbb23f6d006e1691e177aca6af482325beaaacdc9c0802dce722d32ba9a6d8083d448a3c114c8821a23c54703b407be9929f42753d
7
- data.tar.gz: ed096de42c3d010a099dfd636897c313d4d47624a93a0549f9c3296dd6a393ee338b4c8963e4c06b63c4afe824251918fd83326179db9ba48b311c4109119d96
6
+ metadata.gz: 4d3fad1677f0a62c1d0405c92dcc95823413aa5ccbc77c4bac20e21a8feca788bc8c124705720fa8139ebf453eac7482ed82bae79a0278fd01f74262afb5172f
7
+ data.tar.gz: 26cb2665936482d1aef4088ef689344baa4b1f7ef3818da98fa2cd2f2d1e98ba4144d92c5fc3c6187e24c39257cd0ffec938cec9d7b96570010cbf53a59d54d8
data/README.md CHANGED
@@ -1,35 +1,69 @@
1
1
  # Frankly
2
- ![Build Status](https://travis-ci.org/kenrett/frankly.svg?branch=master)
3
2
 
4
- An opinionated sinatra app skeleton generator with Rake tasks, rspec, postgres, pry and more!
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
- Type this into the command line:
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
- gem install frankly
26
+
27
+ ### Options
28
+
29
+ ```sh
30
+ frankly my_app --bundle
31
+ frankly my_app --skip-git
12
32
  ```
13
33
 
14
- ## Dependency
34
+ - `--bundle`: runs `bundle install` in the generated app
35
+ - `--skip-git`: skips `git init`
15
36
 
16
- Frankly is dependent on using postgres as your database. If you don't have it installed, please check out this great blogpost for [OSX](https://launchschool.com/blog/how-to-install-postgresql-on-a-mac) or [Linux](https://launchschool.com/blog/how-to-install-postgres-for-linux) from [LaunchSchool](https://launchschool.com/) on how to get set up!
37
+ ## Generated app quickstart
17
38
 
18
- ## Usage
39
+ ```sh
40
+ cd my_app
41
+ bundle install
42
+ bundle exec rackup
43
+ ```
19
44
 
20
- Simple type `frankly APP_NAME` and frankly will create a sinatra scaffold, git init, and bundle your application. Currently frankly does not support special characters or numbers in an `APP_NAME` but please feel free to make a Pull Request if you would like to contribute!
45
+ Open http://localhost:9292.
21
46
 
22
- ## Development
47
+ ## Development (this gem)
23
48
 
24
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
49
+ ```sh
50
+ bin/setup
51
+ bundle exec rspec
52
+ ```
25
53
 
26
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
54
+ ## Release
27
55
 
28
- ## Contributing
56
+ ```sh
57
+ bundle exec rake build
58
+ bundle exec rake install
59
+ bundle exec rake release
60
+ ```
29
61
 
30
- Bug reports and pull requests are welcome on GitHub at https://github.com/kenrett/frankly. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
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
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
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
- require "frankly"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
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
- lib = File.expand_path('../lib', __FILE__)
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 'frankly/version'
5
+ require "frankly/version"
4
6
 
5
7
  Gem::Specification.new do |spec|
6
- spec.name = "frankly"
7
- spec.version = Frankly::VERSION
8
- spec.authors = ["Ken Rettberg"]
9
- spec.email = %q{kenrettberg@gmail.com}
10
- spec.description = %q{Setup a sinatra skeleton like a boss!}
11
- spec.summary = %q{An opinionated sinatra skeleton with Rake tasks, rspec, postgres, and more!}
12
- spec.files = `git ls-files`.split($/)
13
- spec.homepage = %q{https://github.com/kenrett/frankly}
14
- spec.rubygems_version = %q{1.6.2}
15
- spec.license = "MIT"
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.post_install_message = <<-PIC
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = spec.homepage
21
21
 
22
- .
23
- .---------.'---.
24
- '. : .'
25
- '. .::: .' The Chairman
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
- spec.add_development_dependency "bundler", "~> 1.3"
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
- spec.add_runtime_dependency 'thor', '~> 0.19.1'
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
- require 'pathname'
2
- require 'fileutils'
3
- require 'thor'
4
- require 'thor/group'
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('../../../templates', __FILE__)
19
+ File.expand_path("../../templates", __dir__)
12
20
  end
13
21
 
14
- desc "Creates a new Sinatra application"
15
- argument :name, :type => :string, :desc => "The name of the new application"
22
+ def self.exit_on_failure?
23
+ true
24
+ end
16
25
 
17
26
  def setup
18
- @app_path = name.downcase.gsub(/[^a-z|\-|\_]/, '')
27
+ @app_path = sanitized_app_path
19
28
  end
20
29
 
21
30
  def create_app_scaffold
22
- empty_directory "#{@app_path}/app"
23
- create_file "#{@app_path}/app/models/.gitkeep"
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}/config/.gitkeep"
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
- copy_file "Gemfile", "#{@app_path}/Gemfile"
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
- puts "about to run git init"
50
- inside(@app_path) do
51
- run('git init .')
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
- puts "installing dependencies"
57
- inside(@app_path) do
58
- run('bundle')
59
- end
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 __FILE__ == $0
65
- cli = Frankly::CLI.start
66
- end
84
+ Frankly::CLI.start if $PROGRAM_NAME == __FILE__
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Frankly
2
- VERSION = "0.1.6"
4
+ VERSION = "0.2.1"
3
5
  end
data/templates/Gemfile.tt CHANGED
@@ -1,28 +1,23 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
- # PostgreSQL driver
4
- gem 'pg'
3
+ ruby ">= 3.1"
5
4
 
6
- # Sinatra driver
7
- gem 'sinatra', '~> 1.0'
8
- gem 'sinatra-contrib'
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
- gem 'activesupport', '~>5.2'
11
- gem 'activerecord', '~>5.2'
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, :development do
25
- gem 'factory_girl'
26
- gem 'faker'
27
- gem 'pry-byebug'
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
- > **Note**: This branch (master) contains a skeleton without any app code, perfect for creating a _new_ application or challenge. If you're looking for an example app built with this skeleton, take a look at the [example](/../..//tree/example) branch which includes basic CRUD and RSpec tests.
1
+ # Sinatra App
2
2
 
3
- ### Purpose
4
- The Sinatra Skeleton:
3
+ Generated by `frankly`.
5
4
 
6
- 1. Provides a foundation for building challenges or creating a new Sinatra application.
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
- ### Quickstart
7
+ - Ruby 3.1+
8
+ - PostgreSQL
9
+ - Bundler
11
10
 
12
- 1. `bundle install`
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
- rake generate:migration # Create an empty migration in db/migrate, e.g., rake generate:migration NAME=create_tasks
19
- rake generate:model # Create an empty model in app/models, e.g., rake generate:model NAME=User
17
+
18
+ Open http://localhost:9292.
19
+
20
+ ## Development reload
21
+
22
+ ```sh
23
+ bundle exec rerun -- rackup
20
24
  ```
21
25
 
22
- ### Contributing
26
+ ## Database
27
+
28
+ The template uses PostgreSQL via ActiveRecord.
23
29
 
24
- We would love for you to help make the skeleton more awesome, There are three ways to contribute:
30
+ Environment variables:
25
31
 
26
- 1. Ask for a bug fix or enhancement!
27
- 2. Submit a pull request for a bug fix or enhancement!
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
- Be prepared to give and receive specific, actionable, and kind feedback!
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
- require 'rake'
1
+ # frozen_string_literal: true
2
2
 
3
- require ::File.expand_path('../config/environment', __FILE__)
3
+ require "bundler/setup"
4
+ require "fileutils"
5
+ require "active_support/inflector"
4
6
 
5
- # Include all of ActiveSupport's core class extensions, e.g., String#camelize
6
- require 'active_support/core_ext'
7
+ unless defined?(Rails)
8
+ module Rails
9
+ class AppConfig
10
+ def load_database_yaml
11
+ {}
12
+ end
7
13
 
8
- namespace :generate do
9
- desc "Create an empty model in app/models, e.g., rake generate:model NAME=User"
10
- task :model do
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
- model_name = ENV['NAME'].camelize
16
- model_filename = ENV['NAME'].underscore + '.rb'
17
- model_path = APP_ROOT.join('app', 'models', model_filename)
19
+ class AppShim
20
+ def config
21
+ @config ||= AppConfig.new
22
+ end
18
23
 
19
- if File.exist?(model_path)
20
- raise "ERROR: Model file '#{model_path}' already exists"
21
- end
24
+ def paths
25
+ { "db/migrate" => ["db/migrate"] }
26
+ end
22
27
 
23
- puts "Creating #{model_path}"
24
- File.open(model_path, 'w+') do |f|
25
- f.write(<<-EOF.strip_heredoc)
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
- desc "Create an empty migration in db/migrate, e.g., rake generate:migration NAME=create_tasks"
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
- name = ENV['NAME'].camelize
40
- filename = "%s_%s.rb" % [Time.now.strftime('%Y%m%d%H%M%S'), ENV['NAME'].underscore]
41
- path = APP_ROOT.join('db', 'migrate', filename)
35
+ def env
36
+ ENV.fetch("RACK_ENV", "development")
37
+ end
42
38
 
43
- if File.exist?(path)
44
- raise "ERROR: File '#{path}' already exists"
39
+ def application
40
+ @application ||= AppShim.new
45
41
  end
46
42
 
47
- puts "Creating #{path}"
48
- File.open(path, 'w+') do |f|
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
- desc "Create an empty model spec in spec, e.g., rake generate:spec NAME=user"
59
- task :spec do
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
- name = ENV['NAME'].camelize
65
- filename = "%s_spec.rb" % ENV['NAME'].underscore
66
- path = APP_ROOT.join('spec', filename)
52
+ begin
53
+ require "rspec/core/rake_task"
54
+ RSpec::Core::RakeTask.new(:spec)
55
+ rescue LoadError
56
+ end
67
57
 
68
- if File.exist?(path)
69
- raise "ERROR: File '#{path}' already exists"
70
- end
58
+ task default: :spec
71
59
 
72
- puts "Creating #{path}"
73
- File.open(path, 'w+') do |f|
74
- f.write(<<-EOF.strip_heredoc)
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
- namespace :db do
86
- desc "Drop, create, and migrate the database"
87
- task :reset => [:drop, :create, :migrate]
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
- desc "Create the databases at #{DB_NAME}"
90
- task :create do
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
- desc "Drop the database at #{DB_NAME}"
96
- task :drop do
97
- puts "Dropping development and test databases..."
98
- system("dropdb #{APP_NAME}_development && dropdb #{APP_NAME}_test")
99
- end
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
- desc "Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)."
102
- task :migrate do
103
- ActiveRecord::Migrator.migrations_paths << File.dirname(__FILE__) + 'db/migrate'
104
- ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
105
- if ActiveRecord.version.release() < Gem::Version.new('5.2.0')
106
- ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_paths, ENV["VERSION"] ? ENV["VERSION"].to_i : nil) do |migration|
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
- ActiveRecord::MigrationContext.new(ActiveRecord::Migrator.migrations_paths).migrate
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
- desc "rollback your migration--use STEP=number to step back multiple times"
115
- task :rollback do
116
- step = (ENV['STEP'] || 1).to_i
117
- ActiveRecord::Migrator.rollback('db/migrate', step)
118
- Rake::Task['db:version'].invoke if Rake::Task['db:version']
119
- end
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
- desc "Populate the database with dummy data by running db/seeds.rb"
122
- task :seed do
123
- require APP_ROOT.join('db', 'seeds.rb')
134
+ puts "Created #{migration_path}"
124
135
  end
125
136
 
126
- desc "Returns the current schema version number"
127
- task :version do
128
- puts "Current version: #{ActiveRecord::Migrator.current_version}"
129
- end
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
- namespace :test do
132
- desc "Migrate test database"
133
- task :prepare do
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
- desc 'Start PRY with application environment loaded'
140
- task "console" do
141
- exec "pry -r./config/environment"
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
- # In a production environment like Heroku, RSpec might not
146
- # be available. To handle this, rescue the LoadError.
147
- # https://devcenter.heroku.com/articles/getting-started-with-ruby-o#runtime-dependencies-on-development-test-gems
148
- begin
149
- require 'rspec/core/rake_task'
150
- RSpec::Core::RakeTask.new(:spec)
151
- rescue LoadError
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
- task :default => :spec
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
@@ -0,0 +1,2 @@
1
+ <h1>Frankly, it works.</h1>
2
+ <p>Your Sinatra app "<strong><%= @app_name %></strong>" is up and running.</p>
@@ -1,23 +1,15 @@
1
- <!DOCTYPE html>
1
+ <!doctype html>
2
2
  <html lang="en">
3
- <head>
4
- <!--
5
- normalize.css removes cross-browser differences in defaults, e.g.,
6
- differences in how form elements appear between Firefox and IE
7
- See: http://necolas.github.com/normalize.css/
8
- -->
9
- <link rel="stylesheet" href="/css/normalize.css">
10
- <!--
11
- application.css is where you put your styles
12
- -->
13
- <link rel="stylesheet" href="/css/application.css">
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
- # Log queries to STDOUT in development
2
- if Sinatra::Application.development?
3
- ActiveRecord::Base.logger = Logger.new(STDOUT)
4
- end
1
+ # frozen_string_literal: true
5
2
 
6
- # Automatically load every file in APP_ROOT/app/models/*.rb, e.g.,
7
- # autoload "Person", 'app/models/person.rb'
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
- # Heroku controls what database we connect to by setting the DATABASE_URL environment variable
24
- # We need to respect that if we want our Sinatra apps to run on Heroku without modification
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
- DB_NAME = db.path[1..-1]
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
- # Note:
30
- # Sinatra::Application.environment is set to the value of ENV['RACK_ENV']
31
- # if ENV['RACK_ENV'] is set. If ENV['RACK_ENV'] is not set, it defaults
32
- # to :development
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
- # Set up gems listed in the Gemfile.
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
- require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
3
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
4
+ require "bundler/setup"
7
5
 
8
- # Require gems we care about
9
- require 'rubygems'
6
+ require "pathname"
10
7
 
11
- require 'uri'
12
- require 'pathname'
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
- configure do
30
- # By default, Sinatra assumes that the root is the file that calls the configure block.
31
- # Since this is not the case for us, we set it manually.
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
- # Set up the database and models
46
- require APP_ROOT.join('config', 'database')
19
+ require APP_ROOT.join("config", "database")
data/templates/config.ru CHANGED
@@ -1,6 +1,5 @@
1
- # Require config/environment.rb
2
- require ::File.expand_path('../config/environment', __FILE__)
1
+ # frozen_string_literal: true
3
2
 
4
- set :app_file, __FILE__
3
+ require_relative "app"
5
4
 
6
- run Sinatra::Application
5
+ run App
@@ -0,0 +1,7 @@
1
+ .bundle/
2
+ .env
3
+ *.log
4
+ db/*.sqlite3
5
+ db/*.sqlite3-journal
6
+ tmp/
7
+ vendor/bundle/
@@ -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
- $(document).ready(function() {
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.6
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: 2019-02-19 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
- name: bundler
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: :development
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: rake
27
+ name: bundler
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
- - - "~>"
30
+ - - ">="
32
31
  - !ruby/object:Gem::Version
33
- version: '10.0'
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: '10.0'
39
+ version: '2.4'
41
40
  - !ruby/object:Gem::Dependency
42
- name: rspec
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: pry-byebug
55
+ name: rspec
57
56
  requirement: !ruby/object:Gem::Requirement
58
57
  requirements:
59
58
  - - "~>"
60
59
  - !ruby/object:Gem::Version
61
- version: '3.4'
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.4'
67
+ version: '3.13'
69
68
  - !ruby/object:Gem::Dependency
70
- name: thor
69
+ name: pry-byebug
71
70
  requirement: !ruby/object:Gem::Requirement
72
71
  requirements:
73
72
  - - "~>"
74
73
  - !ruby/object:Gem::Version
75
- version: 0.19.1
76
- type: :runtime
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: 0.19.1
83
- description: Setup a sinatra skeleton like a boss!
84
- email: kenrettberg@gmail.com
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
- post_install_message: |2
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: '0'
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
- rubyforge_project:
162
- rubygems_version: 2.7.3
163
- signing_key:
152
+ rubygems_version: 4.0.7
164
153
  specification_version: 4
165
- summary: An opinionated sinatra skeleton with Rake tasks, rspec, postgres, and more!
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