zulip 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7104e27dedb5006e5b02e35bf0a8cadf8c74985b
4
- data.tar.gz: a33826034e2546c0ef6957b1e41bde933ae5b342
3
+ metadata.gz: 1c26f1799992de53d2b0e4d3b949d48c5f483442
4
+ data.tar.gz: f7ab02ae72f18856b636c474c659cd86637580b1
5
5
  SHA512:
6
- metadata.gz: 4597dad59bb5b8269d3149a91c4629a6cf1f455ea961632b6a351cdcb39a1486e5d6a264609bcce36942b9910aea1b357729e5da9116a0c4e5ddca24929fdd40
7
- data.tar.gz: ae289b999a7ebdd71d3504263de80d1255aba4f38aa4c3c141fa80ee28470774793a91e55bbb0bad6c961741cbe321f55725c2140c6302c1d823b20a247d0b5a
6
+ metadata.gz: dcb0d482d015f5700ff7655ef927614949a0c586bfc9cbf028fc39faa91dca2e08c9dde4c6d62ffa942065895c176c7c619a92618d97a91d460dc7f970c03cb3
7
+ data.tar.gz: 652a0ba97e0d108ce5e5358f50f89feb3df088e433f044d52390d410ae0f4b75914af2e10a7d4936acd7cc45202d714ab8fdc569dc76b387883516e2e7009165
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  Gemfile.lock
2
+ pkg/*
data/README.md CHANGED
@@ -6,7 +6,7 @@ A ruby interface to the Zulip API.
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
- `gem 'zulip-rb'`
9
+ `gem 'zulip'`
10
10
 
11
11
  And then execute:
12
12
 
@@ -17,20 +17,17 @@ Or install it yourself as:
17
17
  `$ gem install zulip-rb`
18
18
 
19
19
  ### Configuration
20
- You'll need to register a bot to use the Zulip API.
21
20
  You can obtain your Zulip API key, create bots, and manage bots all
22
21
  from your Zulip [settings page](https://zulip.com/#settings).
23
22
 
24
- Set your api key and your bot's email address by passing a block to your Zulip::Client instance:
23
+ Set your api key and email address by passing a block to your Zulip::Client instance:
25
24
  ```ruby
26
25
  client = Zulip::Client.new do |config|
27
- config.bot_email_address = "YOUR_BOTS_EMAIL_ADDRESS"
26
+ config.email_address = "YOUR_EMAIL_ADDRESS"
28
27
  config.api_key = "YOUR_API_KEY"
29
28
  end
30
29
  ```
31
30
 
32
- You'll need to subscribe your bot to streams you want to read from. Do so by adding your bot's email to the stream's membership from a zulip client, or use the #subscribe method (see example below).
33
-
34
31
  ### Usage
35
32
 
36
33
  Send messages to a stream:
@@ -50,12 +47,12 @@ client.stream_messages do |message|
50
47
  end
51
48
  ```
52
49
 
53
- Get your bot's current subscriptions:
50
+ Get your current subscriptions:
54
51
  ```ruby
55
52
  client.get_subscriptions
56
53
  ```
57
54
 
58
- Subscribe your bot to a stream, passing the stream name:
55
+ Subscribe to a stream, passing the stream name:
59
56
  ```ruby
60
57
  client.subscribe "food"
61
58
  ```
@@ -7,12 +7,14 @@ class ZulipEcho
7
7
 
8
8
  def run
9
9
  client = Zulip::Client.new do |config|
10
- config.bot_email_address = ENV['BOT_EMAIL_ADDRESS'] || "bot@example.com"
10
+ config.email_address = ENV['BOT_EMAIL_ADDRESS'] || "bot@example.com"
11
11
  config.api_key = ENV['BOT_API_KEY'] || "apikey"
12
12
  end
13
13
 
14
- client.stream_messages do |message|
15
- client.send_private_message(private_message_content(message), "example@gmail.com")
14
+ client.stream_private_messages do |message|
15
+ if message.stream == "test-stream"
16
+ client.send_private_message(private_message_content(message), "example@gmail.com")
17
+ end
16
18
  end
17
19
  end
18
20
 
@@ -17,7 +17,7 @@ module Zulip
17
17
  include Zulip::Client::EventStreaming
18
18
  include Zulip::Client::EventParser
19
19
 
20
- attr_accessor :bot_email_address, :api_key
20
+ attr_accessor :email_address, :api_key
21
21
  attr_writer :connection
22
22
  ENDPOINT = "https://api.zulip.com"
23
23
 
@@ -33,7 +33,7 @@ module Zulip
33
33
 
34
34
  def initialize_connection
35
35
  conn = Faraday.new(url: ENDPOINT)
36
- conn.basic_auth(bot_email_address, api_key)
36
+ conn.basic_auth(email_address, api_key)
37
37
  conn
38
38
  end
39
39
 
@@ -1,6 +1,9 @@
1
1
  module Zulip
2
2
  class Client
3
3
  module QueueRegistration
4
+
5
+ class InvalideEmailOrAPI < StandardError; end
6
+
4
7
  EVENT_TYPES = { message: "message" }
5
8
  # TODO: Add support for other event types
6
9
  # TODO: Add support setting apply markdown to false
@@ -13,6 +16,8 @@ module Zulip
13
16
  connection.params = { "event_types" => json_encode_list(event_types) }
14
17
  end
15
18
 
19
+ raise InvalideEmailOrAPI if registration_response['result'] == "error"
20
+
16
21
  QueueRegistrationResponse.new( registration_response['queue_id'],
17
22
  registration_response['last_event_id'] )
18
23
  end
@@ -1,3 +1,3 @@
1
1
  module Zulip
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -17,7 +17,7 @@ module Zulip
17
17
  let(:fake_queue) { double("fake queue", queue_id: "id", last_event_id: -1) }
18
18
 
19
19
  describe "#stream_private_messages" do
20
- it "returns private messages viewable to the bot" do
20
+ it "returns private messages viewable to the user" do
21
21
 
22
22
  # Returns a public-message, then a private message
23
23
  fake_response.stub(:body).and_return(public_message_fixture, private_message_fixture)
@@ -5,7 +5,7 @@ module Zulip
5
5
  class Client
6
6
  describe StreamSubscriptions do
7
7
  describe "#get_subscriptions" do
8
- it "returns the bot's stream subscriptions" do
8
+ it "returns the user's stream subscriptions" do
9
9
  fake_http_response = double("fake http response",
10
10
  body: fixture("get-user-subscriptions.json"))
11
11
  fake_connection = double("fake connection", get: fake_http_response)
@@ -5,7 +5,7 @@ module Zulip
5
5
  class Client
6
6
  describe Users do
7
7
  describe "get_users" do
8
- it "returns users in the bot's realm" do
8
+ it "returns a list of users" do
9
9
 
10
10
  fake_http_response = double("fake http response", body: fixture("get-users.json"))
11
11
  fake_connection = double("fake connection", get: fake_http_response)
@@ -5,11 +5,11 @@ describe Zulip::Client do
5
5
  it "yields itself upon initialization for configuration" do
6
6
 
7
7
  client = Zulip::Client.new do |config|
8
- config.bot_email_address = "bot@example.com"
8
+ config.email_address = "bot@example.com"
9
9
  config.api_key = "apikey"
10
10
  end
11
11
 
12
- expect(client.bot_email_address).to eq "bot@example.com"
12
+ expect(client.email_address).to eq "bot@example.com"
13
13
  expect(client.api_key).to eq "apikey"
14
14
  end
15
15
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zulip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Vergeront
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-18 00:00:00.000000000 Z
11
+ date: 2013-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday