minitel 0.0.1 β†’ 0.1.0

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: 648b98c8dc9f1b7ffb9dbfea6a2608dbf0e28e45
4
- data.tar.gz: 73eb5fee51e79d898d0601ebff1b766231da210c
3
+ metadata.gz: 533325700a781993cff2caa0601121f48f6bc947
4
+ data.tar.gz: f28924e1b4dc9b948d60a5013d3fbe80dcf98f51
5
5
  SHA512:
6
- metadata.gz: 7356837b3e88e75e92e087e474238983a46e810577ecad94eb4d5a6fceb98714e9c92e57a8965520ab058e8ea2fd46441cf37f2d1e10be32991c1499531217ce
7
- data.tar.gz: a9b3532a374f148d609e8105bb1ee22fa715a83982f758b7053b53db266fa2acd66e8b1b05a20db2bc34b3e27ade1273b5f3ff97c5218ede3bb1d73957f42bca
6
+ metadata.gz: a4e7a4e76ca52053180758b98ddc370235d2741b100e948ce60df9ec68d83085c74818213dea25f411571b374d0154c9525dba1dc7f52b3949602bf57d99433a
7
+ data.tar.gz: e03e2a4e45de7a14e8f9afbf2c151e9e940831289246fb510be900cdf741355d9d66dd194a66f8e787143f313e9f067c44bc9c88194a6aa6c924e1266d066e4c
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ InstalledFiles
7
+ _yardoc
8
+ coverage
9
+ doc/
10
+ lib/bundler/man
11
+ pkg
12
+ rdoc
13
+ spec/reports
14
+ test/tmp
15
+ test/version_tmp
16
+ tmp
17
+ *.bundle
18
+ *.so
19
+ *.o
20
+ *.a
21
+ mkmf.log
data/.travis.yml CHANGED
@@ -1,13 +1,14 @@
1
- bundler_args: --without development
2
1
  cache: bundler
3
2
  language: ruby
4
3
  rvm:
5
- - 1.9.2
6
- - 1.9.3
7
- - 2.0.0
8
- - 2.1.0
9
- - 2.1.1
4
+ - 2.1.3
10
5
  - 2.1.2
6
+ - 2.1.1
7
+ - 2.1.0
8
+ - 2.0.0
9
+ - 1.9.3
10
+ - 1.9.2
11
+ - ruby-head
11
12
  script: bundle exec rspec
12
13
  notifications:
13
14
  email: false
data/Gemfile.lock CHANGED
@@ -2,7 +2,7 @@ PATH
2
2
  remote: .
3
3
  specs:
4
4
  minitel (0.0.1)
5
- excon (~> 0, > 0.16)
5
+ excon (~> 0, >= 0.16)
6
6
  multi_json (~> 1.0)
7
7
 
8
8
  GEM
