dry-web-web_pipe 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +37 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +31 -0
  5. data/CHANGELOG.md +283 -0
  6. data/CONTRIBUTING.md +29 -0
  7. data/Gemfile +36 -0
  8. data/LICENSE +22 -0
  9. data/README.md +72 -0
  10. data/Rakefile +6 -0
  11. data/dry-web-web_pipe.gemspec +33 -0
  12. data/exe/dry-web-web_pipe +6 -0
  13. data/lib/dry/web/web_pipe/cli/generate.rb +18 -0
  14. data/lib/dry/web/web_pipe/cli.rb +26 -0
  15. data/lib/dry/web/web_pipe/generate.rb +52 -0
  16. data/lib/dry/web/web_pipe/generators/abstract_generator.rb +54 -0
  17. data/lib/dry/web/web_pipe/generators/abstract_project.rb +116 -0
  18. data/lib/dry/web/web_pipe/generators/flat_project.rb +43 -0
  19. data/lib/dry/web/web_pipe/generators/inflections.rb +21 -0
  20. data/lib/dry/web/web_pipe/generators/sub_app.rb +68 -0
  21. data/lib/dry/web/web_pipe/generators/umbrella_project.rb +29 -0
  22. data/lib/dry/web/web_pipe/templates/.env.test.tt +1 -0
  23. data/lib/dry/web/web_pipe/templates/.env.tt +2 -0
  24. data/lib/dry/web/web_pipe/templates/.gitignore.tt +11 -0
  25. data/lib/dry/web/web_pipe/templates/.keep +0 -0
  26. data/lib/dry/web/web_pipe/templates/.rspec +2 -0
  27. data/lib/dry/web/web_pipe/templates/Gemfile +47 -0
  28. data/lib/dry/web/web_pipe/templates/README.md.tt +15 -0
  29. data/lib/dry/web/web_pipe/templates/Rakefile.tt +109 -0
  30. data/lib/dry/web/web_pipe/templates/application.html.slim +3 -0
  31. data/lib/dry/web/web_pipe/templates/config.ru.tt +7 -0
  32. data/lib/dry/web/web_pipe/templates/console.tt +7 -0
  33. data/lib/dry/web/web_pipe/templates/container.rb.tt +17 -0
  34. data/lib/dry/web/web_pipe/templates/flat_project/boot.rb.tt +12 -0
  35. data/lib/dry/web/web_pipe/templates/flat_project/root.rb.tt +16 -0
  36. data/lib/dry/web/web_pipe/templates/flat_project/router.rb.tt +8 -0
  37. data/lib/dry/web/web_pipe/templates/flat_project/web.rb.tt +52 -0
  38. data/lib/dry/web/web_pipe/templates/import.rb.tt +5 -0
  39. data/lib/dry/web/web_pipe/templates/monitor.rb.tt +10 -0
  40. data/lib/dry/web/web_pipe/templates/operation.rb.tt +11 -0
  41. data/lib/dry/web/web_pipe/templates/persistence.rb.tt +36 -0
  42. data/lib/dry/web/web_pipe/templates/repository.rb.tt +11 -0
  43. data/lib/dry/web/web_pipe/templates/sample_data.rb +1 -0
  44. data/lib/dry/web/web_pipe/templates/seed.rb +1 -0
  45. data/lib/dry/web/web_pipe/templates/settings.rb.tt +10 -0
  46. data/lib/dry/web/web_pipe/templates/setup +7 -0
  47. data/lib/dry/web/web_pipe/templates/spec/db_spec_helper.rb.tt +23 -0
  48. data/lib/dry/web/web_pipe/templates/spec/factories/example.rb +9 -0
  49. data/lib/dry/web/web_pipe/templates/spec/spec_helper.rb.tt +61 -0
  50. data/lib/dry/web/web_pipe/templates/spec/support/db/factory.rb +8 -0
  51. data/lib/dry/web/web_pipe/templates/spec/support/db/helpers.rb.tt +13 -0
  52. data/lib/dry/web/web_pipe/templates/spec/support/web/helpers.rb.tt +9 -0
  53. data/lib/dry/web/web_pipe/templates/spec/web_spec_helper.rb +37 -0
  54. data/lib/dry/web/web_pipe/templates/subapp/boot.rb.tt +5 -0
  55. data/lib/dry/web/web_pipe/templates/subapp/container.rb.tt +21 -0
  56. data/lib/dry/web/web_pipe/templates/subapp/import.rb.tt +7 -0
  57. data/lib/dry/web/web_pipe/templates/subapp/root.rb.tt +18 -0
  58. data/lib/dry/web/web_pipe/templates/subapp/router.rb.tt +10 -0
  59. data/lib/dry/web/web_pipe/templates/subapp/view.rb.tt +17 -0
  60. data/lib/dry/web/web_pipe/templates/subapp/view_context.rb.tt +8 -0
  61. data/lib/dry/web/web_pipe/templates/subapp/web.rb.tt +54 -0
  62. data/lib/dry/web/web_pipe/templates/subapp/welcome.rb.tt +13 -0
  63. data/lib/dry/web/web_pipe/templates/types.rb +6 -0
  64. data/lib/dry/web/web_pipe/templates/umbrella_project/boot.rb.tt +18 -0
  65. data/lib/dry/web/web_pipe/templates/umbrella_project/router.rb.tt +8 -0
  66. data/lib/dry/web/web_pipe/templates/view.rb.tt +15 -0
  67. data/lib/dry/web/web_pipe/templates/view_context.rb.tt +31 -0
  68. data/lib/dry/web/web_pipe/templates/welcome.html.slim +1 -0
  69. data/lib/dry/web/web_pipe/templates/welcome.rb.tt +11 -0
  70. data/lib/dry/web/web_pipe/version.rb +7 -0
  71. data/lib/dry-web-web_pipe.rb +1 -0
  72. data/script/ci +67 -0
  73. data/script/setup +47 -0
  74. data/script/teardown +42 -0
  75. data/spec/integration/new_app_spec.rb +21 -0
  76. data/spec/spec_helper.rb +22 -0
  77. data/spec/support/app.rb +64 -0
  78. data/spec/support/bundler.rb +113 -0
  79. data/spec/support/cli.rb +47 -0
  80. data/spec/support/directories.rb +37 -0
  81. data/spec/support/env.rb +84 -0
  82. data/spec/support/files.rb +59 -0
  83. data/spec/support/project.rb +60 -0
  84. data/spec/support/requests.rb +5 -0
  85. data/spec/support/silently.rb +28 -0
  86. data/spec/unit/generators/inflections_spec.rb +33 -0
  87. metadata +268 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 85d5ccb3ea47bbb1fefbebb2011b334060481b4c84a512b2c75b7180624c1c61
