puppet_forge 1.0.6 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/CHANGELOG.md +23 -0
  2. data/MAINTAINERS +13 -0
  3. data/README.md +48 -6
  4. data/lib/puppet_forge.rb +4 -0
  5. data/lib/puppet_forge/connection.rb +81 -0
  6. data/lib/puppet_forge/connection/connection_failure.rb +26 -0
  7. data/lib/puppet_forge/error.rb +34 -0
  8. data/lib/{her → puppet_forge}/lazy_accessors.rb +20 -27
  9. data/lib/{her → puppet_forge}/lazy_relations.rb +28 -9
  10. data/lib/puppet_forge/middleware/symbolify_json.rb +72 -0
  11. data/lib/puppet_forge/tar.rb +10 -0
  12. data/lib/puppet_forge/tar/mini.rb +81 -0
  13. data/lib/puppet_forge/unpacker.rb +68 -0
  14. data/lib/puppet_forge/v3.rb +11 -0
  15. data/lib/puppet_forge/v3/base.rb +106 -73
  16. data/lib/puppet_forge/v3/base/paginated_collection.rb +23 -14
  17. data/lib/puppet_forge/v3/metadata.rb +197 -0
  18. data/lib/puppet_forge/v3/module.rb +2 -1
  19. data/lib/puppet_forge/v3/release.rb +33 -8
  20. data/lib/puppet_forge/v3/user.rb +2 -0
  21. data/lib/puppet_forge/version.rb +1 -1
  22. data/puppet_forge.gemspec +6 -3
  23. data/spec/fixtures/v3/modules/puppetlabs-apache.json +21 -1
  24. data/spec/fixtures/v3/releases/puppetlabs-apache-0.0.1.json +4 -1
  25. data/spec/integration/forge/v3/module_spec.rb +79 -0
  26. data/spec/integration/forge/v3/release_spec.rb +75 -0
  27. data/spec/integration/forge/v3/user_spec.rb +70 -0
  28. data/spec/spec_helper.rb +15 -8
  29. data/spec/unit/forge/connection/connection_failure_spec.rb +30 -0
  30. data/spec/unit/forge/connection_spec.rb +53 -0
  31. data/spec/unit/{her → forge}/lazy_accessors_spec.rb +20 -13
  32. data/spec/unit/{her → forge}/lazy_relations_spec.rb +60 -46
  33. data/spec/unit/forge/middleware/symbolify_json_spec.rb +63 -0
  34. data/spec/unit/forge/tar/mini_spec.rb +85 -0
  35. data/spec/unit/forge/tar_spec.rb +9 -0
  36. data/spec/unit/forge/unpacker_spec.rb +58 -0
  37. data/spec/unit/forge/v3/base/paginated_collection_spec.rb +68 -46
  38. data/spec/unit/forge/v3/base_spec.rb +1 -1
  39. data/spec/unit/forge/v3/metadata_spec.rb +300 -0
  40. data/spec/unit/forge/v3/module_spec.rb +14 -36
  41. data/spec/unit/forge/v3/release_spec.rb +9 -30
  42. data/spec/unit/forge/v3/user_spec.rb +7 -7
  43. metadata +127 -41
  44. checksums.yaml +0 -7
  45. data/lib/puppet_forge/middleware/json_for_her.rb +0 -37
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: e3eb04785957d801bbfd33d52bd3f859db06f4a9
4
- data.tar.gz: 8defe188b3118818d7222b1d16375838660b3322
5
- SHA512:
6
- metadata.gz: 28e43bfe05a501839ec3cc3939d425c9d12ca066155943da0b5a394360a9a7f5c832d692a895cefce8fe8001a0a6c177e26d22f77a1fa08521a44c728814b055
7
- data.tar.gz: f889839152a072ad099881cbf501c4466219ffc6dc49144d753c1c9f83a751dae7532efcd1fc9be058bd2a0e4e4fc4b595dc5e5d51084d8766627b1271c70aa9
@@ -1,37 +0,0 @@
1
- module PuppetForge
2
-
3
- # Namespace for Faraday middleware used by this project.
4
- module Middleware
5
-
6
- # This middleware transforms the incoming JSON data into the format
7
- # expected by Her, but does so only conditionally, based on the incoming
8
- # content type. This allows the model's simple Her connection to be used to
9
- # download non-JSON content without blowing up.
10
- #
11
- # @private
12
- class JSONForHer < Her::Middleware::DefaultParseJSON
13
-
14
- # Overrides Her::Middleware::DefaultParseJSON#parse with a way to bypass
15
- # the default handling of a :metadata key – we want metadata to be handled
16
- # lazily, just like every other attribute, and we don't use the :metadata
17
- # key the way they expect us to.
18
- #
19
- # @see Her::Middleware::DefaultParseJSON#parse
20
- def parse(body)
21
- json = parse_json(body)
22
- errors = json.delete(:errors) || {}
23
- return { :data => json, :errors => errors, :metadata => {} }
24
- end
25
-
26
- # Overrides Her::Middleware::DefaultParseJSON#on_complete with a bail-out
27
- # plan - if the content-type is non-JSON, the JSON processing is skipped.
28
- #
29
- # @see Her::Middleware::DefaultParseJSON#on_complete
30
- def on_complete(env)
31
- env[:response] ||= env[:response_headers] # Faraday forward compatibility with 0.9.x
32
- return env unless env[:response]['content-type'] =~ /\bjson($|;)/
33
- super
34
- end
35
- end
36
- end
37
- end