cardiac 0.2.0.pre8 → 0.2.0.pre9

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/lib/cardiac/model/declarations.rb +4 -2
  3. data/lib/cardiac/railtie.rb +10 -0
  4. data/lib/cardiac/resource/builder.rb +4 -0
  5. data/lib/cardiac/util.rb +3 -2
  6. data/lib/cardiac/version.rb +1 -1
  7. data/spec/rails-3.2/Gemfile.lock +11 -11
  8. data/spec/rails-3.2/app_root/app/models/dummy.rb +7 -0
  9. data/spec/rails-3.2/app_root/log/test.log +11165 -0
  10. data/spec/rails-4.2/Gemfile +9 -0
  11. data/spec/rails-4.2/Gemfile.lock +157 -0
  12. data/spec/{rails-4.0 → rails-4.2}/Rakefile +0 -0
  13. data/spec/{rails-4.0 → rails-4.2}/app_root/app/assets/javascripts/application.js +0 -0
  14. data/spec/{rails-4.0 → rails-4.2}/app_root/app/assets/stylesheets/application.css +0 -0
  15. data/spec/{rails-4.0 → rails-4.2}/app_root/app/controllers/application_controller.rb +0 -0
  16. data/spec/{rails-4.0 → rails-4.2}/app_root/app/helpers/application_helper.rb +0 -0
  17. data/spec/rails-4.2/app_root/app/models/dummy.rb +7 -0
  18. data/spec/{rails-4.0 → rails-4.2}/app_root/app/views/layouts/application.html.erb +0 -0
  19. data/spec/{rails-4.0 → rails-4.2}/app_root/config/application.rb +0 -0
  20. data/spec/{rails-4.0 → rails-4.2}/app_root/config/boot.rb +0 -0
  21. data/spec/{rails-4.0 → rails-4.2}/app_root/config/database.yml +0 -0
  22. data/spec/{rails-4.0 → rails-4.2}/app_root/config/environment.rb +0 -0
  23. data/spec/{rails-4.0 → rails-4.2}/app_root/config/environments/development.rb +0 -0
  24. data/spec/{rails-4.0 → rails-4.2}/app_root/config/environments/production.rb +1 -1
  25. data/spec/{rails-4.0 → rails-4.2}/app_root/config/environments/test.rb +1 -1
  26. data/spec/{rails-4.0 → rails-4.2}/app_root/config/initializers/backtrace_silencers.rb +0 -0
  27. data/spec/{rails-4.0 → rails-4.2}/app_root/config/initializers/inflections.rb +0 -0
  28. data/spec/{rails-4.0 → rails-4.2}/app_root/config/initializers/mime_types.rb +0 -0
  29. data/spec/{rails-4.0 → rails-4.2}/app_root/config/initializers/secret_token.rb +0 -0
  30. data/spec/{rails-4.0 → rails-4.2}/app_root/config/initializers/session_store.rb +0 -0
  31. data/spec/{rails-4.0 → rails-4.2}/app_root/config/initializers/wrap_parameters.rb +0 -0
  32. data/spec/{rails-4.0 → rails-4.2}/app_root/config/locales/en.yml +0 -0
  33. data/spec/{rails-4.0 → rails-4.2}/app_root/config/routes.rb +0 -0
  34. data/spec/{rails-4.0 → rails-4.2}/app_root/db/test.sqlite3 +0 -0
  35. data/spec/{rails-4.0 → rails-4.2}/app_root/log/development.log +0 -0
  36. data/spec/{rails-4.0 → rails-4.2}/app_root/log/test.log +11097 -0
  37. data/spec/{rails-4.0 → rails-4.2}/app_root/public/404.html +0 -0
  38. data/spec/{rails-4.0 → rails-4.2}/app_root/public/422.html +0 -0
  39. data/spec/{rails-4.0 → rails-4.2}/app_root/public/500.html +0 -0
  40. data/spec/{rails-4.0 → rails-4.2}/app_root/public/favicon.ico +0 -0
  41. data/spec/{rails-4.0 → rails-4.2}/app_root/script/rails +0 -0
  42. data/spec/{rails-4.0 → rails-4.2}/spec/spec_helper.rb +0 -0
  43. data/spec/shared/cardiac/model/base_spec.rb +3 -360
  44. data/spec/shared/cardiac/model/declarations_spec.rb +74 -0
  45. data/spec/shared/cardiac/model/persistence_spec.rb +179 -0
  46. data/spec/shared/cardiac/model/querying_spec.rb +144 -0
  47. metadata +76 -66
  48. data/spec/rails-4.0/Gemfile +0 -9
  49. data/spec/rails-4.0/Gemfile.lock +0 -132
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a64ebdb5e3d7c84014a482fcd37f11a3d0ca5aa
4
- data.tar.gz: 030d065a6799a43cc0be72f5966739a836644703
3
+ metadata.gz: 5fb4366a0918ce0607b3ebcfd481618c9433cb72
4
+ data.tar.gz: 4bdf1442aad5d3ffb9722dabf6c0a6a4cd6d03fe
5
5
  SHA512:
6
- metadata.gz: 38c93e3c1226a490a0db649e7c56e765439ed4ea15e45d1d402a5e2a0616a4c65b6f88f24c046c50f05d5b54efd763489924400f591b178142eb1c14f8971336
7
- data.tar.gz: 8dbac010606ffffa29850f908ce53ed683ed572842240864fa0c8aaae06a2b071465744249169917d2450120c46724607b0762924cd2415a874028dff2092055
6
+ metadata.gz: 32faed90e5e2b90998026ebe79db65382bace7fde17a8a8af382fc43ff8fe291f8e2f293e76e2ef265135c120c855881ae1341aaa8ed47cc5ea1a6a832b9c9c8
7
+ data.tar.gz: 5a370a11eeccff0d0a53aee2bdd99d05493b3e2d1531eee4c15ad364992591355f95a16d0075aaffcf1ca97ec4ae724b2f2fde267b228ad3d54b94378f0a7144
@@ -22,10 +22,12 @@ module Cardiac
22
22
 
