ferris-bueller 0.0.1 → 0.0.2

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: bdfbffb726a39dad7e3cbef79559e7c00330d53f
4
- data.tar.gz: 329a4fa79b56b17eb91378bf41d29de2c81c0d5a
3
+ metadata.gz: c5cd0bb225b443bbd5cd93bb39a5c36b216e61bc
4
+ data.tar.gz: ac947c90b3c291b59e71caf4ba15765da8c47d7c
5
5
  SHA512:
6
- metadata.gz: 5cf95d2f4a02faa32358101b05902ecd2accf5dcc82a2a9062d15af11a587d7a1fd5e74f25fa5295bd50e8f0129c45fe586fbb13ae776083343cc1f0dd44d7d9
7
- data.tar.gz: d386502333cfaf28a1990b2f51ff47db07b48fa8475c6945499ae955dd15e4264c9eb81fd9770a4f73f222954d8ad93b0838cefa0e81dae946e23b231ea8b556
6
+ metadata.gz: 8094033f7c2e10ac62d306e307ae89b47783956d51f1885b61f94e20bfe37cb464bd95950a1ae9d56c98e2e656366a5ea034629429af82aa6f01c2219b87819e
7
+ data.tar.gz: 6573073a948f2cf9386afe6d2fc374289be838e4d1e6db263d5dfce039f7b138a44bbcf3a7619e6b3b999346aa6e49d5fc99f4d976b9caa4c86e37408c080c88
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -1,12 +1,12 @@
1
1
  require 'json'
2
2
  require 'net/http'
3
3
 
4
- require 'ferris'
5
4
  require 'thin/logging'
6
5
  require 'queryparams'
7
6
 
8
7
  require_relative 'constants'
9
8
  require_relative 'web'
9
+ require_relative 'slack_api'
10
10
 
11
11
 
12
12
  module FerrisBueller
@@ -24,7 +24,7 @@ module FerrisBueller
24
24
  Web.set :store, @store
25
25
  Web.set :logger, log
26
26
  Web.set :verification_token, options.verification_token
27
- Web.set :api, Ferris::API.new(token: options.api_token, logger: log)
27
+ Web.set :api, SlackAPI.new(token: options.api_token, logger: log)
28
28
 
29
29
  if log.level >= ::Logger::DEBUG
30
30
  Web.set :raise_errors, true
@@ -0,0 +1,30 @@
1
+ require 'json'
2
+ require 'net/http'
3
+
4
+ require 'slog'
5
+
6
+ Thread.abort_on_exception = true
7
+
8
+
9
+ module FerrisBueller
10
+ class SlackAPI
11
+ def initialize options={}
12
+ @token = options.fetch :token
13
+ @logger = options.fetch :logger, Slog.new
14
+ @api_url = options.fetch :api_url, 'https://slack.com/api'
15
+ log.trace event: 'API client initialized'
16
+ end
17
+
18
+ def send method, options={}
19
+ uri = URI File.join(@api_url, method)
20
+ options = { token: @token }.merge(options)
21
+ log.trace event: 'sending api request', method: method, options: options
22
+ res = Net::HTTP.post_form uri, options
23
+ log.debug event: 'sent api request', method: method, options: options, response: res
24
+ JSON.parse res.body
25
+ end
26
+
27
+ private
28
+ def log ; @logger end
29
+ end
30
+ end
@@ -1,7 +1,6 @@
1
1
  require 'json'
2
2
 
3
3
  require 'sinatra/base'
4
- require 'fuzzystringmatch'
5
4
 
6
5
  require_relative 'metadata'
7
6
  require_relative 'replies'
@@ -1,5 +1,11 @@
1
+ require 'fuzzystringmatch/pure/jarowinkler'
2
+
3
+
1
4
  module FerrisBueller
2
5
  module WebHelpers
6
+ JARO_WINKLER = FuzzyStringMatch::JaroWinklerPure.new
7
+
8
+ def options ; settings.options end
3
9
 
4
10
  def store ; settings.store end
5
11
 
@@ -59,10 +65,9 @@ module FerrisBueller
59
65
  def compare name1, name2
60
66
  return nil if name1.nil? || name1.empty?
61
67
  return nil if name2.nil? || name2.empty?
62
- @@jaro ||= FuzzyStringMatch::JaroWinkler.create :native
63
68
  n1 = name1.gsub(/\W/, '').downcase
64
69
  n2 = name2.gsub(/\W/, '').downcase
65
- @@jaro.getDistance n1, n2
70
+ JARO_WINKLER.getDistance n1, n2
66
71
  end
67
72
 
68
73
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ferris-bueller
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
  - Sean Clemmer
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.4'
83
- - !ruby/object:Gem::Dependency
84
- name: ferris
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: eventmachine
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -168,6 +154,7 @@ files:
168
154
  - lib/ferris-bueller/metadata.rb
169
155
  - lib/ferris-bueller/mjolnir.rb
170
156
  - lib/ferris-bueller/replies.rb
157
+ - lib/ferris-bueller/slack_api.rb
171
158
  - lib/ferris-bueller/web.rb
172
159
  - lib/ferris-bueller/web_helpers.rb
173
160
  homepage: https://github.com/sczizzo/ferris-bueller