4
+ data.tar.gz: eb6d2c58d706e1f09b903fae1f0e3675d0be09e2cd786a117168b9a83a007818
5
+ SHA512:
6
+ metadata.gz: 6ae7e5a9c3d9828f7bbabacbc3f8028eac9803995694bd0defbb01ad6d7e1c08d635ef550e2afeddf3ad76c74ad34f780bac157316ada11a8d18d799b126977f
7
+ data.tar.gz: 24526219ac143218c95ea6ca11d21c1a343f90ecffc4b790465d3a2781ad82038a221465fc5ab2a5efc5fb796e4f09725e83720ed8f2917e0abc2da6aa6f8231
data/.gitignore ADDED
@@ -0,0 +1,37 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /test/tmp/
8
+ /test/version_tmp/
9
+ /tmp/
10
+
11
+ ## Testing
12
+ /spec/reports/
13
+ /spec/examples.txt
14
+
15
+ ## Documentation cache and generated files:
16
+ /.yardoc/
17
+ /_yardoc/
18
+ /doc/
19
+ /rdoc/
20
+
21
+ ## Environment normalisation:
22
+ /.bundle/
23
+ /lib/bundler/man/
24
+
25
+ # for a library or gem, you might want to ignore these files since the code is
26
+ # intended to run in multiple environments; otherwise, check them in:
27
+ Gemfile.lock
28
+ # .ruby-version
29
+ # .ruby-gemset
30
+
31
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
32
+ .rvmrc
33
+
34
+ .byebug_history
35
+ /vendor/cache/
36
+
37
+ .idea
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,31 @@
1
+ language: ruby
2
+ dist: trusty
3
+ services:
4
+ - postgresql
5
+ cache: bundler
6
+ install: true
7
+ before_install:
8
+ - gem update --system
9
+ before_script:
10
+ - psql -c 'create database sandbox_test;' -U postgres
11
+ script:
12
+ - ./script/ci
13
+ rvm:
14
+ - 2.6.3
15
+ - 2.5.5
16
+ - 2.4.5
17
+ - jruby-9.2.7.0
18
+ env:
19
+ global:
20
+ - JRUBY_OPTS='--dev -J-Xmx1024M'
21
+ matrix:
22
+ allow_failures:
23
+ - rvm: jruby-9.2.7.0
24
+ notifications:
25
+ email: false
26
+ webhooks:
27
+ urls:
28
+ - https://webhooks.gitter.im/e/19098b4253a72c9796db
29
+ on_success: change # options: [always|never|change] default: always
30
+ on_failure: always # options: [always|never|change] default: always
31
+ on_start: false # default: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,283 @@
1
+ # Change Log
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
+ and this project adheres to [Semantic Versioning](http://semver.org/).
6
+
7
+ # Unreleased
8
+
9
+ [dry-web-roda project](https://github.com/dry-rb/dry-web-roda) has been forked
10
+ into this repository. For this first version, only the minimal changes to adapt
11
+ it for `web_pipe` has been made:
12
+
13
+ - Generate skeleton using `web_pipe` for the controller layer for both flat and
14
+ umbrella arquitectures.
15
+ - Generate skeleton using `hanami-router` for the router layer for both flat
16
+ and umbrella arquitectures.
17
+ - Update dependencies to meet `web_pipe` requirements.
18
+
19
+ Besides, ruby 2.3 support has been dropped.
20
+
21
+ ### Added
22
+
23
+ # FORKED AS dry-web-we_pipe
24
+
25
+ # 0.12.0 - 2019-04-16
26
+
27
+ ### Changed
28
+
29
+ - Update generated app to work with latest releases of dry-rb gems, including dry-view 0.7.0 and dry-monitor 0.3.0 (parndt in [#94][pr94])
30
+ - [BREAKING] `view` roda helper now expects the dry-view context object to be registered in the container as `"view_context"` (instead of previous `"view.context"`) (parndt in [#94][pr94])
31
+
32
+ [pr94]: https://github.com/dry-rb/dry-web-roda/pull/94/files
33
+
34
+ [Compare v0.11.0...v0.12.0](https://github.com/dry-rb/dry-web-roda/compare/v0.11.0...v0.12.0)
35
+
36
+ # 0.11.0 - 2018-02-21
37
+
38
+ ### Changed
39
+
40
+ - Use Roda 3.0 and compatible version of roda-flow (GustavoCaso & alejandrobabio)
41
+
42
+ [Compare v0.10.0...v0.11.0](https://github.com/dry-rb/dry-web-roda/compare/v0.10.0...v0.11.0)
43
+
44
+ # 0.10.0 - 2018-02-13
45
+
46
+ ### Changed
47
+
48
+ - Use dry-system and dry-web latest version (solnic + timriley)
49
+ - Force `Kernel#system` to receive hash with string values (alejandrobabio)
50
+ - Downgrade `roda-flow` to `0.3.1` to avoid 404 on root page (GustavoCaso)
51
+ - Replace shotgun with rerun to start the generated projects (GustavoCaso)
52
+
53
+ To start a project now:
54
+
55
+ ```sh
56
+ bundle exec rerun -- rackup --port 4000 config.ru
57
+ ```
58
+
59
+ In generated projects:
60
+
61
+ - Require dry-system 0.9 (GustavoCaso)
62
+ - Add ability to define custom view key resolver in `dry_view` Roda plugin (AMHOL)
63
+
64
+ [Compare v0.9.1...v0.10.0](https://github.com/dry-rb/dry-web-roda/compare/v0.9.1...v0.10.0)
65
+
66
+ # 0.9.1 - 2017-11-01
67
+
68
+ ### Changed
69
+
70
+ - In generated projects, require dry-view 0.4 (timriley)
71
+
72
+ # 0.9.0 - 2017-10-27
73
+
74
+ ### Changed
75
+
76
+ - `Dry::Web::Roda::Application` no longer automatically enables `error_handler` and `multi_route` Roda plugins (timriley)
77
+ - `DryView` Roda plugin no longer automatically enables `csrf` and `flash` Roda plugins (timriley)
78
+ - `DryView` Roda plugin no longer populates its `#view_context_options` with flash and CSRF data (timriley)
79
+
80
+ In generated projects:
81
+
82
+ - Nest sub-apps under the root project namespace (e.g. `MyApp::Main`) instead of keeping them at the top-level (`Main`) (timriley)
83
+ - Rename `Dry::Web::Roda::Application` subclasses from `Application` to `Web` (timriley)
84
+ - Comment out `r.multi_route` routing instruction in `Web` classes by default, to avoid future Roda exceptions (timriley)
85
+ - Enable more Roda plugins (`csrf`, `error_handler`, `flash`, `multi_route`) directly in `Web` classes (timriley)
86
+ - Add default implementation of `#view_context_options` to `Web` classes for `dry_view` Roda plugin (timriley)
87
+
88
+ # 0.8.0 - 2017-10-26
89
+
90
+ ### Changed
91
+
92
+ In generated projects:
93
+
94
+ - Work with dry-system 0.8 (timriley)
95
+ - Use dry-systems own settings component in `boot/settings.rb` for project configuration (timriley)
96
+ - Rename `:rom` bootable component to `:persistence` so it can be automatically resolved and lazily loaded (timriley)
97
+ - Use rom-rb 4.0 (timriley)
98
+
99
+ # 0.7.5 - 2017-07-25
100
+
101
+ ### Added
102
+
103
+ - `Application.container` shortcut (solnic)
104
+
105
+ ### Changed
106
+
107
+ - An app will use `rack_monitor` only if its container is configured with listeners (solnic)
108
+
109
+ # 0.7.4 - 2017-07-25
110
+
111
+ ### Added
112
+
113
+ - Added db:create and db:drop take tasks, to create and drop the application database (GustavoCaso)
114
+
115
+ ### Changed
116
+
117
+ - Use Postgres environment variables to provide connection info to `pg_dump` command in db:structure:dump rake task (timriley)
118
+ - Remove error handling block from generated sub-app application classes, since an error handling block is already provided in the top-level umbrella application class (timriley)
119
+
120
+ ### Fixed
121
+
122
+ - Prevent duplicate log entries in generated umbrella architecture projects (timriley)
123
+
124
+ # 0.7.3 - 2017-07-10
125
+
126
+ ### Fixed
127
+
128
+ - `#call` matcher blocks work properly when inheriting from `Operation` in generated project (alejandrobabio)
129
+
130
+ ### Changed
131
+
132
+ - In generated project, require `pry-byebug` instead of `byebug` alone (alejandrobabio)
133
+ - In generated project's `web_spec_helper.rb`, use updated `save_path` setting for Capybara (alejandrobabio)
134
+
135
+ # 0.7.2 - 2017-07-03
136
+
137
+ ### Fixed
138
+
139
+ - Add missing rom-factory dependency to generated project Gemfile (alejandrobabio)
140
+ - Fix reference to main application class in generated spec helpers file (alejandrobabio)
141
+
142
+ # 0.7.1 - 2017-06-22
143
+
144
+ ### Fixed
145
+
146
+ - Fix spelling of generated "lib/persistence" directory (timriley)
147
+ - Stop generating a welcome view in the umbrella system (timriley)
148
+
149
+ # 0.7.0 - 2017-06-16
150
+
151
+ ### Added
152
+
153
+ In generated app:
154
+
155
+ - Shared `Operation` class for all application operations to inherit from (timriley)
156
+ - Enable `auto_restrictions` relation plugin for ROM (timriley)
157
+ - Register low-level database connection object as "persistence.db" in core container (timriley)
158
+
159
+ ### Changed
160
+
161
+ In generated app:
162
+
163
+ - Use full database URL to include credentials in pg_dump (lukkor)
164
+ - Move view controller and context classes into main lib/ dirs (timriley)
165
+ - Use dry-system 0.7.0 magic comments to prevent auto-registration of base repository, view controller and view context classes (timriley)
166
+ - Update dry-system dependency to support string paths for container root configs (timriley)
167
+ - [BREAKING] Use Dry::Web::Settings from dry-web 0.7.0, which loads settings from .env files instead of .yml files (timriley)
168
+ - [BREAKING] Provide settings object via a bootable component
169
+ - [BREAKING] Remove special transactions setup harness, since dry-transaction 0.10.0 supports class-based transactions
170
+
171
+ # 0.6.3 - 2017-03-02
172
+
173
+ ### Changed
174
+
175
+ - Use the newly-released rom/rom-sql instrumentation plugin to generate SQL logs, rather than a local monkey patch (timriley)
176
+
177
+ # 0.6.2 - 2017-02-20
178
+
179
+ ### Fixed
180
+
181
+ - Support dashed names when generating projects, e.g. `dry-web-roda new my-app` (radar & timriley)
182
+ - Require securerandom for generating session keys in new flat architecture projects (alexandru-calinoiu)
183
+
184
+ # 0.6.1 - 2017-02-08
185
+
186
+ ### Added
187
+
188
+ - In generated projects, set up dry-monitor for request logging (timriley)
189
+ - In generated projects, use dry-monitor to log SQL queries (timriley)
190
+ - Add new flat project generator: `dry-web-roda new <your_app> --arch=flat` (timriley)
191
+
192
+ ### Changed
193
+
194
+ - Renamed sub-app generator from `dry-web-roda generate app` to `dry-web-roda generate sub_app` (timriley)
195
+
196
+ ### Fixed
197
+
198
+ - Ensure dry-monitor is set up in `Application` regardless of the order in which the application's configs are applied (timriley)
199
+
200
+ # 0.6.1 - 2017-02-03
201
+
202
+ ### Added
203
+
204
+ - In generated projects, integrate with dry-monitor (via dry-web) for centralized application logging and error reporting (solnic)
205
+
206
+ # 0.5.1 - 2016-12-27
207
+
208
+ ### Fixed
209
+
210
+ - `.gitignore` in generated umbrella app correctly ignores `log/` directory (alsemyonov)
211
+
212
+ # 0.5.0 - 2016-10-21
213
+
214
+ ### Changed
215
+
216
+ - Depend on the version of shotgun with fixes for Rack 2.0 (timriley)
217
+ - Update to work with latest dry-web and dry-system
218
+ - Expect `system/` dirs instead of `component/` (gotar)
219
+ - Update bootable dependency files to match latest dry-system API for bootable dependencies with lifecycles (gotar)
220
+ - Use latest released versions of rom-repository and rom-sql, instead of relying on their master branches (wafcio)
221
+ - Replace dry-result_matcher gem with dry-matcher (gotar)
222
+ - Add dry-monads and dry-struct gems to generated Gemfile (gotar)
223
+ - Expect symbols for flash keys in generated `Page` class (timriley)
224
+
225
+ ### Fixed
226
+
227
+ - Update `view` roda plugin to expect default namespace in sub-app containers (timriley)
228
+
229
+ # 0.4.0 - 2016-08-15
230
+
231
+ Update to dry-web with dry-system (solnic)
232
+
233
+ # 0.3.0 - 2016-07-26
234
+
235
+ ### Added
236
+
237
+ - Set a default namespace on sub-app containers generated by the CLI (timriley)
238
+
239
+ ### Changed
240
+
241
+ - Use latest dry-web for latest dry-component injector API (timriley)
242
+
243
+ # 0.2.3 / 2016-07-23
244
+
245
+ ### Changed
246
+
247
+ - By default, don't display warning output when running specs (timriley)
248
+
249
+ # 0.2.2 / 2016-07-18
250
+
251
+ ### Fixed
252
+
253
+ - Fixed a misnamed module in sub-app generator (hl)
254
+ - Removed a deprecated option from the `pg_dump` invocation after migrations (timriley)
255
+
256
+ # 0.2.1 / 2016-06-22
257
+
258
+ ### Fixed
259
+
260
+ - Fixed a broken require in generated apps (timriley)
261
+
262
+ # 0.2.0 / 2016-06-22
263
+
264
+ ### Added
265
+
266
+ - Added a `dry-web-roda` executable CLI command, which can generate new dry-web-roda projects and apps within projects (timriley)
267
+
268
+ To generate a new project:
269
+
270
+ ```sh
271
+ dry-web-roda new my_new_project
272
+ ```
273
+
274
+ And to generate a new app within an existing project:
275
+
276
+ ```sh
277
+ dry-web-roda generate app my_sub_app --umbrella=my_new_project
278
+ ```
279
+ - Added the beginnings of a skeleton-based code generator, to support the above (timriley)
280
+
281
+ # 0.1.0 / 2016-06-12
282
+
283
+ - Extracted from dry-web (timriley)
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,29 @@
1
+ # Issue Guidelines
2
+
3
+ ## Reporting bugs
4
+
5
+ If you found a bug, report an issue and describe what's the expected behavior versus what actually happens. If the bug causes a crash, attach a full backtrace. If possible, a reproduction script showing the problem is highly appreciated.
6
+
7
+ ## Reporting feature requests
8
+
9
+ Report a feature request **only after discussing it first on [discuss.dry-rb.org](https://discuss.dry-rb.org)** where it was accepted. Please provide a concise description of the feature, don't link to a discussion thread, and instead summarize what was discussed.
10
+
11
+ ## Reporting questions, support requests, ideas, concerns etc.
12
+
13
+ **PLEASE DON'T** - use [discuss.dry-rb.org](http://discuss.dry-rb.org) instead.
14
+
15
+ # Pull Request Guidelines
16
+
17
+ A Pull Request will only be accepted if it addresses a specific issue that was reported previously, or fixes typos, mistakes in documentation etc.
18
+
19
+ Other requirements:
20
+
21
+ 1) Do not open a pull request if you can't provide tests along with it. If you have problems writing tests, ask for help in the related issue.
22
+ 2) Follow the style conventions of the surrounding code. In most cases, this is standard ruby style.
23
+ 3) Add API documentation if it's a new feature
24
+ 4) Update API documentation if it changes an existing feature
25
+ 5) Bonus points for sending a PR to [github.com/dry-rb/dry-rb.org](github.com/dry-rb/dry-rb.org) which updates user documentation and guides
26
+
27
+ # Asking for help
28
+
29
+ If these guidelines aren't helpful, and you're stuck, please post a message on [discuss.dry-rb.org](https://discuss.dry-rb.org).
data/Gemfile ADDED
@@ -0,0 +1,36 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'pry'
6
+ gem 'byebug', platform: :mri
7
+ gem 'codeclimate-test-reporter', platform: :rbx
8
+
9
+ # Generated application dependencies
10
+ gem "hanami-router", "~> 1.3"
11
+ gem "web_pipe", "~> 0.7"
12
+ gem "puma"
13
+ gem "rack_csrf"
14
+ gem "rerun"
15
+ gem "rack", ">= 2.0"
16
+ gem "pg"
17
+ gem "rom", "~> 5.1"
18
+ gem "rom-factory", "~> 0.5"
19
+ gem "rom-sql", "~> 3.0"
20
+ gem "dry-matcher", "~> 0.7"
21
+ gem "dry-monads", "~> 1.2"
22
+ gem "dry-struct", "~> 1.0"
23
+ gem "dry-system", "~> 0.9"
24
+ gem "dry-transaction", "~> 0.13"
25
+ gem "dry-types", "~> 1.0"
26
+ gem "dry-validation", "~> 1.0"
27
+ gem "dry-view", "~> 0.7"
28
+ gem "dry-web", "~> 0.8"
29
+ gem "slim"
30
+ gem "pry-byebug", platform: :mri
31
+ gem "capybara"
32
+ gem "capybara-screenshot"
33
+ gem "database_cleaner"
34
+ gem "poltergeist"
35
+ gem "rspec"
36
+ gem "rack-flash3", "~> 1.0"
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015-2016 dry-rb team
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,72 @@
1
+ [gem]: https://rubygems.org/gems/dry-web-web_pipe
2
+ [travis]: https://travis-ci.org/waiting-for-dev/dry-web-web_pipe
3
+
4
+ [![Gem Version](https://badge.fury.io/rb/dry-web-web_pipe.svg)][gem]
5
+ [![Build Status](https://travis-ci.org/waiting-for-dev/dry-web-web_pipe.svg?branch=master)][travis]
6
+
7
+ Integration between [dry-web](https://github.com/dry-rb/dry-web) and [web_pipe](https://github.com/waiting-for-dev/web_pipe) with [hanami-router](https://github.com/hanami/router).
8
+
9
+ This is a fork of [dry-web-roda](https://github.com/dry-rb/dry-web-roda) where the roda dependency has been changed to web_pipe + hanami-router.
10
+
11
+ dry-web-web_pipe offers a CLI for generating new projects.
12
+
13
+ ### Umbrella projects
14
+
15
+ To generate a new _umbrella project_ (functionality divided into sub-apps):
16
+
17
+ ```sh
18
+ $ dry-web-web_pipe new <your_project_name>
19
+ ```
20
+
21
+ And to generate sub-apps within your project:
22
+
23
+ ```sh
24
+ $ dry-web-web_pipe generate sub_app <your_sub_app_name> --umbrella=<your_project_name>
25
+ ```
26
+
27
+ ### Flat projects
28
+
29
+ To generate a new _flat project_ (a simpler architecture, with a single module for your entire app):
30
+
31
+ ```sh
32
+ $ dry-web-web_pipe new <your_project_name> --arch=flat
33
+ ```
34
+
35
+ ## Generated skeleton
36
+
37
+ ### Umbrella projects
38
+
39
+ Main (hanami) router goes to `lib/<your_project_name>/router.rb`. It mounts
40
+ subapp routers, which are in
41
+ `apps/<your_sub_app_name>/system/<your_project_name>/<your_sub_app_name>/router.rb`.
42
+
43
+ Remember to update main router when adding new sub-apps.
44
+
45
+ web_pipe actions go to
46
+ `apps/<your_sub_app_name>/lib/<your_project_name>/<your_sub_app_name>/actions/`
47
+
48
+ As a base `web_pipe` to be composed there is
49
+ `apps/<your_sub_app_name>/lib/<your_project_name>/<your_sub_app_name>/web.rb`.
50
+
51
+ ### Flat projects
52
+
53
+ Hanami router goes to `system/<your_project_name>/router.rb`.
54
+
55
+ web_pipe actions go to `lib/<your_project_name>/actions/`.
56
+
57
+ As a base `web_pipe` to be composed there is
58
+ `apps/<your_project_name>/lib/web.rb`.
59
+
60
+ ## LICENSE
61
+
62
+ See `LICENSE` file.
63
+
64
+ ## Contributing
65
+
66
+ Bug reports and pull requests are welcome on GitHub at https://github.com/waiting-for-dev/dry-web-web_pipe.
67
+
68
+ ## Acknowledgements
69
+
70
+ The support code for testing the CLI and generated app are derived from
71
+ [hanami/hanami](https://github.com/hanami/hanami). Thank you to Luca and the
72
+ Hanami team!
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require "rspec/core/rake_task"
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: [:spec]
@@ -0,0 +1,33 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "dry/web/web_pipe/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "dry-web-web_pipe"
7
+ spec.version = Dry::Web::WebPipe::VERSION
8
+ spec.authors = ["Marc Busqué"]
9
+ spec.email = ["waiting-for-dev@lamarciana.com"]
10
+ spec.summary = "web_pipe integration for dry-web apps"
11
+ spec.description = spec.summary
12
+ spec.homepage = "https://github.com/waiting-for-dev/dry-web-web_pipe"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.bindir = "exe"
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.required_ruby_version = '>= 2.4.0'
22
+
23
+ spec.add_runtime_dependency "dry-configurable", "~> 0.2"
24
+ spec.add_runtime_dependency "inflecto", "~> 0.0"
25
+ spec.add_runtime_dependency "thor", "~> 0.19"
26
+
27
+ spec.add_development_dependency "aruba"
28
+ spec.add_development_dependency "bundler", ">= 1.7"
29
+ spec.add_development_dependency "rake", "~> 11.0"
30
+ spec.add_development_dependency "rspec", "~> 3.4"
31
+ spec.add_development_dependency "capybara", "~> 2.5"
32
+ spec.add_development_dependency "waitutil"
33
+ end
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "dry/web/web_pipe/cli"
5
+
6
+ Dry::Web::WebPipe::CLI.start ARGV
@@ -0,0 +1,18 @@
1
+ require "thor"
2
+
3
+ module Dry
4
+ module Web
5
+ module WebPipe
6
+ class CLI
7
+ class Generate < Thor
8
+ desc "generate sub_app APP", "Generate a sub-app within a dry-web umbrella app"
9
+ option :umbrella, required: true, banner: "UMBRELLA_NAME", desc: "Provide the name of the umbrella app, e.g. my_project"
10
+ def sub_app(app_name)
11
+ require "dry/web/web_pipe/generators/sub_app"
12
+ Dry::Web::WebPipe::Generators::SubApp.new(app_name, umbrella: options[:umbrella]).call
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,26 @@
1
+ require "thor"
2
+
3
+ module Dry
4
+ module Web
5
+ module WebPipe
6
+ class CLI < Thor
7
+ desc "new APP", "Generate a new dry-web-web_pipe project"
8
+ option :arch, required: false, default: "umbrella", enum: %w[umbrella flat], banner: "ARCH", desc: "Project architecture (umbrella/flat)"
9
+ def new(app_name)
10
+ case options[:arch]
11
+ when "umbrella"
12
+ require "dry/web/web_pipe/generators/umbrella_project"
13
+ Generators::UmbrellaProject.new(app_name).call
14
+ when "flat"
15
+ require "dry/web/web_pipe/generators/flat_project"
16
+ Generators::FlatProject.new(app_name).call
17
+ end
18
+ end
19
+
20
+ desc "generate GENERATOR", "Generate a new component for an existing dry-web-web_pipe project"
21
+ require "dry/web/web_pipe/cli/generate"
22
+ subcommand "generate", CLI::Generate
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,52 @@
1
+ require "pathname"
2
+ require "thor"
3
+
4
+ module Dry
5
+ module Web
6
+ module WebPipe
7
+ class Generate
8
+ TEMPLATES_DIR = "templates".freeze
9
+ SOURCE_DIR = Pathname(__FILE__).dirname.join(TEMPLATES_DIR)
10
+
11
+ attr_reader :target_dir, :template_scope, :template_files, :processor
12
+
13
+ def initialize(target_dir, template_scope)
14
+ @target_dir = target_dir
15
+ @template_scope = template_scope
16
+ @template_files = Dir[SOURCE_DIR.join('**/{.,}*')]
17
+
18
+ @processor = Class.new(Thor) do
19
+ include Thor::Actions
20
+ end.new
21
+ @processor.class.source_root SOURCE_DIR
22
+ end
23
+
24
+ def call(source, target)
25
+ source = Pathname(source)
26
+ aboslute_source_path = source.expand_path(SOURCE_DIR)
27
+ target_file = get_target_file(target)
28
+ template_file = template_files.find { |f| f == aboslute_source_path.to_s } or raise "missing template file +#{source}+"
29
+ template_file = Pathname(template_file)
30
+
31
+ processor.template template_file, target_file, template_scope
32
+
33
+ create_executable(target_file) if executable?(template_file)
34
+ end
35
+
36
+ private
37
+
38
+ def get_target_file(target)
39
+ Pathname.getwd.join(target_dir, target)
40
+ end
41
+
42
+ def create_executable(file)
43
+ FileUtils.chmod "a+x", file
44
+ end
45
+
46
+ def executable?(file)
47
+ file.file? && file.executable?
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end