jaconda 1.0.2 → 2.0.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/README.markdown +87 -27
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/jaconda.gemspec +12 -5
- data/lib/jaconda.rb +9 -31
- data/lib/jaconda/base.rb +16 -0
- data/lib/jaconda/member.rb +19 -0
- data/lib/jaconda/message.rb +14 -0
- data/lib/jaconda/notification.rb +17 -0
- data/lib/jaconda/presence.rb +4 -0
- data/lib/jaconda/room.rb +29 -0
- data/lib/jaconda/upload.rb +5 -0
- metadata +18 -9
data/README.markdown
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Jaconda API
|
2
2
|
--------------
|
3
3
|
|
4
|
-
The official ruby wrapper for working with the [Jaconda REST API](http://help.jaconda.im/
|
4
|
+
The official ruby wrapper for working with the [Jaconda REST API](http://help.jaconda.im/kb/api-v2/jaconda-api-documentation)'s XML interface.
|
5
5
|
|
6
6
|
## Installation
|
7
7
|
|
@@ -13,46 +13,106 @@ ActiveResource
|
|
13
13
|
|
14
14
|
## Usage
|
15
15
|
|
16
|
-
|
16
|
+
### Sending notifications
|
17
17
|
|
18
|
-
Jaconda::
|
18
|
+
Jaconda::Notification.authenticate(:subdomain => "JACONDA_SUBDOMAIN",
|
19
|
+
:room_id => "ROOM_ID",
|
20
|
+
:room_token => "ROOM_TOKEN")
|
19
21
|
|
20
|
-
|
22
|
+
Jaconda::Notification.notify(:text => "146 tests, 1399 assertions, 0 failures, 0 errors",
|
23
|
+
:sender_name => "Build Server")
|
21
24
|
|
22
|
-
|
23
|
-
Jaconda::Room.find(123) # find individual room by ID
|
25
|
+
### Using API
|
24
26
|
|
25
|
-
|
27
|
+
Jaconda::API.authenticate(:subdomain => "JACONDA_SUBDOMAIN",
|
28
|
+
:token => "API_TOKEN")
|
26
29
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
+
Jaconda::API.authenticate(:subdomain => "JACONDA_SUBDOMAIN",
|
31
|
+
:email => "EMAIL",
|
32
|
+
:password => "PASSWORD")
|
33
|
+
|
34
|
+
#### Finding rooms
|
35
|
+
|
36
|
+
Jaconda::API::Room.find(:all)
|
37
|
+
Jaconda::API::Room.find("support")
|
38
|
+
|
39
|
+
#### Finding who's available in the room
|
40
|
+
|
41
|
+
room = Jaconda::API::Room.find("support")
|
42
|
+
room.available_users
|
43
|
+
|
44
|
+
#### Finding who has access to the room
|
30
45
|
|
31
|
-
|
46
|
+
room = Jaconda::API::Room.find("support")
|
47
|
+
room.presences
|
32
48
|
|
33
|
-
|
34
|
-
|
49
|
+
#### Creating a Room
|
50
|
+
|
51
|
+
Jaconda::API::Room.create(:jid => "awesome.project",
|
52
|
+
:title => "Awesome Project Room")
|
53
|
+
|
54
|
+
#### Updating a Room
|
55
|
+
|
56
|
+
room = Jaconda::API::Room.find("support")
|
57
|
+
room.topic = "Deadline: 3 apr"
|
35
58
|
room.save
|
36
59
|
|
37
|
-
|
60
|
+
#### Finding messages
|
38
61
|
|
39
|
-
room = Jaconda::Room.find(
|
62
|
+
room = Jaconda::API::Room.find("support")
|
40
63
|
room.messages
|
41
|
-
|
42
|
-
|
43
|
-
Jaconda::Message.find(:all, :params => { :room_id =>
|
64
|
+
room.messages(:page => 2)
|
65
|
+
|
66
|
+
Jaconda::API::Message.find(:all, :params => { :room_id => "support",
|
67
|
+
:per_page => 100,
|
68
|
+
:page => 2 })
|
69
|
+
|
70
|
+
#### Finding messages on date
|
71
|
+
|
72
|
+
room = Jaconda::API::Room.find("support")
|
73
|
+
room.transcript
|
74
|
+
room.transcript(:date => Date.yesterday)
|
75
|
+
|
76
|
+
Jaconda::API::Message.transcript(:room_id => "support",
|
77
|
+
:date => Date.today - 1.month)
|
78
|
+
|
79
|
+
#### Searching for messages
|
80
|
+
|
81
|
+
room = Jaconda::API::Room.find("support")
|
82
|
+
room.search(:text => "bug")
|
83
|
+
room.search(:text => "commit", :per_page => 5)
|
84
|
+
|
85
|
+
Jaconda::API::Message.search(:room_id => "support",
|
86
|
+
:text => "issue",
|
87
|
+
:page => 2)
|
88
|
+
|
89
|
+
#### Saying something
|
90
|
+
|
91
|
+
Jaconda::API::Message.create(:room_id => "support",
|
92
|
+
:text => "Hello from the API!")
|
93
|
+
|
94
|
+
Jaconda::API::Message.create(:room_id => "support",
|
95
|
+
:text => "is loving Jaconda!",
|
96
|
+
:kind => "me")
|
97
|
+
|
98
|
+
Jaconda::API::Message.create(:room_id => "support",
|
99
|
+
:text => "Hello from the API!",
|
100
|
+
:kind => "voice")
|
101
|
+
|
102
|
+
#### Finding members
|
44
103
|
|
45
|
-
|
104
|
+
Jaconda::API::Member.find(:all)
|
105
|
+
Jaconda::API::Member.find(123)
|
46
106
|
|
47
|
-
|
107
|
+
#### Inviting new member
|
48
108
|
|
49
|
-
|
109
|
+
Jaconda::API::Member.create(:name => "Anton",
|
110
|
+
:email => "developer@gmail.com")
|
50
111
|
|
51
|
-
|
52
|
-
room.users
|
53
|
-
|
54
|
-
Jaconda::User.find(:all, :params => { :room_id => 123 })
|
112
|
+
#### Finding uploads
|
55
113
|
|
56
|
-
|
114
|
+
room = Jaconda::API::Room.find("support")
|
115
|
+
room.uploads
|
57
116
|
|
58
|
-
Jaconda::
|
117
|
+
member = Jaconda::API::Member.find(123)
|
118
|
+
member.uploads
|
data/Rakefile
CHANGED
@@ -9,7 +9,7 @@ begin
|
|
9
9
|
gem.email = "ant.mironov@gmail.com"
|
10
10
|
gem.homepage = "http://github.com/mironov/jaconda-api"
|
11
11
|
gem.authors = ["Anton Mironov"]
|
12
|
-
gem.add_dependency "activeresource"
|
12
|
+
gem.add_dependency "activeresource", "~> 2.3.5"
|
13
13
|
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
14
14
|
end
|
15
15
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
data/jaconda.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{jaconda}
|
8
|
-
s.version = "
|
8
|
+
s.version = "2.0.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Anton Mironov"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-02-27}
|
13
13
|
s.email = %q{ant.mironov@gmail.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
@@ -23,6 +23,13 @@ Gem::Specification.new do |s|
|
|
23
23
|
"VERSION",
|
24
24
|
"jaconda.gemspec",
|
25
25
|
"lib/jaconda.rb",
|
26
|
+
"lib/jaconda/base.rb",
|
27
|
+
"lib/jaconda/member.rb",
|
28
|
+
"lib/jaconda/message.rb",
|
29
|
+
"lib/jaconda/notification.rb",
|
30
|
+
"lib/jaconda/presence.rb",
|
31
|
+
"lib/jaconda/room.rb",
|
32
|
+
"lib/jaconda/upload.rb",
|
26
33
|
"test/helper.rb",
|
27
34
|
"test/test_jaconda.rb"
|
28
35
|
]
|
@@ -41,14 +48,14 @@ Gem::Specification.new do |s|
|
|
41
48
|
s.specification_version = 3
|
42
49
|
|
43
50
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
44
|
-
s.add_runtime_dependency(%q<activeresource>, ["
|
51
|
+
s.add_runtime_dependency(%q<activeresource>, ["~> 2.3.5"])
|
45
52
|
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
46
53
|
else
|
47
|
-
s.add_dependency(%q<activeresource>, ["
|
54
|
+
s.add_dependency(%q<activeresource>, ["~> 2.3.5"])
|
48
55
|
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
49
56
|
end
|
50
57
|
else
|
51
|
-
s.add_dependency(%q<activeresource>, ["
|
58
|
+
s.add_dependency(%q<activeresource>, ["~> 2.3.5"])
|
52
59
|
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
53
60
|
end
|
54
61
|
end
|
data/lib/jaconda.rb
CHANGED
@@ -1,31 +1,9 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
self.user = api_token
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class Room < API
|
15
|
-
def users(options = {})
|
16
|
-
User.find(:all, :params => options.update(:room_id => id))
|
17
|
-
end
|
18
|
-
|
19
|
-
def messages(options = {})
|
20
|
-
Message.find(:all, :params => options.update(:room_id => id))
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class User < API
|
25
|
-
self.prefix = "/api/rooms/:room_id/"
|
26
|
-
end
|
27
|
-
|
28
|
-
class Message < API
|
29
|
-
self.prefix = "/api/rooms/:room_id/"
|
30
|
-
end
|
31
|
-
end
|
1
|
+
require "active_resource"
|
2
|
+
|
3
|
+
require "jaconda/base"
|
4
|
+
require "jaconda/notification"
|
5
|
+
require "jaconda/room"
|
6
|
+
require "jaconda/upload"
|
7
|
+
require "jaconda/member"
|
8
|
+
require "jaconda/presence"
|
9
|
+
require "jaconda/message"
|
data/lib/jaconda/base.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Jaconda
|
2
|
+
class API < ActiveResource::Base
|
3
|
+
self.prefix = "/api/v2/"
|
4
|
+
|
5
|
+
def self.authenticate(options)
|
6
|
+
self.site = "https://#{options[:subdomain]}.jaconda.im"
|
7
|
+
if options[:token]
|
8
|
+
self.user = options[:token]
|
9
|
+
self.password = "x"
|
10
|
+
else
|
11
|
+
self.user = options[:email]
|
12
|
+
self.password = options[:password]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Jaconda
|
2
|
+
class API::Member < API
|
3
|
+
self.element_name = "user"
|
4
|
+
|
5
|
+
def self.collection_name
|
6
|
+
"members"
|
7
|
+
end
|
8
|
+
|
9
|
+
def presences
|
10
|
+
API::Presence.prefix = "/api/v2/members/:user_id/"
|
11
|
+
API::Presence.find(:all, :params => {:user_id => id})
|
12
|
+
end
|
13
|
+
|
14
|
+
def uploads
|
15
|
+
API::Upload.prefix = "/api/v2/members/:user_id/"
|
16
|
+
API::Upload.find(:all, :params => {:user_id => id})
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Jaconda
|
2
|
+
class API::Message < API
|
3
|
+
self.prefix = "/api/v2/rooms/:room_id/"
|
4
|
+
|
5
|
+
def self.search(options = {})
|
6
|
+
get(:search, options)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.transcript(options = {})
|
10
|
+
date = options[:date] || Date.today
|
11
|
+
get("#{date.year}/#{date.month}/#{date.day}", options)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Jaconda
|
2
|
+
class Notification < ActiveResource::Base
|
3
|
+
self.prefix = "/api/v2/rooms/:room_id/"
|
4
|
+
self.element_name = ""
|
5
|
+
|
6
|
+
def self.authenticate(options)
|
7
|
+
self.site = "https://#{options[:subdomain]}.jaconda.im"
|
8
|
+
@room_id = options[:room_id]
|
9
|
+
self.user = options[:room_token]
|
10
|
+
self.password = "x"
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.notify(params = {})
|
14
|
+
post(:notify, :message => params, :room_id => @room_id)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/jaconda/room.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
module Jaconda
|
2
|
+
class API::Room < API
|
3
|
+
def id
|
4
|
+
jid
|
5
|
+
end
|
6
|
+
|
7
|
+
def presences
|
8
|
+
API::Presence.prefix = "/api/v2/rooms/:room_id/"
|
9
|
+
API::Presence.find(:all, :params => {:room_id => id})
|
10
|
+
end
|
11
|
+
|
12
|
+
def uploads
|
13
|
+
API::Upload.prefix = "/api/v2/rooms/:room_id/"
|
14
|
+
API::Upload.find(:all, :params => {:room_id => id})
|
15
|
+
end
|
16
|
+
|
17
|
+
def messages(options = {})
|
18
|
+
API::Message.find(:all, :params => options.update(:room_id => id))
|
19
|
+
end
|
20
|
+
|
21
|
+
def search(options = {})
|
22
|
+
API::Message.search(options.update(:room_id => id))
|
23
|
+
end
|
24
|
+
|
25
|
+
def transcript(options = {})
|
26
|
+
API::Message.transcript(options.update(:room_id => id))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jaconda
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
7
|
- 2
|
10
|
-
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 2.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Anton Mironov
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-02-27 00:00:00 +05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -24,12 +24,14 @@ dependencies:
|
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 9
|
30
30
|
segments:
|
31
|
-
-
|
32
|
-
|
31
|
+
- 2
|
32
|
+
- 3
|
33
|
+
- 5
|
34
|
+
version: 2.3.5
|
33
35
|
type: :runtime
|
34
36
|
version_requirements: *id001
|
35
37
|
- !ruby/object:Gem::Dependency
|
@@ -63,6 +65,13 @@ files:
|
|
63
65
|
- VERSION
|
64
66
|
- jaconda.gemspec
|
65
67
|
- lib/jaconda.rb
|
68
|
+
- lib/jaconda/base.rb
|
69
|
+
- lib/jaconda/member.rb
|
70
|
+
- lib/jaconda/message.rb
|
71
|
+
- lib/jaconda/notification.rb
|
72
|
+
- lib/jaconda/presence.rb
|
73
|
+
- lib/jaconda/room.rb
|
74
|
+
- lib/jaconda/upload.rb
|
66
75
|
- test/helper.rb
|
67
76
|
- test/test_jaconda.rb
|
68
77
|
has_rdoc: true
|