flowhook 0.1.0 → 0.2.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: 32a9cb67ca6f2fbf7405bb1219511d4efd010600
4
- data.tar.gz: 3c1f823fa4bca3d5eae463711a349b15758ac101
3
+ metadata.gz: 3ef3accfdf817486caf58a34df33f656c6908f60
4
+ data.tar.gz: 2ff0ed28eeff44a6e50c660d239210ef1eafe4a9
5
5
  SHA512:
6
- metadata.gz: 6a8bf94bc500f0d3ddff805a2e3660e07e6cdf866b06540155032a671751f29e6c09f2d58892ff2aa554c7813b054b3d2a020a9c1c0ecbfcc64791a3505f8e0c
7
- data.tar.gz: e0e33f1f09bcd189d0287d0cccdd3e406670d805dddd9c5074f1f1b9c9e1c08c070d1999ece547d434065d96f79b34974aea92d4cd1daa753d348003c8d5e38d
6
+ metadata.gz: c0ad8aa207baab8269c12dade703aa2f5931498d2e8d11fb04c96661b446e915d6dab7e7acd48f8a5ddf16bb5b86551891c647b63e285792979ec604ccbd2aee
7
+ data.tar.gz: 7b2e1022a07d6440c4b53396315ff65540bca2aa22692d04859f437fa9be246b484219ebaab0441bd81e50ba1a18cce70e9b434f43a43d2bf60dba3dc0ca6bb3
@@ -19,7 +19,7 @@ module Flowhook
19
19
  private
20
20
 
21
21
  def setup_options
22
- %w[url path token flows events daemonize help version].each do |option|
22
+ %w[url path token private flows events daemonize help version].each do |option|
23
23
  send("setup_#{option}_option")
24
24
  end
25
25
  end
@@ -42,6 +42,12 @@ module Flowhook
42
42
  end
43
43
  end
44
44
 
45
+ def setup_private_option
46
+ on('-P', '--[no-]private', 'Enable to receive private message') do |enabled|
47
+ options.private = enabled
48
+ end
49
+ end
50
+
45
51
  def setup_flows_option
46
52
  on('-F', '--flows FLOW1, FLOW2', Array, 'The flows wants to straming') do |flows|
47
53
  options.flows = flows
@@ -79,6 +85,7 @@ module Flowhook
79
85
  options.path = Dir.pwd
80
86
  options.url = nil
81
87
  options.token = nil
88
+ options.private = false
82
89
  options.flows = []
83
90
  options.events = []
84
91
  options.daemonize = false
@@ -3,9 +3,10 @@ module Flowhook
3
3
  class Streaming
4
4
  STREAMING_URL = 'https://stream.flowdock.com/flows'.freeze
5
5
 
6
- def initialize(token, flows = [], events = [])
6
+ def initialize(token, use_private = false, flows = [], events = [])
7
7
  @token = token
8
8
  @flows = flows
9
+ @private = use_private ? 1 : 0
9
10
  @events = events
10
11
  @queue = Queue.new
11
12
  @thread = nil
@@ -43,6 +44,7 @@ module Flowhook
43
44
  end
44
45
 
45
46
  def streaming
47
+ STDOUT.puts uri
46
48
  Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
47
49
  http.request request do |response|
48
50
  response.read_body do |chunk|
@@ -59,7 +61,9 @@ module Flowhook
59
61
  end
60
62
 
61
63
  def uri
62
- @uri ||= URI("#{STREAMING_URL}?filter=#{@flows.join(',')}")
64
+ @uri ||= URI("#{STREAMING_URL}?filter=#{@flows.join(',')}").tap do |uri|
65
+ uri.query += '&user=1' if @private
66
+ end
63
67
  end
64
68
  end
65
69
  end
@@ -1,3 +1,3 @@
1
1
  module Flowhook
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
@@ -103,6 +103,7 @@ module Flowhook
103
103
  def initialize_stream
104
104
  @stream = Streaming.new(
105
105
  @options.token,
106
+ @options.private,
106
107
  @options.flows,
107
108
  @options.events
108
109
  )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flowhook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - 蒼時弦也
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-10 00:00:00.000000000 Z
11
+ date: 2018-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -70,7 +70,6 @@ files:
70
70
  - bin/setup
71
71
  - exe/flowhook
72
72
  - flowhook.gemspec
73
- - flowhook.pid
74
73
  - lib/flowhook.rb
75
74
  - lib/flowhook/options.rb
76
75
  - lib/flowhook/streaming.rb
@@ -1 +0,0 @@
1
- 95962