highrise 1.0.4 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  pkg/**
2
+ highrise.gemspec
@@ -1,10 +1,10 @@
1
- # Highrise (1.0)
1
+ # Highrise (1.2.0)
2
2
 
3
3
  ## What is it?
4
4
 
5
5
  This gem provides a set of classes to access information on [Highrise][h] via the published [API][api]:
6
6
 
7
- Comment, Company, Email, Group, Case, Membership, Note, Person, Subject, Tag, Task, User.
7
+ Account, Comment, Company, Deal, Email, Group, Case, Membership, Note, Person, Subject, Tag, Task, User.
8
8
 
9
9
  All these classes are inherited from ActiveResouce::Base. Refer to the [ActiveResouce][ar] documentation for more information.
10
10
 
@@ -16,17 +16,13 @@ All these classes are inherited from ActiveResouce::Base. Refer to the [ActiveRe
16
16
 
17
17
  ### Documentation
18
18
 
19
- I'm on [rdoc.info][rdoc] and here're some [metrics][devver]
19
+ I'm on [rdoc.info][rdoc] and here're some [metrics][caliper]
20
20
 
21
21
  ### Configure your key
22
22
 
23
23
  require 'rubygems'
24
24
  require 'highrise'
25
25
 
26
- Highrise::Base.site = 'http://your_api:login@your_site.highrisehq.com/'
27
-
28
- or
29
-
30
26
  Highrise::Base.site = 'http://your_site.highrisehq.com'
31
27
  Highrise::Base.user = 'api-auth-token'
32
28
 
@@ -64,10 +60,6 @@ Comments are welcome. Send your feedback through the [issue tracker on GitHub][i
64
60
  * [Luis Gustavo][lg]
65
61
  * [Thiago Lelis][tl]
66
62
 
67
- ## Shameless advertisement
68
-
69
- This plugin is brought to you by [Improve It][ii].
70
-
71
63
  ## Special Thanks
72
64
 
73
65
  [Rails Envy Podcast Episode #77][re] for mentioning
@@ -77,11 +69,9 @@ for writing an excellent tutorial and [posting your source][e] on GitHub.
77
69
  [api]: http://developer.37signals.com/highrise
78
70
  [ar]: http://api.rubyonrails.org/classes/ActiveResource/Base.html
79
71
  [c]: http://api.rubyonrails.org/classes/ActiveSupport/Cache
80
- [co]: http://github.com/kmayer
81
72
  [e]: http://github.com/primedia/endeca/tree/master
82
73
  [h]: http://www.highrisehq.com/
83
- [i]: http://github.com/kmayer/highrise/issues
84
- [ii]: http://www.improveit.com.br/en
74
+ [i]: http://github.com/tapajos/highrise/issues
85
75
  [km]: http://github.com/kmayer
86
76
  [lg]: http://github.com/luisbebop
87
77
  [mit]:http://www.opensource.org/licenses/mit-license.php
@@ -90,5 +80,5 @@ for writing an excellent tutorial and [posting your source][e] on GitHub.
90
80
  [re]: http://www.railsenvy.com/2009/4/29/rails-envy-podcast-episode-077-04-29-2009
91
81
  [rh]: http://reinh.com/blog/2009/04/27/how-to-cache-anything-with-activesupport.html
92
82
  [tl]: http://github.com/ThiagoLelis
93
- [rdoc]: http://rdoc.info/projects/kmayer/highrise
94
- [devver]: https://devver.net/caliper/project?repo=git%3A%2F%2Fgithub.com%2Fkmayer%2Fhighrise.git
83
+ [rdoc]: http://rdoc.info/projects/tapajos/highrise
84
+ [caliper]: https://devver.net/caliper/project?repo=git%3A%2F%2Fgithub.com%2Ftapajos%2Fhighrise.git
@@ -1,5 +1,5 @@
1
1
  ---
2
- :minor: 0
3
- :patch: 4
2
+ :patch: 0
4
3
  :major: 1
4
+ :minor: 2
5
5
  :build:
@@ -78,7 +78,7 @@ module Cachable
78
78
  end
79
79
 
80
80
  def cache_key(*args)
81
- args.to_s
81
+ args.join('/')
82
82
  end
83
83
 
84
84
  def fetch(args, &block)
@@ -16,3 +16,5 @@ require 'highrise/person'
16
16
  require 'highrise/task'
17
17
  require 'highrise/user'
18
18
  require 'highrise/tag'
19
+ require 'highrise/deal'
20
+ require 'highrise/account'
@@ -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
@@ -10,5 +10,9 @@ module Highrise
10
10
  def people
11
11
  Person.find(:all, :from => "/companies/#{id}/people.xml")
12
12
  end
13
+
14
+ def label
15
+ 'Party'
16
+ end
13
17
  end
14
18
  end
@@ -0,0 +1,5 @@
1
+ module Highrise
2
+ class Deal < Subject
3
+
4
+ end
5
+ end
@@ -22,5 +22,9 @@ module Highrise
22
22
  def web_address
23
23
  contact_data.web_addresses.first
24
24
  end
25
+
26
+ def label
27
+ 'Party'
28
+ end
25
29
  end
26
30
  end
@@ -4,6 +4,12 @@ module Highrise
4
4
  Note.find_all_across_pages(:from => "/#{self.class.collection_name}/#{id}/notes.xml")
5
5
  end
6
6
 
7
+ def add_note(attrs={})
8
+ attrs[:subject_id] = self.id
9
+ attrs[:subject_type] = self.label
10
+ Note.create attrs
11
+ end
12
+
7
13
  def emails
8
14
  Email.find_all_across_pages(:from => "/#{self.class.collection_name}/#{id}/emails.xml")
9
15
  end
@@ -11,5 +17,9 @@ module Highrise
11
17
  def upcoming_tasks
12
18
  Task.find(:all, :from => "/#{self.class.collection_name}/#{id}/tasks.xml")
13
19
  end
20
+
21
+ def label
22
+ self.class.name.split('::').last
23
+ end
14
24
  end
15
25
  end
@@ -1,18 +1,25 @@
1
1
  module Highrise
2
- class Tag < Base
3
- @@tags = {}
2
+ class Tag < Base
3
+ @cache = self.cache_store || ActiveSupport::Cache::MemoryStore.new
4
+
4
5
  def ==(object)
5
6
  (object.instance_of?(self.class) && object.id == self.id && object.name == self.name)
6
7
  end
7
8
 
8
- def self.find_by_name(arg)
9
- if @@tags == {}
10
- self.find(:all).each do |tag|
11
- @@tags[tag.id] = tag
12
- @@tags[tag.name] = tag
13
- end
9
+ class << self
10
+ # This find(:all) is very expensive, so cache all tags, once.
11
+ def find_by_name(arg)
12
+ @cache.fetch(to_key([self.to_s, arg])) {
13
+ tags = self.find(:all).each{|tag| @cache.write(to_key([self.to_s, tag.name]), tag)}
14
+ tags.find{|tag| tag.name == arg}
15
+ }
16
+ end
17
+
18
+ private
19
+
20
+ def to_key(*args)
21
+ args.join('/')
14
22
  end
15
- @@tags[arg]
16
23
  end
17
24
  end
18
25
  end
@@ -3,5 +3,15 @@ module Highrise
3
3
  def join(group)
4
4
  Membership.create(:user_id => id, :group_id => group.id)
5
5
  end
6
+
7
+ # Permits API-key retrieval using name and password.
8
+ # Highrise::User.site = "https://yourcompany.highrise.com"
9
+ # Highrise::User.user = "your_user_name"
10
+ # Highrise::User.password = "s3kr3t"
11
+ # Highrise::User.me.token # contains the API token for "your_user_name"
12
+ def self.me
13
+ user = User.new()
14
+ find(:one, :from => "/me.xml")
15
+ end
6
16
  end
7
17
  end
@@ -0,0 +1,16 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Highrise::Account do
4
+ before(:each) do
5
+ @account = Highrise::Account.new
6
+ end
7
+
8
+ it "should be instance of Highrise::Base" do
9
+ @account.kind_of?(Highrise::Base).should be_true
10
+ end
11
+
12
+ it "should delegate to find(:one, :from => '/account.xml') when account is called" do
13
+ Highrise::Account.should_receive(:find).with(:one, {:from => "/account.xml"}).and_return(@account)
14
+ Highrise::Account.me.should == @account
15
+ end
16
+ end
@@ -29,7 +29,6 @@ describe Highrise::Company do
29
29
  describe "people" do
30
30
 
31
31
  it "should delegate to Highrise::Person.find with correct params" do
32
- @company.should_receive(:id).and_return(1)
33
32
  Highrise::Person.should_receive(:find).with(:all, {:from=>"/companies/1/people.xml"}).and_return("people")
34
33
  @company.people.should == "people"
35
34
  end
@@ -64,5 +63,17 @@ describe Highrise::Company do
64
63
 
65
64
  end
66
65
 
66
+ describe ".label" do
67
+ it "should return 'Party' for label" do
68
+ @company.label.should == 'Party'
69
+ end
70
+ end
71
+
72
+ describe ".add_note" do
73
+ it "should delegate to Highrise::Note.create with correct params" do
74
+ Highrise::Note.should_receive(:create).with({:body=>"body", :subject_id=>1, :subject_type=>'Party'}).and_return(mock('note'))
75
+ @company.add_note :body=>'body'
76
+ end
77
+ end
67
78
 
68
79
  end
@@ -0,0 +1,20 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Highrise::Deal do
4
+
5
+ before(:each) do
6
+ @deal = Highrise::Deal.new(:id => 1)
7
+ end
8
+
9
+ it "should be instance of Highrise::Subject" do
10
+ @deal.kind_of?(Highrise::Subject).should be_true
11
+ end
12
+
13
+ describe ".add_note" do
14
+ it "should delegate to Highrise::Note.create with correct params" do
15
+ Highrise::Note.should_receive(:create).with({:body=>"body", :subject_id=>1, :subject_type=>'Deal'}).and_return(mock('note'))
16
+ @deal.add_note :body=>'body'
17
+ end
18
+ end
19
+
20
+ end
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../spec_helper'
3
3
  describe Highrise::Note do
4
4
 
5
5
  before(:each) do
6
- @note = Highrise::Note.new
6
+ @note = Highrise::Note.new(:id => 1)
7
7
  end
8
8
 
9
9
  it "should be instance of Highrise::Base" do
@@ -13,7 +13,6 @@ describe Highrise::Note do
13
13
  describe "comments" do
14
14
 
15
15
  it "should delegate to Highrise::Comment.find with correct params" do
16
- @note.should_receive(:id).and_return(1)
17
16
  Highrise::Comment.should_receive(:find).with(:all, {:from=>"/notes/1/comments.xml"}).and_return("comments")
18
17
  @note.comments.should == "comments"
19
18
  end
@@ -78,4 +78,17 @@ describe Highrise::Person do
78
78
 
79
79
  end
80
80
 
81
+ describe ".label" do
82
+ it "should return 'Party' for label" do
83
+ @person.label.should == 'Party'
84
+ end
85
+ end
86
+
87
+ describe ".add_note" do
88
+ it "should delegate to Highrise::Note.create with correct params" do
89
+ Highrise::Note.should_receive(:create).with({:body=>"body", :subject_id=>1, :subject_type=>'Party'}).and_return(mock('note'))
90
+ @person.add_note :body=>'body'
91
+ end
92
+ end
93
+
81
94
  end
@@ -3,41 +3,47 @@ require File.dirname(__FILE__) + '/../spec_helper'
3
3
  describe Highrise::Subject do
4
4
 
5
5
  before(:each) do
6
- @subject = Highrise::Subject.new
6
+ @subject = Highrise::Subject.new(:id => 1)
7
7
  end
8
-
8
+
9
9
  it "should be instance of Highrise::Base" do
10
10
  @subject.kind_of?(Highrise::Base).should be_true
11
11
  end
12
-
13
- describe ".notes" do
14
12
 
15
- it "should delegate to Highrise::Note with correct params" do
16
- @subject.should_receive(:id).and_return(1)
17
- Highrise::Note.should_receive(:find_all_across_pages).with({:from=>"/subjects/1/notes.xml"}).and_return("notes")
13
+ describe ".notes" do
14
+ it "should delegate to Highrise::Note with correct params" do Highrise::Note.should_receive(:find_all_across_pages).with({:from=>"/subjects/1/notes.xml"}).and_return("notes")
18
15
  @subject.notes.should == "notes"
19
16
  end
17
+ end
20
18
 
19
+ describe ".add_note" do
20
+ it "should delegate to Highrise::Note.create with correct params" do
21
+ Highrise::Note.should_receive(:create).with({:body=>"body", :subject_id=>1, :subject_type=>'Subject'}).and_return(mock('note'))
22
+ @subject.add_note :body=>'body'
23
+ end
21
24
  end
22
25
 
23
26
  describe ".emails" do
24
-
25
27
  it "should delegate to Highrise::Email with correct params" do
26
- @subject.should_receive(:id).and_return(1)
27
28
  Highrise::Email.should_receive(:find_all_across_pages).with({:from=>"/subjects/1/emails.xml"}).and_return("emails")
28
29
  @subject.emails.should == "emails"
29
30
  end
30
-
31
31
  end
32
-
32
+
33
+
33
34
  describe ".upcoming_tasks" do
34
35
 
35
36
  it "should delegate to Highrise::Task with correct params" do
36
- @subject.should_receive(:id).and_return(1)
37
37
  Highrise::Task.should_receive(:find).with(:all, {:from=>"/subjects/1/tasks.xml"}).and_return("tasks")
38
38
  @subject.upcoming_tasks.should == "tasks"
39
39
  end
40
40
 
41
41
  end
42
+
43
+ describe ".label" do
44
+ it "should return the class name as a string" do
45
+ @subject.label.should == "Subject"
46
+ end
47
+ end
42
48
 
43
49
  end
@@ -1,7 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
3
  describe Highrise::Tag do
4
-
5
4
  before(:each) do
6
5
  Highrise::Base.site = 'http://example.com.i/'
7
6
  @tag = Highrise::Tag.new(:id => 1, :name => "Name")
@@ -10,11 +10,16 @@ describe Highrise::User do
10
10
  @user.kind_of?(Highrise::Base).should be_true
11
11
  end
12
12
 
13
+ it "should delegate to find(:one, :from => '/me.xml') when me is called" do
14
+ Highrise::User.should_receive(:find).with(:one, {:from => "/me.xml"}).and_return(@user)
15
+ Highrise::User.me.should == @user
16
+ end
17
+
13
18
  def join(group)
14
19
  Membership.create(:user_id => id, :group_id => group.id)
15
20
  end
16
21
 
17
- describe ".joind" do
22
+ describe ".join" do
18
23
 
19
24
  it "should delegate to Highrise::Membership.create" do
20
25
  group_mock = mock("group")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: highrise
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Marcos Tapaj\xC3\xB3s"
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-11-11 00:00:00 -02:00
13
+ date: 2010-02-15 00:00:00 -10:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -61,13 +61,14 @@ files:
61
61
  - examples/config_initializers_highrise.rb
62
62
  - examples/extending.rb
63
63
  - examples/sample.rb
64
- - highrise.gemspec
65
64
  - install.rb
66
65
  - lib/cachable.rb
67
66
  - lib/highrise.rb
67
+ - lib/highrise/account.rb
68
68
  - lib/highrise/base.rb
69
69
  - lib/highrise/comment.rb
70
70
  - lib/highrise/company.rb
71
+ - lib/highrise/deal.rb
71
72
  - lib/highrise/email.rb
72
73
  - lib/highrise/group.rb
73
74
  - lib/highrise/kase.rb
@@ -81,9 +82,11 @@ files:
81
82
  - lib/highrise/task.rb
82
83
  - lib/highrise/user.rb
83
84
  - spec/cachable_spec.rb
85
+ - spec/highrise/account_spec.rb
84
86
  - spec/highrise/base_spec.rb
85
87
  - spec/highrise/comment_spec.rb
86
88
  - spec/highrise/company_spec.rb
89
+ - spec/highrise/deal_spec.rb
87
90
  - spec/highrise/email_spec.rb
88
91
  - spec/highrise/group_spec.rb
89
92
  - spec/highrise/kase_spec.rb
@@ -128,9 +131,11 @@ specification_version: 3
128
131
  summary: Ruby wrapper around Highrise API
129
132
  test_files:
130
133
  - spec/cachable_spec.rb
134
+ - spec/highrise/account_spec.rb
131
135
  - spec/highrise/base_spec.rb
132
136
  - spec/highrise/comment_spec.rb
133
137
  - spec/highrise/company_spec.rb
138
+ - spec/highrise/deal_spec.rb
134
139
  - spec/highrise/email_spec.rb
135
140
  - spec/highrise/group_spec.rb
136
141
  - spec/highrise/kase_spec.rb
@@ -1,119 +0,0 @@
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{highrise}
8
- s.version = "1.0.3"
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{2009-11-11}
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
- "install.rb",
40
- "lib/cachable.rb",
41
- "lib/highrise.rb",
42
- "lib/highrise/base.rb",
43
- "lib/highrise/comment.rb",
44
- "lib/highrise/company.rb",
45
- "lib/highrise/email.rb",
46
- "lib/highrise/group.rb",
47
- "lib/highrise/kase.rb",
48
- "lib/highrise/membership.rb",
49
- "lib/highrise/note.rb",
50
- "lib/highrise/pagination.rb",
51
- "lib/highrise/person.rb",
52
- "lib/highrise/subject.rb",
53
- "lib/highrise/tag.rb",
54
- "lib/highrise/taggable.rb",
55
- "lib/highrise/task.rb",
56
- "lib/highrise/user.rb",
57
- "spec/cachable_spec.rb",
58
- "spec/highrise/base_spec.rb",
59
- "spec/highrise/comment_spec.rb",
60
- "spec/highrise/company_spec.rb",
61
- "spec/highrise/email_spec.rb",
62
- "spec/highrise/group_spec.rb",
63
- "spec/highrise/kase_spec.rb",
64
- "spec/highrise/membership_spec.rb",
65
- "spec/highrise/note_spec.rb",
66
- "spec/highrise/pagination_spec.rb",
67
- "spec/highrise/person_spec.rb",
68
- "spec/highrise/subject_spec.rb",
69
- "spec/highrise/tag_spec.rb",
70
- "spec/highrise/task_spec.rb",
71
- "spec/highrise/user_spec.rb",
72
- "spec/spec.opts",
73
- "spec/spec_helper.rb",
74
- "uninstall.rb"
75
- ]
76
- s.homepage = %q{http://github.com/tapajos/highrise}
77
- s.rdoc_options = ["--charset=UTF-8"]
78
- s.require_paths = ["lib"]
79
- s.rubygems_version = %q{1.3.5}
80
- s.summary = %q{Ruby wrapper around Highrise API}
81
- s.test_files = [
82
- "spec/cachable_spec.rb",
83
- "spec/highrise/base_spec.rb",
84
- "spec/highrise/comment_spec.rb",
85
- "spec/highrise/company_spec.rb",
86
- "spec/highrise/email_spec.rb",
87
- "spec/highrise/group_spec.rb",
88
- "spec/highrise/kase_spec.rb",
89
- "spec/highrise/membership_spec.rb",
90
- "spec/highrise/note_spec.rb",
91
- "spec/highrise/pagination_spec.rb",
92
- "spec/highrise/person_spec.rb",
93
- "spec/highrise/subject_spec.rb",
94
- "spec/highrise/tag_spec.rb",
95
- "spec/highrise/task_spec.rb",
96
- "spec/highrise/user_spec.rb",
97
- "spec/spec_helper.rb",
98
- "examples/config_initializers_highrise.rb",
99
- "examples/extending.rb",
100
- "examples/sample.rb"
101
- ]
102
-
103
- if s.respond_to? :specification_version then
104
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
105
- s.specification_version = 3
106
-
107
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
108
- s.add_runtime_dependency(%q<activeresource>, [">= 2.1"])
109
- s.add_runtime_dependency(%q<activesupport>, [">= 2.1"])
110
- else
111
- s.add_dependency(%q<activeresource>, [">= 2.1"])
112
- s.add_dependency(%q<activesupport>, [">= 2.1"])
113
- end
114
- else
115
- s.add_dependency(%q<activeresource>, [">= 2.1"])
116
- s.add_dependency(%q<activesupport>, [">= 2.1"])
117
- end
118
- end
119
-