sipwizard 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sipwizard.gemspec
4
+
5
+ group :test do
6
+ gem 'minitest', '~> 4.7.5'
7
+ gem 'guard'
8
+ gem 'guard-minitest'
9
+ gem 'pry'
10
+ gem 'pry-debugger'
11
+ gem 'turn'
12
+ end
13
+
14
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,9 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard :minitest do
5
+ # with Minitest::Spec
6
+ watch(%r{^spec/(.*)_spec\.rb})
7
+ watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
8
+ watch(%r{^spec/spec_helper\.rb}) { 'spec' }
9
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 gregory
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Sipwizard
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'sipwizard'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install sipwizard
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,3 @@
1
+ module Sipwizard
2
+ class Configuration < Struct.new(:api_key); end
3
+ end
@@ -0,0 +1,29 @@
1
+ require 'faraday'
2
+ require 'faraday_middleware'
3
+
4
+ module Sipwizard
5
+ class Connection
6
+ API_PATH = 'https://www.sipsorcery.com/rest/v0.1/provisioning.svc'
7
+
8
+ attr_accessor :faraday_connection
9
+
10
+ def initialize(faraday_adapter=Faraday.default_adapter)
11
+ @faraday_connection = Faraday.new do |faraday|
12
+ faraday.request :url_encoded #for post/put params
13
+ faraday.response :logger
14
+ faraday.response :json, content_type: /\bjson\z/
15
+ faraday.adapter faraday_adapter
16
+ end
17
+
18
+ @faraday_connection.headers['apikey'] = Sipwizard.config.api_key
19
+ end
20
+
21
+ def self.uri_for_path(path)
22
+ "#{API_PATH}#{path}"
23
+ end
24
+
25
+ def get(path, params={})
26
+ self.faraday_connection.get(Connection.uri_for_path(path), params)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module Sipwizard
2
+ VERSION = "0.0.1"
3
+ end
data/lib/sipwizard.rb ADDED
@@ -0,0 +1,11 @@
1
+ Dir[File.dirname(__FILE__) + '/sipwizard/*.rb'].each{ |file| require file }
2
+
3
+ module Sipwizard
4
+ extend self
5
+
6
+ attr_accessor :config
7
+
8
+ def configure
9
+ @config = Configuration.new.tap{ |configuration| yield(configuration) }
10
+ end
11
+ end
data/sipwizard.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'sipwizard/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "sipwizard"
8
+ spec.version = Sipwizard::VERSION
9
+ spec.authors = ["gregory"]
10
+ spec.email = ["greg2502@gmail.com"]
11
+ spec.description = %q{SIP Sorcery ruby client}
12
+ spec.summary = %q{Wrapper around the sip sorcery api}
13
+ spec.homepage = "http://github.com/gregory/sipwizard"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency 'rack', "~> 1.5.2"
24
+ spec.add_development_dependency "faraday", '~> 0.8.9'
25
+ spec.add_development_dependency "faraday_middleware", "~> 0.9.0"
26
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sipwizard::Configuration do
4
+ describe '.new' do
5
+ subject{ Sipwizard::Configuration.new(api_key) }
6
+
7
+ let(:api_key){ 'foo' }
8
+
9
+ it 'has a api_key' do
10
+ subject.api_key.must_equal api_key
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sipwizard::Connection do
4
+ let(:default_faraday_adapter) { Faraday::Adapter::NetHttp }
5
+ subject{ Sipwizard::Connection.new }
6
+
7
+ it 'returns a Faraday::Connection with the nethttp adapter' do
8
+ subject.faraday_connection.must_be_instance_of Faraday::Connection
9
+ subject.faraday_connection.builder.handlers.must_include default_faraday_adapter
10
+ end
11
+
12
+ describe '.uri_for_path' do
13
+ let(:path){ 'bar' }
14
+ subject{ Sipwizard::Connection.uri_for_path(path) }
15
+
16
+ it "returns the base_uri of the api" do
17
+ subject.must_equal "#{Sipwizard::Connection::API_PATH}#{path}"
18
+ end
19
+ end
20
+
21
+ describe 'get(params)' do
22
+ let(:params){ { foo: 'bar' } }
23
+ let(:path){ '/path' }
24
+ let(:uri){ Sipwizard::Connection.uri_for_path(path) }
25
+ let(:faraday_connection) { Minitest::Mock.new }
26
+ let(:connection) do
27
+ Sipwizard::Connection.new.tap do |connection|
28
+ connection.faraday_connection = faraday_connection
29
+ end
30
+ end
31
+
32
+ subject { connection.get(path, params) }
33
+
34
+ it 'calls connection.get with the right uri' do
35
+ response = Minitest::Mock.new
36
+ faraday_connection.expect :get, response, [uri, params]
37
+ subject
38
+ faraday_connection.verify
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sipwizard do
4
+ subject{ Sipwizard }
5
+
6
+ describe '.configure' do
7
+ let(:api_key){ 'johndoe_key' }
8
+
9
+ before do
10
+ subject.configure do |config|
11
+ config.api_key = api_key
12
+ end
13
+ end
14
+
15
+ it 'has set the api_key' do
16
+ subject.config.api_key.must_equal api_key
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ Bundler.require(:test)
4
+
5
+ require_relative '../lib/sipwizard'
6
+
7
+ require 'minitest/autorun'
8
+ require 'minitest/pride'
9
+
10
+ Turn.config do |c|
11
+ c.format = :outline
12
+ c.natural = true
13
+ end
14
+
15
+ MiniTest::Spec.before :each do
16
+ Sipwizard.configure do |config|
17
+ config.api_key = 'default_api'
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sipwizard
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - gregory
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-01-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ none: false
21
+ name: bundler
22
+ type: :development
23
+ prerelease: false
24
+ requirement: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ version: '1.3'
29
+ none: false
30
+ - !ruby/object:Gem::Dependency
31
+ version_requirements: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ! '>='
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ none: false
37
+ name: rake
38
+ type: :development
39
+ prerelease: false
40
+ requirement: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ none: false
46
+ - !ruby/object:Gem::Dependency
47
+ version_requirements: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ~>
50
+ - !ruby/object:Gem::Version
51
+ version: 1.5.2
52
+ none: false
53
+ name: rack
54
+ type: :development
55
+ prerelease: false
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ~>
59
+ - !ruby/object:Gem::Version
60
+ version: 1.5.2
61
+ none: false
62
+ - !ruby/object:Gem::Dependency
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: 0.8.9
68
+ none: false
69
+ name: faraday
70
+ type: :development
71
+ prerelease: false
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: 0.8.9
77
+ none: false
78
+ - !ruby/object:Gem::Dependency
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ~>
82
+ - !ruby/object:Gem::Version
83
+ version: 0.9.0
84
+ none: false
85
+ name: faraday_middleware
86
+ type: :development
87
+ prerelease: false
88
+ requirement: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ~>
91
+ - !ruby/object:Gem::Version
92
+ version: 0.9.0
93
+ none: false
94
+ description: SIP Sorcery ruby client
95
+ email:
96
+ - greg2502@gmail.com
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files: []
100
+ files:
101
+ - .gitignore
102
+ - Gemfile
103
+ - Guardfile
104
+ - LICENSE.txt
105
+ - README.md
106
+ - Rakefile
107
+ - lib/sipwizard.rb
108
+ - lib/sipwizard/configuration.rb
109
+ - lib/sipwizard/connection.rb
110
+ - lib/sipwizard/version.rb
111
+ - sipwizard.gemspec
112
+ - spec/lib/sipwizard/configuration_spec.rb
113
+ - spec/lib/sipwizard/connection_spec.rb
114
+ - spec/lib/sipwizard_spec.rb
115
+ - spec/spec_helper.rb
116
+ homepage: http://github.com/gregory/sipwizard
117
+ licenses:
118
+ - MIT
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ none: false
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ none: false
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 1.8.23
138
+ signing_key:
139
+ specification_version: 3
140
+ summary: Wrapper around the sip sorcery api
141
+ test_files:
142
+ - spec/lib/sipwizard/configuration_spec.rb
143
+ - spec/lib/sipwizard/connection_spec.rb
144
+ - spec/lib/sipwizard_spec.rb
145
+ - spec/spec_helper.rb
146
+ has_rdoc: