lolcommits-flowdock 0.0.2 → 0.0.3

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
- SHA1:
3
- metadata.gz: da117e289d89581e6e34b7002936eb08ca96917e
4
- data.tar.gz: 37a28fcc8654a791ffe64d40b9f2d4b24ec19f4c
2
+ SHA256:
3
+ metadata.gz: 7b4d082a0f2ffcf6ba1e23524651483ba3d420653a0d32a5f0ead6e95668c580
4
+ data.tar.gz: d0207703b7a7eb504cf03235ea283c1855c7997a5d568b502515b5ed60af4711
5
5
  SHA512:
6
- metadata.gz: 4580e61013b34dd74f1378e3d1a4fda9c5ba81129505bacad136b47938d93ddf5231f57416eb5335cb16bf35e103d8b6c5843653a88530f03ed64d3d590899d5
7
- data.tar.gz: 53fd8644b307d83c6439c661f0c7eefa72755821834957213931a43f097e6421b90619163a03ac3101798a744a7873762d1c4e63d1004f89edf35736248fdf27
6
+ metadata.gz: c3861509e304d695f127e7c24aaf05ea14ea95b00eb2be7005bea58de5937489d2f7b186c570c336e8ea3abfce9a8ca8dea9d768055576f69ae0b691573600bc
7
+ data.tar.gz: '0289f21f6fac6530755e334d5e752b7478d7ff8d0d2d377bf4271fb164c50633135663dbcfde55e9e5fc003b2d71d556c243457035b8bfa4c5f81ad11ae094d1'
data/.travis.yml CHANGED
@@ -4,13 +4,14 @@ cache: bundler
4
4
  rvm:
5
5
  - 2.0.0
6
6
  - 2.1.10
7
- - 2.2.8
8
- - 2.3.5
9
- - 2.4.2
7
+ - 2.2.9
8
+ - 2.3.6
9
+ - 2.4.3
10
+ - 2.5.0
10
11
  - ruby-head
11
12
 
12
13
  before_install:
13
- - gem install bundler -v 1.13.7
14
+ - gem update --system
14
15
  - git --version
15
16
  - git config --global user.email "lol@commits.org"
16
17
  - git config --global user.name "Lolcommits"
data/Gemfile CHANGED
@@ -1,4 +1,2 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
-
4
- gem "lolcommits", git: "https://github.com/mroth/lolcommits.git"
@@ -1,5 +1,5 @@
1
1
  module Lolcommits
2
2
  module Flowdock
3
- VERSION = "0.0.2".freeze
3
+ VERSION = "0.0.3".freeze
4
4
  end
5
5
  end
@@ -7,15 +7,6 @@ module Lolcommits
7
7
  module Plugin
8
8
  class Flowdock < Base
9
9
 
10
- ##
11
- # Returns the name of the plugin. Identifies the plugin to lolcommits.
12
- #
13
- # @return [String] the plugin name
14
- #
15
- def self.name
16
- 'flowdock'
17
- end
18
-
19
10
  ##
20
11
  # Returns position(s) of when this plugin should run during the capture
21
12
  # process. Posting to Flowdock happens when a new capture is ready.
@@ -26,18 +17,6 @@ module Lolcommits
26
17
  [:capture_ready]
27
18
  end
28
19
 
29
- ##
30
- # Returns true if the plugin has been configured. An access token,
31
- # organization and flow must be set.
32
- #
33
- # @return [Boolean] true/false indicating if plugin is configured
34
- #
35
- def configured?
36
- !!(configuration['access_token'] &&
37
- configuration['organization'] &&
38
- configuration['flow'])
39
- end
40
-
41
20
  ##
42
21
  # Prompts the user to configure plugin options. Options are enabled
43
22
  # (true/false), a Flowdock Personal API token, and the Flowdock
@@ -47,30 +26,24 @@ module Lolcommits
47
26
  #
48
27
  def configure_options!
49
28
  options = super
50
- if options['enabled']
29
+ if options[:enabled]
51
30
  puts "\nCopy (or create) your Flowdock personal API token (paste it below)"
52
31
  open_url("https://flowdock.com/account/tokens")
53
32
  print "API token: "
54
33
  access_token = gets.strip
55
34
  flowdock.access_token = access_token
56
35
 
