glip-poster 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf78cb00473593f849b8a6fdbddc778f677d4884
4
- data.tar.gz: 36e1cb0d1738cfbebc0975ddefa2116ec809766b
3
+ metadata.gz: 1e04b1814536e841a21c40ef76ebc22efb374901
4
+ data.tar.gz: 7225cb0a4e817bf2f6f810594ec35fb94a33d0c6
5
5
  SHA512:
6
- metadata.gz: ea165044446914a0c5fe3a446303ff6e42740cc4e70a6c48a3895bc17536e5d1ecc8e91d2c25c6f772a6fa4d312046af46fc0b08189c6183c1e012dd28ebaa6e
7
- data.tar.gz: 94a6adeac3f4d6244c883bc85ff44ebcf3ffcf20a83aaa36045f5f8f2cf6fa754a9fb5a5d1934500c98827d52fe4e462f7bd806da8b407975b81e50cf6bc6083
6
+ metadata.gz: b504dff9e41d75bf616b97cfbf5ff0bbf72381b04aba84b1a11745afa54e622a232bf0070afbc3ff46dd4a40349651e0c9e84b044f293a2c6bb0076b89c32610
7
+ data.tar.gz: 4fa261626d489515e6229fa1577e46a264f7027e2b8291880f0c4ed2df30fbdf8c53e1f2a3f736a33bafb32dc14ba04b5d6c3b10c54d4ce68c6b7ff6fcf8a695
data/README.md CHANGED
@@ -32,41 +32,37 @@ $ gem install glip-poster
32
32
 
33
33
  ## Glip setup
34
34
 
35
- This gem will use a incoming webHook integration on Glip. First, you need to create a new Glip webhook integration. In Glip.com, click on 'Integrations' if the left column and then select the "Glip Webhooks" integration. After you select a conversation, a webhook URL will be displayed for you which will be used by this gem to post messages to. The URL looks like the following:
35
+ This gem uses an incoming webhook integration on Glip. To create a new Glip webhook integration, in Glip.com, click on "Integrations" in the left column and then select the "Glip Webhooks" integration. After you select a conversation, a webhook URL will be presented which you will use with this gem to post messages to. The URL looks like the following:
36
36
 
37
37
  ```http
38
38
  https://hooks.glip.com/webhook/11112222-3333-4444-5555-666677778888
39
39
  ```
40
40
 
41
- You can instantiate the `Glip::Poster` class with the full URL or the webhook ID (GUID) only.
42
-
43
41
  ## Usage
44
42
 
45
- First you have to initialize your poster and then you can use `send_message` to send your message. You must have a webhook URL configured in Glip using the "Glip Webhooks" integration.
43
+ Initialize your poster and then call the `send_message` method to send your message. You must supply the webhook URL or webhook ID configured in the desired "Glip Webhooks" integration.
46
44
 
47
45
  ```ruby
48
- require 'glip-poster'
46
+ require 'glip_poster' # note underscore
49
47
 
50
- poster = Glip::Poster.new(YOUR_WEBHOOK_URL)
48
+ poster = Glip::Poster.new(YOUR_WEBHOOK_URL) # or YOUR_WEBHOOK_ID (GUID)
51
49
  poster.send_message('Hi there!') # Faraday::Response
52
50
  ```
53
51
 
54
52
  You can send text in Markdown:
55
53
 
56
54
  ```ruby
57
- poster = Glip::Poster.new(YOUR_WEBHOOK_URL)
58
- poster.send_message('* Location: [The Funky Buddha Lounge](http://www.thefunkybuddha.com)\n*Beer Advocate Rating: [99](http://tinyurl.com/psf4uzq)')
55
+ poster.send_message("* Location: [The Funky Buddha Lounge](http://www.thefunkybuddha.com)\n*Beer Advocate Rating: [99](http://tinyurl.com/psf4uzq)")
59
56
  ```
60
57
 
61
58
  You can use an options array if you don't want to use the default settings.
62
59
 
63
60
  ```ruby
64
61
  options = {
65
- icon: "http://example.com/icon.png",
66
- activity: "Activity Alert",
67
- title: "A New Incoming Message Has Been Received"
62
+ icon: 'http://example.com/icon.png',
63
+ activity: 'Activity Alert',
64
+ title: 'A New Incoming Message Has Been Received'
68
65
  }
69
- poster = Glip::Poster.new(YOUR_WEBHOOK_URL)
70
66
  poster.send_message('Hi there!', options)
71
67
  ```
72
68
 
data/Rakefile CHANGED
@@ -13,7 +13,6 @@ end
13
13
 
14
14
  desc 'Generate YARD documentation.'
15
15
  task :gendoc do
16
- # puts 'yard doc generation disabled until JRuby build native extensions for redcarpet or yard removes the dependency.'
17
16
  system 'yardoc'
18
17
  system 'yard stats --list-undoc'
19
18
  end
@@ -7,14 +7,14 @@ Gem::Specification.new do |s|
7
7
  s.name = 'glip-poster'
