catch 0.0.5 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,3 +2,6 @@ pkg/*
2
2
  *.gem
3
3
  .bundle
4
4
  .irbrc
5
+ catch*.gem
6
+ .rvmrc
7
+ Gemfile.lock
@@ -1,11 +1,26 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- catch (0.0.1)
4
+ catch (0.0.7)
5
+ faraday_middleware (~> 0.6)
6
+ hashie (~> 1.0.0)
7
+ multi_json (~> 1.0.0)
5
8
 
6
9
  GEM
7
10
  remote: http://rubygems.org/
8
11
  specs:
12
+ addressable (2.2.5)
13
+ fakeweb (1.3.0)
14
+ faraday (0.6.1)
15
+ addressable (~> 2.2.4)
16
+ multipart-post (~> 1.1.0)
17
+ rack (>= 1.1.0, < 2)
18
+ faraday_middleware (0.6.3)
19
+ faraday (~> 0.6.0)
20
+ hashie (1.0.0)
21
+ multi_json (1.0.0)
22
+ multipart-post (1.1.0)
23
+ rack (1.2.2)
9
24
 
10
25
  PLATFORMS
11
26
  ruby
@@ -13,3 +28,4 @@ PLATFORMS
13
28
  DEPENDENCIES
14
29
  bundler (>= 1.0.0)
15
30
  catch!
31
+ fakeweb (>= 1.3.0)
data/README.md CHANGED
@@ -4,13 +4,13 @@ Ruby wrapper for the [Catch API](http://developer.catch.com).
4
4
 
5
5
  ## Installation
6
6
 
7
- sudo gem install catch
7
+ gem install catch
8
8
 
9
9
  ## Usage
10
10
 
11
11
  ### Instantiate a client (Basic Auth)
12
12
 
13
- catch = Catch::Client.new(:username => "fooman", :password => "supersecrete")
13
+ catch = Catch::Client.new(:username => "fooman", :password => "supersecret")
14
14
 
15
15
  ### or configure once
16
16
 
@@ -44,6 +44,8 @@ Ruby wrapper for the [Catch API](http://developer.catch.com).
44
44
 
45
45
  catch.tags
46
46
 
47
+ See the [Catch API](http://developer.catch.com) documentation for more information.
48
+
47
49
  ## Note on Patches/Pull Requests
48
50
 
49
51
  * Fork the project.
data/Rakefile CHANGED
@@ -1,2 +1,12 @@
1
1
  require 'bundler'
2
+ require 'rake/testtask'
3
+
4
+ lib_dir = File.expand_path('lib')
5
+ test_dir = File.expand_path('test')
6
+
2
7
  Bundler::GemHelper.install_tasks
8
+
9
+ Rake::TestTask.new(:test) do |test|
10
+ test.libs = [lib_dir, test_dir]
11
+ test.pattern = 'test/**/*rb'
12
+ end
@@ -8,6 +8,8 @@ module Catch
8
8
  attr_accessor :username
9
9
  attr_accessor :password
10
10
 
11
+ # Configures default credentials easily
12
+ # @yield [username, password]
11
13
  def configure
12
14
  yield self
13
15
  true
@@ -17,6 +19,7 @@ module Catch
17
19
  require 'catch/comment'
18
20
  require 'catch/media'
19
21
  require 'catch/note'
22
+ require 'catch/place'
20
23
  require 'catch/search'
21
24
  require 'catch/tag'
22
25
  require 'catch/user'
@@ -3,6 +3,7 @@ module Catch
3
3
  include Comment
4
4
  include Media
5
5
  include Note
6
+ include Place
6
7
  include Search
7
8
  include Tag
8
9
  include User
@@ -17,6 +18,9 @@ module Catch
17
18
  media_connection.basic_auth(@username, password)
18
19
  end
19
20
 
21
+ # Raw HTTP connection, either Faraday::Connection
22
+ #
23
+ # @return [Faraday::Connection]
20
24
  def connection
21
25
  @connection ||= Faraday.new(:url => @api_url, :headers => default_headers) do |builder|
22
26
  builder.request :multipart
@@ -28,6 +32,11 @@ module Catch
28
32
  end
