highrise 2.0.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/Gemfile +3 -0
  2. data/Gemfile.lock +38 -0
  3. data/MIT-LICENSE +1 -1
  4. data/README.mkdn +21 -29
  5. data/Rakefile +6 -31
  6. data/autotest/discover.rb +1 -3
  7. data/examples/config_initializers_highrise.rb +1 -9
  8. data/examples/sample.rb +0 -1
  9. data/highrise.gemspec +24 -117
  10. data/lib/highrise.rb +6 -5
  11. data/lib/highrise/account.rb +0 -1
  12. data/lib/highrise/base.rb +15 -3
  13. data/lib/highrise/comment.rb +1 -2
  14. data/lib/highrise/company.rb +3 -2
  15. data/lib/highrise/deal.rb +4 -1
  16. data/lib/highrise/deal_category.rb +3 -0
  17. data/lib/highrise/group.rb +1 -2
  18. data/lib/highrise/kase.rb +13 -2
  19. data/lib/highrise/membership.rb +1 -2
  20. data/lib/highrise/pagination.rb +8 -1
  21. data/lib/highrise/party.rb +11 -0
  22. data/lib/highrise/person.rb +1 -4
  23. data/lib/highrise/recording.rb +5 -0
  24. data/lib/highrise/searchable.rb +22 -0
  25. data/lib/highrise/subject.rb +6 -0
  26. data/lib/highrise/tag.rb +0 -5
  27. data/lib/highrise/taggable.rb +4 -1
  28. data/lib/highrise/task_category.rb +3 -0
  29. data/lib/highrise/version.rb +3 -0
  30. data/spec/highrise/account_spec.rb +5 -11
  31. data/spec/highrise/base_spec.rb +45 -10
  32. data/spec/highrise/comment_spec.rb +2 -11
  33. data/spec/highrise/company_spec.rb +10 -72
  34. data/spec/highrise/deal_category_spec.rb +13 -0
  35. data/spec/highrise/deal_spec.rb +16 -13
  36. data/spec/highrise/email_spec.rb +7 -19
  37. data/spec/highrise/group_spec.rb +2 -11
  38. data/spec/highrise/kase_spec.rb +10 -18
  39. data/spec/highrise/membership_spec.rb +2 -11
  40. data/spec/highrise/note_spec.rb +8 -17
  41. data/spec/highrise/pagination_behavior.rb +20 -0
  42. data/spec/highrise/pagination_spec.rb +4 -6
  43. data/spec/highrise/party_spec.rb +16 -0
  44. data/spec/highrise/person_spec.rb +23 -80
  45. data/spec/highrise/recording_spec.rb +13 -0
  46. data/spec/highrise/searchable_behavior.rb +13 -0
  47. data/spec/highrise/searchable_spec.rb +8 -0
  48. data/spec/highrise/subject_spec.rb +20 -35
  49. data/spec/highrise/tag_spec.rb +8 -13
  50. data/spec/highrise/taggable_behavior.rb +27 -0
  51. data/spec/highrise/taggable_spec.rb +9 -0
  52. data/spec/highrise/task_category_spec.rb +13 -0
  53. data/spec/highrise/task_spec.rb +6 -18
  54. data/spec/highrise/user_spec.rb +11 -28
  55. data/spec/spec_helper.rb +9 -18
  56. metadata +55 -42
  57. data/CHANGELOG +0 -131
  58. data/VERSION.yml +0 -5
  59. data/install.rb +0 -1
  60. data/lib/cachable.rb +0 -83
  61. data/spec/cachable_spec.rb +0 -84
  62. data/spec/spec.opts +0 -7
  63. data/uninstall.rb +0 -1
