rogerio-augusto-highrise 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/.gitignore +2 -0
  2. data/CHANGELOG +136 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.mkdn +84 -0
  5. data/Rakefile +40 -0
  6. data/VERSION.yml +5 -0
  7. data/autotest/discover.rb +3 -0
  8. data/examples/config_initializers_highrise.rb +12 -0
  9. data/examples/extending.rb +31 -0
  10. data/examples/sample.rb +10 -0
  11. data/highrise.gemspec +129 -0
  12. data/install.rb +1 -0
  13. data/lib/cachable.rb +83 -0
  14. data/lib/highrise/account.rb +8 -0
  15. data/lib/highrise/base.rb +7 -0
  16. data/lib/highrise/comment.rb +4 -0
  17. data/lib/highrise/company.rb +18 -0
  18. data/lib/highrise/deal.rb +5 -0
  19. data/lib/highrise/deal_category.rb +4 -0
  20. data/lib/highrise/email.rb +9 -0
  21. data/lib/highrise/group.rb +4 -0
  22. data/lib/highrise/kase.rb +8 -0
  23. data/lib/highrise/membership.rb +4 -0
  24. data/lib/highrise/note.rb +9 -0
  25. data/lib/highrise/pagination.rb +29 -0
  26. data/lib/highrise/person.rb +30 -0
  27. data/lib/highrise/subject.rb +25 -0
  28. data/lib/highrise/tag.rb +12 -0
  29. data/lib/highrise/taggable.rb +17 -0
  30. data/lib/highrise/task.rb +11 -0
  31. data/lib/highrise/user.rb +17 -0
  32. data/lib/highrise.rb +22 -0
  33. data/spec/cachable_spec.rb +84 -0
  34. data/spec/highrise/account_spec.rb +16 -0
  35. data/spec/highrise/base_spec.rb +13 -0
  36. data/spec/highrise/comment_spec.rb +14 -0
  37. data/spec/highrise/company_spec.rb +79 -0
  38. data/spec/highrise/deal_category_spec.rb +12 -0
  39. data/spec/highrise/deal_spec.rb +20 -0
  40. data/spec/highrise/email_spec.rb +25 -0
  41. data/spec/highrise/group_spec.rb +14 -0
  42. data/spec/highrise/kase_spec.rb +25 -0
  43. data/spec/highrise/membership_spec.rb +14 -0
  44. data/spec/highrise/note_spec.rb +23 -0
  45. data/spec/highrise/pagination_spec.rb +10 -0
  46. data/spec/highrise/person_spec.rb +96 -0
  47. data/spec/highrise/subject_spec.rb +49 -0
  48. data/spec/highrise/tag_spec.rb +23 -0
  49. data/spec/highrise/task_spec.rb +23 -0
  50. data/spec/highrise/user_spec.rb +35 -0
  51. data/spec/spec.opts +7 -0
  52. data/spec/spec_helper.rb +20 -0
  53. data/uninstall.rb +1 -0
  54. metadata +179 -0
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ pkg/**
2
+ .rvmrc
data/CHANGELOG ADDED
@@ -0,0 +1,136 @@
1
+ Author: Marcos Tapajós <tapajos@gmail.com>
2
+ Date: Wed Aug 25 23:05:00 2010 -0300
3
+
4
+ Version bump to 2.0.1 -- Add Gemspec. It is necessary to use GemBundler with :git => repository...
5
+
6
+ Author: Kenneth Mayer <kmayer@bitwrangler.com>
7
+ Date: Wed Feb 17 09:42:25 2010 -1000
8
+
9
+ Version bump to 2.0.0 -- Complete rewrite of Cachable. Interface has changed, see docs and examples.
10
+
11
+ Author: Kenneth Mayer <kmayer@bitwrangler.com>
12
+ Date: Mon Feb 15 13:41:28 2010 -1000
13
+
14
+ Version bump to 1.2.0
15
+
16
+ Added Account class to handle the /account.xml end point.
17
+
18
+ Author: Marcos Tapajós <tapajos@gmail.com>
19
+ Date: Wed Feb 10 22:57:34 2010 -0200
20
+
21
+ Version bump to 1.1.0 -- Added Deal class, .add_note helper, /me.xml endpoint
22
+
23
+ Author: Kenneth Mayer <kmayer@bitwrangler.com>
24
+ Date: Wed Sep 2 08:56:42 2009 -1000
25
+
26
+ Version bump to 1.0.1
27
+
28
+ Added a couple of convenience methods.
29
+
30
+ Author: Kenneth Mayer <kmayer@bitwrangler.com>
31
+ Date: Tue Sep 1 21:32:19 2009 -1000
32
+
33
+ Version bump to 1.0.0
34
+
35
+ Revised Taggable interface to support new tag API from 37Sigs and (removed curl dependencies)
36
+
37
+ Refactored Cachable
38
+
39
+ Author: Kenneth Mayer <kmayer@bitwrangler.com>
40
+ Date: Fri May 29 22:34:03 2009 -1000
41
+
42
+ Version bump to 0.13.0
43
+
44
+ Added Tag.find_by_name
45
+
46
+ 2009-05-27 Ken Mayer <kmayer@bitwrangler.com>
47
+
48
+ * Version 0.12.0
49
+
50
+ * Added store_options attribute, so fetches will work work with
51
+ :mem_cache_store and :expires_in
52
+
53
+ 2009-05-20 Ken Mayer <kmayer@bitwrangler.com>
54
+
55
+ * Version 0.11.0
56
+
57
+ * Added untag_id! to Taggable, in case you already know the id and don't
58
+ need to search for it again.
59
+
60
+ 2009-05-16 Ken Mayer <kmayer@bitwrangler.com>
61
+
62
+ * Version 0.10.0
63
+
64
+ * Simplified caching store interface, left configuration up to end-user with
65
+ less magic
66
+
67
+ * Removed version.rb module & tests. No one will ever use it, why clutter up
68
+ the code.
69
+
70
+ 2009-05-05 Ken Mayer <kmayer@bitwrangler.com>
71
+
72
+ * Version 0.9.2
73
+
74
+ * Refactored cachable to be more idiomatic ruby
75
+
76
+ * Dropped the SHA1 hashing from cache_key
77
+
78
+ 2009-05-04 Ken Mayer <kmayer@bitwrangler.com>
79
+
80
+ * Version 0.9.0
81
+
82
+ * Changed cache_store= interface to accept :none (to disable caching),
83
+ :rails (to use the default Rails cache, whatever that happens to be), and,
84
+ consequently, restores the lookup_store default behavior (given nil or
85
+ empty options returns a new, default cache_store).
86
+
87
+ * Documentation update. Created and back-filled CHANGELOG
88
+
89
+ 2009-05-01 Ken Mayer <kmayer@bitwrangler.com>
90
+
91
+ * Version 0.8.0
92
+
93
+ * Added caching feature
94
+
95
+ * Added example code
96
+
97
+ * Documentation update
98
+
99
+ * Updated gemspec
100
+
101
+ 2009-04-26 Ken Mayer <kmayer@bitwrangler.com>
102
+
103
+ * Version 0.7.0
104
+
105
+ * Refactored Tag & Taggable so ::Tag is a subclass of Base. This adds
106
+ ::Tag.find(:all) to your quiver of tools. All existing functionality
107
+ passes tests, but the interface to ::Tag.new has changed. You have to
108
+ treat it like all of other ARes, that is, use a Hash (instead of
109
+ positional parameters) to initialize the model.
110
+
111
+ 2009-04-22 Luis Bepop
112
+
113
+ * Version 0.6.3
114
+
115
+ * Support to tags refactored. Include curl helper to improve support for
116
+ objects without ActiveResource base like 'tag' which needs a parse in a
117
+ html document from a httprequest.
118
+
119
+ 2009-04-06 slainer68
120
+
121
+ * Version 0.6.2
122
+
123
+ * Modularize Taggable
124
+
125
+ 2009-03-31 ThiagoLelis
126
+
127
+ * Version 0.6.1
128
+
129
+ * Add Person.tag that show a array of tags, and Perton.tag(name), add a new
130
+ tag to a person.
131
+
132
+ 2009-01-14 Marcos Tapajós
133
+
134
+ * Version 0.5.0
135
+
136
+ * Initial import
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Ken Mayer & Marcos Tapajos
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.mkdn ADDED
@@ -0,0 +1,84 @@
1
+ # Highrise (2.0.0)
2
+
3
+ ## What is it?
4
+
5
+ This gem provides a set of classes to access information on [Highrise][h] via the published [API][api]:
6
+
7
+ Account, Comment, Company, Deal, DealCategory, Email, Group, Case, Membership, Note, Person, Subject, Tag, Task, User.
8
+
9
+ All these classes are inherited from ActiveResouce::Base. Refer to the [ActiveResouce][ar] documentation for more information.
10
+
11
+ ## Installing
12
+
13
+ gem install highrise
14
+
15
+ ### Dependencies (see the Rakefile or run <code>rake check_dependencies</code>)
16
+
17
+ ### Documentation
18
+
19
+ I'm on [rdoc.info][rdoc] and here're some [metrics][caliper]
20
+
21
+ ### Configure your key
22
+
23
+ require 'rubygems'
24
+ require 'highrise'
25
+
26
+ Highrise::Base.site = 'http://your_site.highrisehq.com'
27
+ Highrise::Base.user = 'api-auth-token'
28
+
29
+ and, if you want [caching][c]:
30
+
31
+ Highrise::Base.connection.cache_store= <your normal ActiveSupport::Caching options>
32
+
33
+ If you are using this in a Rails application, putting this code in a config/initializers/highrise.rb
34
+ file is recommended. See config_initializers_highrise.rb in the examples/ directory.
35
+
36
+ ## Usage
37
+
38
+ @tags = Highrise::Tag.find(:all)
39
+
40
+ @people = Highrise::Person.find_all_across_pages(:params => {:tag_id => 12345})
41
+
42
+ @person.tag!("VIP")
43
+
44
+ ## License
45
+
46
+ This code is free to be used under the terms of the [MIT license][mit].
47
+
48
+ ## Bugs, Issues, Kudos and Catcalls
49
+
50
+ Comments are welcome. Send your feedback through the [issue tracker on GitHub][i]
51
+
52
+ ## Authors
53
+
54
+ * [Marcos Tapajós][mt]
55
+ * [Ken Mayer][km]
56
+
57
+ ## Contributors
58
+
59
+ * [Nicolas Bianco][nb]
60
+ * [Luis Gustavo][lg]
61
+ * [Thiago Lelis][tl]
62
+
63
+ ## Special Thanks
64
+
65
+ [Rails Envy Podcast Episode #77][re] for mentioning
66
+ [How to Cache Anything With ActiveSupport][rh] on the very *day* I started writing the cache code. Thank you, Rein
67
+ for writing an excellent tutorial and [posting your source][e] on GitHub.
68
+
69
+ [api]: http://developer.37signals.com/highrise
70
+ [ar]: http://api.rubyonrails.org/classes/ActiveResource/Base.html
71
+ [c]: http://api.rubyonrails.org/classes/ActiveSupport/Cache
72
+ [e]: http://github.com/primedia/endeca/tree/master
73
+ [h]: http://www.highrisehq.com/
74
+ [i]: http://github.com/tapajos/highrise/issues
75
+ [km]: http://github.com/kmayer
76
+ [lg]: http://github.com/luisbebop
77
+ [mit]:http://www.opensource.org/licenses/mit-license.php
78
+ [mt]: http://www.improveit.com.br/en/company/tapajos
79
+ [nb]: http://github.com/slainer86
80
+ [re]: http://www.railsenvy.com/2009/4/29/rails-envy-podcast-episode-077-04-29-2009
81
+ [rh]: http://reinh.com/blog/2009/04/27/how-to-cache-anything-with-activesupport.html
82
+ [tl]: http://github.com/ThiagoLelis
83
+ [rdoc]: http://rdoc.info/projects/tapajos/highrise
84
+ [caliper]: https://devver.net/caliper/project?repo=git%3A%2F%2Fgithub.com%2Ftapajos%2Fhighrise.git
data/Rakefile ADDED
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+
3
+ gem 'rspec', ">= 1.3.0"
4
+ require 'spec/rake/spectask'
5
+
6
+ begin
7
+ require 'jeweler'
8
+ Jeweler::Tasks.new do |gemspec|
9
+ gemspec.name = "highrise"
10
+ gemspec.summary = "Ruby wrapper around Highrise API"
11
+ gemspec.email = ["marcos@tapajos.me", "kmayer@bitwrangler.com"]
12
+ gemspec.homepage = "http://github.com/tapajos/highrise"
13
+ gemspec.description = %{
14
+ Based on the original API module from DHH, http://developer.37signals.com/highrise/, this
15
+ gem is a cleaned up, tested version of the same. Contributors have added support for tags
16
+ which are not supported by the API directly
17
+
18
+ Configure by adding the following:
19
+
20
+ require 'highrise'
21
+ Highrise::Base.site = 'http://your_site.highrisehq.com/'
22
+ Highrise::Base.user = 'your_api_auth_token'
23
+ }
24
+ gemspec.authors = ["Marcos Tapajós", "Ken Mayer"]
25
+ gemspec.add_dependency('activeresource', '>= 2.1')
26
+ gemspec.add_dependency('activesupport', '>= 2.1')
27
+ end
28
+ Jeweler::GemcutterTasks.new
29
+ rescue LoadError
30
+ puts "Jeweler not available. Install it with: sudo gem install jeweler"
31
+ end
32
+
33
+ desc 'Default: run unit tests.'
34
+ task :default => :spec
35
+
36
+ desc "Run all specs"
37
+ Spec::Rake::SpecTask.new do |t|
38
+ t.spec_files = FileList['spec/**/*_spec.rb']
39
+ t.spec_opts = ['--options', 'spec/spec.opts']
40
+ end
data/VERSION.yml ADDED
@@ -0,0 +1,5 @@
1
+ ---
2
+ :major: 2
3
+ :minor: 0
4
+ :build:
5
+ :patch: 1
@@ -0,0 +1,3 @@
1
+ Autotest.add_discovery do
2
+ "rspec"
3
+ end
@@ -0,0 +1,12 @@
1
+ if Rails.env != 'test' then
2
+ Highrise::Base.site = 'https://example.com.i'
3
+ # For backward compatability
4
+ if Highrise::Base.respond_to? :user
5
+ Highrise::Base.user = 'my_fancy_auth_token'
6
+ else
7
+ Highrise::Base.site = 'https://my_fancy_auth_token@example.com.i'
8
+ end
9
+ # The cache store can be anything that ActiveSupport can handle
10
+ Highrise::Base.connection.cache_store = ActiveSupport::Cache.lookup_store :mem_cache_store
11
+ Highrise::Base.connection.store_options = { :expires_in => 60.seconds }
12
+ end
@@ -0,0 +1,31 @@
1
+ #
2
+ # Example of extending a class when you need to synthesize an attribute.
3
+ #
4
+ # Adds Highrise::Person.{phone,fax,email} to the Person class inside your
5
+ # module
6
+ #
7
+
8
+ module MyModule
9
+ include Highrise
10
+
11
+ Highrise::Person.class_eval do
12
+ class << self
13
+ def lookup(id, list, item, location)
14
+ module_eval <<-EOT
15
+ def #{id}
16
+ contact_data.#{list}.each do |i|
17
+ return i.#{item}.strip if i.location == "#{location}"
18
+ end
19
+ ''
20
+ end
21
+ EOT
22
+ end
23
+
24
+ private :lookup
25
+ end
26
+
27
+ lookup(:phone, 'phone_numbers', 'number', 'Work')
28
+ lookup(:fax, 'phone_numbers', 'number', 'Fax')
29
+ lookup(:email, 'email_addresses', 'address', 'Work')
30
+ end
31
+ end
@@ -0,0 +1,10 @@
1
+ require 'highrise'
2
+ require 'pp'
3
+
4
+ Highrise::Base.site = 'https://yoursite.highrisehq.com'
5
+ Highrise::Base.user = 'xxx'
6
+ Highrise::Base.connection.cache_store = :memory_store
7
+
8
+ @tags = Highrise::Tag.find(:all)
9
+
10
+ pp @tags
data/highrise.gemspec ADDED
@@ -0,0 +1,129 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{rogerio-augusto-highrise}
8
+ s.version = "2.0.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Marcos Tapaj\303\263s", "Ken Mayer"]
12
+ s.date = %q{2010-08-25}
13
+ s.description = %q{
14
+ Based on the original API module from DHH, http://developer.37signals.com/highrise/, this
15
+ gem is a cleaned up, tested version of the same. Contributors have added support for tags
16
+ which are not supported by the API directly
17
+
18
+ Configure by adding the following:
19
+
20
+ require 'highrise'
21
+ Highrise::Base.site = 'http://your_site.highrisehq.com/'
22
+ Highrise::Base.user = 'your_api_auth_token'
23
+ }
24
+ s.email = ["marcos@tapajos.me", "kmayer@bitwrangler.com"]
25
+ s.extra_rdoc_files = [
26
+ "README.mkdn"
27
+ ]
28
+ s.files = [
29
+ ".gitignore",
30
+ "CHANGELOG",
31
+ "MIT-LICENSE",
32
+ "README.mkdn",
33
+ "Rakefile",
34
+ "VERSION.yml",
35
+ "autotest/discover.rb",
36
+ "examples/config_initializers_highrise.rb",
37
+ "examples/extending.rb",
38
+ "examples/sample.rb",
39
+ "highrise.gemspec",
40
+ "install.rb",
41
+ "lib/cachable.rb",
42
+ "lib/highrise.rb",
43
+ "lib/highrise/account.rb",
44
+ "lib/highrise/base.rb",
45
+ "lib/highrise/comment.rb",
46
+ "lib/highrise/company.rb",
47
+ "lib/highrise/deal.rb",
48
+ "lib/highrise/deal_category.rb",
49
+ "lib/highrise/email.rb",
50
+ "lib/highrise/group.rb",
51
+ "lib/highrise/kase.rb",
52
+ "lib/highrise/membership.rb",
53
+ "lib/highrise/note.rb",
54
+ "lib/highrise/pagination.rb",
55
+ "lib/highrise/person.rb",
56
+ "lib/highrise/subject.rb",
57
+ "lib/highrise/tag.rb",
58
+ "lib/highrise/taggable.rb",
59
+ "lib/highrise/task.rb",
60
+ "lib/highrise/user.rb",
61
+ "spec/cachable_spec.rb",
62
+ "spec/highrise/account_spec.rb",
63
+ "spec/highrise/base_spec.rb",
64
+ "spec/highrise/comment_spec.rb",
65
+ "spec/highrise/company_spec.rb",
66
+ "spec/highrise/deal_spec.rb",
67
+ "spec/highrise/deal_category_spec.rb",
68
+ "spec/highrise/email_spec.rb",
69
+ "spec/highrise/group_spec.rb",
70
+ "spec/highrise/kase_spec.rb",
71
+ "spec/highrise/membership_spec.rb",
72
+ "spec/highrise/note_spec.rb",
73
+ "spec/highrise/pagination_spec.rb",
74
+ "spec/highrise/person_spec.rb",
75
+ "spec/highrise/subject_spec.rb",
76
+ "spec/highrise/tag_spec.rb",
77
+ "spec/highrise/task_spec.rb",
78
+ "spec/highrise/user_spec.rb",
79
+ "spec/spec.opts",
80
+ "spec/spec_helper.rb",
81
+ "uninstall.rb"
82
+ ]
83
+ s.homepage = %q{http://github.com/tapajos/highrise}
84
+ s.rdoc_options = ["--charset=UTF-8"]
85
+ s.require_paths = ["lib"]
86
+ s.rubygems_version = %q{1.3.7}
87
+ s.summary = %q{Ruby wrapper around Highrise API}
88
+ s.test_files = [
89
+ "spec/cachable_spec.rb",
90
+ "spec/highrise/account_spec.rb",
91
+ "spec/highrise/base_spec.rb",
92
+ "spec/highrise/comment_spec.rb",
93
+ "spec/highrise/company_spec.rb",
94
+ "spec/highrise/deal_spec.rb",
95
+ "spec/highrise/deal_category_spec.rb",
96
+ "spec/highrise/email_spec.rb",
97
+ "spec/highrise/group_spec.rb",
98
+ "spec/highrise/kase_spec.rb",
99
+ "spec/highrise/membership_spec.rb",
100
+ "spec/highrise/note_spec.rb",
101
+ "spec/highrise/pagination_spec.rb",
102
+ "spec/highrise/person_spec.rb",
103
+ "spec/highrise/subject_spec.rb",
104
+ "spec/highrise/tag_spec.rb",
105
+ "spec/highrise/task_spec.rb",
106
+ "spec/highrise/user_spec.rb",
107
+ "spec/spec_helper.rb",
108
+ "examples/config_initializers_highrise.rb",
109
+ "examples/extending.rb",
110
+ "examples/sample.rb"
111
+ ]
112
+
113
+ if s.respond_to? :specification_version then
114
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
115
+ s.specification_version = 3
116
+
117
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
118
+ s.add_runtime_dependency(%q<activeresource>, [">= 2.1"])
119
+ s.add_runtime_dependency(%q<activesupport>, [">= 2.1"])
120
+ else
121
+ s.add_dependency(%q<activeresource>, [">= 2.1"])
122
+ s.add_dependency(%q<activesupport>, [">= 2.1"])
123
+ end
124
+ else
125
+ s.add_dependency(%q<activeresource>, [">= 2.1"])
126
+ s.add_dependency(%q<activesupport>, [">= 2.1"])
127
+ end
128
+ end
129
+
data/install.rb ADDED
@@ -0,0 +1 @@
1
+ # Install hook code here
data/lib/cachable.rb ADDED
@@ -0,0 +1,83 @@
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
@@ -0,0 +1,8 @@
1
+ module Highrise
2
+ class Account < Base
3
+ def self.me
4
+ user = Account.new()
5
+ find(:one, :from => "/account.xml")
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ require File.dirname(__FILE__) + '/../cachable'
2
+
3
+ module Highrise
4
+ class Base < ActiveResource::Base
5
+ include ::Cachable
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ module Highrise
2
+ class Comment < Base
3
+ end
4
+ end
@@ -0,0 +1,18 @@
1
+ module Highrise
2
+ class Company < Subject
3
+ include Pagination
4
+ include Taggable
5
+
6
+ def self.find_all_across_pages_since(time)
7
+ find_all_across_pages(:params => { :since => time.utc.to_s(:db).gsub(/[^\d]/, '') })
8
+ end
9
+
10
+ def people
11
+ Person.find(:all, :from => "/companies/#{id}/people.xml")
12
+ end
13
+
14
+ def label
15
+ 'Party'
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ module Highrise
2
+ class Deal < Subject
3
+
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ module Highrise
2
+ class DealCategory < Base
3
+ end
4
+ end
@@ -0,0 +1,9 @@
1
+ module Highrise
2
+ class Email < Base
3
+ include Pagination
4
+
5
+ def comments
6
+ Comment.find(:all, :from => "/emails/#{email_id}/comments.xml")
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,4 @@
1
+ module Highrise
2
+ class Group < Base
3
+ end
4
+ end
@@ -0,0 +1,8 @@
1
+ module Highrise
2
+ class Kase < Subject
3
+ def close!
4
+ self.closed_at = Time.now.utc
5
+ save
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,4 @@
1
+ module Highrise
2
+ class Membership < Base
3
+ end
4
+ end
@@ -0,0 +1,9 @@
1
+ module Highrise
2
+ class Note < Base
3
+ include Pagination
4
+
5
+ def comments
6
+ Comment.find(:all, :from => "/notes/#{id}/comments.xml")
7
+ end
8
+ end
9
+ end