lita-ship-to-pastebin 0.1.3 → 0.1.4

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: 2d3728fd0fe6c594c7c24ffbf5b6c106aab202d9
4
- data.tar.gz: 4a1e28ab90366ea894ed5e753b1cebd9b67a2b54
3
+ metadata.gz: c47e3044d282045679ec73fc387bfdb8794faf1a
4
+ data.tar.gz: 439b816a12a815f98ffb007465f48247c98fdef0
5
5
  SHA512:
6
- metadata.gz: 643d7499e5d5b9b93e9412a8701d69009417bf567b3e0f77cfffe6c4d1d92d08ad20a9ada07d060b7a3f32a91bc07406719e6d6edb9fbcda6e09c361904ff5db
7
- data.tar.gz: de4e3d77469aa3a91fe7cf8bf0a8ba629b9d28ca7a3b4e4d4813ae823c16ac710cfa99aac96bc4d2621b9493c256b54bc14968b50b6f5e5716b7b5683189e257
6
+ metadata.gz: af83e2c38fbbc7f7500f5c6ba47465395be4319cbe113eefe4ae8af2db881e028855617f8b4a22d05f293eecd97919be616e84721bc49fe25bcba823345c39a9
7
+ data.tar.gz: 64e75e91ec78f44951c61da576a141bc102fd80d1b72753ce6e771bac818e3c39bbbc2f36bc2b4cbd2d598b742b973e10747c1c2e78c8f0e9de0d141b540aabb
data/.gitignore CHANGED
@@ -16,7 +16,7 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
 
19
- # i heart vim
19
+ #Vim!
20
20
  *.swp
21
21
  *.swo
22
22
  *~
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --format=doc
@@ -0,0 +1,32 @@
1
+ require 'lita-ship-to-pastebin'
2
+
3
+ module Lita
4
+ module Handlers
5
+ class Bigtext < Handler
6
+ Lita.register_handler(self)
7
+
8
+ # START:snip
9
+ route(/^bigtext/i,
10
+ :hide_bigtext,
11
+ command: true,
12
+ help: {
13
+ 'bigtext' => 'gimme a wall of text hidden behind a pastebin URL'
14
+ })
15
+
16
+ def hide_bigtext(message)
17
+ message.reply longtext
18
+ end
19
+
20
+ def snip_text(text)
21
+ Lita::Extensions::ShipToPastebin.new.save_to_pastebin(text)
22
+ end
23
+
24
+ def longtext
25
+ (1..100).each.map do
26
+ %w[able baker charlie delta echo alpha bravo hawaii].sample
27
+ end.join(' ')
28
+ end
29
+ # END:snip
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,12 @@
1
+ require "lita"
2
+
3
+ Lita.load_locales Dir[File.expand_path(
4
+ File.join("..", "..", "locales", "*.yml"), __FILE__
5
+ )]
6
+
7
+ require "lita/handlers/bigtext"
8
+
9
+ Lita::Handlers::Bigtext.template_root File.expand_path(
10
+ File.join("..", "..", "templates"),
11
+ __FILE__
12
+ )
@@ -1,24 +1,25 @@
1
1
  Gem::Specification.new do |spec|
2
- spec.name = "lita-ship-to-pastebin"
3
- spec.version = "0.1.3"
4
- spec.authors = ["Daniel J. Pritchett"]
5
- spec.email = ["dpritchett@gmail.com"]
6
- spec.description = "Expose helper method to pastebin-ify any input text"
7
- spec.summary = "Expose helper method to pastebin-ify any input text"
8
- spec.homepage = "https://github.com/dpritchett/lita-ship-to-pastebin"
9
- spec.license = "MIT"
10
- spec.metadata = { "lita_plugin_type" => "extension" }
2
+ spec.name = 'lita-ship-to-pastebin'
3
+ spec.version = '0.1.4'
4
+ spec.authors = ['Daniel J. Pritchett']
5
+ spec.email = ['dpritchett@gmail.com']
6
+ spec.description = 'Expose helper method to pastebin-ify any input text'
7
+ spec.summary = 'Expose helper method to pastebin-ify any input text'
8
+ spec.homepage = 'https://github.com/dpritchett/lita-ship-to-pastebin'
9
+ spec.license = 'MIT'
10
+ spec.metadata = { 'lita_plugin_type' => 'extension' }
11
11
 
12
12
  spec.files = `git ls-files`.split($/)
13
13
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
14
14
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
- spec.require_paths = ["lib"]
15
+ spec.require_paths = ['lib']
16
16
 
17
- spec.add_runtime_dependency "lita", ">= 4.7"
17
+ spec.add_runtime_dependency 'lita', '>= 4.7'
18
18
 
