clavem 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,13 +6,13 @@
6
6
  <title>
7
7
  Top Level Namespace
8
8
 
9
- &mdash; Documentation by YARD 0.8.5.2
9
+ &mdash; Documentation by YARD 0.8.6.2
10
10
 
11
11
  </title>
12
12
 
13
- <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
14
 
15
- <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
16
 
17
17
  <script type="text/javascript" charset="utf-8">
18
18
  hasFrames = window.top.frames.main ? true : false;
@@ -103,9 +103,9 @@
103
103
  </div>
104
104
 
105
105
  <div id="footer">
106
- Generated on Sat Apr 13 12:17:41 2013 by
106
+ Generated on Sun Jul 14 19:41:23 2013 by
107
107
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
108
- 0.8.5.2 (ruby-1.9.3).
108
+ 0.8.6.2 (ruby-1.9.3).
109
109
  </div>
110
110
 
111
111
  </body>
@@ -27,8 +27,8 @@ module Clavem
27
27
  #
28
28
  # @attribute url
29
29
  # @return [String] The URL where to send the user to start authorization..
30
- # @attribute ip
31
- # @return [String] The IP address on which listening for replies. Default is `127.0.0.1`.
30
+ # @attribute host
31
+ # @return [String] The host address on which listening for replies. Default is `localhost`.
32
32
  # @attribute port
33
33
  # @return [Fixnum] The port on which listening for replies. Default is `2501`.
34
34
  # @attribute command
@@ -50,7 +50,7 @@ module Clavem
50
50
  class Authorizer
51
51
  include R18n::Helpers
52
52
  attr_accessor :url
53
- attr_accessor :ip
53
+ attr_accessor :host
54
54
  attr_accessor :port
55
55
  attr_accessor :command
56
56
  attr_accessor :title
@@ -63,7 +63,7 @@ module Clavem
63
63
 
64
64
  # Returns a unique (singleton) instance of the authorizer.
65
65
  #
66
- # @param ip [String] The IP address on which listening for replies. Default is `127.0.0.1`.
66
+ # @param host [String] The host address on which listening for replies. Default is `localhost`.
67
67
  # @param port [Fixnum] The port on which listening for replies. Default is `2501`.
68
68
  # @param command [String|nil] The command to open the URL. `{{URL}}` is replaced with the specified URL. Default is `open "{{URL}}"`.
69
69
  # @param title [String|nil] The title for response template. Default is `Clavem Authorization`
@@ -72,15 +72,15 @@ module Clavem
72
72
  # @param response_handler [Proc] A Ruby block to handle response and check for success. See {#default_response_handler}.
73
73
  # @param force [Boolean] If to force recreation of the instance.
74
74
  # @return [Authorizer] The unique (singleton) instance of the authorizer.
75
- def self.instance(ip = "127.0.0.1", port = 2501, command = nil, title = nil, template = nil, timeout = 0, force = false, &response_handler)
75
+ def self.instance(host = "localhost", port = 2501, command = nil, title = nil, template = nil, timeout = 0, force = false, &response_handler)
76
76
  @instance = nil if force
77
- @instance ||= Clavem::Authorizer.new(ip, port, command, title, template, timeout, &response_handler)
77
+ @instance ||= Clavem::Authorizer.new(host, port, command, title, template, timeout, &response_handler)
78
78
  @instance
79
79
  end
80
80
 
81
81
  # Creates a new authorizer.
82
82
  #
83
- # @param ip [String] The IP address on which listening for replies. Default is `127.0.0.1`.
83
+ # @param host [String] The host address on which listening for replies. Default is `localhost`.
84
84
  # @param port [Fixnum] The port on which listening for replies. Default is `2501`.
85
85
  # @param command [String|nil] The command to open the URL. `{{URL}}` is replaced with the specified URL. Default is `open "{{URL}}"`.
86
86
  # @param title [String|nil] The title for response template. Default is `Clavem Authorization`
