hoboken 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +33 -0
  3. data/.github/ISSUE_TEMPLATE/code_change.md +11 -0
  4. data/.github/PULL_REQUEST_TEMPLATE.md +25 -0
  5. data/.gitignore +3 -0
  6. data/.rubocop.yml +13 -5
  7. data/.tool-versions +1 -0
  8. data/CHANGELOG.md +131 -0
  9. data/CODE_OF_CONDUCT.md +8 -0
  10. data/CONTRIBUTING.md +16 -0
  11. data/README.md +10 -14
  12. data/Rakefile +7 -16
  13. data/hoboken.gemspec +18 -8
  14. data/lib/hoboken/add_ons/active_record.rb +142 -0
  15. data/lib/hoboken/add_ons/airbrake.rb +64 -0
  16. data/lib/hoboken/add_ons/heroku.rb +5 -1
  17. data/lib/hoboken/add_ons/internationalization.rb +2 -2
  18. data/lib/hoboken/add_ons/metrics.rb +3 -2
  19. data/lib/hoboken/add_ons/omniauth.rb +9 -8
  20. data/lib/hoboken/add_ons/rubocop.rb +10 -4
  21. data/lib/hoboken/add_ons/sequel.rb +55 -29
  22. data/lib/hoboken/add_ons/sidekiq.rb +137 -0
  23. data/lib/hoboken/add_ons/turnip.rb +109 -0
  24. data/lib/hoboken/add_ons/twbs.rb +5 -35
  25. data/lib/hoboken/add_ons/vcr.rb +54 -0
  26. data/lib/hoboken/generate.rb +18 -10
  27. data/lib/hoboken/templates/Gemfile.erb.tt +13 -3
  28. data/lib/hoboken/templates/README.md.tt +18 -6
  29. data/lib/hoboken/templates/Rakefile.tt +11 -0
  30. data/lib/hoboken/templates/active_record.rake +11 -0
  31. data/lib/hoboken/templates/airbrake.rb.tt +13 -0
  32. data/lib/hoboken/templates/classic.rb.tt +6 -20
  33. data/lib/hoboken/templates/classic_environment.rb.tt +51 -0
  34. data/lib/hoboken/templates/config.ru.tt +2 -4
  35. data/lib/hoboken/templates/console +19 -0
  36. data/lib/hoboken/templates/example_worker.rb.tt +14 -0
  37. data/lib/hoboken/templates/metrics.rake.tt +3 -1
  38. data/lib/hoboken/templates/modular.rb.tt +8 -25
  39. data/lib/hoboken/templates/modular_environment.rb.tt +62 -0
  40. data/lib/hoboken/templates/rspec.rake.tt +7 -3
  41. data/lib/hoboken/templates/rubocop.yml.tt +23 -3
  42. data/lib/hoboken/templates/seeds.rb +12 -0
  43. data/lib/hoboken/templates/server +15 -0
  44. data/lib/hoboken/templates/setup +28 -0
  45. data/lib/hoboken/templates/sidekiq.rb.tt +21 -0
  46. data/lib/hoboken/templates/spec/app_spec.rb.tt +0 -2
  47. data/lib/hoboken/templates/spec/example_worker_spec.rb.tt +16 -0
  48. data/lib/hoboken/templates/spec/rack_matchers.rb.tt +8 -6
  49. data/lib/hoboken/templates/spec/spec_helper.rb.tt +2 -6
  50. data/lib/hoboken/templates/spec/turnip_helper.rb.tt +10 -0
  51. data/lib/hoboken/templates/styles.css.tt +1 -1
  52. data/lib/hoboken/templates/support/rack_test_assertions.rb.tt +5 -3
  53. data/lib/hoboken/templates/test/test_helper.rb.tt +2 -5
  54. data/lib/hoboken/templates/test/unit/example_worker_test.rb.tt +20 -0
  55. data/lib/hoboken/templates/vcr_setup.rb.tt +15 -0
  56. data/lib/hoboken/templates/views/index.erb.tt +1 -1
  57. data/lib/hoboken/templates/views/layout.erb.tt +3 -3
  58. data/lib/hoboken/version.rb +1 -1
  59. data/lib/hoboken.rb +54 -10
  60. data/test/integration/active_record_test.rb +66 -0
  61. data/test/integration/airbrake_test.rb +31 -0
  62. data/test/integration/generate_classic_test.rb +75 -0
  63. data/test/integration/generate_modular_test.rb +83 -0
  64. data/test/integration/github_action_test.rb +13 -0
  65. data/test/integration/heroku_test.rb +14 -0
  66. data/test/integration/internationalization_test.rb +26 -0
  67. data/test/integration/metrics_test.rb +54 -0
  68. data/test/integration/omniauth_test.rb +143 -0
  69. data/test/integration/rubocop_test.rb +39 -0
  70. data/test/integration/sequel_test.rb +64 -0
  71. data/test/integration/sidekiq_test.rb +105 -0
  72. data/test/integration/travis_test.rb +13 -0
  73. data/test/integration/turnip_test.rb +51 -0
  74. data/test/integration/twitter_bootstrap_test.rb +39 -0
  75. data/test/integration/vcr_test.rb +54 -0
  76. data/test/test_helper.rb +21 -10
  77. data/www/Gemfile +4 -0
  78. data/www/README.md +2 -0
  79. data/www/config.rb +11 -0
  80. data/www/source/documentation.html.erb +274 -0
  81. data/www/source/images/hoboken-running.png +0 -0
  82. data/www/source/images/hoboken.png +0 -0
  83. data/www/source/images/sinatra.png +0 -0
  84. data/www/source/index.html.erb +44 -0
  85. data/www/source/javascripts/all.js +1 -0
  86. data/www/source/layouts/layout.erb +38 -0
  87. data/www/source/stylesheets/all.css.scss +116 -0
  88. data/www/source/stylesheets/normalize.css +375 -0
  89. metadata +230 -44
  90. data/lib/hoboken/add_ons/sprockets.rb +0 -99
  91. data/lib/hoboken/templates/console.sh +0 -5
  92. data/lib/hoboken/templates/server.sh +0 -12
  93. data/lib/hoboken/templates/setup.sh +0 -7
  94. data/lib/hoboken/templates/sprockets.rake +0 -39
  95. data/lib/hoboken/templates/sprockets_chain.rb +0 -30
  96. data/lib/hoboken/templates/sprockets_helper.rb +0 -17
  97. data/test/integration/add_on_test.rb +0 -505
  98. data/test/integration/generate_test.rb +0 -203
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d42754fed3189d3de171e54745f49f492b0ff0581aafa53493f0d7f15efbb8b0
4
- data.tar.gz: 1cd847b097a929db83a36932d959b2b8d0d94273b408231f06f47c6ae6c6e13d
3
+ metadata.gz: 2fcb30215523759b04d0249c6ced1c702ece948178682820867f7fb9bc8a84cd
4
+ data.tar.gz: 80e5100fc0a2e7aa1fd319b7fc6b1555633ab936b1fa487845a5010dcf149153
5
5
  SHA512:
