gitter-client 0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7c95b4a7978d9298a0945cd63a7333c441b7298c
4
+ data.tar.gz: 01805a22298c06c82de2c5b394c8eaaf28f4a516
5
+ SHA512:
6
+ metadata.gz: 30ae936a089a21b80879aad26aea8ddca5a9fea3d83df8d9602d2e9609b89e1bf4fe066a60ff300f261c2ee5d19e63a593dbc85636f03cf29c542eab6f5dac43
7
+ data.tar.gz: 7c0881d1a3153c86173d6be2c314e723fcc8caff788fa273338c86a2c26ae5c470a9a9a4aef887f6f51d409b199e804edec0129f12d3157e54e0a0a82a059b1e
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ruby-gitter.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 Chris Kacerguis
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # gitter-client
2
+ Ruby Library for interacting with the Gitter API
3
+
4
+ ## Installation
5
+
6
+ Add this line to your application's Gemfile:
7
+
8
+ gem 'gitter-client'
9
+
10
+ And then execute:
11
+
12
+ $ bundle
13
+
14
+ Or install it yourself as:
15
+
16
+ $ gem install gitter-client
17
+
18
+ ## Usage
19
+
20
+ To create a new client:
21
+
22
+ ```ruby
23
+ require 'gitter-client'
24
+
25
+ # Create a new client
26
+ client = Gitter::Client.new('TOKEN')
27
+ ```
28
+
29
+ The following client methods are available
30
+
31
+ ### Rooms
32
+
33
+ ```ruby
34
+ # Get a list of rooms
35
+ client.rooms
36
+
37
+ # Get the users of a specific room
38
+ client.room_users('ROOM_ID')
39
+
40
+ # Get the room channels
41
+ client.room_channels('ROOM_ID')
42
+
43
+ # join a room
44
+ client.join_room('kristenmills/ruby-gitter')
45
+ ```
46
+
47
+ ### Messages
48
+
49
+ ```ruby
50
+ # Get a list of messages
51
+ client.messages('ROOM_ID', limit: 50)
52
+
53
+ # Send a message
54
+ client.send_message('Hello everyone', 'ROOM_ID')
55
+
56
+ #Update a message
57
+ client.update_message('Hello everybody', 'ROOM_ID', 'CHAT_ID')
58
+ ```
59
+
60
+ ### Users
61
+
62
+ ```ruby
63
+ # Get the current user
64
+ client.current_user
65
+
66
+ # Get the users rooms
67
+ client.user_rooms('USER_ID')
68
+
69
+ # Mark the following chats as read
70
+ client.user_read_messages('USER_ID', 'ROOM_ID', ['CHAT_ID1', 'CHAT_ID2'])
71
+
72
+ # Get unread items and mentions from the room
73
+ client.user_unread_messages('USER_ID', 'ROOM_ID')
74
+
75
+ # Get the users organizations
76
+ client.user_orgs('USER_ID')
77
+
78
+ # Get the users repos
79
+ client.user_repos('USER_ID')
80
+
81
+ # Get the users channels
82
+ client.user_channels('USER_ID')
83
+ ```
84
+
85
+
86
+ ## Contributing
87
+
88
+ Note, this library is based off the excellent lib from Kristen Mills, I was unsuccessful
89
+ in getting in touch with her for changes, so I re-did this using a lot of her things.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gitter/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gitter-client"
8
+ spec.version = Gitter::VERSION
9
+ spec.authors = ["chriskacerguis"]
10
+ spec.email = ["chris@chriskacerguis.com"]
11
+ spec.summary = "Gitter API Client for Ruby"
12
+ spec.description = "Gitter API Client for Ruby"
13
+ spec.homepage = "https://github.com/chriskacerguis/gitter-client"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_runtime_dependency "httparty"
25
+ spec.add_runtime_dependency "hashie"
26
+ end
data/lib/gitter.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "gitter/version"
2
+ require "gitter/client"
3
+
4
+ module Gitter
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,23 @@
1
+ require "httparty"
2
+ require "gitter/client/rooms"
3
+ require "gitter/client/messages"
4
+ require "gitter/client/users"
5
+
6
+ module Gitter
7
+ class Client
8
+ include HTTParty
9
+ include Gitter::Client::Rooms
10
+ include Gitter::Client::Messages
11
+ include Gitter::Client::Users
12
+
13
+ base_uri "https://api.gitter.im/v1"
14
+
15
+ def initialize(token)
16
+ @headers = {
17
+ "Content-Type" => "application/json",
18
+ "Accept" => "application/json",
19
+ "Authorization" => "Bearer #{token}"
20
+ }
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,25 @@
1
+ require 'hashie/mash'
2
+ require 'json'
3
+
4
+ module Gitter
5
+ class Client
6
+ module Messages
7
+
8
+ def messages(room_id, options={})
9
+ message_list = []
10
+ self.class.get("/rooms/#{room_id}/chatMessages", headers: @headers, query: options).each do |message|
11
+ message_list << Hashie::Mash.new(message)
12
+ end
13
+ message_list
14
+ end
15
+
16
+ def send_message(message, room_id)
17
+ Hashie::Mash.new(self.class.post("/rooms/#{room_id}/chatMessages", headers: @headers, body: { text: message }.to_json ))
18
+ end
19
+
20
+ def update_message(message, room_id, chat_id)
21
+ Hashie::Mash.new(self.class.put("/rooms/#{room_id}/chatMessages/#{chat_id}", headers: @headers, body: { text: message }.to_json ))
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,35 @@
1
+ require 'hashie/mash'
2
+
3
+ module Gitter
4
+ class Client
5
+ module Rooms
6
+ def rooms
7
+ room_list = []
8
+ self.class.get("/rooms", headers: @headers).each do |room|
9
+ room_list << Hashie::Mash.new(room)
10
+ end
11
+ room_list
12
+ end
13
+
14
+ def room_users(room_id)
15
+ user_list = []
16
+ self.class.get("/rooms/#{room_id}/users", headers: @headers).each do |user|
17
+ user_list << Hashie::Mash.new(user)
18
+ end
19
+ user_list
20
+ end
21
+
22
+ def room_channels(room_id)
23
+ channel_list = []
24
+ self.class.get("/rooms/#{room_id}/channels", headers: @headers).each do |channel|
25
+ channel_list << Hashie::Mash.new(channel)
26
+ end
27
+ channel_list
28
+ end
29
+
30
+ def join_room(uri)
31
+ Hashie::Mash.new(self.class.post("/rooms", headers: @headers, query: { uri: uri } ))
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,56 @@
1
+ require 'hashie/mash'
2
+ require 'json'
3
+
4
+ module Gitter
5
+ class Client
6
+ module Users
7
+
8
+ def current_user
9
+ Hashie::Mash.new(self.class.get("/user", headers: @headers)[0])
10
+ end
11
+
12
+ def user_rooms(user_id)
13
+ room_list = []
14
+ self.class.get("/user/#{user_id}/rooms", headers: @headers).each do |room|
15
+ room_list << Hashie::Mash.new(room)
16
+ end
17
+ room_list
18
+ end
19
+
20
+ def user_read_messages(user_id, room_id, chat_ids)
21
+ Hashie::Mash.new(self.class.post("/user/#{user_id}/rooms/#{room_id}/unreadItems", headers: @headers, body: { chat: chat_ids }.to_json))
22
+ end
23
+
24
+ def user_unread_messages(user_id, room_id)
25
+ msg_list = []
26
+ Hashie::Mash.new(self.class.get("/user/#{user_id}/rooms/#{room_id}/unreadItems", headers: @headers).each do |msg|
27
+ msg_list << Hashie::Mash.new(msg)
28
+ end
29
+ end
30
+
31
+ def user_orgs(user_id)
32
+ org_list = []
33
+ self.class.get("/user/#{user_id}/orgs", headers: @headers).each do |org|
34
+ org_list << Hashie::Mash.new(org)
35
+ end
36
+ org_list
37
+ end
38
+
39
+ def user_repos(user_id)
40
+ repo_list = []
41
+ self.class.get("/user/#{user_id}/repos", headers: @headers).each do |repo|
42
+ repo_list << Hashie::Mash.new(repo)
43
+ end
44
+ repo_list
45
+ end
46
+
47
+ def user_channels(user_id)
48
+ channel_list = []
49
+ self.class.get("/user/#{user_id}/channels", headers: @headers).each do |channel|
50
+ channel_list << Hashie::Mash.new(channel)
51
+ end
52
+ channel_list
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,3 @@
1
+ module Gitter
2
+ VERSION = "0.2.0"
3
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gitter-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - chriskacerguis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: httparty
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: hashie
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Gitter API Client for Ruby
84
+ email:
85
+ - chris@chriskacerguis.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - Gemfile
91
+ - LICENSE
92
+ - README.md
93
+ - Rakefile
94
+ - gitter-client.gemspec
95
+ - lib/gitter.rb
96
+ - lib/gitter/client.rb
97
+ - lib/gitter/client/messages.rb
98
+ - lib/gitter/client/rooms.rb
99
+ - lib/gitter/client/users.rb
100
+ - lib/gitter/version.rb
101
+ homepage: https://github.com/chriskacerguis/gitter-client
102
+ licenses:
103
+ - MIT
104
+ metadata: {}
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 2.4.5.1
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: Gitter API Client for Ruby
125
+ test_files: []