19
- spec.add_development_dependency "bundler", "~> 1.3"
20
- spec.add_development_dependency "pry-byebug"
21
- spec.add_development_dependency "rake"
22
- spec.add_development_dependency "rack-test"
23
- spec.add_development_dependency "rspec", ">= 3.0.0"
19
+ spec.add_development_dependency 'bundler', '~> 1.3'
20
+ spec.add_development_dependency 'pry-byebug'
21
+ spec.add_development_dependency 'rake'
22
+ spec.add_development_dependency 'rack-test'
23
+ spec.add_development_dependency 'rspec', '>= 3.0.0'
24
+ spec.add_development_dependency 'webmock', '~> 3.3'
24
25
  end
@@ -1,10 +1,13 @@
1
- require "spec_helper"
1
+ require 'webmock/rspec'
2
+ require 'spec_helper'
2
3
 
3
4
  describe Lita::Extensions::ShipToPastebin, lita: true do
4
5
  subject { Lita::Extensions::ShipToPastebin.new }
5
6
 
7
+ before { stub_pastebin_calls! }
8
+
6
9
  it 'saves text to pastebin' do
7
10
  actual = subject.save_to_pastebin 'hey john', title: 'hey there john'
8
- expect(actual).to match /https:\/\/pastebin/
11
+ expect(actual).to include('https://pastebin.com/')
9
12
  end
10
13
  end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe Lita::Handlers::Bigtext, lita_handler: true do
4
+ let(:robot) { Lita::Robot.new(registry) }
5
+ let(:response) { double('response') }
6
+
7
+ before { stub_pastebin_calls! }
8
+
9
+ context 'managing walls of text' do
10
+ let(:longtext) { subject.longtext }
11
+
12
+ it 'should generate a lot of words on demand' do
13
+ expect(longtext.length > 512).to be_truthy
14
+ end
15
+
16
+ it 'should leverage the pastebin extension' do
17
+ result = subject.snip_text(longtext)
18
+
19
+ # only one phrase, not 100 words
20
+ expect(result.split.length > 10).to be_falsey
21
+
22
+ # stubbing out Faraday calls to hide from Pastebin API limits
23
+ expect(result).to include('https://pastebin.com/')
24
+ end
25
+ end
26
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,24 @@
1
- require "lita-ship-to-pastebin"
2
- require "lita/rspec"
1
+ require 'lita-bigtext'
2
+ require 'lita/rspec'
3
3
 
4
4
  # A compatibility mode is provided for older plugins upgrading from Lita 3. Since this plugin
5
5
  # was generated with Lita 4, the compatibility mode should be left disabled.
6
6
  Lita.version_3_compatibility_mode = false
7
+
8
+ # call me in a before block anywhere you're calling pastebin!
9
+ # This will save you from fairly low-overhead API limits.
10
+ def stub_pastebin_calls!
11
+ stub_request(:post, 'https://pastebin.com/api/api_post.php')
12
+ .with(body: {
13
+ 'api_dev_key' => /[a-f0-9]+/,
14
+ 'api_option' => 'paste',
15
+ 'api_paste_code' => /\W+/,
16
+ 'api_paste_name' => /\W+/ },
17
+ headers: {
18
+ 'Accept' => '*/*',
19
+ 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
20
+ 'Content-Type' => 'application/x-www-form-urlencoded',
21
+ 'User-Agent' => 'Faraday v0.15.0'
22
+ })
23
+ .to_return(status: 200, body: 'https://pastebin.com/6ig4DLUQ', headers: {})
24
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-ship-to-pastebin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Pritchett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-21 00:00:00.000000000 Z
11
+ date: 2018-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: 3.0.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.3'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.3'
97
111
  description: Expose helper method to pastebin-ify any input text
98
112
  email:
99
113
  - dpritchett@gmail.com
@@ -102,16 +116,20 @@ extensions: []
102
116
  extra_rdoc_files: []
103
117
  files:
104
118
  - ".gitignore"
119
+ - ".rspec"
105
120
  - ".travis.yml"
106
121
  - Gemfile
107
122
  - LICENSE
108
123
  - README.md
109
124
  - Rakefile
125
+ - lib/lita-bigtext.rb
110
126
  - lib/lita-ship-to-pastebin.rb
111
127
  - lib/lita/extensions/ship_to_pastebin.rb
128
+ - lib/lita/handlers/bigtext.rb
112
129
  - lita-ship-to-pastebin.gemspec
113
130
  - locales/en.yml
114
131
  - spec/lita/extensions/ship_to_pastebin_spec.rb
132
+ - spec/lita/handlers/bigtext_spec.rb
115
133
  - spec/spec_helper.rb
116
134
  homepage: https://github.com/dpritchett/lita-ship-to-pastebin
117
135
  licenses:
@@ -140,4 +158,5 @@ specification_version: 4
140
158
  summary: Expose helper method to pastebin-ify any input text
141
159
  test_files:
142
160
  - spec/lita/extensions/ship_to_pastebin_spec.rb
161
+ - spec/lita/handlers/bigtext_spec.rb
143
162
  - spec/spec_helper.rb