clearbit-slack 0.1.6 → 0.1.7

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: f3cf57a0df8063f3a47776b72f19dbbeb0f51d8f
4
- data.tar.gz: ac062a72596c9aa60e5d38e466480a9082f599fd
3
+ metadata.gz: d3df4ad6c821c679221eca8bd10935dc96b26676
4
+ data.tar.gz: 15640d0b6fa936992f12d7fdc47d7a32175db3f7
5
5
  SHA512:
6
- metadata.gz: ed2a5bd839097f66abc36fbac74de58304b0490e8f30b25b585d6db9f2c712b08596b075eeacc1b414233cd400cf35d2c1f79dcfcdfb104430d6ae0abb6b0924
7
- data.tar.gz: 25e5d5d53017f4a5ffef214e46f2e0e22157f631361067435ba9a9f21ad36769e73d77eb1238677fcbc479e54814a5a29d431e431c95aae3f9c8d090d970704e
6
+ metadata.gz: 119d51bac1ce6a03cea7de6b1c66dfb76233ef0ff22c6a5b03b3d09f457d33e5a18565faecb92948390a7f922d7e6f8ef6a21c4ec0d8bda348c0a5b7139549ba
7
+ data.tar.gz: c424fb2643f245050a6023b715902c4ad9b435595318c75d4a504edb28cba566bad903a2eaf35460147a7e6d9f3289d7454ee76e121e1a1179ed360246a6f4e3
Binary file
@@ -9,18 +9,19 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Harlow Ward"]
10
10
  spec.email = ["harlow@clearbit.com"]
11
11
 
12
- spec.summary = %q{Push Clearbit data into Slack channel}
13
- spec.description = %q{Push Clearbit data into Slack channel}
12
+ spec.summary = %q{Clean beautiful customer data. Now in Slack.}
13
+ spec.description = %q{Push rich Clearbit enrichment data in a Slack channel.}
14
14
  spec.homepage = "https://github.com/clearbit/clearbit-slack"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
17
  spec.require_paths = ["lib"]
18
18
 
19
- spec.add_dependency 'clearbit', '~> 0.2.2'
20
- spec.add_dependency 'maccman-mash', '~> 0.0.2'
21
- spec.add_dependency 'slack-notifier', '~> 1.2.1'
22
19
  spec.add_development_dependency 'bundler', '~> 1.9'
23
- spec.add_development_dependency 'pry', '~> 0.10.1'
20
+ spec.add_development_dependency 'pry', '~> 0.10', '>= 0.10.1'
24
21
  spec.add_development_dependency 'rake', '~> 10.0'
25
- spec.add_development_dependency 'rspec'
22
+ spec.add_development_dependency 'rspec', '~> 3.5', '>= 3.5.0'
23
+
24
+ spec.add_runtime_dependency 'clearbit', '~> 0.2', '>= 0.2.2'
25
+ spec.add_runtime_dependency 'maccman-mash', '~> 0.0', '>= 0.0.2'
26
+ spec.add_runtime_dependency 'slack-notifier', '~> 1.2', '>= 1.2.1'
26
27
  end
@@ -11,8 +11,8 @@ require 'clearbit/slack/attachments/company'
11
11
 
12
12
  module Clearbit
13
13
  module Slack
14
- def self.ping(attrs = {})
15
- Notifier.new(attrs).ping
14
+ def self.ping(attrs = {}, options = {})
15
+ Notifier.new(attrs, options).ping
16
16
  end
17
17
 
18
18
  def self.slack_url
@@ -11,6 +11,10 @@ module Clearbit
11
11
 
12
12
  def as_json(options = {})
13
13
  {
14
+ fallback: fallback,
15
+ author_name: person.name.full_name,
16
+ author_icon: person.avatar,
17
+ text: person.bio,
14
18
  color: color,
15
19
  fields: fields.compact
16
20
  }
@@ -18,9 +22,18 @@ module Clearbit
18
22
 
19
23
  private
20
24
 
25
+ def fallback
26
+ str = person.email
27
+
28
+ if name = person.name.full_name
29
+ str << ' - %s' % name
30
+ end
31
+
32
+ str
33
+ end
34
+
21
35
  def fields
