kmayer-highrise 0.7.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.
Files changed (43) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.mkdn +69 -0
  3. data/Rakefile +68 -0
  4. data/lib/highrise/base.rb +4 -0
  5. data/lib/highrise/comment.rb +4 -0
  6. data/lib/highrise/company.rb +14 -0
  7. data/lib/highrise/curlhelper.rb +27 -0
  8. data/lib/highrise/curly.rb +96 -0
  9. data/lib/highrise/email.rb +9 -0
  10. data/lib/highrise/group.rb +4 -0
  11. data/lib/highrise/kase.rb +8 -0
  12. data/lib/highrise/membership.rb +4 -0
  13. data/lib/highrise/note.rb +9 -0
  14. data/lib/highrise/pagination.rb +29 -0
  15. data/lib/highrise/person.rb +20 -0
  16. data/lib/highrise/subject.rb +15 -0
  17. data/lib/highrise/tag.rb +7 -0
  18. data/lib/highrise/taggable.rb +29 -0
  19. data/lib/highrise/task.rb +11 -0
  20. data/lib/highrise/user.rb +7 -0
  21. data/lib/highrise/version.rb +9 -0
  22. data/lib/highrise.rb +26 -0
  23. data/spec/highrise/base_spec.rb +13 -0
  24. data/spec/highrise/comment_spec.rb +14 -0
  25. data/spec/highrise/companies/16883216.html +1723 -0
  26. data/spec/highrise/company_spec.rb +70 -0
  27. data/spec/highrise/curlhelper_spec.rb +35 -0
  28. data/spec/highrise/curly_spec.rb +36 -0
  29. data/spec/highrise/email_spec.rb +25 -0
  30. data/spec/highrise/group_spec.rb +14 -0
  31. data/spec/highrise/kase_spec.rb +25 -0
  32. data/spec/highrise/membership_spec.rb +14 -0
  33. data/spec/highrise/note_spec.rb +23 -0
  34. data/spec/highrise/pagination_spec.rb +7 -0
  35. data/spec/highrise/people/16887003.html +1733 -0
  36. data/spec/highrise/person_spec.rb +83 -0
  37. data/spec/highrise/subject_spec.rb +43 -0
  38. data/spec/highrise/tag_spec.rb +21 -0
  39. data/spec/highrise/task_spec.rb +23 -0
  40. data/spec/highrise/user_spec.rb +30 -0
  41. data/spec.opts +7 -0
  42. data/spec_helper.rb +20 -0
  43. metadata +99 -0
@@ -0,0 +1,83 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Highrise::Person do
4
+
5
+ before(:each) do
6
+ Highrise::Base.site = 'http://example.com.i:3000'
7
+ @person = Highrise::Person.new
8
+ returning @tags = [] do
9
+ @tags << Highrise::Tag.new(:id => "414578", :name => "cliente")
10
+ @tags << Highrise::Tag.new(:id => "414587", :name => "walk")
11
+ end
12
+ end
13
+
14
+ it "should be instance of Highrise::Subject" do
15
+ @person.kind_of?(Highrise::Subject).should be_true
16
+ end
17
+
18
+ describe ".find_all_across_pages_since" do
19
+
20
+ it "should delegate to find_all_across_pages with correct params" do
21
+ time = Time.parse("Wed Jan 14 15:43:11 -0200 2009")
22
+ Highrise::Person.should_receive(:find_all_across_pages).with({:params=>{:since=>"20090114174311"}}).and_return("result")
23
+ Highrise::Person.find_all_across_pages_since(time).should == "result"
24
+ end
25
+
26
+ end
27
+
28
+ describe ".company" do
29
+
30
+ it "should return nil when doesn't have company_id" do
31
+ @person.should_receive(:company_id).and_return(nil)
32
+ @person.company.should be_nil
33
+ end
34
+
35
+ it "should delegate to Highrise::Company when have company_id" do
36
+ @person.should_receive(:company_id).at_least(2).times.and_return(1)
37
+ Highrise::Company.should_receive(:find).with(1).and_return("company")
38
+ @person.company.should == "company"
39
+ end
40
+
41
+ end
42
+
43
+ describe ".name" do
44
+
45
+ it "should concat fist_name with last_name and strip" do
46
+ @person.should_receive(:first_name).and_return("Marcos")
47
+ @person.should_receive(:last_name).and_return("Tapajós ")
48
+ @person.name.should == "Marcos Tapajós"
49
+ end
50
+
51
+ end
52
+
53
+ describe ".tags" do
54
+
55
+ it "should return an array of all tags for that user." do
56
+ file_path = File.dirname(__FILE__) + "/people/16887003.html"
57
+ @person.stub!(:get_document).and_return(Hpricot(File.open(file_path,"r"){|f| f.read}))
58
+ @person.tags.should == @tags
59
+ end
60
+
61
+ end
62
+
63
+ describe "tag!(tag_name)" do
64
+
65
+ it "should create a tag for this user." do
66
+ @person.should_receive(:post).with(:tags, :name => "Forum_User" ).at_least(1).times.and_return(true)
67
+ @person.tag!("Forum_User").should be_true
68
+ end
69
+
70
+ end
71
+
72
+ describe "untag!(tag_name)" do
73
+
74
+ it "should delete a tag for this user." do
75
+ file_path = File.dirname(__FILE__) + "/people/16887003.html"
76
+ @person.stub!(:get_document).and_return(Hpricot(File.open(file_path,"r"){|f| f.read}))
77
+ @person.should_receive(:delete).with("tags/414578").at_least(1).times.and_return(true)
78
+ @person.untag!("cliente").should be_true
79
+ end
80
+
81
+ end
82
+
83
+ end
@@ -0,0 +1,43 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Highrise::Subject do
4
+
5
+ before(:each) do
6
+ @subject = Highrise::Subject.new
7
+ end
8
+
9
+ it "should be instance of Highrise::Base" do
10
+ @subject.kind_of?(Highrise::Base).should be_true
11
+ end
12
+
13
+ describe ".notes" do
14
+
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")
18
+ @subject.notes.should == "notes"
19
+ end
20
+
21
+ end
22
+
23
+ describe ".emails" do
24
+
25
+ it "should delegate to Highrise::Email with correct params" do
26
+ @subject.should_receive(:id).and_return(1)
27
+ Highrise::Email.should_receive(:find_all_across_pages).with({:from=>"/subjects/1/emails.xml"}).and_return("emails")
28
+ @subject.emails.should == "emails"
29
+ end
30
+
31
+ end
32
+
33
+ describe ".upcoming_tasks" do
34
+
35
+ it "should delegate to Highrise::Task with correct params" do
36
+ @subject.should_receive(:id).and_return(1)
37
+ Highrise::Task.should_receive(:find).with(:all, {:from=>"/subjects/1/tasks.xml"}).and_return("tasks")
38
+ @subject.upcoming_tasks.should == "tasks"
39
+ end
40
+
41
+ end
42
+
43
+ end
@@ -0,0 +1,21 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Highrise::Tag do
4
+
5
+ before(:each) do
6
+ Highrise::Base.site = 'http://example.com.i/'
7
+ @tag = Highrise::Tag.new
8
+ end
9
+
10
+ it "should be instance of Highrise::Base" do
11
+ @tag.kind_of?(Highrise::Base).should be_true
12
+ end
13
+
14
+ it "should support equality" do
15
+ @tag.id = 1
16
+ @tag.name = "Name"
17
+
18
+ tag = Highrise::Tag.new(:id => 1, :name => "Name")
19
+ @tag.should == tag
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Highrise::Task do
4
+
5
+ before(:each) do
6
+ @task = Highrise::Task.new
7
+ end
8
+
9
+ it "should be instance of Highrise::Base" do
10
+ @task.kind_of?(Highrise::Base).should be_true
11
+ end
12
+
13
+ describe ".complete!" do
14
+
15
+ it "should delegate to load_attributes_from_response" do
16
+ @task.should_receive(:load_attributes_from_response).with("post")
17
+ @task.should_receive(:post).with(:complete).and_return("post")
18
+ @task.complete!
19
+ end
20
+
21
+ end
22
+
23
+ end
@@ -0,0 +1,30 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Highrise::User do
4
+
5
+ before(:each) do
6
+ @user = Highrise::User.new
7
+ end
8
+
9
+ it "should be instance of Highrise::Base" do
10
+ @user.kind_of?(Highrise::Base).should be_true
11
+ end
12
+
13
+ def join(group)
14
+ Membership.create(:user_id => id, :group_id => group.id)
15
+ end
16
+
17
+ describe ".joind" do
18
+
19
+ it "should delegate to Highrise::Membership.create" do
20
+ group_mock = mock("group")
21
+ group_mock.should_receive(:id).and_return(2)
22
+ @user.should_receive(:id).and_return(1)
23
+ Highrise::Membership.should_receive(:create).with({:user_id=>1, :group_id=>2})
24
+ @user.join(group_mock)
25
+ end
26
+
27
+ end
28
+
29
+
30
+ end
data/spec.opts ADDED
@@ -0,0 +1,7 @@
1
+ --colour
2
+ --format
3
+ progress
4
+ --loadby
5
+ mtime
6
+ --reverse
7
+ --backtrace
data/spec_helper.rb ADDED
@@ -0,0 +1,20 @@
1
+ require File.dirname(__FILE__) + '/lib/highrise'
2
+
3
+ def turn_methods_public(classe, method_name = nil)
4
+ if method_name
5
+ classe.class_eval do
6
+ public method_name
7
+ end
8
+ else
9
+ turn_all_methods_public classe
10
+ end
11
+ end
12
+
13
+ def turn_all_methods_public(classe)
14
+ classe.class_eval do
15
+ private_instance_methods.each { |instance_method| public instance_method }
16
+ private_methods.each { |method| public_class_method method }
17
+ protected_instance_methods.each { |instance_method| public instance_method }
18
+ protected_methods.each { |method| public_class_method method }
19
+ end
20
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kmayer-highrise
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.0
5
+ platform: ruby
6
+ authors:
7
+ - "Marcos Tapaj\xC3\xB3s"
8
+ - Ken Mayer
9
+ autorequire: highrise
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2009-04-28 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description: "Based on the original API module from DHH, http://developer.37signals.com/highrise/, this gem is a cleaned up, tested version of the same. Contributors have added support for tags which are not supported by the API directly Configure by adding the following: require 'rubygems' require 'highrise' Highrise::Base.site = 'http://your_api:login@your_site.highrisehq.com/'"
18
+ email: kmayer@bitwrangler.com
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files:
24
+ - README.mkdn
25
+ files:
26
+ - README.mkdn
27
+ - Rakefile
28
+ - MIT-LICENSE
29
+ - spec.opts
30
+ - spec_helper.rb
31
+ - lib/highrise
32
+ - lib/highrise/base.rb
33
+ - lib/highrise/comment.rb
34
+ - lib/highrise/company.rb
35
+ - lib/highrise/curlhelper.rb
36
+ - lib/highrise/curly.rb
37
+ - lib/highrise/email.rb
38
+ - lib/highrise/group.rb
39
+ - lib/highrise/kase.rb
40
+ - lib/highrise/membership.rb
41
+ - lib/highrise/note.rb
42
+ - lib/highrise/pagination.rb
43
+ - lib/highrise/person.rb
44
+ - lib/highrise/subject.rb
45
+ - lib/highrise/tag.rb
46
+ - lib/highrise/taggable.rb
47
+ - lib/highrise/task.rb
48
+ - lib/highrise/user.rb
49
+ - lib/highrise/version.rb
50
+ - lib/highrise.rb
51
+ - spec/highrise
52
+ - spec/highrise/base_spec.rb
53
+ - spec/highrise/comment_spec.rb
54
+ - spec/highrise/companies
55
+ - spec/highrise/companies/16883216.html
56
+ - spec/highrise/company_spec.rb
57
+ - spec/highrise/curlhelper_spec.rb
58
+ - spec/highrise/curly_spec.rb
59
+ - spec/highrise/email_spec.rb
60
+ - spec/highrise/group_spec.rb
61
+ - spec/highrise/kase_spec.rb
62
+ - spec/highrise/membership_spec.rb
63
+ - spec/highrise/note_spec.rb
64
+ - spec/highrise/pagination_spec.rb
65
+ - spec/highrise/people
66
+ - spec/highrise/people/16887003.html
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
+ has_rdoc: true
73
+ homepage: http://github.com/kmayer/highrise
74
+ post_install_message:
75
+ rdoc_options: []
76
+
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: "0"
84
+ version:
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: "0"
90
+ version:
91
+ requirements: []
92
+
93
+ rubyforge_project:
94
+ rubygems_version: 1.2.0
95
+ signing_key:
96
+ specification_version: 3
97
+ summary: Ruby wrapper around Highrise API
98
+ test_files: []
99
+