tinder 0.1.9 → 1.1.7

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.
@@ -1,12 +1,3 @@
1
- 0.1.9
2
- * Repackaging to include multipart file
3
-
4
- 0.1.8
5
- * Get the list of available files [Christopher MacGown]
6
- * Upload files [Joshua Want]
7
- * Find rooms even when full [Josh Owens]
8
- * Join rooms as a guest [Ian Lesperance]
9
-
10
1
  0.1.7 - 2008-07-24
11
2
  * Don't join the room when only speaking [Brian Donovan]
12
3
  * Added support for HTTP proxies
@@ -5,6 +5,5 @@ Rakefile
5
5
  init.rb
6
6
  lib/tinder.rb
7
7
  lib/tinder/campfire.rb
8
- lib/tinder/multipart.rb
9
8
  lib/tinder/room.rb
10
9
  lib/tinder/version.rb
data/README.txt CHANGED
@@ -6,15 +6,11 @@ Tinder is a library for interfacing with Campfire, the chat application from 37S
6
6
 
7
7
  campfire = Campfire.new 'mysubdomain'
8
8
  campfire.login 'myemail@example.com', 'mypassword'
9
-
10
9
  room = campfire.create_room 'New Room', 'My new campfire room to test tinder'
11
10
  room.rename 'New Room Name'
12
11
  room.speak 'Hello world!'
13
12
  room.paste "my pasted\ncode"
14
13
  room.destroy
15
-
16
- room = campfire.find_room_by_guest_hash 'abc123', 'John Doe'
17
- room.speak 'Hello world!'
18
14
 
19
15
  See the RDoc for more details.
20
16
 
@@ -40,4 +36,5 @@ The source for Tinder is available at http://source.collectiveidea.com/public/ti
40
36
  == ToDo
41
37
 
42
38
  * Tests! (unit and remote)
39
+ * Log in via guest url
43
40
  * Marshmallow-style integration scripts for exception notification and continuous integration
data/Rakefile CHANGED
@@ -1,12 +1,5 @@
1
1
  require 'rubygems'
2
2
  require 'hoe'
3
- begin
4
- require 'spec/rake/spectask'
5
- rescue LoadError
6
- puts 'To use rspec for testing you must install rspec gem:'
7
- puts '$ sudo gem install rspec'
8
- exit
9
- end
10
3
  require File.join(File.dirname(__FILE__), 'lib', 'tinder', 'version')
11
4
 
12
5
  # RDOC_OPTS = ['--quiet', '--title', "Tinder",
@@ -28,14 +21,4 @@ hoe = Hoe.new('tinder', ENV['VERSION'] || Tinder::VERSION::STRING) do |p|
28
21
  p.changes = p.paragraphs_of('CHANGELOG.txt', 0..1).join("\n\n")
29
22
  p.extra_deps << ['activesupport']
30
23
  p.extra_deps << ['hpricot']
31
- p.extra_deps << ['mime-types']
32
- end
33
-
34
- desc "Run the specs under spec"
35
- Spec::Rake::SpecTask.new do |t|
36
- t.spec_opts = ['--options', "spec/spec.opts"]
37
- t.spec_files = FileList['spec/**/*_spec.rb']
38
24
  end
39
-
40
- desc "Default task is to run specs"
41
- task :default => :spec
@@ -4,13 +4,9 @@ module Tinder
4
4
  #
5
5
  # campfire = Tinder::Campfire.new 'mysubdomain'
6
6
  # campfire.login 'myemail@example.com', 'mypassword'
7
- #
8
7
  # room = campfire.create_room 'New Room', 'My new campfire room to test tinder'
9
8
  # room.speak 'Hello world!'
10
9
  # room.destroy
11
- #
12
- # room = campfire.find_room_by_guest_hash 'abc123', 'John Doe'
13
- # room.speak 'Hello world!'
14
10
  class Campfire
15
11
  attr_reader :subdomain, :uri
16
12
 
@@ -60,10 +56,8 @@ module Tinder
60
56
  # Get an array of all the available rooms
61
57
  # TODO: detect rooms that are full (no link)
62
58
  def rooms