6
- metadata.gz: 501df84e547ff6ace6e5b987f8f8723f349767647b9fdb532a949b6c8fe65b72502b349309948f7a8a92d09c9091c89b5f05745d288d363893c6fe5647930f4a
7
- data.tar.gz: 168647168f6a62fdc1410d63994de32706710eff8017a91bedd31ce961ac6d2379d9494671d0d6154d1ff7a113140ec21b477eb809215bbed9b90e4b84366177
6
+ metadata.gz: 4752cce9842dcedc3f9163c11d0470fb9ce21a049a08b3086a7955c492503dc573a97f6bdf548a9532b9853721ee5e079a0ebb0e49fe6e5b90121a7efa3b24d5
7
+ data.tar.gz: 8b186dbe7ee60e1a50445fa787abe02333eb23960034685b394a14d46014a946f1f0de9122169fb1e9fec750b68c451d98ea3b10db8d7b745473521faa37afdb
@@ -0,0 +1,33 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: bug?
6
+ assignees: bnadlerjr
7
+
8
+ ---
9
+
10
+ <!--- The GitHub Issue tracker is **ONLY** used for reporting bugs and tracking code changes. Please use StackOverflow or GitHub Discussions for questions or support issues. New features should be discussed on GitHub Discussions **before** creating an issue. For a roadmap of upcoming features, check the GitHub Projects page. --->
11
+
12
+ <!--- Make sure to add **all the information needed to understand the bug** so that someone can help. If the info is missing we'll add the 'Needs more information' label and close the issue until there is enough information. --->
13
+
14
+ **Describe the bug**
15
+ <!--- A clear and concise description of what the bug is. --->
16
+
17
+ **To Reproduce**
18
+ <!--- Provide a link to a live example, or an unambiguous set of steps to reproduce this bug. Include code to reproduce, if relevant. --->
19
+
20
+ **Expected behavior**
21
+ <!--- A clear and concise description of what you expected to happen. --->
22
+
23
+ **Screenshots**
24
+ <!--- If applicable, add screenshots to help explain your problem. --->
25
+
26
+ **Environment (please complete the following information):**
27
+ - Hoboken Version: [e.g. 0.8.0]
28
+ - Ruby Version: [e.g. 2.7]
29
+ - OS and Version: [e.g. macOS Big Sur, Windows 10]
30
+ - Browser and Version (if applicable): [e.g. chrome, safari]
31
+
32
+ **Additional context**
33
+ <!--- Add any other context about the problem here. --->
@@ -0,0 +1,11 @@
1
+ ---
2
+ name: Code change
3
+ about: Feature work, refactoring or any other code changes
4
+ title: ''
5
+ assignees: bnadlerjr
6
+
7
+ ---
8
+
9
+ <!--- The GitHub Issue tracker is **ONLY** used for reporting bugs and tracking code changes. Please use StackOverflow or GitHub Discussions for questions or support issues. New features should be discussed on GitHub Discussions **before** creating an issue. For a roadmap of upcoming features, check the GitHub Projects page. --->
10
+
11
+ <!--- Describe the requested code change. --->
@@ -0,0 +1,25 @@
1
+ **Description**
2
+ <!--- Describe your changes. Why is this change required? What problem does it solve? Does this PR introduce a breaking change to the public API? --->
3
+
4
+ **Related Issue**
5
+ <!--- Link to related issue --->
6
+
7
+ **Screenshots**
8
+ <!--- Optional screenshots --->
9
+
10
+ **Type of Change**
11
+ <!--- Place an `x` in each box that applies: --->
12
+ [ ] Bug fix (non-breaking change which fixes an issue)
13
+ [ ] New feature (non-breaking change which adds functionality)
14
+ [ ] Code change (non-breaking change which changes existing non-public API)
15
+ [ ] Breaking change (fix or feature that would cause existing functionality to change)
16
+
17
+ **Checklist**
18
+ <!--- Place an `x` in each box if you have performed the indicated task. --->
19
+ [ ] I have followed the guidelines in the `CONTRIBUTING.md` document.
20
+ [ ] I have ensured that my code follows the code style of this project.
21
+ [ ] I have checked to ensure there aren't other open [Pull Requests](../../../pulls) for the same update / change.
22
+ [ ] I have checked that the CI build passes all tests and linters.
23
+ [ ] I have added tests to cover my changes.
24
+ [ ] I have made any necessary changes to the documentation.
25
+ [ ] I have updated the `Unreleased` section of the `CHANGELOG.md` with a brief description of my change along with my GitHub username.
data/.gitignore CHANGED
@@ -3,6 +3,9 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
+ /www/.cache
7
+ /www/.sass-cache
8
+ /www/build
6
9
  Gemfile.lock