23
23
  ##
24
24
  # :method: identify
25
+ #
25
26
  # This member identifies a singular subresource by converting the given argument
26
- # to a parameter and appending it to the path.
27
+ # to a parameter and appending it to the path. Parameters are properly CGI escaped.
28
+ #
27
29
  # This member is used by all query/persistence methods that operate on existing records.
28
- subresource :identify, lambda{|id_or_model| path(id_or_model.to_param) } do
30
+ subresource :identify, lambda{|id_or_model| path(Array(id_or_model).map{|v| CGI.escape(v.to_param)}.to_param) } do
29
31
 
30
32
  ##
31
33
  # :method: update_instance
@@ -80,6 +80,16 @@ module Cardiac
80
80
  self.logger ||= ::Rails.logger
81
81
  end
82
82
  end
83
+
84
+ # Rails 4.2+, or when the GlobalID gem is explicitly loaded.
85
+ initializer 'cardiac_model.global_id' do
86
+ ActiveSupport.on_load(:cardiac_model) do
87
+ if defined? ::GlobalID
88
+ require 'global_id/identification'
89
+ send :include, ::GlobalID::Identification
90
+ end
91
+ end
92
+ end
83
93
 
84
94
  # Make sure that the model layer is already available when running a script.
85
95
  runner do
@@ -1,3 +1,5 @@
1
+ require 'delegate'
2
+
1
3
  module Cardiac
2
4
  class ResourceBuilder < Proxy
3
5
 
@@ -6,6 +8,8 @@ module Cardiac
6
8
  @base, @extensions, @extension_block = base, extensions, extension_block
7
9
  @extensions.compact!
8
10
  end
11
+
12
+ delegate :to_url, :to_uri, :to_relative_uri, :to_relative_url, to: :__subresource__
9
13
 
10
14
  # Returns a copy of our subresource.
11
15
  def to_resource
data/lib/cardiac/util.rb CHANGED
@@ -28,12 +28,13 @@ module Cardiac
28
28
  # Base proxy class.
29
29
  #
30
30
  # On Ruby 2.0 and above, we can use ActiveSupport's ProxyObject, otherwise we must use BlankSlate.
31
- class Proxy < (RUBY_VERSION>='2.0' && defined?(::ActiveSupport::ProxyObject) ? ::ActiveSupport::ProxyObject : ::BlankSlate)
31
+ class Proxy < (::RUBY_VERSION>='2.0' && defined?(::ActiveSupport::ProxyObject) ? ::ActiveSupport::ProxyObject : ::BlankSlate)
32
32
 
33
33
  # We at least would like some basics here.
34
- %w(kind_of? is_a? inspect class method send).each do |k|
34
+ %w(kind_of? is_a? inspect class method send Array).each do |k|
35
35
  define_method k, ::Kernel.instance_method(k)
36
36
  end
37
+ define_method :Hash, ::Kernel.instance_method(:Hash) if ::RUBY_VERSION>='2.0'
37
38
  %w(class extend send object_id public_send).each do |k|
38
39
  define_method :"__#{k}__", ::Kernel.instance_method(k)
39
40
  end
@@ -1,3 +1,3 @@
1
1
  module Cardiac
2
- VERSION = '0.2.0.pre8'
2
+ VERSION = '0.2.0.pre9'
3
3
  end
@@ -1,17 +1,17 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- cardiac (0.2.0.pre6)
5
- active_attr (>= 0.8.2)
6
- activemodel (>= 3.2, < 4.1)
7
- activesupport (>= 3.2, < 4.1)
4
+ cardiac (0.2.0.pre9)
5
+ active_attr (~> 0.8, >= 0.8.2)
6
+ activemodel (>= 3.2, < 5.0)
7
+ activesupport (>= 3.2, < 5.0)
8
8
  i18n (~> 0.6, >= 0.6.4)
9
- json (> 1.8.0)
10
- mime-types (> 1.1)
9
+ json (~> 1.8, > 1.8.0)
10
+ mime-types (~> 1.1, > 1.1)
11
11
  multi_json (~> 1.0)
12
- rack (>= 1.4.5)
12
+ rack (~> 1.4, >= 1.4.5)
13
13
  rack-cache (~> 1.2)
14
- rack-client (~> 0.4.2)
14
+ rack-client (~> 0.4, >= 0.4.2)
15
15
 
16
16
  GEM
17
17
  remote: http://rubygems.org/
@@ -29,9 +29,9 @@ GEM
29
29
  rack-cache (~> 1.2)
30
30
  rack-test (~> 0.6.1)
31
31
  sprockets (~> 2.2.1)
32
- active_attr (0.8.4)
33
- activemodel (>= 3.0.2, < 4.2)
34
- activesupport (>= 3.0.2, < 4.2)
32
+ active_attr (0.8.5)
33
+ activemodel (>= 3.0.2, < 5.0)
34
+ activesupport (>= 3.0.2, < 5.0)
35
35
  activemodel (3.2.19)
36
36
  activesupport (= 3.2.19)
37
37
  builder (~> 3.0.0)
@@ -0,0 +1,7 @@
1
+ class Dummy < Cardiac::Model::Base
2
+ self.base_resource = 'http://localhost/dummy'
3
+
4
+ attribute :id, type: Integer
5
+ attribute :name, type: String
6
+
7
+ end