63
- Hpricot(get.body).search("//div.room").collect do |a|
64
- name = a.search("//h2/a").inner_html.strip
65
- name = a.search("//h2").inner_html.strip if name.empty?
66
- Room.new(self, room_id_from_element(a.attributes['id']), name)
59
+ Hpricot(get.body).search("//h2/a").collect do |a|
60
+ Room.new(self, room_id_from_url(a.attributes['href']), a.inner_html)
67
61
  end
68
62
  end
69
63
 
@@ -71,13 +65,6 @@ module Tinder
71
65
  def find_room_by_name(name)
72
66
  rooms.detect {|room| room.name == name }
73
67
  end
74
-
75
- # Find a campfire room by its guest hash
76
- def find_room_by_guest_hash(hash, name)
77
- res = post(hash, :name => name)
78
-
79
- Room.new(self, room_id_from_url(res['location'])) if verify_response(res, :redirect)
80
- end
81
68
 
82
69
  # Creates and returns a new Room with the given +name+ and optionally a +topic+
83
70
  def create_room(name, topic = nil)
@@ -124,10 +111,6 @@ module Tinder
124
111
  def room_id_from_url(url)
125
112
  url.scan(/room\/(\d*)/).to_s
126
113
  end
127
-
128
- def room_id_from_element(element)
129
- element.split("_").last
130
- end
131
114
 
132
115
  def url_for(*args)
133
116
  options = {:only_path => true}.merge(args.last.is_a?(Hash) ? args.pop : {})
@@ -138,11 +121,8 @@ module Tinder
138
121
  def post(path, data = {}, options = {})
139
122
  perform_request(options) do
140
123
  returning Net::HTTP::Post.new(url_for(path)) do |request|
141
- if options[:multipart]
142
- request.body = data
143
- else
144
- request.set_form_data(flatten(data))
145
- end
124
+ request.add_field 'Content-Type', 'application/x-www-form-urlencoded'
125
+ request.set_form_data flatten(data)
146
126
  end
147
127
  end
148
128
  end
@@ -159,11 +139,6 @@ module Tinder
159
139
  request.add_field 'X-Requested-With', 'XMLHttpRequest'
160
140
  request.add_field 'X-Prototype-Version', '1.5.1.1'
161
141
  end
162
- if options[:multipart]
163
- request.add_field 'Content-Type', 'multipart/form-data, boundary=' + Multipart::MultipartPost::BOUNDARY + " "
164
- else
165
- request.add_field 'Content-Type', 'application/x-www-form-urlencoded'
166
- end
167
142
  end
168
143
  end
169
144
 
@@ -95,17 +95,8 @@ module Tinder
95
95
 
96
96
  # Post a new message to the chat room
97
97
  def speak(message, options = {})
98
- post_options = {
99
- :message => message,
100
- :t => Time.now.to_i
101
- }.merge(options)
102
-
103
- post_options.delete(:paste) unless post_options[:paste]
104
- response = post("room/#{id}/speak", post_options, :ajax => true)
105
-
106
- if verify_response(response, :success)
107
- message
108
- end
98
+ message if verify_response(post("room/#{id}/speak", {:message => message,
99
+ :t => Time.now.to_i}.merge(options), :ajax => true), :success)
109
100
  end
110
101
 
111
102
  def paste(message)
@@ -116,7 +107,7 @@ module Tinder
116
107
  def users
117
108
  @campfire.users name
118
109
  end
119
-
110
+
120
111
  # Get and array of the messages that have been posted to the room. Each
121
112
  # messages is a hash with:
122
113
  # * +:person+: the display name of the person that posted the message
@@ -172,22 +163,7 @@ module Tinder
172
163
  }
173
164
  end
174
165
  end
175
-
176
- def upload(filename)
177
- File.open(filename, "rb") do |file|
178
- params = Multipart::MultipartPost.new({'upload' => file, 'submit' => "Upload"})
179
- verify_response post("upload.cgi/room/#{@id}/uploads/new", params.query, :multipart => true), :success
180
- end
181
- end
182
-
183
- # Get the list of latest files for this room
184
- def files(count = 5)
185
- join
186
- (Hpricot(@room.body)/"#file_list li a").to_a[0,count].map do |link|
187
- @campfire.send :url_for, link.attributes['href'][1..-1], :only_path => false
188
- end
189
- end
190
-
166
+
191
167
  protected
