cinch-strawpoll 0.1.9 → 0.1.10

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: 994e62844ab8772ea0bfe932a2cdad2af289f5c6
4
- data.tar.gz: 1a6406f35263261c1bfac09e79f5e8dfb4b05f16
3
+ metadata.gz: 4981e93314d1814a22980324947d06626a5805cc
4
+ data.tar.gz: a4ce0b3da4ed862fd0e92804d32559b1bd17765b
5
5
  SHA512:
6
- metadata.gz: a2e9e48f55c2c3fc4c5c6529548349f94f8e59136523bd534c3bcc5e673e8ec6c31e1f7c1ed908dabbeefa875158ae358177b51aaa2ec195f1be767c3511801c
7
- data.tar.gz: 491407e1be7e7fefbcc46a149e9283d8c42ba070101c2ddba8d08765c4d64351ff54cbea2e29bccafab5a0ddadfa866f4c1071354f34c573634c77d39af9c9ae
6
+ metadata.gz: 1923e0a3ac31ca27efd7105d760e077e47e6d088de7f6feec49486c6b9dca9019e9b105b3b48ff321202c0bac4b1c9d42b5a67927e24b3d831a099087c151bd9
7
+ data.tar.gz: 375905e71a330c6716be30f20ae3b8d70de437b854eb66c3bd7d606bb0bb1bf7ddfbcd5fcbf9c3ff05f04be3d6e4a81169712564cf6347b97b35b1fc5d62c84e
data/.gitignore CHANGED
@@ -1,35 +1,11 @@
1
1
  *.gem
2
- *.rbc
2
+ /bin
3
3
  /.config
4
- /coverage/
5
- /InstalledFiles
6
- /pkg/
7
- /spec/reports/
8
- /test/tmp/
9
- /test/version_tmp/
10
- /tmp/
11
-
12
- ## Specific to RubyMotion:
13
- .dat*
14
- .repl_history
15
- build/
16
-
17
- ## Documentation cache and generated files:
18
- /.yardoc/
19
- /_yardoc/
20
- /doc/
21
- /rdoc/
22
-
23
- ## Environment normalisation:
24
4
  /.bundle/
25
5
  /vendor/bundle
26
- /lib/bundler/man/
27
6
 
28
7
  # for a library or gem, you might want to ignore these files since the code is
29
8
  # intended to run in multiple environments; otherwise, check them in:
30
9
  Gemfile.lock
31
10
  .ruby-version
32
11
  .ruby-gemset
33
-
34
- # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
- .rvmrc
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  source 'https://rubygems.org'
2
3
 
3
4
  # Gem's dependencies are in gemspec
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
  # file: cinch-strawpoll.gemspec
3
4
 
4
5
  lib = File.expand_path('../lib', __FILE__)
@@ -6,27 +7,28 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
7
  require 'cinch/plugins/strawpoll/version'
7
8
 
8
9
  Gem::Specification.new do |spec|
9
- spec.name = 'cinch-strawpoll'
10
- spec.version = Cinch::Plugins::Strawpoll::VERSION
11
- spec.authors = ['Alex Hanna']
12
- spec.email = ['tinnvec@gmail.com']
13
- spec.description = 'A Strawpoll plugin for Cinch.'
14
- spec.summary = 'A Cinch plugin for creating polls on http://strawpoll.me'
15
- spec.homepage = 'https://github.com/tinnvec/cinch-strawpoll'
16
- spec.license = 'MIT'
10
+ spec.name = 'cinch-strawpoll'
11
+ spec.version = Cinch::Plugins::Strawpoll::VERSION
12
+ spec.authors = ['Alex Hanna']
13
+ spec.email = ['tinnvec@gmail.com']
14
+ spec.description = 'Strawpoll plugin for Cinch.'
15
+ spec.summary = 'Cinch plugin for creating polls on http://strawpoll.me'
16
+ spec.homepage = 'https://github.com/tinnvec/cinch-strawpoll'
17
+ spec.license = 'MIT'
17
18
 
18
- spec.files = `git ls-files`.split("\n")
19
- spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
- spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
- spec.require_paths = ['lib']
19
+ spec.files = `git ls-files`.split("\n")
20
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ spec.executables = `git ls-files -- bin/*`.split("\n")
22
+ .map { |f| File.basename(f) }
23
+ spec.require_paths = ['lib']
22
24
 
23
- # Gem dependencies
24
- spec.add_dependency 'cinch', '~> 2.3.1', '>= 2.3.1'
25
- spec.add_dependency 'cinch-authentication', '~> 0.1.1'
26
- spec.add_dependency 'httparty', '~> 0.13.7'
27
- spec.add_dependency 'json', '~> 1.8.3', '>= 1.8.3'
25
+ # Gem dependencies
26
+ spec.add_dependency 'cinch', '~> 2.3.1', '>= 2.3.1'
27
+ spec.add_dependency 'cinch-authentication', '~> 0.1.1'
28
+ spec.add_dependency 'httparty', '~> 0.13.7'
29
+ spec.add_dependency 'json', '~> 1.8.3', '>= 1.8.3'
28
30
 
29
- # Development dependencies
30
- spec.add_development_dependency 'bundler', '~> 1.3'
31
- spec.add_development_dependency 'rake', '~> 0'
31
+ # Development dependencies
32
+ spec.add_development_dependency 'bundler', '~> 1.3'
33
+ spec.add_development_dependency 'rake', '~> 0'
32
34
  end
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
  # file: lib/cinch/plugins/strawpoll.rb
3
4
 
4
5
  require 'cinch'
@@ -7,53 +8,57 @@ require 'cinch/extensions/authentication'
7
8
  require_relative 'strawpoll/api'
8
9
 
9
10
  module Cinch
10
- module Plugins
11
- class Strawpoll
12
- include Cinch::Plugin
13
- include Cinch::Extensions::Authentication
14
-
15
- enable_authentication
16
-
17
- set :plugin_name, 'strawpoll'
18
- set :help, '!poll <title> | <choice>, <choice> - Request a ' +
19
- 'strawpoll using <title> and a minimum of 2 <choice> ' +
20
- 'separated by commas.'
21
-
22
- match(/(poll?)\s(.+)\|(.+)/)
23
-
24
- def initialize(*args)
25
- super
26
- @repeat_time = config[:repeat_time] || 60
27
- @repeat_count = config[:repeat_count] || 3
28
- @allow_pol = config[:allow_pol] || false
29
-
30
- @strawpoll_api = StrawpollApi.new
31
- end
32
-
33
- def execute(m, mode, title, choices_string)
34
- return if mode == 'pol' && !@allow_pol
35
-
36
- choices = choices_string.split(',').collect { |o| o = o.strip }
37
- choices << 'pol pot' if mode == 'pol' && @allow_pol
38
-
39
- response = @strawpoll_api.create_poll(title.strip, choices)
40
-
41
- if !response['id'].nil? && @repeat_count > 0
42
- Thread.new(Channel(m.channel)) do |channel|
43
- @repeat_count.times do
44
- announcement = Format(:white, :blue, " VOTE ")
45
- announcement += " #{title.strip}"
46
- announcement += " https://strawpoll.me/#{response['id']}"
47
- channel.send(announcement)
48
- sleep @repeat_time
49
- end
50
- end
51
- else
52
- m.user.notice "Error: #{response['error']}"
53
- end
54
- end
55
-
56
- private
11
+ module Plugins
12
+ # Strawpoll plugin
13
+ class Strawpoll
14
+ include Cinch::Plugin
15
+ include Cinch::Extensions::Authentication
16
+
17
+ enable_authentication
18
+
19
+ set :plugin_name, 'strawpoll'
20
+ set :help, '!poll <title> | <choice>, <choice> - Request a' \
21
+ ' strawpoll using <title> and a minimum of 2 <choice>' \
22
+ ' separated by commas.'
23
+
24
+ match(/(poll?)\s(.+)\|(.+)/)
25
+
26
+ def initialize(*args)
27
+ super
28
+ @repeat_time = config[:repeat_time] || 60
29
+ @repeat_count = config[:repeat_count] || 3
30
+ @allow_pol = config[:allow_pol] || false
31
+ @strawpoll_api = StrawpollApi.new
32
+ end
33
+
34
+ def execute(_m, mode, _title, choices_string)
35
+ return if mode == 'pol' && !@allow_pol
36
+ choices = choices_string.split(',').collect(&:strip)
37
+ choices << 'pol pot' if mode == 'pol' && @allow_pol
38
+ response = @strawpoll_api.create_poll(title.strip, choices)
39
+ return if @repeat_count < 1
40
+ do_announcements(response['id'], title, choices)
41
+ end
42
+
43
+ private
44
+
45
+ def do_announcements(poll_id, title)
46
+ if poll_id.nil?
47
+ m.user.notice "Error: #{response['error']}"
48
+ return
57
49
  end
50
+ Thread.new(Channel(channel)) do |c|
51
+ @repeat_count.times do
52
+ c.send(format_announcement(title, poll_id))
53
+ sleep @repeat_time
54
+ end
55
+ end
56
+ end
57
+
58
+ def format_announcement(title, poll_id)
59
+ "#{Format(:white, :blue, ' VOTE ')}#{title.strip}" \
60
+ " https://strawpoll.me/#{poll_id}"
61
+ end
58
62
  end
63
+ end
59
64
  end
@@ -1,29 +1,31 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
  # file: lib/cinch/plugins/strawpoll/api.rb
3
4
 
4
5
  require 'httparty'
5
6
  require 'json'
6
7
 
8
+ # Strawpoll api adapter
7
9
  class StrawpollApi