@@ -88,10 +88,10 @@ module Clavem
88
88
  # @param timeout [Fixnum] The amount of milliseconds to wait for response from the remote endpoint before returning a failure. Default is `0`, which means *disabled*.
89
89
  # @param response_handler [Proc] A Ruby block to handle response and check for success. See {#default_response_handler}.
90
90
  # @return [Authorizer] The new authorizer.
91
- def initialize(ip = "127.0.0.1", port = 2501, command = nil, title = nil, template = nil, timeout = 0, &response_handler)
91
+ def initialize(host = "localhost", port = 2501, command = nil, title = nil, template = nil, timeout = 0, &response_handler)
92
92
  @i18n = self.localize
93
93
 
94
- @ip = ip.ensure_string
94
+ @host = host.ensure_string
95
95
  @port = port.to_integer
96
96
  @command = command.ensure_string
97
97
  @title = title.ensure_string
@@ -147,7 +147,7 @@ module Clavem
147
147
  #
148
148
  # @return [String] The callback_url for this authorizer.
149
149
  def callback_url
150
- "http://#{ip}:#{port}/"
150
+ "http://#{host}:#{port}/"
151
151
  end
152
152
 
153
153
  # Handles a response from the remote endpoint.
@@ -172,7 +172,7 @@ module Clavem
172
172
  private
173
173
  # sanitize_arguments
174
174
  def sanitize_arguments
175
- @ip = "127.0.0.1" if @ip.blank?
175
+ @host = "localhost" if @host.blank?
176
176
  @port = 2501 if @port.to_integer < 1
177
177
  @command = "open \"{{URL}}\"" if @command.blank?
178
178
  @title = @i18n.default_title if @title.blank?
@@ -208,7 +208,7 @@ module Clavem
208
208
 
209
209
  # Prepare the webserver for handling the response.
210
210
  def setup_webserver
211
- @server = ::WEBrick::HTTPServer.new(:BindAddress => @ip, :Port => @port, :Logger => WEBrick::Log.new("/dev/null"), :AccessLog => [nil, nil])
211
+ @server = ::WEBrick::HTTPServer.new(BindAddress: @host, Port: @port, Logger: WEBrick::Log.new("/dev/null"), AccessLog: [nil, nil])
212
212
  @server.mount_proc("/"){ |request, response| dispatch_request(request, response) }
213
213
  end
214
214
 
@@ -217,7 +217,7 @@ module Clavem
217
217
  # @param [WEBrick::HTTPRequest] request The request that the remote endpoint made to notify authorization status.
218
218
  # @param [WEBrick::HTTPResponse] response The request to send to the browser.
219
219
  def dispatch_request(request, response)
220
- @token = @response_handler ? @response_handler.call(self, request, response) : self.default_response_handler(self, request, response)
220
+ @token = @response_handler ? @response_handler.call(self, request, response) : default_response_handler(self, request, response)
221
221
 
222
222
  if @status == :waiting then
223
223
  if @token.present? then
@@ -13,10 +13,10 @@ module Clavem
13
13
  MAJOR = 1
14
14
 
15
15
  # The minor version.
16
- MINOR = 2
16
+ MINOR = 3
17
17
 
18
18
  # The patch version.
19
- PATCH = 2
19
+ PATCH = 0
20
20
 
21
21
  # The current version of clavem.
22
22
  STRING = [MAJOR, MINOR, PATCH].compact.join(".")
@@ -40,27 +40,27 @@ describe Clavem::Authorizer do
40
40
 
41
41
  describe ".instance" do
42
42
  it("should call .new with the passed arguments") do
43
- ::Clavem::Authorizer.should_receive(:new).with("IP", "PORT", "COMMAND", "TITLE", "TEMPLATE", "TIMEOUT")
44
- ::Clavem::Authorizer.instance("IP", "PORT", "COMMAND", "TITLE", "TEMPLATE", "TIMEOUT")
43
+ ::Clavem::Authorizer.should_receive(:new).with("HOST", "PORT", "COMMAND", "TITLE", "TEMPLATE", "TIMEOUT")
44
+ ::Clavem::Authorizer.instance("HOST", "PORT", "COMMAND", "TITLE", "TEMPLATE", "TIMEOUT")
45
45
  end