192
168
 
193
169
  def messages
@@ -2,7 +2,7 @@ module Tinder #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- TINY = 9
5
+ TINY = 7
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tinder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Keepers
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-28 00:00:00 -05:00
12
+ date: 2008-07-24 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -32,16 +32,6 @@ dependencies:
32
32
  - !ruby/object:Gem::Version
33
33
  version: "0"
34
34
  version:
35
- - !ruby/object:Gem::Dependency
36
- name: mime-types
37
- type: :runtime
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: "0"
44
- version:
45
35
  - !ruby/object:Gem::Dependency
46
36
  name: hoe
47
37
  type: :development
@@ -50,7 +40,7 @@ dependencies:
50
40
  requirements:
51
41
  - - ">="
52
42
  - !ruby/object:Gem::Version
53
- version: 1.8.2
43
+ version: 1.7.0
54
44
  version:
55
45
  description: An API for interfacing with Campfire, the 37Signals chat application.
56
46
  email: brandon@opensoul.org
@@ -70,7 +60,6 @@ files:
70
60
  - init.rb
71
61
  - lib/tinder.rb
72
62
  - lib/tinder/campfire.rb
73
- - lib/tinder/multipart.rb
74
63
  - lib/tinder/room.rb
75
64
  - lib/tinder/version.rb
76
65
  has_rdoc: true
@@ -96,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
85
  requirements: []
97
86
 
98
87
  rubyforge_project: tinder
99
- rubygems_version: 1.3.1
88
+ rubygems_version: 1.2.0
100
89
  signing_key:
101
90
  specification_version: 2
102
91
  summary: An (unofficial) Campfire API
@@ -1,64 +0,0 @@
1
- require 'rubygems'
2
- require 'mime/types'
3
- require 'net/http'
4
- require 'cgi'
5
-
6
- module Multipart #:nodoc:
7
- # From: http://deftcode.com/code/flickr_upload/multipartpost.rb
8
- ## Helper class to prepare an HTTP POST request with a file upload
9
- ## Mostly taken from
10
- #http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/113774
11
- ### WAS:
12
- ## Anything that's broken and wrong probably the fault of Bill Stilwell
13
- ##(bill@marginalia.org)
14
- ### NOW:
15
- ## Everything wrong is due to keith@oreilly.com
16
-
17
- class Param #:nodoc:
18
- attr_accessor :k, :v
19
- def initialize(k, v)
20
- @k = k
21
- @v = v
22
- end
23
-
24
- def to_multipart
25
- "Content-Disposition: form-data; name=\"#{k}\"\r\n\r\n#{v}\r\n"
26
- end
27
- end
28
-
29
- class FileParam #:nodoc:
30
- attr_accessor :k, :filename, :content
31
- def initialize(k, filename, content)
32
- @k = k
33
- @filename = filename
34
- @content = content
35
- end
36
-
37
- def to_multipart
38
- "Content-Disposition: form-data; name=\"#{k}\"; filename=\"#{filename}\"\r\n" +
39
- "Content-Transfer-Encoding: binary\r\n" +
40
- "Content-Type: #{MIME::Types.type_for(@filename)}\r\n\r\n" +
41
- @content + "\r\n"
42
- end
43
- end
44
-
45
- class MultipartPost #:nodoc:
46
- BOUNDARY = 'campfire-is-awesome'
47
- HEADER = {"Content-type" => "multipart/form-data, boundary=" + BOUNDARY + " "}
48
- TIMEOUT_SECONDS = 30
49
-
50
- attr_accessor :params, :query, :headers
51
- def initialize(params)
52
- @params = params
53
- @query = {}
54
- self.prepare_query
55
- end
56
-
57
- def prepare_query()
58
- @query = @params.map do |k,v|
59
- param = v.respond_to?(:read) ? FileParam.new(k, v.path, v.read) : Param.new(k, v)
60
- "--#{BOUNDARY}\r\n#{param.to_multipart}"
61
- end.join("") + "--#{BOUNDARY}--"
62
- end
63
- end
64
- end