8
- include HTTParty
10
+ include HTTParty
9
11
 
10
- base_uri 'https://strawpoll.me/api/v2'
12
+ base_uri 'https://strawpoll.me/api/v2'
11
13
 
12
- def create_poll(title, choices)
13
- response = create_poll_request(title, choices)
14
- return response
15
- end
14
+ def create_poll(title, choices)
15
+ response = create_poll_request(title, choices)
16
+ response
17
+ end
16
18
 
17
- private
19
+ private
18
20
 
19
- def create_poll_request(title, choices)
20
- options = {
21
- headers: { 'Content-Type' => 'application/json' },
22
- body: {
23
- title: title, options: choices, multi: false
24
- }.to_json
25
- }
26
- response = self.class.post('/polls', options)
27
- return JSON.parse(response.body)
28
- end
21
+ def create_poll_request(title, choices)
22
+ options = {
23
+ headers: { 'Content-Type' => 'application/json' },
24
+ body: {
25
+ title: title, options: choices, multi: false
26
+ }.to_json
27
+ }
28
+ response = self.class.post('/polls', options)
29
+ JSON.parse(response.body)
30
+ end
29
31
  end
@@ -1,10 +1,11 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: false
2
3
  # file: lib/cinch/plugins/strawpoll/version.rb
3
4
 
4
5
  module Cinch
5
- module Plugins
6
- module Strawpoll
7
- VERSION = '0.1.9'
8
- end
6
+ module Plugins
7
+ module Strawpoll
8
+ VERSION = '0.1.10'.freeze
9
9
  end
10
+ end
10
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cinch-strawpoll
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Hanna
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-21 00:00:00.000000000 Z
11
+ date: 2016-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cinch
@@ -106,14 +106,10 @@ dependencies:
106
106
  - - "~>"
107
107
  - !ruby/object:Gem::Version
108
108
  version: '0'
109
- description: A Strawpoll plugin for Cinch.
109
+ description: Strawpoll plugin for Cinch.
110
110
  email:
111
111
  - tinnvec@gmail.com
112
- executables:
113
- - htmldiff
114
- - ldiff
115
- - rake
116
- - rspec
112
+ executables: []
117
113
  extensions: []
118
114
  extra_rdoc_files: []
119
115
  files:
@@ -122,10 +118,6 @@ files:
122
118
  - Gemfile
123
119
  - LICENSE
124
120
  - README.md
125
- - bin/htmldiff
126
- - bin/ldiff
127
- - bin/rake
128
- - bin/rspec
129
121
  - cinch-strawpoll.gemspec
130
122
  - lib/cinch/plugins/strawpoll.rb
131
123
  - lib/cinch/plugins/strawpoll/api.rb
@@ -153,5 +145,5 @@ rubyforge_project:
153
145
  rubygems_version: 2.5.1
154
146
  signing_key:
155
147
  specification_version: 4
156
- summary: A Cinch plugin for creating polls on http://strawpoll.me
148
+ summary: Cinch plugin for creating polls on http://strawpoll.me
157
149
  test_files: []
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
- #
4
- # This file was generated by Bundler.
5
- #
6
- # The application 'htmldiff' is installed as part of a gem, and
7
- # this file is here to facilitate running it.
8
- #
9
-
10
- require "pathname"
11
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
- Pathname.new(__FILE__).realpath)
13
-
14
- require "rubygems"
15
- require "bundler/setup"
16
-
17
- load Gem.bin_path("cinch-strawpoll", "htmldiff")
data/bin/ldiff DELETED
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
- #
4
- # This file was generated by Bundler.
5
- #
6
- # The application 'ldiff' is installed as part of a gem, and
7
- # this file is here to facilitate running it.
8
- #
9
-
10
- require "pathname"
11
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
- Pathname.new(__FILE__).realpath)
13
-
14
- require "rubygems"
15
- require "bundler/setup"
16
-
17
- load Gem.bin_path("cinch-strawpoll", "ldiff")
data/bin/rake DELETED
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
- #
4
- # This file was generated by Bundler.
5
- #
6
- # The application 'rake' is installed as part of a gem, and
7
- # this file is here to facilitate running it.
8
- #
9
-
10
- require "pathname"
11
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
- Pathname.new(__FILE__).realpath)
13
-
14
- require "rubygems"
15
- require "bundler/setup"
16
-
17
- load Gem.bin_path("cinch-strawpoll", "rake")
data/bin/rspec DELETED
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
- #
4
- # This file was generated by Bundler.
5
- #
6
- # The application 'rspec' is installed as part of a gem, and
7
- # this file is here to facilitate running it.
8
- #
9
-
10
- require "pathname"
11
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
- Pathname.new(__FILE__).realpath)
13
-
14
- require "rubygems"
15
- require "bundler/setup"
16
-
17
- load Gem.bin_path("cinch-strawpoll", "rspec")