data/Guardfile ADDED
@@ -0,0 +1,16 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ # Note: The cmd option is now required due to the increasing number of ways
5
+ # rspec may be run, below are examples of the most common uses.
6
+ # * bundler: 'bundle exec rspec'
7
+ # * bundler binstubs: 'bin/rspec'
8
+ # * spring: 'bin/rsspec' (This will use spring if running and you have
9
+ # installed the spring binstubs per the docs)
10
+ # * zeus: 'zeus rspec' (requires the server to be started separetly)
11
+ # * 'just' rspec: 'rspec'
12
+ guard :rspec, cmd: 'bundle exec rspec' do
13
+ watch(%r{^spec/.+_spec\.rb$})
14
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
15
+ end
16
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/Readme.md ADDED
@@ -0,0 +1,5 @@
1
+ # 𝕄𝕀ℕ𝕀𝕋𝔼𝕃
2
+ A 𝕋𝔼𝕃𝔼𝕏 client
3
+
4
+ [![Build Status](https://travis-ci.org/heroku/minitel.svg?branch=master)](https://travis-ci.org/heroku/minitel)
5
+
data/changelog.txt ADDED
@@ -0,0 +1,9 @@
1
+ 0.1.0 2014-10-08
2
+ ================
3
+
4
+ Bump minimum version of Excon to redact passwords on errors
5
+
6
+ 0.0.1 2014-10-04
7
+ ================
8
+
9
+ initial release
data/lib/minitel.rb CHANGED
@@ -1,5 +1,3 @@
1
- Minitel = Module.new
2
-
3
1
  require 'minitel/version'
4
2
  require 'minitel/client'
5
3
 
@@ -3,25 +3,58 @@ require 'excon'
3
3
 
4
4
  module Minitel
5
5
  class Client
6
- attr_accessor :telex_url
6
+ attr_accessor :connection
7
7
 
8
8
  def initialize(telex_url)
9
- raise "Bad Url" unless telex_url.start_with? "https://"
10
- self.telex_url = telex_url
9
+ unless telex_url.start_with? "https://"
10
+ raise ArgumentError, "Bad Url"
11
+ end
12
+ self.connection = Excon.new(telex_url)
11
13
  end
12
14
 
13
15
  def notify_app(args)
16
+ keywords = [:app_uuid, :body, :title]
17
+ app_uuid, body, title = args[:app_uuid], args[:body], args[:title]
18
+
19
+ ensure_strict_args(args.keys, keywords)
20
+ ensure_no_nils(args, keywords)
21
+ ensure_is_uuid(app_uuid)
22
+
14
23
  message = {
15
- title: args.fetch(:title),
16
- body: args.fetch(:body),
17
- target: {type: 'app', id: args.fetch(:app_uuid)}
24
+ title: title,
25
+ body: body,
26
+ target: {type: 'app', id: app_uuid}
18
27
  }
19
28
 
20
- response = Excon.post("#{telex_url}/producer/messages",
29
+ response = connection.post(
30
+ path: "/producer/messages",
21
31
  body: MultiJson.dump(message),
22
32
  expects: 201)
23
33
 
24
34
  MultiJson.load(response.body)
25
35
  end
36
+
37
+ private
38
+
39
+ # A Ruby 2.1 required keyword argument sorta backport
40
+ def ensure_strict_args(keys, accept_keys)
41
+ if keys.sort != accept_keys.sort
42
+ delta = accept_keys - keys
43
+ raise ArgumentError, "missing or extra keywords: #{delta.join(', ')}"
44
+ end
45
+ end
46
+
47
+ def ensure_no_nils(args, keys)
48
+ keys.each do |key|
49
+ raise ArgumentError, "keyword #{key} is nil" unless args[key]
50
+ end
51
+ end
52
+
53
+ def ensure_is_uuid(uuid)
54
+ unless uuid =~ /\A[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}\z/i
55
+ raise ArgumentError, "not formated like a uuid"
56
+ end
57
+ end
58
+
26
59
  end
27
60
  end
@@ -1,3 +1,3 @@
1
1
  module Minitel
2
- VERSION = '0.0.1'
2
+ VERSION = '0.1.0'
3
3
  end
data/minitel.gemspec CHANGED
@@ -1,6 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require_relative 'lib/minitel'
2
+ require File.expand_path("../lib/minitel/version", __FILE__)
4
3
 
5
4
  Gem::Specification.new do |gem|
6
5
  gem.name = "minitel"
@@ -15,10 +14,10 @@ Gem::Specification.new do |gem|
15
14
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
15
  gem.require_paths = ["lib"]
17
16
  gem.version = Minitel::VERSION
18
- gem.platform = Gem::Platform::RUBY
17
+ gem.platform = Gem::Platform::RUBY
19
18
  gem.license = "MIT"
20
19
 
21
- gem.add_runtime_dependency 'excon', '~> 0', "> 0.16"
20
+ gem.add_runtime_dependency 'excon', '~> 0', ">= 0.20"
22
21
  gem.add_runtime_dependency 'multi_json', '~> 1.0'
23
22
 
24
23
  gem.add_development_dependency 'rspec', '~> 3.0'
@@ -0,0 +1,84 @@
1
+ require 'spec_helper'
2
+
3
+ describe Minitel::Client, '#initialize' do
4
+ it 'requires an https url' do
5
+ expect{ Minitel::Client.new('http://user:pass@what.com') }.to raise_error(ArgumentError)
6
+ expect{ Minitel::Client.new('https://user:pass@what.com') }.to_not raise_error
7
+ end
8
+
9
+ it 'uses the given url and credentials' do
10
+ url = "https://u:p@foo.com"
11
+ mock = double(:excon)
12
+ expect(Excon).to receive(:new).with(url).and_return(mock)
13
+
14
+ client = Minitel::Client.new(url)
15
+
16
+ expect(client.connection).to eq(mock)
17
+ end
18
+ end
19
+
20
+ describe Minitel::Client, '#notify_app' do
21
+ describe 'arguments' do
22
+ let(:defaults) { {title: 'a title', body: 'a body', app_uuid: SecureRandom.uuid} }
23
+ let(:client) { Minitel::Client.new('https://u:p@h.com') }
24
+
25
+ before do
26
+ Excon.stub({}, body: MultiJson.dump({}), status: 201)
27
+ end
28
+
29
+ it 'works when all 3 are present' do
30
+ expect { client.notify_app(defaults) }.to_not raise_error
31
+ end
32
+
33
+ [:title, :body, :app_uuid].each do |key|
34
+ it "fails when #{key} is missing from the arg hash" do
35
+ defaults.delete(key)
36
+ expect { client.notify_app(defaults) }.to raise_error(ArgumentError)
37
+ end
38
+
39
+ it "fails when #{key} is nil" do
40
+ defaults[key] = nil
41
+ expect { client.notify_app(defaults) }.to raise_error(ArgumentError)
42
+ end
43
+ end
44
+
45
+ it 'fails if app_uuid is not a uuid' do
46
+ defaults[:app_uuid] = "not a uuid"
47
+ expect { client.notify_app(defaults) }.to raise_error(ArgumentError)
48
+ end
49
+
50
+ it 'fails if there is an extra key' do
51
+ defaults.merge!( {foo: 3} )
52
+ expect { client.notify_app(defaults) }.to raise_error(ArgumentError)
53
+ end
54
+ end
55
+
56
+ describe 'action' do
57
+ let(:defaults) { {title: 'a title', body: 'a body', app_uuid: SecureRandom.uuid} }
58
+ let(:client) { Minitel::Client.new('https://u:p@h.com') }
59
+
60
+ before do
61
+ request = {path: '/producer/messages', method: :post}
62
+ response = {status: 201, body: MultiJson.dump({'success' => true})}
63
+ body = MultiJson.dump({
64
+ title: 'a title',
65
+ body: 'a body',
66
+ target: {type: 'app', id: defaults[:app_uuid]}
67
+ })
68
+
69
+ Excon.stub(request.merge(body: body), response)
70
+ end
71
+
72
+ it 'posts a proper json body to the producer messages endpoint' do
73
+ expect{ client.notify_app(defaults) }.to_not raise_error
74
+
75
+ unstubbed_body = defaults.merge({title: 'bad title'})
76
+ expect{ client.notify_app(unstubbed_body) }.to raise_error(Excon::Errors::StubNotFound)
77
+ end
78
+
79
+ it 'returns a parsed json response' do
80
+ result = client.notify_app(defaults)
81
+ expect(result['success']).to eq(true)
82
+ end
83
+ end
84
+ end
data/spec/spec_helper.rb CHANGED
@@ -1 +1,13 @@
1
+ require 'rubygems'
1
2
  require 'rspec'
3
+ require 'minitel'
4
+
5
+ RSpec.configure do |config|
6
+ config.before(:all) do
7
+ Excon.defaults[:mock] = true
8
+ end
9
+
10
+ config.after(:each) do
11
+ Excon.stubs.clear
12
+ end
13
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Leinweber
@@ -28,7 +28,7 @@ cert_chain:
28
28
  5bkhRfJHSD/uX/cHbjmopLRbPlHrGbZTDIP4VEC5l0QLPiZ1nhKQnf3+U0+FSy2o
29
29
  CCngcLCR6q+mLf+A4L54VxmyrtFpcBfmkU72QYyf3vJ9QipL3XbvJvbpPkWSn1DX
30
30
  -----END CERTIFICATE-----
31
- date: 2014-10-04 00:00:00.000000000 Z
31
+ date: 2014-10-08 00:00:00.000000000 Z
32
32
  dependencies:
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: excon
@@ -37,9 +37,9 @@ dependencies:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
39
  version: '0'
40
- - - ">"
40
+ - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: '0.16'
42
+ version: '0.20'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -47,9 +47,9 @@ dependencies:
47
47
  - - "~>"
48
48
  - !ruby/object:Gem::Version
49
49
  version: '0'
50
- - - ">"
50
+ - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: '0.16'
52
+ version: '0.20'
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: multi_json
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -85,15 +85,20 @@ executables: []
85
85
  extensions: []
86
86
  extra_rdoc_files: []
87
87
  files:
88
+ - ".gitignore"
88
89
  - ".travis.yml"
89
90
  - Gemfile
90
91
  - Gemfile.lock
92
+ - Guardfile
91
93
  - LICENSE
94
+ - Rakefile
95
+ - Readme.md
96
+ - changelog.txt
92
97
  - lib/minitel.rb
93
98
  - lib/minitel/client.rb
94
99
  - lib/minitel/version.rb
95
100
  - minitel.gemspec
96
- - spec/minitel_spec.rb
101
+ - spec/minitel/client_spec.rb
97
102
  - spec/spec_helper.rb
98
103
  homepage: https://github.com/heroku/minitel
99
104
  licenses:
@@ -120,6 +125,6 @@ signing_key:
120
125
  specification_version: 4
121
126
  summary: "\U0001D54B\U0001D53C\U0001D543\U0001D53C\U0001D54F client: see https://github.com/heroku/telex"
122
127
  test_files:
123
- - spec/minitel_spec.rb
128
+ - spec/minitel/client_spec.rb
124
129
  - spec/spec_helper.rb
125
130
  has_rdoc:
metadata.gz.sig CHANGED
Binary file
data/spec/minitel_spec.rb DELETED
@@ -1,7 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Minitel do
4
- it 'dummy test' do
5
- expect(Minitel).to be_kind_of(Module)
6
- end
7
- end