22
36
  [
23
- bio,
24
37
  email,
25
38
  location,
26
39
  employment,
@@ -32,11 +45,6 @@ module Clearbit
32
45
  ]
33
46
  end
34
47
 
35
- def bio
36
- return unless person.bio
37
- field 'Bio', person.bio, false
38
- end
39
-
40
48
  def email
41
49
  return unless person.email
42
50
  field 'Email', person.email
@@ -2,6 +2,17 @@ module Clearbit
2
2
  module Slack
3
3
  class Configuration
4
4
  attr_accessor :slack_url, :slack_channel
5
+
6
+ def to_hash
7
+ {
8
+ slack_url: slack_url,
9
+ slack_channel: slack_channel
10
+ }
11
+ end
12
+
13
+ def merge(hash)
14
+ to_hash.merge(hash)
15
+ end
5
16
  end
6
17
  end
7
18
  end
@@ -1,50 +1,50 @@
1
1
  module Clearbit
2
2
  module Slack
3
3
  class Notifier
4
- attr_reader :company, :message, :person, :given_name, :family_name, :email
5
-
6
- def initialize(attrs = {})
7
- @company = attrs[:company]
8
- @message = attrs[:message]
9
- @person = attrs[:person]
10
- @given_name = attrs[:given_name]
11
- @family_name = attrs[:family_name]
12
- @email = attrs[:email]
4
+ attr_reader :company, :message, :person,
5
+ :given_name, :family_name, :email,
6
+ :slack_url, :slack_channel, :slack_icon
7
+
8
+ def initialize(attrs = {}, options = {})
9
+ options = Slack.configuration.merge(options)
10
+
11
+ @company = attrs[:company]
12
+ @message = attrs[:message]
13
+ @person = attrs[:person]
14
+ @given_name = attrs[:given_name]
15
+ @family_name = attrs[:family_name]
16
+ @email = attrs[:email]
17
+ @slack_url = options[:slack_url]
18
+ @slack_channel = options[:slack_channel]
19
+ @slack_icon = options[:slack_icon]
13
20
  end
14
21
 
15
22
  def ping
16
- notifier = ::Slack::Notifier.new(
17
- Slack.slack_url,
18
- channel: Slack.slack_channel,
19
- icon_url: icon_url,
20
- username: username
23
+ notifier.ping(message.to_s, attachments: attachments)
24
+ end
25
+
26
+ def notifier
27
+ ::Slack::Notifier.new(
28
+ slack_url,
29
+ channel: slack_channel,
30
+ icon_url: slack_icon,
21
31
  )
32
+ end
22
33
 
23
- attachments << Attachments::Person.new(person).as_json
34
+ def attachments
35
+ result = []
36
+
37
+ result << Attachments::Person.new(person).as_json
24
38
 
25
39
  if company
26
- attachments << Attachments::Company.new(company).as_json
40
+ result << Attachments::Company.new(company).as_json
27
41
  end
28
42
 
29
- notifier.ping message.to_s, attachments: attachments
43
+ result
30
44
  end
31
45
 
32
46
  private
33
47
 
34
- def icon_url
35
- person && person.avatar || ''
36
- end
37
-
38
- def username
39
- if person.name.full_name
40
- person.name.full_name
41
- elsif person.name.given_name && person.name.family_name
42
- [person.name.given_name, person.name.family_name].join(' ')
43
- else
44
- 'Unknown'
45
- end
46
- end
47
-
48
48
  def person
49
49
  @person ||= unknown_person
50
50
  end
@@ -58,10 +58,6 @@ module Clearbit
58
58
  }
59
59
  )
60
60
  end
61
-
62
- def attachments
63
- @attachments ||= []
64
- end
65
61
  end
66
62
  end
67
63
  end
@@ -1,5 +1,5 @@
1
1
  module Clearbit
2
2
  module Slack
3
- VERSION = '0.1.6'
3
+ VERSION = '0.1.7'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,114 +1,144 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clearbit-slack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harlow Ward
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-24 00:00:00.000000000 Z
11
+ date: 2016-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: clearbit
14
+ name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.2.2
20
- type: :runtime
19
+ version: '1.9'
20
+ type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.2.2
26
+ version: '1.9'
27
27
  - !ruby/object:Gem::Dependency
