trailblazer 0.3.3 → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/CHANGES.md +12 -0
  4. data/Gemfile +2 -1
  5. data/README.md +73 -38
  6. data/Rakefile +1 -1
  7. data/lib/trailblazer/autoloading.rb +4 -1
  8. data/lib/trailblazer/endpoint.rb +7 -13
  9. data/lib/trailblazer/operation.rb +54 -40
  10. data/lib/trailblazer/operation/builder.rb +26 -0
  11. data/lib/trailblazer/operation/collection.rb +1 -2
  12. data/lib/trailblazer/operation/controller.rb +36 -48
  13. data/lib/trailblazer/operation/dispatch.rb +11 -11
  14. data/lib/trailblazer/operation/model.rb +50 -0
  15. data/lib/trailblazer/operation/model/dsl.rb +29 -0
  16. data/lib/trailblazer/operation/model/external.rb +34 -0
  17. data/lib/trailblazer/operation/policy.rb +87 -0
  18. data/lib/trailblazer/operation/policy/guard.rb +34 -0
  19. data/lib/trailblazer/operation/representer.rb +33 -12
  20. data/lib/trailblazer/operation/resolver.rb +30 -0
  21. data/lib/trailblazer/operation/responder.rb +0 -1
  22. data/lib/trailblazer/operation/worker.rb +24 -7
  23. data/lib/trailblazer/version.rb +1 -1
  24. data/test/collection_test.rb +2 -1
  25. data/test/{crud_test.rb → model_test.rb} +17 -35
  26. data/test/operation/builder_test.rb +41 -0
  27. data/test/operation/dsl/callback_test.rb +108 -0
  28. data/test/operation/dsl/contract_test.rb +104 -0
  29. data/test/operation/dsl/representer_test.rb +143 -0
  30. data/test/operation/external_model_test.rb +71 -0
  31. data/test/operation/guard_test.rb +97 -0
  32. data/test/operation/policy_test.rb +97 -0
  33. data/test/operation/resolver_test.rb +83 -0
  34. data/test/operation_test.rb +7 -75
  35. data/test/rails/__respond_test.rb +20 -0
  36. data/test/rails/controller_test.rb +4 -102
  37. data/test/rails/endpoint_test.rb +7 -47
  38. data/test/rails/fake_app/controllers.rb +16 -21
  39. data/test/rails/fake_app/rails_app.rb +5 -0
  40. data/test/rails/fake_app/song/operations.rb +11 -4
  41. data/test/rails/respond_test.rb +95 -0
  42. data/test/responder_test.rb +6 -6
  43. data/test/rollback_test.rb +2 -2
  44. data/test/worker_test.rb +13 -9
  45. data/trailblazer.gemspec +2 -2
  46. metadata +38 -15
  47. data/lib/trailblazer/operation/crud.rb +0 -82
  48. data/lib/trailblazer/rails/railtie.rb +0 -34
  49. data/test/rails/fake_app/views/bands/show.html.erb +0 -1
@@ -1,34 +0,0 @@
1
- module Trailblazer
2
- class Railtie < Rails::Railtie
3
- def self.autoload_operations(app)
4
- Dir.glob("app/concepts/**/crud.rb") do |f|
5
- path = f.sub("app/concepts/", "")
6
- model = path.sub("/crud.rb", "")
7
-
8
- require_dependency "#{app.root}/app/models/#{model}" # load the model file, first (thing.rb).
9
- require_dependency "#{app.root}/#{f}" # load app/concepts/{concept}/crud.rb (Thing::Create, Thing::Update, and so on).
10
- end
11
- end
12
-
13
- def self.autoload_cells(app)
14
- Dir.glob("app/concepts/**/*cell.rb") do |f|
15
- require_dependency "#{app.root}/#{f}" # load app/concepts/{concept}/cell.rb.
16
- end
17
- end
18
-
19
- # This is to autoload Operation::Dispatch, etc. I'm simply assuming people find this helpful in Rails.
20
- initializer "trailblazer.library_autoloading" do
21
- require "trailblazer/autoloading"
22
- end
23
-
24
- # thank you, http://stackoverflow.com/a/17573888/465070
25
- initializer 'trailblazer.install', after: :load_config_initializers do |app|
26
- # the trb autoloading has to be run after initializers have been loaded, so we can tweak inclusion of features in
27
- # initializers.
28
- ActionDispatch::Reloader.to_prepare do
29
- Trailblazer::Railtie.autoload_operations(app)
30
- Trailblazer::Railtie.autoload_cells(app)
31
- end
32
- end
33
- end
34
- end
@@ -1 +0,0 @@
1
- bands/show.html: <%= [@klass, @model.class, @form.is_a?(Reform::Form), @operation.class, @locality].join(",") %>