57
- puts "\nEnter your Flowdock organization name (tab to autocomplete)"
58
- organization = prompt_autocomplete_hash("Organization: ", flowdock.organizations)
59
-
60
- puts "\nEnter your Flowdock flow name (tab to autocomplete)"
61
- flow = prompt_autocomplete_hash("Flow: ", flowdock.flows)
36
+ organization = configure_organization
37
+ flow = configure_flow
38
+ raise Interrupt unless flow && organization
62
39
 
63
40
  options.merge!(
64
- 'access_token' => access_token,
65
- 'flow' => flow,
66
- 'organization' => organization
41
+ access_token: access_token,
42
+ flow: flow,
43
+ organization: organization
67
44
  )
68
45
  end
69
- rescue Interrupt
70
- debug "aborting due to user cancelling configuration"
71
- options ||= {}
72
- options['enabled'] = false
73
- ensure
46
+
74
47
  options
75
48
  end
76
49
 
@@ -84,8 +57,8 @@ module Lolcommits
84
57
  def run_capture_ready
85
58
  print "Posting to Flowdock ... "
86
59
  message = flowdock.create_message(
87
- organization: configuration['organization'],
88
- flow: configuration['flow'],
60
+ organization: configuration[:organization],
61
+ flow: configuration[:flow],
89
62
  params: {
90
63
  event: 'file',
91
64
  content: File.new(runner.main_image),
@@ -103,24 +76,25 @@ module Lolcommits
103
76
 
104
77
  private
105
78
 
106
- def prompt_autocomplete_hash(prompt, items, name: 'name', value: 'parameterized_name', suggest_words: 5)
107
- words = items.map {|item| item[name] }.sort
108
- puts "e.g. #{words.take(suggest_words).join(", ")}" if suggest_words > 0
109
- completed_input = gets_autocomplete(prompt, words)
110
- items.find { |item| item[name] == completed_input }[value]
79
+ def configure_organization
80
+ orgs = flowdock.organizations
81
+ if orgs.empty?
82
+ puts "\nNo Flowdock organizations found, please check your account at flowdock.com"
83
+ nil
84
+ else
85
+ puts "\nEnter your Flowdock organization name (tab to autocomplete, Ctrl+c cancels)"
86
+ prompt_autocomplete_hash("Organization: ", orgs, value: "parameterized_name")
87
+ end
111
88
  end
112
89
 
113
- def gets_autocomplete(prompt, words)
114
- completion_handler = proc { |s| words.grep(/^#{Regexp.escape(s)}/) }
115
- Readline.completion_append_character = ""
116
- Readline.completion_proc = completion_handler
117
-
118
- while line = Readline.readline(prompt, true).strip
119
- if words.include?(line)
120
- return line
121
- else
122
- puts "'#{line}' not found"
123
- end
90
+ def configure_flow
91
+ flows = flowdock.flows
92
+ if flows.empty?
93
+ puts "\nNo Flowdock flows found, please check your account at flowdock.com"
94
+ nil
95
+ else
96
+ puts "\nEnter your Flowdock flow name (tab to autocomplete, Ctrl+c cancels)"
97
+ prompt_autocomplete_hash("Flow: ", flows, value: "parameterized_name")
124
98
  end
125
99
  end
126
100
 
@@ -130,7 +104,7 @@ module Lolcommits
130
104
 
131
105
  def flowdock
132
106
  @flowdock ||= Lolcommits::Flowdock::Client.new(
133
- configuration['access_token']
107
+ configuration[:access_token]
134
108
  )
135
109
  end
136
110
  end
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
37
37
 
38
38
  spec.add_runtime_dependency "rest-client"
39
39
 
40
- spec.add_development_dependency "lolcommits", ">= 0.9.8"
40
+ spec.add_development_dependency "lolcommits", ">= 0.10.0"
41
41
  spec.add_development_dependency "bundler"
42
42
  spec.add_development_dependency "webmock"
43
43
  spec.add_development_dependency "pry"
@@ -6,14 +6,6 @@ describe Lolcommits::Plugin::Flowdock do
6
6
  include Lolcommits::TestHelpers::GitRepo
7
7
  include Lolcommits::TestHelpers::FakeIO
8
8
 
9
- def plugin_name
10
- "flowdock"
11
- end
12
-
13
- it "should have a name" do
14
- ::Lolcommits::Plugin::Flowdock.name.must_equal plugin_name
15
- end
16
-
17
9
  it "should run on capture ready" do
18
10
  ::Lolcommits::Plugin::Flowdock.runner_order.must_equal [:capture_ready]
19
11
  end
@@ -31,28 +23,22 @@ describe Lolcommits::Plugin::Flowdock do
31
23
  @plugin ||= Lolcommits::Plugin::Flowdock.new(runner: runner)
32
24
  end
33
25
 
34
- def valid_enabled_config
35
- @config ||= OpenStruct.new(
36
- read_configuration: { "flowdock" => flowdock_config }
37
- )
38
- end
39
-
40
- def flowdock_config
26
+ def plugin_config
41
27
  {
42
- "enabled" => true,
43
- "access_token" => "f4f6aa86fd747a00e75238810412x543",
44
- 'organization' => 'myorg',
45
- 'flow' => 'myflow'
28
+ enabled: true,
29
+ access_token: "f4f6aa86fd747a00e75238810412x543",
30
+ organization: "myorg",
31
+ flow: "myflow"
46
32
  }
47
33
  end
48
34
 
49
35
  describe "#enabled?" do
50
- it "is false by default" do
51
- plugin.enabled?.must_equal false
36
+ it "is not enabled by default" do
37
+ assert_nil plugin.enabled?
52
38
  end
53
39
 
54
40
  it "is true when configured" do
55
- plugin.config = valid_enabled_config
41
+ plugin.configuration = plugin_config
56
42
  plugin.enabled?.must_equal true
57
43
  end
58
44
  end
@@ -63,8 +49,8 @@ describe Lolcommits::Plugin::Flowdock do
63
49
 
64
50
  it "posts lolcommit as a new file message to Flowdock" do
65
51
  in_repo do
66
- plugin.config = valid_enabled_config
67
- message_url = "https://api.flowdock.com/flows/#{flowdock_config['organization']}/#{flowdock_config['flow']}/messages"
52
+ plugin.configuration = plugin_config
53
+ message_url = "https://api.flowdock.com/flows/#{plugin_config[:organization]}/#{plugin_config[:flow]}/messages"
68
54
  valid_response = { id: "123", event: "file", tags: ["lolcommits"]}
69
55
 
70
56
  stub_request(:post, message_url).to_return(status: 200, body: valid_response.to_json)
@@ -86,15 +72,6 @@ describe Lolcommits::Plugin::Flowdock do
86
72
  end
87
73
 
88
74
  describe "configuration" do
89
- it "returns false when not configured" do
90
- plugin.configured?.must_equal false
91
- end
92
-
93
- it "returns true when configured" do
94
- plugin.config = valid_enabled_config
95
- plugin.configured?.must_equal true
96
- end
97
-
98
75
  it "allows plugin options to be configured" do
99
76
  # enabled, access token, organization and flow
100
77
  access_token = "mytoken"
@@ -123,16 +100,16 @@ describe Lolcommits::Plugin::Flowdock do
123
100
  configured_plugin_options = plugin.configure_options!
124
101
  end
125
102
 
126
- output.must_match(/Enter your Flowdock organization name \(tab to autocomplete\)/)
103
+ output.must_match(/Enter your Flowdock organization name \(tab to autocomplete, Ctrl\+c cancels\)/)
127
104
  output.must_match(/e.g. Another, My Org/)
128
- output.must_match(/Enter your Flowdock flow name \(tab to autocomplete\)/)
105
+ output.must_match(/Enter your Flowdock flow name \(tab to autocomplete, Ctrl\+c cancels\)/)
129
106
  output.must_match(/e.g. Flowtwo, My Flow/)
130
107
 
131
108
  configured_plugin_options.must_equal({
132
- "enabled" => true,
133
- "access_token" => access_token,
134
- "organization" => "myorgparam",
135
- "flow" => "myflowparam"
109
+ enabled: true,
110
+ access_token: access_token,
111
+ organization: "myorgparam",
112
+ flow: "myflowparam"
136
113
  })
137
114
  end
138
115
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lolcommits-flowdock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Hutchinson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-06 00:00:00.000000000 Z
11
+ date: 2018-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.9.8
33
+ version: 0.10.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.9.8
40
+ version: 0.10.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -172,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
172
  version: '0'
173
173
  requirements: []
174
174
  rubyforge_project:
175
- rubygems_version: 2.6.13
175
+ rubygems_version: 2.7.3
176
176
  signing_key:
177
177
  specification_version: 4
178
178
  summary: Posts lolcommits to Flowdockr