8
8
  s.version = version
9
9
  s.date = '2016-01-31'
10
- s.summary = 'Glip Poster - Ruby SDK for post messages via Glip webhooks'
11
- s.description = 'A Ruby SDK for post messages via Glip webhooks'
10
+ s.summary = 'Glip Poster - Ruby SDK to post messages via Glip webhooks'
11
+ s.description = 'A Ruby SDK to post messages via Glip webhooks'
12
12
  s.authors = ['John Wang']
13
13
  s.email = 'johncwang@gmail.com'
14
14
  s.homepage = 'https://github.com/grokify/'
15
15
  s.licenses = ['MIT']
16
16
  s.files = Dir['lib/**/**/*'] # + Dir['bin/*']
17
- s.files += Dir['[A-Z]*'] + Dir['test/**/*']
17
+ s.files += Dir['[A-Z]*'] + Dir['test/**/*']
18
18
  # s.files.reject! { |fn| fn.include? "CVS" }
19
19
  # s.required_ruby_version = '>= 1.8.7' # 1.8.7+ is tested
20
20
  s.add_dependency 'faraday', '~> 0.9', '>= 0.9'
@@ -3,7 +3,7 @@ require 'faraday_middleware'
3
3
 
4
4
  module Glip
5
5
  class Poster
6
- VERSION = '0.0.3'
6
+ VERSION = '0.1.0'
7
7
  GLIP_WEBHOOK_BASE_URL = 'https://hooks.glip.com/webhook/'
8
8
 
9
9
  attr_reader :webhook_url
@@ -14,11 +14,11 @@ module Glip
14
14
  set_webhook_url(webhook_url_or_id)
15
15
 
16
16
  @options = {}
17
-
18
- @http = Faraday.new(:url => GLIP_WEBHOOK_BASE_URL) do |faraday|
19
- faraday.request :json
17
+
18
+ @http = Faraday.new(url: GLIP_WEBHOOK_BASE_URL) do |faraday|
19
+ faraday.request :json
20
20
  faraday.response :logger
21
- faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
21
+ faraday.adapter Faraday.default_adapter # use Net::HTTP
22
22
  end
23
23
  end
24
24
 
@@ -28,15 +28,17 @@ module Glip
28
28
  elsif webhook_url_or_id =~ %r{^https?://}
29
29
  @webhook_url = webhook_url_or_id
30
30
  else
31
- raise 'must include webhook URL or id argument'
31
+ fail ArgumentError, 'must include webhook URL or id argument'
32
32
  end
33
33
  end
34
34
 
35
- def send_message(message, opts={})
36
- return @http.post do |req|
35
+ def send_message(message, opts = {})
36
+ response = @http.post do |req|
37
37
  req.url @webhook_url
38
- req.body = @options.merge(opts).merge({body: message})
38
+ req.body = @options.merge(opts).merge(body: message)
39
39
  end
40
+
41
+ response
40
42
  end
41
43
  end
42
44
  end
@@ -0,0 +1 @@
1
+ require 'glip-poster/poster'
@@ -3,6 +3,6 @@ Coveralls.wear!
3
3
 
4
4
  require 'test/unit'
5
5
  require 'mocha/test_unit'
6
- require 'glip-poster'
6
+ require 'glip_poster'
7
7
 
8
8
  poster = Glip::Poster.new('deadbeef')
@@ -9,7 +9,7 @@ class GlipPosterTest < Test::Unit::TestCase
9
9
  end
10
10
 
11
11
  def test_url
12
- url = 'https://hooks.glip.com/webhook/11111111-2222-3333-4444-555555555555'
12
+ url = 'https://hooks.glip.com/webhook/11112222-3333-4444-5555-666677778888'
13
13
  poster = Glip::Poster.new(url)
14
14
  assert_equal url, poster.webhook_url
15
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glip-poster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Wang
@@ -50,7 +50,7 @@ dependencies:
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
52
  version: '0'
53
- description: A Ruby SDK for post messages via Glip webhooks
53
+ description: A Ruby SDK to post messages via Glip webhooks
54
54
  email: johncwang@gmail.com
55
55
  executables: []
56
56
  extensions: []
@@ -63,8 +63,8 @@ files:
63
63
  - README.md
64
64
  - Rakefile
65
65
  - glip-poster.gemspec
66
- - lib/glip-poster.rb
67
66
  - lib/glip-poster/poster.rb
67
+ - lib/glip_poster.rb
68
68
  - test/test_base.rb
69
69
  - test/test_setup.rb
70
70
  homepage: https://github.com/grokify/
@@ -90,5 +90,5 @@ rubyforge_project:
90
90
  rubygems_version: 2.4.8
91
91
  signing_key:
92
92
  specification_version: 4
93
- summary: Glip Poster - Ruby SDK for post messages via Glip webhooks
93
+ summary: Glip Poster - Ruby SDK to post messages via Glip webhooks
94
94
  test_files: []
@@ -1 +0,0 @@
1
- require 'glip-poster/poster'