peritus_private_pub 1.0.4 → 1.0.5

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: d2d74b2ca28c9454171edb4bb8eb0e38bbd62bcb
4
- data.tar.gz: 426e6520b232983706ccd0154cd61aa0de7824c7
3
+ metadata.gz: ecb5cfd2854e690c5ca9093deaa7cb7eb48b3863
4
+ data.tar.gz: 51f96b16162ea332c6ff2e1a2cf7e82d08ae0345
5
5
  SHA512:
6
- metadata.gz: a104218d7fda5508ef4bf28515d541954a33e72bba3b5f0d303820511eaf4fb9a19f5f9b0d13d2c28f5683353132a6a90ccc7d035a44315ef212e4238cf439dd
7
- data.tar.gz: da07fdb106ae2b6e6f82daea5a1f53dbf8252164d8fc3fa3731a17c7c093ef8d41e37d730b5b0696d15b678cf07f039bee49ceaeb69439115ffa532f8513ba58
6
+ metadata.gz: 14671721191294a08524a8d114f67f29751380dae039bdeb9c60cdf290a57f632085bbb57e2da5e5832bb00c9451830bed5db16e0f1260052fc7cc65023c3367
7
+ data.tar.gz: 9cccc0fc1b37b9481fb06db738aa381101b7d3be71324b46738c2ee4f4e85fc2014dc24c7f0c6b07321f5893eccb91f073be37e1b229404e9b1a477b0190df0c
@@ -2,6 +2,7 @@ require "digest/sha1"
2
2
  require "net/http"
3
3
  require "net/https"
4
4
  require "erb"
5
+ require "YAML"
5
6
 
6
7
  require "private_pub/faye_extension"
7
8
  require "private_pub/engine" if defined? Rails
@@ -22,6 +23,8 @@ module PrivatePub
22
23
  yaml = YAML.load(ERB.new(File.read(filename)).result)[environment.to_s]
23
24
  raise ArgumentError, "The #{environment} environment does not exist in #{filename}" if yaml.nil?
24
25
  yaml.each { |k, v| config[k.to_sym] = v }
26
+ url = URI.parse(config[:server])
27
+ raise Error, "No host defined. Ensure LOCAL_IP is defined" unless url.host
25
28
  end
26
29
 
27
30
  # Publish the given data to a specific channel. This ends up sending
@@ -32,9 +35,7 @@ module PrivatePub
32
35
 
33
36
  # Sends the given message hash to the Faye server using Net::HTTP.
34
37
  def publish_message(message)
35
- if config[:server].nil? or config[:server].blank?
36
- raise Error, "No server specified, ensure private_pub.yml was loaded properly and that LOCAL_IP is defined."
37
- end
38
+ raise Error, "No server specified, ensure private_pub.yml was loaded properly." unless config[:server]
38
39
 
39
40
  url = URI.parse(config[:server])
40
41
 
@@ -60,10 +61,6 @@ module PrivatePub
60
61
  # Returns a subscription hash to pass to the PrivatePub.sign call in JavaScript.
61
62
  # Any options passed are merged to the hash.
62
63
  def subscription(options = {})
63
- if config[:server].nil? or config[:server].blank?
64
- raise Error, "No server specified, ensure private_pub.yml was loaded properly and that LOCAL_IP is defined."
65
- end
66
-
67
64
  sub = {:server => config[:server], :timestamp => (Time.now.to_f * 1000).round}.merge(options)
68
65
  sub[:signature] = Digest::SHA1.hexdigest([config[:secret_token], sub[:channel], sub[:timestamp]].join)
69
66
  sub
@@ -1,13 +1,13 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "peritus_private_pub"
3
- s.version = "1.0.4"
3
+ s.version = "1.0.5"
4
4
  s.author = "Tyler DeWitt"
5
5
  s.email = "tdewitt@peritus.com"
6
6
  s.homepage = "https://github.com/PeritusSolutions/peritus_private_pub"
7
7
  s.summary = "Private pub/sub messaging in Rails."
8
8
  s.description = "Private pub/sub messaging in Rails through Faye."
9
9
 
10
- s.files = Dir["{app,lib,spec}/**/*", "[A-Z]*", "init.rb"] - ["Gemfile.lock"]
10
+ s.files = Dir["{app,lib,spec}/**/*", "[A-Z]*", "init.rb"] - ["Gemfile.lock"] - Dir["*.gem"]
11
11
  s.require_path = "lib"
12
12
 
13
13
  s.add_dependency 'faye'
@@ -6,3 +6,7 @@ production:
6
6
  server: http://example.com/faye
7
7
  secret_token: PRODUCTION_SECRET_TOKEN
8
8
  signature_expiration: 600
9
+ no_host:
10
+ server: http://:9292/faye
11
+ secret_token: NO_HOST_SECRET_TOKEN
12
+ signature_expiration: 600
@@ -26,6 +26,12 @@ describe PrivatePub do
26
26
  PrivatePub.config[:signature_expiration].should eq(600)
27
27
  end
28
28
 
29
+ it "raises an exception when no host is defined in server" do
30
+ lambda {
31
+ PrivatePub.load_config("spec/fixtures/private_pub.yml", "no_host")
32
+ }.should raise_error PrivatePub::Error
33
+ end
34
+
29
35
  it "raises an exception if an invalid environment is passed to load_config" do
30
36
  lambda {
31
37
  PrivatePub.load_config("spec/fixtures/private_pub.yml", :test)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peritus_private_pub
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler DeWitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-11 00:00:00.000000000 Z
11
+ date: 2015-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faye
@@ -85,7 +85,6 @@ files:
85
85
  - lib/private_pub/engine.rb
86
86
  - lib/private_pub/faye_extension.rb
87
87
  - lib/private_pub/view_helpers.rb
88
- - peritus_private_pub-1.0.3.gem
89
88
  - peritus_private_pub.gemspec
90
89
  - spec/fixtures/private_pub.yml
91
90
  - spec/javascripts/private_pub_spec.js
Binary file