data/VERSION.yml DELETED
@@ -1,5 +0,0 @@
1
- ---
2
- :major: 2
3
- :minor: 0
4
- :build:
5
- :patch: 1
data/install.rb DELETED
@@ -1 +0,0 @@
1
- # Install hook code here
data/lib/cachable.rb DELETED
@@ -1,83 +0,0 @@
1
- # Caching is a way to speed up slow ActiveResource queries by keeping the result of
2
- # a request around to be reused by subsequent requests.
3
- #
4
- # Caching is turned OFF by default.
5
- #
6
- # == Usage
7
- #
8
- # require 'cachable'
9
- #
10
- # module CachedResource < ActiveResource::Base
11
- # include ::Cachable
12
- # end
13
- #
14
- #
15
- # == Caching stores
16
- #
17
- # All the caching stores from ActiveSupport::Cache are available
18
- # as backends for caching. See the Rails rdoc for more information on
19
- # these stores
20
- #
21
- # === Configuration examples ('off' is the default):
22
- # CachedResource.connection.cache_store = ActiveSupport::Cache.lookup_store :memory_store
23
- # CachedResource.connection.cache_store = ActiveSupport::Cache.lookup_store :file_store, "/path/to/cache/directory"
24
- # CachedResource.connection.cache_store = ActiveSupport::Cache.lookup_store :drb_store, "druby://localhost:9192"
25
- # CachedResource.connection.cache_store = ActiveSupport::Cache.lookup_store :mem_cache_store, "localhost"
26
- # CachedResource.connection.cache_store = MyOwnStore.new("parameter")
27
- #
28
- # === If you are using a store that has write options, you can set them
29
- # CachedResource.connection.cache_options = { :expires_in => 60.seconds }
30
- #
31
- # Note: To ensure that caching is turned off, set CachedResource.connection.cache_store = nil
32
- #
33
- # FYI: You can use this with *any* active resource class, not just Highrise.
34
-
35
- module Cachable
36
- def self.included(base)
37
- ActiveResource::Connection.class_eval do
38
- def cache_store
39
- @cache_store ||= nil
40
- end
41
-
42
- def cache_store=(store)
43
- @cache_store = store
44
- end
45
-
46
- def cache_options
47
- @cache_options ||= {}
48
- end
49
- alias :store_options :cache_options
50
-
51
- def cache_options=(options)
52
- @cache_options = options
53
- end
54
- alias :store_options= :cache_options=
55
-
56
- def is_caching?
57
- !@cache_store.nil?
58
- end
59
-
60
- def get_with_cache(path, headers = {})
61
- return get_without_cache(path, headers) unless is_caching?
62
- cache_store.fetch(cache_key(path), cache_options) {get_without_cache(path, headers)}
63
- end
64
- alias_method_chain :get, :cache
65
-
66
- def put_with_cache(path, body = '', headers = {})
67
- cache_store.delete(cache_key(path))
68
- put_without_cache(path, body, headers)
69
- end
70
- alias_method_chain :put, :cache
71
-
72
- def delete_with_cache(path, headers = {})
73
- cache_store.delete(cache_key(path))
74
- delete_without_cache(path, headers)
75
- end
76
- alias_method_chain :delete, :cache
77
-
78
- def cache_key(*args)
79
- args.join(':')
80
- end
81
- end
82
- end
83
- end
@@ -1,84 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- class CachedResource < ActiveResource::Base
4
- include ::Cachable
5
- end
6
-
7
- describe CachedResource, "class configuration" do
8
- before(:each) do
9
- CachedResource.site = 'http://example.com.i:3000'
10
- end
11
-
12
- it "should tell us if caching is active" do
13
- CachedResource.connection.cache_store = ActiveSupport::Cache.lookup_store :memory_store
14
- CachedResource.connection.is_caching?.should == true
15
- end
16
-
17
- it "should tell us if caching is not active" do
18
- CachedResource.connection.cache_store = nil
19
- CachedResource.connection.is_caching?.should == false
20
- end
21
- end
22
-
23
- describe CachedResource do
24
- before(:all) do
25
- CachedResource.site = 'http://example.com.i:3000'
26
- CachedResource.connection.cache_store = ActiveSupport::Cache.lookup_store :memory_store
27
- end
28
-
29
- after(:all) do
30
- CachedResource.connection.cache_store = :none
31
- end
32
-
33
- before(:each) do
34
- @thing = CachedResource.new(:id => 1)
35
- @key = :key
36
- CachedResource.connection.stub!(:cache_key).and_return(@key)
37
- end
38
-
39
- context "when a cached response is available" do
40
- before(:each) do
41
- CachedResource.connection.cache_store.write(@key, @thing.attributes)
42
- end
43
-
44
- it "should NOT make a request to the RESTful server" do
45
- CachedResource.connection.should_not_receive(:get_without_cache)
46
- CachedResource.find(1)
47
- end
48
-
49
- it "should read from the cache" do
50
- CachedResource.find(1).should == @thing
51
- end
52
-
53
- it "should delete from the cache when an object is DELETEd" do
54
- CachedResource.connection.should_receive(:delete_without_cache)
55
- CachedResource.delete(1)
56
- CachedResource.connection.cache_store.read(@key).should == nil
57
- end
58
-
59
- it "should delete from the cache when an object is modified" do
60
- thing = CachedResource.find(1)
61
- thing.stub(:load_attributes_from_response).and_return(@thing.attributes)
62
- CachedResource.connection.should_receive(:put_without_cache)
63
- thing.save
64
- CachedResource.connection.cache_store.read(@key).should == nil
65
- end
66
- end
67
-
68
- context "when a cached response is NOT available" do
69
- before(:each) do
70
- CachedResource.connection.cache_store.delete(@key)
71
- end
72
-
73
- it "SHOULD perform an ActiveResource request" do
74
- CachedResource.connection.should_receive(:get_without_cache).and_return(@thing.attributes)
75
- CachedResource.find(1)
76
- end
77
-
78
- it "should cache the response using the caching key" do
79
- CachedResource.connection.should_receive(:get_without_cache).and_return(@thing.attributes)
80
- CachedResource.find(1)
81
- CachedResource.connection.cache_store.read(@key).should == @thing.attributes
82
- end
83
- end
84
- end
data/spec/spec.opts DELETED
@@ -1,7 +0,0 @@
1
- --colour
2
- --format
3
- progress
4
- --loadby
5
- mtime
6
- --reverse
7
- -rubygems
data/uninstall.rb DELETED
@@ -1 +0,0 @@
1
- # Uninstall hook code here