29
33
  end
30
34
 
35
+ # Raw HTTP connection, either Faraday::Connection
36
+ #
37
+ # media_connection is used for calls which do not return JSON data.
38
+ #
39
+ # @return [Faraday::Connection]
31
40
  def media_connection
32
41
  @media_connection ||= Faraday.new(:url => @api_url, :headers => default_headers) do |builder|
33
42
  builder.request :multipart
@@ -36,7 +45,8 @@ module Catch
36
45
  builder.use Faraday::Response::Mashify
37
46
  end
38
47
  end
39
- private
48
+
49
+ private
40
50
 
41
51
  def default_headers
42
52
  headers = {
@@ -1,12 +1,19 @@
1
1
  module Catch
2
2
  module Comment
3
- def comments(note_id, params={})
3
+
4
+ # Retrieve a list of all comments for a note.
5
+ #
6
+ # @param [Integer] note_id Note ID
7
+ def comments(note_id)
4
8
  connection.get do |req|
5
9
  req.url("comments/#{note_id}")
6
- req.params.merge!(params)
7
10
  end.body.notes
8
11
  end
9
12
 
13
+ # Retrieves a single comment from the server.
14
+ #
15
+ # @param [Integer] note_id Note ID
16
+ # @param [Integer] comment_id Comment ID
10
17
  def comment(note_id, comment_id)
11
18
  params = {:comment => comment_id}
12
19
  connection.get do |req|
@@ -15,12 +22,29 @@ module Catch
15
22
  end.body.notes.first
16
23
  end
17
24
 
25
+ # Adds a new comment to a note.
26
+ #
27
+ # @param [Integer] note_id Note ID
28
+ # @option params [String] :source Source (application) which created the comment.
29
+ # @option params [String] :text The text of the comment
30
+ # @option params [DateTime] :created_at Date at which the comment was created.
31
+ # @option params [DateTime] :modified_at Date of last modification
32
+ # @option params [DateTime] :server_modified_at Providing the server_modified_at timestamp will ensure that the object being modified is not out of date.
18
33
  def add_comment(note_id, params={})
19
34
  payload = params.map {|k,v| "#{k}=#{v}"}.join("&")
20
35
  response = connection.post "comments/#{note_id}", payload
21
36
  response.body.notes.first
22
37
  end
23
38
 
39
+ # Edits an existing comment.
40
+ #
41
+ # @param [Integer] note_id Note ID
42
+ # @param [Integer] comment_id Comment ID
43
+ # @option params [String] :source Source (application) which created the comment.
44
+ # @option params [String] :text The text of the comment
45
+ # @option params [DateTime] :created_at Date at which the comment was created.
46
+ # @option params [DateTime] :modified_at Date of last modification
47
+ # @option params [DateTime] :server_modified_at Providing the server_modified_at timestamp will ensure that the object being modified is not out of date.
24
48
  def modify_comment(note_id, comment_id, params={})
25
49
  payload = {:comment => comment_id }
26
50
  payload.merge! params
@@ -31,6 +55,10 @@ module Catch
31
55
  end.body.notes.first
32
56
  end
33
57
 
58
+ # Remove a single comment from a note.
59
+ #
60
+ # @param [Integer] note_id Note ID
61
+ # @param [Integer] comment_id Comment ID
34
62
  def delete_comment(note_id, comment_id)
35
63
  connection.delete("comments/#{note_id}?comment=#{comment_id}").body.status == 'ok'
36
64
  end
@@ -1,12 +1,30 @@
1
1
  module Catch
2
2
  module Media
3
3
 
4
+ # Adds a file to a note.
5
+ #
6
+ # @param [Integer] note_id Note ID
7
+ # @param [String] filepath The full path to the file to add to the note
8
+ # @option params [String] :content_type The content type
9
+ # @option params [String] :content_type The content type
10
+ # @option params [Boolean] :voicenote_hunt If this media is a voicenote
11
+ # @option params [DateTime] :created_at Date at which the comment was created.
12
+ # @option params [DateTime] :server_modified_at Providing the server_modified_at timestamp will ensure that the object being modified is not out of date.
4
13
  def add_media(id, filepath, params={})
5
14
  params.merge!({:data => Faraday::UploadIO.new(filepath, 'image/jpeg')})
6
15
 
7
16
  connection.put("media/#{id}", params).body
8
17
  end
9
18
 
19
+ # Return the media file
20
+ #
21
+ # @param [Integer] note_id Note ID
22
+ # @param [String] media_id Media ID
23
+ # @option params [String] :size For images, the size to which to scale the image.
24
+ # small images are at most 128 pixels in the longer dimension.
25
+ # medium images are at most 800 pixels in the longer dimension.
26
+ # large images are at most 9999 pixels in the longer dimension.
27
+ # @option params [boolean] :original For images whether or not to return the original unscaled image. The scaling process removes all additional metadata, including EXIF geocoding. You must use this flag if you want to retain such data.
10
28
  def media(note_id, media_id, params={})
11
29
  media_connection.get do |req|
12
30
  req.url("media/#{note_id}/#{media_id}")
@@ -14,10 +32,18 @@ module Catch
14
32
  end.body
15
33
  end
16
34
 
35
+ # Deletes a file attachment from a note
36
+ #
37
+ # @param [Integer] note_id Note ID
38
+ # @param [String] media_id Media ID
17
39
  def delete_media(note_id, media_id)
18
40
  connection.delete("media/#{note_id}/#{media_id}").body.status == 'ok'
19
41
  end
20
42
 
43
+ # It really doesn't look like shared_media has any value at this point
44
+ # since all it is doing is retrieving a file from the url key of the media
45
+ # object. Skipping until this has value.
46
+
21
47
  # def shared_media(note_id, media_id, params={})
22
48
  # media_connection.get do |req|
23
49
  # req.url("media/#{note_id}/#{media_id}")
@@ -1,5 +1,18 @@
1
1
  module Catch
2
2
  module Note
3
+ # Lists multiple notes for the current user.
4
+ #
5
+ # @option params [String] :sort default is created_dec
6
+ # Specifies a note sort order. Valid sort orders are:
7
+ # created_asc sort by note creation date in ascending order (most recent first)
8
+ # create_dec sort by note creation date in descending order (most recent last)
9
+ # modified_asc sort by note modification date in ascending order (most recent first)
10
+ # modified_dec sort by note modification date in descending order (most recent last)
11
+ # text_asc sort by the note text content from in ascending order (A to Z)
12
+ # text_dec sort by the note text content from in descending order (Z to A)
13
+ # @option params [Boolean] :full Whether or not to return full results.
14
+ # @option params [Integer] :limit The number of results to return per page. The default is to return all results.
15
+ # @option params [Integer] :offset The offset from which to collect results, with default of zero. The number of results is specified by limit.
3
16
  def notes(params={})
4
17
  connection.get do |req|
5
18
  req.url("notes")
@@ -7,22 +20,61 @@ module Catch
7
20
  end.body.notes
8
21
  end
9
22
 
23
+ # Retrieves a single note
24
+ #
25
+ # @param [Integer] note_id Note ID
26
+ # @option params [Boolean] :full Whether or not to return full results.
10
27
  def note(id)
11
28
  connection.get("notes/#{id}").body.notes.first
12
29
  end
13
30
 
31
+ # Create a new note.
32
+ #
33
+ # @option params [Integer] :latitude The latitude.
34
+ # @option params [Integer] :longitude The longitude.
35
+ # @option params [String] :source Source (application) which created note.
36
+ # @option params [String] :text The text of the note
37
+ # @option params [String] :mode The sharing settings for the note. If unset, private is implied. (public | private | shared)
38
+ # @option params [Float] :accuracy_position The accuracy of coordinates from GPS.
39
+ # @option params [Float] :altitude The altitude from GPS associated with the note.
40
+ # @option params [Float] :bearing The bearing from GPS associated with the note
41
+ # @option params [Float] :speed The speed from GPS associated with the note
42
+ # @option params [Float] :speed The speed from GPS associated with the note
43
+ # @option params [DateTime] :created_at Date at which the comment was created.
44
+ # @option params [DateTime] :modified_at Date of last modification
45
+ # @option params [DateTime] :reminder_at Will present a reminder at the time specified on supported devices
46
+ # Waiting on annotations
14
47
  def add_note(params={})
15
48
  payload = params.map {|k,v| "#{k}=#{v}"}.join("&")
16
49
  response = connection.post "notes", payload
17
50
  response.body.notes.first
18
51
  end
19
52
 
53
+ # Modify a note
54
+ #
55
+ # @option params [Integer] :latitude The latitude.
56
+ # @option params [Integer] :longitude The longitude.
57
+ # @option params [String] :source Source (application) which created note.
58
+ # @option params [String] :text The text of the note
59
+ # @option params [String] :mode The sharing settings for the note. If unset, private is implied. (public | private | shared)
60
+ # @option params [Float] :accuracy_position The accuracy of coordinates from GPS.
61
+ # @option params [Float] :altitude The altitude from GPS associated with the note.
62
+ # @option params [Float] :bearing The bearing from GPS associated with the note
63
+ # @option params [Float] :speed The speed from GPS associated with the note
64
+ # @option params [Float] :speed The speed from GPS associated with the note
65
+ # @option params [DateTime] :created_at Date at which the comment was created.
66
+ # @option params [DateTime] :modified_at Date of last modification
67
+ # @option params [DateTime] :reminder_at Will present a reminder at the time specified on supported devices
68
+ # Waiting on annotations
20
69
  def modify_note(id, params={})
21
70
  payload = params.map {|k,v| "#{k}=#{v}"}.join("&")
22
71
  response = connection.post "notes/#{id}", payload
23
72
  response.body.notes.first
24
73
  end
25
74
 
75
+ # Deletes a note, or annotations of a note if specified
76
+ #
77
+ # @param [Integer] note_id Note ID
26
78
  def delete_note(id)
27
79
  connection.delete("notes/#{id}").body.status == 'ok'
28
80
  end
@@ -0,0 +1,67 @@
1
+ module Catch
2
+ module Place
3
+
4
+ # Lists all places for the user
5
+ #
6
+ def places(params={})
7
+ connection.get do |req|
8
+ req.url("places")
9
+ req.params.merge!(params)
10
+ end.body.result
11
+ end
12
+
13
+ # Returns a place by id
14
+ #
15
+ # @param [Integer] :id The id of a place
16
+ def place(id)
17
+ connection.get("places/#{id}").body
18
+ end
19
+
20
+ # Add a place
21
+ #
22
+ # @param [Integer] :latitude The latitude.
23
+ # @param [Integer] :longitude The longitude.
24
+ # @option params [String] :address The address of the place.
25
+ # @option params [String] :name The name of the place
26
+ # @option params [String] :phone A phone number for the place
27
+ # @option params [Integer] :rating A rating for the place (0 - 5)
28
+ # @option params [DateTime] :created_at Date at which the comment was created.
29
+ # @option params [DateTime] :modified_at Date of last modification
30
+ # @option params [String] :category A category for the place
31
+ # Waiting on annotations
32
+ def add_place(latitude, longitude, params={})
33
+ params[:latitude] = latitude
34
+ params[:longitude] = longitude
35
+ payload = params.map {|k,v| "#{k}=#{v}"}.join("&")
36
+ response = connection.put "places", payload
37
+ response.body.result
38
+ end
39
+
40
+ # Modifies the properties of a place
41
+ #
42
+ # @param [Integer] :id The id of a place
43
+ # @option params [Integer] :latitude The latitude.
44
+ # @option params [Integer] :longitude The longitude.
45
+ # @option params [String] :address The address of the place.
46
+ # @option params [String] :name The name of the place
47
+ # @option params [String] :phone A phone number for the place
48
+ # @option params [Integer] :rating A rating for the place (0 - 5)
49
+ # @option params [DateTime] :created_at Date at which the comment was created.
50
+ # @option params [DateTime] :modified_at Date of last modification
51
+ # @option params [String] :category A category for the place
52
+ # @option params [DateTime] :server_modified_at Providing the server_modified_at timestamp will ensure that the object being modified is not out of date
53
+ # Waiting on annotations
54
+ def modify_place(id, params={})
55
+ payload = params.map {|k,v| "#{k}=#{v}"}.join("&")
56
+ response = connection.post "places/#{id}", payload
57
+ response.body.result
58
+ end
59
+
60
+ # Deletes the place
61
+ #
62
+ # @param [Integer] :id The id of a place
63
+ def delete_place(id)
64
+ connection.delete("places/#{id}").body.status == 'ok'
65
+ end
66
+ end
67
+ end
@@ -1,5 +1,22 @@
1
1
  module Catch
2
2
  module Search
3
+
4
+ # Search the user's notes
5
+ #
6
+ # @param [String] :q The search query
7
+ # @option params [Float] :lat Latitude in degrees
8
+ # @option params [Float] :lng Longitude in degrees
9
+ # @option params [String] :sort default is created_dec
10
+ # Specifies a note sort order. Valid sort orders are:
11
+ # created_asc sort by note creation date in ascending order (most recent first)
12
+ # create_dec sort by note creation date in descending order (most recent last)
13
+ # modified_asc sort by note modification date in ascending order (most recent first)
14
+ # modified_dec sort by note modification date in descending order (most recent last)
15
+ # text_asc sort by the note text content from in ascending order (A to Z)
16
+ # text_dec sort by the note text content from in descending order (Z to A)
17
+ # @option params [Boolean] :full Whether or not to return full results.
18
+ # @option params [Integer] :limit The number of results to return per page. The default is to return all results.
19
+ # @option params [Integer] :offset The offset from which to collect results, with default of zero. The number of results is specified by limit.
3
20
  def search(query, params={})
4
21
  params[:q] = query
5
22
 
@@ -1,5 +1,10 @@
1
1
  module Catch
2
2
  module Tag
3
+
4
+ # Provide a list of all tags in this user's notes. The response provides
5
+ # count (number of notes using this tag) and modified (most recent
6
+ # timestamp when a note using this tag was modified) properties for each
7
+ # tag
3
8
  def tags
4
9
  connection.get("tags").body.tags
5
10
  end
@@ -1,5 +1,7 @@
1
1
  module Catch
2
2
  module User
3
+
4
+ # Retrieve information about the current user
3
5
  def user
4
6
  connection.get("user").body.user
5
7
  end
@@ -1,3 +1,3 @@
1
1
  module Catch
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -22,12 +22,6 @@ describe Catch::Comment do
22
22
  it "retrieves values from a comment within the retrieved array" do
23
23
  @comments.first.text.must_equal "Lorem ipsum dolor1"
24
24
  end
25
-
26
- it "takes a hash as a parameter" do
27
- params = {:limit => 2}
28
- stub_get(build_url(@comments_url, params), "comments.json", params)
29
- @client.comments(123, params).first.id.must_equal "1234"
30
- end
31
25
  end
32
26
 
33
27
  describe "#comment(id)" do
@@ -0,0 +1,20 @@
1
+ {
2
+ "status":"ok",
3
+ "result": {
4
+ "category":[],
5
+ "rating":null,
6
+ "name":"Somewhere",
7
+ "phone":null,
8
+ "created_at":"2011-05-26T19:43:05.450Z",
9
+ "modified_at":"2011-05-26T19:43:05.450Z",
10
+ "uri":"https://catch.com/v2/places/abc123",
11
+ "created_by":123,
12
+ "server_modified_at":"2011-06-01T12:32:59.938Z",
13
+ "location":{
14
+ "latitude":90,
15
+ "longitude":90
16
+ },
17
+ "address":null,
18
+ "id":"abc123"
19
+ }
20
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "status":"ok",
3
+ "result": {
4
+ "category":[],
5
+ "rating":null,
6
+ "name":"Lorem ipsum",
7
+ "phone":null,
8
+ "created_at":"2011-05-26T19:43:05.450Z",
9
+ "modified_at":"2011-05-26T19:43:05.450Z",
10
+ "uri":"https://catch.com/v2/places/abc123",
11
+ "created_by":123,
12
+ "server_modified_at":"2011-06-01T12:32:59.938Z",
13
+ "location":{
14
+ "latitude":90,
15
+ "longitude":90
16
+ },
17
+ "address":null,
18
+ "id":"abc123"
19
+ }
20
+ }
21
+
@@ -0,0 +1,17 @@
1
+ {
2
+ "category":[],
3
+ "rating":null,
4
+ "name":"Somewhere",
5
+ "phone":null,
6
+ "created_at":"2011-05-26T19:43:05.450Z",
7
+ "modified_at":"2011-05-26T19:43:05.450Z",
8
+ "uri":"https://catch.com/v2/places/abc123",
9
+ "created_by":123,
10
+ "server_modified_at":"2011-06-01T12:32:59.938Z",
11
+ "location":{
12
+ "latitude":90,
13
+ "longitude":90
14
+ },
15
+ "address":null,
16
+ "id":"abc123"
17
+ }
@@ -0,0 +1 @@
1
+ {"status": "ok"}
@@ -0,0 +1,49 @@
1
+ {
2
+ "status":"ok",
3
+ "result":[
4
+ {
5
+ "category":[], "rating":null,
6
+ "name":null,
7
+ "phone":null,
8
+ "created_at":"2011-05-13T22:15:52.080Z",
9
+ "modified_at":"2011-05-13T22:15:52.081Z",
10
+ "uri":"https://catch.com/v2/places/abc123",
11
+ "created_by":22935233,
12
+ "server_modified_at":"2011-05-17T12:38:16.052Z",
13
+ "location":{"latitude":90,
14
+ "longitude":90},
15
+ "address":null,
16
+ "id":"abc123"
17
+ },
18
+ {
19
+ "category":[],
20
+ "rating":null,
21
+ "name":null,
22
+ "phone":null,
23
+ "created_at":"2011-05-13T22:15:52.080Z",
24
+ "modified_at":"2011-05-13T22:15:52.081Z",
25
+ "uri":"https://catch.com/v2/places/def456",
26
+ "created_by":22935233,
27
+ "server_modified_at":"2011-05-17T12:38:40.150Z",
28
+ "location":{"latitude":90,
29
+ "longitude":90},
30
+ "address":null,
31
+ "id":"def456"
32
+ },
33
+ {
34
+ "category":[],
35
+ "rating":null,
36
+ "name":null,
37
+ "phone":null,
38
+ "created_at":"2011-05-26T19:43:05.450Z",
39
+ "modified_at":"2011-05-26T19:43:05.450Z",
40
+ "uri":"https://catch.com/v2/places/ghi789",
41
+ "created_by":22935233,
42
+ "server_modified_at":"2011-06-01T12:32:59.938Z",
43
+ "location":{"latitude":90,
44
+ "longitude":90},
45
+ "address":null,
46
+ "id":"ghi789"
47
+ }
48
+ ]
49
+ }
@@ -8,6 +8,7 @@ describe Catch::Media do
8
8
  @note_id = "123"
9
9
  @media_id = "123abc"
10
10
  @media_url = "https://fooman:123123123@api.catch.com/v2/media"
11
+ @media_file = "test/fixtures/media.jpg"
11
12
  @client = catch_test_client
12
13
  end
13
14
 
@@ -17,16 +18,18 @@ describe Catch::Media do
17
18
 
18
19
  it "posts a file to an existing note" do
19
20
  stub_put("#{@media_url}/#{@note_id}", "media.json")
20
- media = @client.add_media(@note_id, "test/fixtures/media.jpg")
21
+ media = @client.add_media(@note_id, @media_file)
21
22
  media.id.must_equal('123abc')
22
23
  end
23
24
  end
24
25
 
25
26
  describe "#media" do
26
27
  it "retrieves a media file" do
28
+ file_contents = File.open(@media_file, "r").map {|line| line}.join
27
29
  stub_get("#{@media_url}/#{@note_id}/#{@media_id}", "media.jpg")
28
30
  media_file = @client.media(@note_id, @media_id)
29
- puts media_file.size
31
+
32
+ media_file.must_equal file_contents
30
33
  end
31
34
  end
32
35
 
@@ -0,0 +1,76 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+
4
+ require 'helper'
5
+
6
+ describe Catch::Place do
7
+ before do
8
+ @client = catch_test_client
9
+ end
10
+
11
+ describe "#places" do
12
+ before do
13
+ @places_url = "https://fooman:123123123@api.catch.com/v2/places"
14
+ stub_get(@places_url, "places.json")
15
+ @places = @client.places
16
+ end
17
+
18
+ it "retrieves a list of places as an array" do
19
+ @places.must_be_instance_of Array
20
+ end
21
+
22
+ it "retrieves values from a place within the retrieved array" do
23
+ @places.first.id.must_equal "abc123"
24
+ end
25
+ end
26
+
27
+ describe "#place(id)" do
28
+ before do
29
+ @id = 'abc123'
30
+ stub_get("https://fooman:123123123@api.catch.com/v2/places/#{@id}", "place.json")
31
+ @place = @client.place(@id)
32
+ end
33
+
34
+ it "retrieves values of a place" do
35
+ @place.id.must_equal @id
36
+ @place.name.must_equal "Somewhere"
37
+ end
38
+ end
39
+
40
+ describe "#add_place(latitude, longitude, options={})" do
41
+ before do
42
+ stub_put("https://fooman:123123123@api.catch.com/v2/places","add_place.json")
43
+ end
44
+
45
+ it "adds a new place" do
46
+ place = @client.add_place(90, 90)
47
+ place.id.must_equal "abc123"
48
+ place.name.must_equal "Somewhere"
49
+ end
50
+ end
51
+
52
+ describe "#modify_place(id, options={})" do
53
+ before do
54
+ @id = 'abc123'
55
+ stub_post("https://fooman:123123123@api.catch.com/v2/places/#{@id}", "modified_place.json")
56
+ end
57
+
58
+ it "returns the updated place" do
59
+ place = @client.modify_place(@id, {:name => "Lorem ipsum"})
60
+ place.id.must_equal @id
61
+ place.name.must_equal "Lorem ipsum"
62
+ end
63
+ end
64
+
65
+ describe "#delete_place(id)" do
66
+ before do
67
+ @id = 'abc123'
68
+ stub_delete("https://fooman:123123123@api.catch.com/v2/places/#{@id}", "place_delete.json")
69
+ end
70
+
71
+ it "deletes a specified place" do
72
+ place = @client.delete_place(@id)
73
+ place.must_equal true
74
+ end
75
+ end
76
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 5
9
- version: 0.0.5
8
+ - 7
9
+ version: 0.0.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Samuel Mullen
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-05-19 00:00:00 -05:00
17
+ date: 2011-06-03 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -112,12 +112,14 @@ files:
112
112
  - lib/catch/comment.rb
113
113
  - lib/catch/media.rb
114
114
  - lib/catch/note.rb
115
+ - lib/catch/place.rb
115
116
  - lib/catch/search.rb
116
117
  - lib/catch/tag.rb
117
118
  - lib/catch/user.rb
118
119
  - lib/catch/version.rb
119
120
  - test/client_test.rb
120
121
  - test/comment_test.rb
122
+ - test/fixtures/add_place.json
121
123
  - test/fixtures/comment.json
122
124
  - test/fixtures/comment_delete.json
123
125
  - test/fixtures/comments.json
@@ -126,15 +128,20 @@ files:
126
128
  - test/fixtures/media_delete.json
127
129
  - test/fixtures/modified_comment.json
128
130
  - test/fixtures/modified_note.json
131
+ - test/fixtures/modified_place.json
129
132
  - test/fixtures/note.json
130
133
  - test/fixtures/note_delete.json
131
134
  - test/fixtures/notes.json
135
+ - test/fixtures/place.json
136
+ - test/fixtures/place_delete.json
137
+ - test/fixtures/places.json
132
138
  - test/fixtures/search.json
133
139
  - test/fixtures/tags.json
134
140
  - test/fixtures/user.json
135
141
  - test/helper.rb
136
142
  - test/media_test.rb
137
143
  - test/note_test.rb
144
+ - test/place_test.rb
138
145
  - test/search_test.rb
139
146
  - test/tag_test.rb
140
147
  - test/user_test.rb