46
46
 
47
47
  it("should return the same instance") do
48
- ::Clavem::Authorizer.stub(:new) do Time.now end
48
+ ::Clavem::Authorizer.stub(:new) { Time.now }
49
49
  authorizer = ::Clavem::Authorizer.instance("FIRST")
50
50
  expect(::Clavem::Authorizer.instance("SECOND")).to be(authorizer)
51
51
  end
52
52
 
53
53
  it("should return a new instance if requested to") do
54
- ::Clavem::Authorizer.stub(:new) do Time.now end
54
+ ::Clavem::Authorizer.stub(:new) { Time.now }
55
55
  authorizer = ::Clavem::Authorizer.instance("FIRST")
56
- expect(::Clavem::Authorizer.instance("IP", "PORT", "COMMAND", "TITLE", "TEMPLATE", "TIMEOUT", true)).not_to be(authorizer)
56
+ expect(::Clavem::Authorizer.instance("HOST", "PORT", "COMMAND", "TITLE", "TEMPLATE", "TIMEOUT", true)).not_to be(authorizer)
57
57
  end
58
58
  end
59
59
 
60
60
  describe "#initialize" do
61
61
  it("should handle default arguments") do
62
62
  authorizer = ::Clavem::Authorizer.new
63
- expect(authorizer.ip).to eq("127.0.0.1")
63
+ expect(authorizer.host).to eq("localhost")
64
64
  expect(authorizer.port).to eq(2501)
65
65
  expect(authorizer.command).to eq("open \"{{URL}}\"")
66
66
  expect(authorizer.title).to eq("Clavem Authorization")
@@ -70,8 +70,8 @@ describe Clavem::Authorizer do
70
70
  end
71
71
 
72
72
  it("should assign arguments") do
73
- authorizer = ::Clavem::Authorizer.new("IP", 2511, "COMMAND", "TITLE", "TEMPLATE", 2) do end
74
- expect(authorizer.ip).to eq("IP")
73
+ authorizer = ::Clavem::Authorizer.new("HOST", 2511, "COMMAND", "TITLE", "TEMPLATE", 2) do end
74
+ expect(authorizer.host).to eq("HOST")
75
75
  expect(authorizer.port).to eq(2511)
76
76
  expect(authorizer.command).to eq("COMMAND")
77
77
  expect(authorizer.title).to eq("TITLE")
@@ -157,7 +157,7 @@ describe Clavem::Authorizer do
157
157
 
158
158
  describe "#callback_url" do
159
159
  it("should return the correct callback") do
160
- expect(::Clavem::Authorizer.new.callback_url).to eq("http://127.0.0.1:2501/")
160
+ expect(::Clavem::Authorizer.new.callback_url).to eq("http://localhost:2501/")
161
161
  expect(::Clavem::Authorizer.new("10.0.0.1", "80").callback_url).to eq("http://10.0.0.1:80/")
162
162
  end
163
163
  end
@@ -201,7 +201,7 @@ describe Clavem::Authorizer do
201
201
  instance.send(:open_endpoint)
202
202
 
203
203
  Kernel.should_receive(:system).with("COMMAND")
204
- ::Clavem::Authorizer.new("IP", "PORT", "COMMAND").send(:open_endpoint)
204
+ ::Clavem::Authorizer.new("HOST", "PORT", "COMMAND").send(:open_endpoint)
205
205
  end
206
206
 
207
207
  it("should raise exception in case of failures") do
@@ -223,7 +223,7 @@ describe Clavem::Authorizer do
223
223
  describe "#setup_timeout_handling" do
224
224
  it("should not set a timeout handler by default") do
