cp-sparrow 0.0.12 → 0.0.14

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/.gitignore +2 -1
  3. data/.ruby-version +1 -1
  4. data/LICENSE.txt +1 -1
  5. data/README.md +96 -13
  6. data/lib/sparrow.rb +21 -4
  7. data/lib/sparrow/configuration.rb +23 -2
  8. data/lib/sparrow/core_ext/hash.rb +2 -0
  9. data/lib/sparrow/dependencies.rb +15 -0
  10. data/lib/sparrow/http_message.rb +103 -0
  11. data/lib/sparrow/logger.rb +53 -0
  12. data/lib/sparrow/middleware.rb +44 -63
  13. data/lib/sparrow/request_http_message.rb +22 -0
  14. data/lib/sparrow/request_middleware.rb +8 -10
  15. data/lib/sparrow/response_http_message.rb +49 -0
  16. data/lib/sparrow/response_middleware.rb +32 -28
  17. data/lib/sparrow/response_steward.rb +13 -0
  18. data/lib/sparrow/route_parser.rb +28 -5
  19. data/lib/sparrow/steward.rb +125 -0
  20. data/lib/sparrow/strategies.rb +6 -0
  21. data/lib/sparrow/strategies/form_hash.rb +27 -11
  22. data/lib/sparrow/strategies/ignore.rb +33 -5
  23. data/lib/sparrow/strategies/json_format_strategies.rb +4 -0
  24. data/lib/sparrow/strategies/json_format_strategies/array_json_format_strategy.rb +23 -0
  25. data/lib/sparrow/strategies/json_format_strategies/default_json_format_strategy.rb +11 -2
  26. data/lib/sparrow/strategies/json_format_strategies/json_format_strategy.rb +21 -6
  27. data/lib/sparrow/strategies/json_format_strategies/rack_body_json_format_strategy.rb +22 -0
  28. data/lib/sparrow/strategies/key_transformation.rb +2 -0
  29. data/lib/sparrow/strategies/key_transformation/camelize_key.rb +45 -17
  30. data/lib/sparrow/strategies/key_transformation/underscore_key.rb +17 -6
  31. data/lib/sparrow/strategies/raw_input.rb +29 -7
  32. data/lib/sparrow/strategies/transform_params.rb +46 -21
  33. data/lib/sparrow/transformable.rb +28 -20
  34. data/lib/sparrow/version.rb +1 -1
  35. data/sparrow.gemspec +1 -1
  36. data/spec/integration/apps/rails_app/config/boot.rb +1 -1
  37. data/spec/integration/rack/camel_caser_spec.rb +2 -2
  38. data/spec/unit/camelize_key_spec.rb +9 -7
  39. data/spec/unit/configuration_spec.rb +3 -0
  40. data/spec/unit/http_message.rb +66 -0
  41. data/spec/unit/logger_spec.rb +6 -0
  42. data/spec/unit/{camel_caser_spec.rb → sparrow_spec.rb} +8 -2
  43. data/spec/unit/steward_spec.rb +31 -0
  44. metadata +24 -13
  45. data/lib/sparrow/path_normalizer.rb +0 -10
  46. data/lib/sparrow/strategies/json_format_strategies/array_strategy.rb +0 -17
  47. data/lib/sparrow/strategies/json_format_strategies/rack_body.rb +0 -17
  48. data/lib/sparrow/strategies/key_transformation/key_normalizer.rb +0 -9
  49. data/spec/unit/path_normalizer_spec.rb +0 -23
@@ -1,9 +0,0 @@
1
- module Sparrow
2
- module Strategies
3
- module KeyNormalizer
4
- def normalize_key(key)
5
- key.to_s
6
- end
7
- end
8
- end
9
- end
@@ -1,23 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Sparrow
4
- describe PathNormalizer, type: :unit do
5
- let(:clazz) do
6
- Class.new do
7
- include PathNormalizer
8
- end
9
- end
10
-
11
- subject { clazz.new }
12
-
13
- describe '.normalize_path' do
14
- it 'should remove any starting slash from the path string' do
15
- expect(subject.normalize_path('/panda')).to eq 'panda'
16
- end
17
-
18
- it 'should not touch any strings that do not start with a slash' do
19
- expect(subject.normalize_path('panda')).to eq 'panda'
20
- end
21
- end
22
- end
23
- end