7
10
  InstalledFiles
8
11
  _yardoc
data/.rubocop.yml CHANGED
@@ -1,5 +1,6 @@
1
1
  require:
2
2
  - rubocop-rake
3
+ - rubocop-performance
3
4
  - rubocop-rspec # for generated projects
4
5
 
5
6
  AllCops:
@@ -7,24 +8,31 @@ AllCops:
7
8
  - 'test/tmp/*/sample/Gemfile'
8
9
  - 'test/fixtures/**/*'
9
10
  - 'vendor/bundle/**/*'
11
+ - 'www/**/*'
10
12
  NewCops: enable
11
13
  TargetRubyVersion: 2.6
12
14
 
13
- Metrics/BlockLength:
14
- IgnoredMethods:
15
- - run_hoboken
15
+ Layout/LineLength:
16
+ Max: 90
16
17
 
17
18
  Layout/SpaceAroundEqualsInParameterDefault:
18
19
  EnforcedStyle: no_space
19
20
 
21
+ Metrics/BlockLength:
22
+ IgnoredMethods:
23
+ - run_hoboken
24
+
20
25
  Metrics/ClassLength:
21
26
  Max: 150
22
27
 
23
28
  Metrics/MethodLength:
24
29
  Max: 15
25
30
 
26
- Layout/LineLength:
27
- Max: 90
31
+ RSpec/DescribeClass:
32
+ Enabled: false
33
+
34
+ RSpec/MultipleDescribes:
35
+ Enabled: false
28
36
 
29
37
  Style/BlockDelimiters:
30
38
  EnforcedStyle: braces_for_chaining
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 2.7.3
data/CHANGELOG.md ADDED
@@ -0,0 +1,131 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+ ### Added
9
+ ### Changed
10
+ ### Removed
11
+ ### Fixed
12
+
13
+ ## [0.10.0] - 2022-01-17
14
+ ### Added
15
+ * Add-on for Sidekiq.
16
+
17
+ * Add-on for Turnip.
18
+
19
+ * Add-on for VCR.
20
+
21
+ * Add-on for Airbrake.
22
+
23
+ * Add-on for `sinatra-activerecord`.
24
+
25
+ * Sinatra configuration block for test environment.
26
+
27
+ * More response codes for RSpec matchers / test unit assertions.
28
+
29
+ ### Changed
30
+ * Define `SESSION_SECRET` in `.env` file so that it is defined only once and
31
+ can be re-used by other things (like the Sidekiq UI).
32
+
33
+ * Switch `bin` scripts from bash to Ruby for consistency. Also fixes foreman
34
+ errors w/ rerun gem by installing them separately from the bundle.
35
+
36
+ * Force https in production.
37
+
38
+ * Switch to `sinatra-asset-pipeline`. Remove Sprockets add-on. All non-API
39
+ generated projects use `sinatra-asset-pipeline`.
40
+
41
+ * Various generated `README` improvements.
42
+
43
+ * `--api-only` apps don't get CSRF or cookie support.
44
+
45
+ * Sequel add-on now installs `rubocop-sequel` if Rubocop is detected.
46
+
47
+ * Simplecov from metrics add-on ignores `db/migrate` directory.
48
+
49
+ * RSpec and Rubocop Rake tasks are not loaded in production.
50
+
51
+ * Don't require a CSRF token when running in a test environment.
52
+
53
+ * Allow Rake in all environments.
54
+
55
+ * Enable performance plugin for Rubocop add-on by default.
56
+
57
+ * Database rollbacks now occur for all Rack-enabled test unit tests. For RSpec
58
+ specs, they are enabled for all specs.
59
+
60
+ ### Fixed
61
+ * Set proper application root for BetterErrors gem.
62
+
63
+ * CI task for RSpec projects.
64
+
65
+ * Rerun install in `setup` script needs `fs-event` gem.
66
+
67
+ ## [0.9.0] - 2021-05-06
68
+ ### Added
69
+ * `--api-only` option for core generator.
70
+
71
+ * Add-on for Twitter Bootstrap.
72
+
73
+ * Add-on for GitHub Action.
74
+
75
+ * Add-on for Rubocop.
76
+
77
+ * Added `pry-byebug` gem as part of the core generator.
78
+
79
+ * RSpec support. Add RSpec as an available `--test-framework` option.
80
+
81
+ * Console support via the `racksh` gem along with a Rake task for starting the
82
+ console.
83
+
84
+ * BetterErrors gem as part of the core generator.
85
+
86
+ * `sinatra-flash` for all non-API projects.
87
+
88
+ * Rakefile gets a `ci` task that runs the installed test runner. If the Rubocop
89
+ add-on is also detected, Rubocop will run after the tests.
90
+
91
+ ### Changed
92
+ * Switch to Puma as default server instead of Thin. Add an explicit Puma
93
+ config (`config/puma.rb`).
94
+
95
+ * Switched from sinatra-reloader to [rerun](https://github.com/alexch/rerun).
96
+
97
+ * Update all dependencies.
98
+
99
+ * Silence warnings from transitive gem dependencies in test output.
100
+
101
+ * Move generated Sequel DB setup out of `config.ru` and into its own
102
+ file (`config/db.rb`).
103
+
104
+ * Dev server updates: always include a Procfile; create scripts for `setup`,
105
+ `console`, `server`; server script uses foreman if it's available,
106
+ otherwise rackup; remove Rake tasks for console, server.
107
+
108
+ * Use `sinatra-json` gem from `sinatra-contrib` instead of default JSON gem.
109
+
110
+ * Switch default templates to Erubi; escape HTML by default.
111
+
112
+ * Switch to `test-unit` gem.
113
+
114
+ * Generated `README` overhaul. Show environment variables in a table, bullet
115
+ points showing default options and libraries installed, table of contents,
116
+ etc.
117
+
118
+ ### Fixed
119
+ * Don't attempt to add metrics snippets to non-existent files.
120
+
121
+ * `assert_redirected_to helper` argument.
122
+
123
+ * Hardcoded Omniauth route in generated tests.
124
+
125
+ ## [0.1.0] - 2014-09-05
126
+ * Initial version
127
+
128
+ [Unreleased]: https://github.com/bnadlerjr/hoboken/compare/v0.10.0...HEAD
129
+ [0.10.0]: https://github.com/bnadlerjr/hoboken/compare/v0.9.0...v0.10.0
130
+ [0.9.0]: https://github.com/bnadlerjr/hoboken/compare/v0.0.1...v0.9.0
131
+ [0.0.1]: https://github.com/bnadlerjr/hoboken/releases/tag/v0.0.1
@@ -0,0 +1,8 @@
1
+ ## Code of Conduct
2
+ This code of conduct applies to all of the project's "collaborative space", which is defined as community communications channels, including GitHub Issues, GitHub project, and source code repository.
3
+
4
+ 1. Participants must ensure that their language and actions are free of personal attacks and remarks disparaging to people or groups.
5
+ 1. Behaviour which can be reasonably considered harassment will not be tolerated.
6
+ 1. Discussion should be limited to the project and related technologies.
7
+
8
+ You can report a violation of this code of conduct to the project maintainer, who will take appropriate action.
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,16 @@
1
+ ## How to contribute to Hoboken
2
+
3
+ #### Issue Guidelines
4
+ 1. Issues should only be created for things that are definitely bugs. If you are not sure that the behavior is a bug, ask about it on [GitHub Discussions](https://github.com/bnadlerjr/hoboken/discussions). GitHub Issues should not be used as a help forum.
5
+ 1. **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/bnadlerjr/hoboken/issues).
6
+ 1. If you are sure it is a bug, then post a complete description of the issue, the simplest possible self-contained example showing the problem, and the full backtrace of any exception.
7
+ 1. Issues are generally closed as soon as the problem is considered fixed. However, discussion can still happen after the issue is closed, and the issue will be reopened if additional evidence is provided showing the issue still exists.
8
+
9
+ #### Pull Request Guidelines
10
+ 1. Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
11
+ 1. Try to include tests for all new features and substantial bug fixes.
12
+ 1. Try to include documentation for all new features. In most cases this should include RDoc method documentation, but updates to the [documentation site](https://github.com/bnadlerjr/hoboken-docs) are also appropriate in some cases.
13
+ 1. Follow the style conventions of the surrounding code. In most cases, this is standard ruby style.
14
+ 1. All code in pull requests is assumed to be MIT licensed. Do not submit a pull request if that isn't the case.
15
+ 1. Please do not submit pull requests for code that is not ready to be merged. Pull requests should not be used to "start a conversation" about a possible code change. If the pull request requires a conversation, that conversation should take place on [GitHub Discussions](https://github.com/bnadlerjr/hoboken/discussions).
16
+ 1. Pull requests are generally closed as soon as it appears that the branch will not be merged. However, discussion about the code can still happen after the pull request is closed, and the pull request can be reopened if additional commits to the branch or other changes make it likely that it will be merged.
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/hoboken.png)](http://badge.fury.io/rb/hoboken)
4
4
  ![Build Status](https://github.com/bnadlerjr/hoboken/actions/workflows/ruby.yml/badge.svg)
5
- [![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=bnadlerjr/hoboken)](https://dependabot.com)
5
+ [![Maintainability](https://api.codeclimate.com/v1/badges/75e09f25ee70d6858519/maintainability)](https://codeclimate.com/github/bnadlerjr/hoboken/maintainability)
6
6
 
7
7
  Sinatra project generator and templates.
8
8
 
@@ -49,20 +49,16 @@ Additional generators are available for existing projects generated using Hoboke
49
49
  $ hoboken add:omniauth # OmniAuth authentication (allows you to select a provider)
50
50
  $ hoboken add:rubocop # Basic Rubocop configuration and Rake task.
51
51
  $ hoboken add:sequel # Database access via Sequel gem
52
- $ hoboken add:sprockets # Rack-based asset packaging system
52
+ $ hoboken add:sidekiq # Background processing with the Sidekiq gem
53
53
  $ hoboken add:travis # Basic Travis-CI YAML config
54
+ $ hoboken add:turnip # Gherkin extension for RSpec
54
55
  $ hoboken add:twbs # Twitter Bootstrap (requires Sprockets add-on)
56
+ $ hoboken add:vcr # Record HTTP interactions and replay them during test runs
55
57
 
56
- ### Documentation
58
+ ## Resources
57
59
 
58
- Visit the project [website](http://bobnadler.com/hoboken).
59
-
60
- ## Contributing
61
-
62
- 1. Fork it
63
- 2. Create your feature branch (`git checkout -b my-new-feature`)
64
- 3. Commit your changes (`git commit -am 'Add some feature'`)
65
- 4. Push to the branch (`git push origin my-new-feature`)
66
- 5. Create new Pull Request
67
-
68
- If your contribution requires a change to the documentation, please also make a pull request to the [documentation project](https://github.com/bnadlerjr/hoboken-docs).
60
+ * [Website](https://bobnadler.com/hoboken/)
61
+ * [Source Code](https://github.com/bnadlerjr/hoboken)
62
+ * [Bug Tracking](https://github.com/bnadlerjr/hoboken/issues)
63
+ * [Discussion Forum](https://github.com/bnadlerjr/hoboken/discussions)
64
+ * [Contribution Guidelines](https://github.com/bnadlerjr/hoboken/blob/main/CONTRIBUTING.md)
data/Rakefile CHANGED
@@ -6,21 +6,12 @@ require 'rubocop/rake_task'
6
6
 
7
7
  RuboCop::RakeTask.new
8
8
 
9
- task default: 'test:all'
10
-
11
- desc 'Run CI checks'
12
- task ci: ['test:all', 'rubocop']
13
-
14
- namespace :test do
15
- types = %w[unit integration]
9
+ Rake::TestTask.new do |t|
10
+ t.libs << 'test'
11
+ t.test_files = Dir['test/**/*_test.rb']
12
+ end
16
13
 
17
- types.each do |type|
18
- Rake::TestTask.new(type.to_sym) do |t|
19
- t.libs << "test/#{type}"
20
- t.test_files = Dir["test/#{type}/**/*_test.rb"]
21
- end
22
- end
14
+ task default: 'test'
23
15
 
24
- desc 'Run all tests'
25
- task all: types.map { |s| "test:#{s}" }
26
- end
16
+ desc 'Run CI checks'
17
+ task ci: %w[test rubocop]
data/hoboken.gemspec CHANGED
@@ -13,6 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = 'https://github.com/bnadlerjr/hoboken'
14
14
  spec.license = 'MIT'
15
15
 
16
+ spec.metadata['rubygems_mfa_required'] = 'true'
16
17
  spec.required_ruby_version = '>= 2.6'
17
18
 
18
19
  spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
@@ -20,9 +21,11 @@ Gem::Specification.new do |spec|
20
21
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
22
  spec.require_paths = ['lib']
22
23
 
24
+ spec.add_dependency 'thor', '~> 1.1'
25
+
23
26
  spec.add_development_dependency 'bundler', '~> 2.2'
24
27
  spec.add_development_dependency 'pry-byebug', '~> 3.9'
25
- spec.add_development_dependency 'rake', '~> 13.0'
28
+ spec.add_development_dependency 'rake', '~> 12.3'
26
29
  spec.add_development_dependency 'rubocop', '~> 1.12'
27
30
  spec.add_development_dependency 'rubocop-rake', '~> 0.5'
28
31
  spec.add_development_dependency 'test-unit', '~> 3.4'
@@ -33,30 +36,37 @@ Gem::Specification.new do |spec|
33
36
  #
34
37
  # a) We can get Dependabot notifications for them
35
38
  # b) We can run tests for generated projects
39
+ spec.add_development_dependency 'airbrake', '~> 12.0'
36
40
  spec.add_development_dependency 'better_errors', '~> 2.9'
37
41
  spec.add_development_dependency 'binding_of_caller', '~> 1.0'
38
- spec.add_development_dependency 'bootstrap', '~> 5.0.0.beta3'
42
+ spec.add_development_dependency 'bootstrap', '~> 5.1.0'
39
43
  spec.add_development_dependency 'contest', '~> 0.1'
40
44
  spec.add_development_dependency 'dotenv', '~> 2.7'
41
45
  spec.add_development_dependency 'erubi', '~> 1.10'
46
+ spec.add_development_dependency 'flay', '~> 2.12'
47
+ spec.add_development_dependency 'flog', '~> 4.6'
42
48
  spec.add_development_dependency 'omniauth-twitter', '~> 1.4'
43
49
  spec.add_development_dependency 'puma', '~> 5.2'
44
50
  spec.add_development_dependency 'rack_csrf', '~> 2.6'
45
51
  spec.add_development_dependency 'racksh', '~> 1.0'
46
52
  spec.add_development_dependency 'rack-test', '~> 1.1'
47
- spec.add_development_dependency 'rb-fsevent', '~> 0.10'
48
- spec.add_development_dependency 'rerun', '~> 0.13'
49
53
  spec.add_development_dependency 'rspec', '~> 3.10'
54
+ spec.add_development_dependency 'rubocop-performance', '~> 1.13'
50
55
  spec.add_development_dependency 'rubocop-rspec', '~> 2.2'
56
+ spec.add_development_dependency 'rubocop-sequel', '~> 0.2'
51
57
  spec.add_development_dependency 'sassc', '~> 2.4'
52
58
  spec.add_development_dependency 'sequel', '~> 5.43'
59
+ spec.add_development_dependency 'sidekiq', '~> 6.2'
60
+ spec.add_development_dependency 'simplecov', '~> 0.21'
53
61
  spec.add_development_dependency 'sinatra', '~> 2.1'
62
+ spec.add_development_dependency 'sinatra-activerecord', '~> 2.0'
63
+ spec.add_development_dependency 'sinatra-asset-pipeline', '~> 2.2'
54
64
  spec.add_development_dependency 'sinatra-contrib', '~> 2.1'
55
65
  spec.add_development_dependency 'sinatra-flash', '~> 0.3'
56
- spec.add_development_dependency 'sprockets', '~> 4.0'
66
+ spec.add_development_dependency 'sinatra-r18n', '~> 5.0'
57
67
  spec.add_development_dependency 'sqlite3', '~> 1.4'
68
+ spec.add_development_dependency 'turnip', '~> 4.3'
58
69
  spec.add_development_dependency 'uglifier', '~> 4.2'
59
- spec.add_development_dependency 'yui-compressor', '~> 0.12'
60
-
61
- spec.add_dependency 'thor', '~> 1.1'
70
+ spec.add_development_dependency 'vcr', '~> 6.0'
71
+ spec.add_development_dependency 'webmock', '~> 3.13'
62
72
  end
@@ -0,0 +1,142 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hoboken
4
+ module AddOns
5
+ # ActiveRecord database access via sinatra-activerecord gem.
6
+ #
7
+ class ActiveRecord < Hoboken::Group
8
+ def add_gems
9
+ gem 'sinatra-activerecord', version: '2.0'
10
+ gem 'sqlite3', version: '1.4', group: %i[development test]
11
+ end
12
+
13
+ def setup_directories
14
+ empty_directory('db/migrate')
15
+ empty_directory('tasks')
16
+ end
17
+
18
+ def copy_example_seeds_file
19
+ copy_file('hoboken/templates/seeds.rb', 'db/seeds.rb')
20
+ end
21
+
22
+ def copy_rake_task
23
+ copy_file('hoboken/templates/active_record.rake', 'tasks/active_record.rake')
24
+ end
25
+
26
+ def require_sinatra_activerecord
27
+ location = %r{require_relative '\.\./app'}
28
+ insert_into_file('config/environment.rb', before: location) do
29
+ "require 'sinatra/activerecord'\n\n"
30
+ end
31
+ end
32
+
33
+ def set_database_variable
34
+ snippet = "set :database, ENV['DATABASE_URL']"
35
+ snippet = "register Sinatra::ActiveRecordExtension\n#{snippet}" if modular?
36
+ indentation = classic? ? 2 : 6
37
+ location = /set :erb.+\n/
38
+ insert_into_file('config/environment.rb', after: location) do
39
+ "\n#{indent(snippet, indentation)}\n"
40
+ end
41
+ end
42
+
43
+ def setup_puma_config
44
+ insert_into_file('config/puma.rb', after: 'on_worker_boot do') do
45
+ "\n ActiveRecord::Base.establish_connection"
46
+ end
47
+ end
48
+
49
+ # rubocop:disable Metrics/MethodLength
50
+ def add_database_test_helper_class
51
+ return if rspec?
52
+
53
+ insert_into_file('test/test_helper.rb', before: /ENV\['RACK_ENV'\] = 'test'/) do
54
+ "ENV['DATABASE_URL'] = 'sqlite3:db/test.db'\n"
55
+ end
56
+
57
+ snippet = <<~CODE
58
+ def run(*args, &block)
59
+ result = nil
60
+ ActiveRecord::Base.connection.transaction do
61
+ result = super
62
+ raise ActiveRecord::Rollback
63
+ end
64
+ result
65
+ end
66
+ CODE
67
+
68
+ insert_into_file('test/test_helper.rb', after: /include RackHelpers\n/) do
69
+ "\n#{indent(snippet, 6)}"
70
+ end
71
+ end
72
+ # rubocop:enable Metrics/MethodLength
73
+
74
+ # rubocop:disable Metrics/MethodLength
75
+ def add_database_spec_helper
76
+ return unless rspec?
77
+
78
+ insert_into_file('spec/spec_helper.rb', before: /ENV\['RACK_ENV'\] = 'test'/) do
79
+ "ENV['DATABASE_URL'] = 'sqlite3:db/test.db'\n"
80
+ end
81
+
82
+ snippet = <<~CODE
83
+ config.around do |example|
84
+ ActiveRecord::Base.transaction do
85
+ example.run
86
+ ActiveRecord::Rollback
87
+ end
88
+ end
89
+ CODE
90
+
91
+ location = /RSpec\.configure do \|config\|\n/
92
+ insert_into_file('spec/spec_helper.rb', after: location) do
93
+ "#{indent(snippet, 2)}\n"
94
+ end
95
+ end
96
+ # rubocop:enable Metrics/MethodLength
97
+
98
+ # rubocop:disable Metrics/MethodLength
99
+ def update_readme
100
+ snippet = <<~CODE
101
+ <tr>
102
+ <td>DATABASE_URL</td>
103
+ <td>Yes</td>
104
+ <td>
105
+ `sqlite3:db/test.db` (for the test environment <em>only</em>)
106
+ </td>
107
+ <td>
108
+ Connection URL to the database. The format varies according
109
+ database adapter. Refer to the documentation for the adapter
110
+ you're using for more information. Some examples:
111
+ <dl>
112
+ <dt>Sqlite3</dt>
113
+ <dd>`sqlite3:db/development.db`</dd>
114
+ <dt>PostgreSQL</dt>
115
+ <dd>`postgresql://localhost/myapp_development?pool=5`</dd>
116
+ </dl>
117
+ </td>
118
+ </tr>
119
+ CODE
120
+
121
+ insert_into_file('README.md', after: /<tbody>\n/) do
122
+ indent(snippet, 8)
123
+ end
124
+ end
125
+ # rubocop:enable Metrics/MethodLength
126
+
127
+ def reminders
128
+ say "\nGemfile updated... don't forget to 'bundle install'"
129
+ say <<~TEXT
130
+
131
+ Notes:
132
+ * The sqlite3 gem has been installed for dev and test environments
133
+ only. You will need to specify a gem to use for production.
134
+
135
+ * You will need to specify an environment variable 'DATABASE_URL'
136
+ (either add it to .env or export it). For example, in your .env
137
+ file add: `DATABASE_URL=sqlite3:db/development.db`.
138
+ TEXT
139
+ end
140
+ end
141
+ end
142
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hoboken
4
+ module AddOns
5
+ # Support for official Airbrake library for Ruby applications.
6
+ #
7
+ class Airbrake < ::Hoboken::Group
8
+ def add_gem
9
+ gem 'airbrake', version: '11.0'
10
+ end
11
+
12
+ def setup_config
13
+ template('hoboken/templates/airbrake.rb.tt', 'config/airbrake.rb')
14
+ end
15
+
16
+ def add_middleware
17
+ indentation = classic? ? 2 : 6
18
+ require_snippet = indent("require_relative 'airbrake'\n", indentation)
19
+ middleware_snippet = indent("use Airbrake::Rack::Middleware\n", indentation)
20
+ location = /configure :production do\n/
21
+
22
+ insert_into_file('config/environment.rb', after: location) do
23
+ "#{require_snippet}#{middleware_snippet}\n"
24
+ end
25
+ end
26
+
27
+ # rubocop:disable Metrics/MethodLength
28
+ def update_readme
29
+ snippet = <<~CODE
30
+ <tr>
31
+ <td>AIRBRAKE_PROJECT_ID</td>
32
+ <td>Production Only</td>
33
+ <td>None</td>
34
+ <td>Airbrake project ID. Refer to the project's settings page in Airbrake</td>
35
+ </tr>
36
+ <tr>
37
+ <td>AIRBRAKE_PROJECT_KEY</td>
38
+ <td>Production Only</td>
39
+ <td>None</td>
40
+ <td>Airbrake project key. Refer to the project's settings page in Airbrake</td>
41
+ </tr>
42
+ CODE
43
+
44
+ insert_into_file('README.md', after: /<tbody>\n/) do
45
+ indent(snippet, 8)
46
+ end
47
+ end
48
+ # rubocop:enable Metrics/MethodLength
49
+
50
+ def reminders
51
+ text = <<~TEXT
52
+
53
+ Gemfile updated... don't forget to 'bundle install'
54
+
55
+ You can configure a Airbrake settings in `config/airbrake.rb`. By
56
+ default Airbrake is set to only be used in production environments.
57
+ Don't forget to set your `AIRBRAKE_PROJECT_ID` and `AIRBRAKE_PROJECT_KEY`.
58
+ TEXT
59
+
60
+ say text, :green
61
+ end
62
+ end
63
+ end
64
+ end
@@ -18,7 +18,11 @@ module Hoboken
18
18
  end
19
19
 
20
20
  def reminders
21
- say "\nGemfile updated... don't forget to 'bundle install'"
21
+ say <<~TEXT
22
+ Ready to deploy to Heroku. See the Heroku docs[1] for details.
23
+
24
+ [1]: https://devcenter.heroku.com/articles/rack
25
+ TEXT
22
26
  end
23
27
  end
24
28
  end