225
225
  authorizer = ::Clavem::Authorizer.new
226
- authorizer.stub(:open_endpoint) do end
226
+ authorizer.stub(:open_endpoint)
227
227
  authorizer.stub(:setup_webserver) do authorizer.instance_variable_set(:@server, ::ClavemDummyServer.new) end
228
228
  authorizer.authorize("URL")
229
229
  expect(authorizer.instance_variable_get(:@timeout_handler)).to be_nil
@@ -236,7 +236,7 @@ describe Clavem::Authorizer do
236
236
  server = ::ClavemDummyServer.new
237
237
  server.stub(:start) do sleep(1) end
238
238
 
239
- authorizer = ::Clavem::Authorizer.new("IP", "PORT", "COMMAND", "TITLE", "TEMPLATE", 500)
239
+ authorizer = ::Clavem::Authorizer.new("HOST", "PORT", "COMMAND", "TITLE", "TEMPLATE", 500)
240
240
  authorizer.stub(:open_endpoint) do end
241
241
  authorizer.stub(:setup_webserver) do authorizer.instance_variable_set(:@server, server) end
242
242
  expect { authorizer.authorize("URL") }.to raise_error(::Clavem::Exceptions::Timeout)
@@ -260,7 +260,7 @@ describe Clavem::Authorizer do
260
260
  it "should setup a single request handler on /" do
261
261
  server = ::ClavemDummyServer.new
262
262
  ::WEBrick::HTTPServer.stub(:new).and_return(server)
263
- authorizer = ::Clavem::Authorizer.new("IP", "PORT")
263
+ authorizer = ::Clavem::Authorizer.new("HOST", "PORT")
264
264
  server.should_receive(:mount_proc).with("/")
265
265
  authorizer.send(:setup_webserver)
266
266
  end
@@ -324,7 +324,7 @@ describe Clavem::Authorizer do
324
324
  server = ::ClavemDummyServer.new
325
325
  server.stub(:start) do sleep(1) end
326
326
 
327
- authorizer = ::Clavem::Authorizer.new("IP", "PORT", "COMMAND", "TITLE", "TEMPLATE")
327
+ authorizer = ::Clavem::Authorizer.new("HOST", "PORT", "COMMAND", "TITLE", "TEMPLATE")
328
328
  authorizer.stub(:open_endpoint) do end
329
329
  authorizer.stub(:setup_webserver) do authorizer.instance_variable_set(:@server, server) end
330
330
  authorizer.authorize("URL")
@@ -342,7 +342,7 @@ describe Clavem::Authorizer do
342
342
  server = ::ClavemDummyServer.new
343
343
  server.stub(:start) do sleep(1) end
344
344
 
345
- authorizer = ::Clavem::Authorizer.new("IP", "PORT", "COMMAND", "TITLE", "TEMPLATE", 5000)
345
+ authorizer = ::Clavem::Authorizer.new("HOST", "PORT", "COMMAND", "TITLE", "TEMPLATE", 5000)
346
346
  authorizer.send(:setup_timeout_handling)
347
347
  thread = authorizer.instance_variable_get(:@timeout_thread)
348
348
  thread.should_receive(:exit)
@@ -6,6 +6,9 @@
6
6
 
7
7
  require "pathname"
8
8
  require "simplecov"
9
+ require "coveralls"
10
+
11
+ Coveralls.wear!
9
12
 
10
13
  SimpleCov.start do
11
14
  root = Pathname.new(File.dirname(__FILE__)) + ".."
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clavem
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-13 00:00:00.000000000 Z
12
+ date: 2013-07-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mamertes
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 2.1.2
21
+ version: 2.2.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 2.1.2
29
+ version: 2.2.0
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: webrick
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  version: '0'
113
113
  segments:
114
114
  - 0
115
- hash: -2223468996882033968
115
+ hash: 747595586087603511
116
116
  requirements: []
117
117
  rubyforge_project: clavem
118
118
  rubygems_version: 1.8.25