28
- name: maccman-mash
28
+ name: pry
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.0.2
34
- type: :runtime
33
+ version: '0.10'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 0.10.1
37
+ type: :development
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
41
  - - "~>"
39
42
  - !ruby/object:Gem::Version
40
- version: 0.0.2
43
+ version: '0.10'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 0.10.1
41
47
  - !ruby/object:Gem::Dependency
42
- name: slack-notifier
48
+ name: rake
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
51
  - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: 1.2.1
48
- type: :runtime
53
+ version: '10.0'
54
+ type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
58
  - - "~>"
53
59
  - !ruby/object:Gem::Version
54
- version: 1.2.1
60
+ version: '10.0'
55
61
  - !ruby/object:Gem::Dependency
56
- name: bundler
62
+ name: rspec
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
65
  - - "~>"
60
66
  - !ruby/object:Gem::Version
61
- version: '1.9'
67
+ version: '3.5'
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 3.5.0
62
71
  type: :development
63
72
  prerelease: false
64
73
  version_requirements: !ruby/object:Gem::Requirement
65
74
  requirements:
66
75
  - - "~>"
67
76
  - !ruby/object:Gem::Version
68
- version: '1.9'
77
+ version: '3.5'
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 3.5.0
69
81
  - !ruby/object:Gem::Dependency
70
- name: pry
82
+ name: clearbit
71
83
  requirement: !ruby/object:Gem::Requirement
72
84
  requirements:
73
85
  - - "~>"
74
86
  - !ruby/object:Gem::Version
75
- version: 0.10.1
76
- type: :development
87
+ version: '0.2'
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 0.2.2
91
+ type: :runtime
77
92
  prerelease: false
78
93
  version_requirements: !ruby/object:Gem::Requirement
79
94
  requirements:
80
95
  - - "~>"
81
96
  - !ruby/object:Gem::Version
82
- version: 0.10.1
97
+ version: '0.2'
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: 0.2.2
83
101
  - !ruby/object:Gem::Dependency
84
- name: rake
102
+ name: maccman-mash
85
103
  requirement: !ruby/object:Gem::Requirement
86
104
  requirements:
87
105
  - - "~>"
88
106
  - !ruby/object:Gem::Version
89
- version: '10.0'
90
- type: :development
107
+ version: '0.0'
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 0.0.2
111
+ type: :runtime
91
112
  prerelease: false
92
113
  version_requirements: !ruby/object:Gem::Requirement
93
114
  requirements:
94
115
  - - "~>"
95
116
  - !ruby/object:Gem::Version
96
- version: '10.0'
117
+ version: '0.0'
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: 0.0.2
97
121
  - !ruby/object:Gem::Dependency
98
- name: rspec
122
+ name: slack-notifier
99
123
  requirement: !ruby/object:Gem::Requirement
100
124
  requirements:
125
+ - - "~>"
126
+ - !ruby/object:Gem::Version
127
+ version: '1.2'
101
128
  - - ">="
102
129
  - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
130
+ version: 1.2.1
131
+ type: :runtime
105
132
  prerelease: false
106
133
  version_requirements: !ruby/object:Gem::Requirement
107
134
  requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: '1.2'
108
138
  - - ">="
109
139
  - !ruby/object:Gem::Version
110
- version: '0'
111
- description: Push Clearbit data into Slack channel
140
+ version: 1.2.1
141
+ description: Push rich Clearbit enrichment data in a Slack channel.
112
142
  email:
113
143
  - harlow@clearbit.com
114
144
  executables: []
@@ -122,6 +152,7 @@ files:
122
152
  - LICENSE
123
153
  - README.md
124
154
  - Rakefile
155
+ - clearbit-slack-0.1.5.gem
125
156
  - clearbit-slack.gemspec
126
157
  - lib/clearbit/slack.rb
127
158
  - lib/clearbit/slack/attachments/company.rb
@@ -149,9 +180,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
180
  version: '0'
150
181
  requirements: []
151
182
  rubyforge_project:
152
- rubygems_version: 2.4.5
183
+ rubygems_version: 2.2.2
153
184
  signing_key:
154
185
  specification_version: 4
155
- summary: Push Clearbit data into Slack channel
186
+ summary: Clean beautiful customer data. Now in Slack.
156
187
  test_files: []
157
- has_rdoc: