flashover 0.0.2 → 0.0.3

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.
Files changed (4) hide show
  1. data/Gemfile.lock +1 -1
  2. data/flashover.gemspec +2 -2
  3. data/lib/flashover.rb +17 -13
  4. metadata +3 -3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- flashover (0.0.2)
4
+ flashover (0.0.3)
5
5
  redis (>= 3.0.2)
6
6
 
7
7
  GEM
data/flashover.gemspec CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |s|
7
7
  ## If your rubyforge_project name is different, then edit it and comment out
8
8
  ## the sub! line in the Rakefile
9
9
  s.name = 'flashover'
10
- s.version = '0.0.2'
11
- s.date = '2013-02-06'
10
+ s.version = '0.0.3'
11
+ s.date = '2013-02-08'
12
12
  # s.rubyforge_project = 'flashover'
13
13
 
14
14
  ## Make sure your summary is short. The description may be as long
data/lib/flashover.rb CHANGED
@@ -4,7 +4,7 @@ require "openssl"
4
4
 
5
5
  class Flashover
6
6
 
7
- VERSION = "0.0.2"
7
+ VERSION = "0.0.3"
8
8
 
9
9
  MESSAGE_TYPES = [
10
10
  :sms,
@@ -17,9 +17,9 @@ class Flashover
17
17
 
18
18
  attr_accessor :redis, :environment
19
19
 
20
- def initialize redis, passphrase, salt
20
+ def initialize(redis, passphrase, salt)
21
21
  @redis = redis
22
- @crypto = Crypto.new passphrase, salt
22
+ @crypto = Crypto.new(passphrase, salt)
23
23
  end
24
24
 
25
25
  # 'type' dictates the message pipeline payload is shoved down
@@ -29,7 +29,7 @@ class Flashover
29
29
  # -> :email
30
30
  # -> :page_view
31
31
  # -> :generic
32
- def event type, payload
32
+ def event(type, payload)
33
33
  begin
34
34
  @redis.publish(convert_symbol_to_channel(type), build_payload(payload))
35
35
  true
@@ -44,19 +44,24 @@ class Flashover
44
44
  end
45
45
  end
46
46
 
47
- def listen &blk
47
+ def listen(listening_channel = nil, &blk)
48
48
  raise MaryPoppins.new("block must have two args") unless blk.arity == 2
49
49
 
50
50
  @redis.subscribe(redis_message_types) do |on|
51
51
  on.message do |channel, message|
52
- yield convert_channel_to_symbol(channel), parse_message(message)
52
+ channel = convert_channel_to_symbol(channel)
53
+ if listening_channel
54
+ yield(channel, parse_message(message)) if listening_channel == channel
55
+ else
56
+ yield(channel, parse_message(message))
57
+ end
53
58
  end
54
59
  end
55
60
  end
56
61
 
57
62
  MESSAGE_TYPES.each do |message_type|
58
- define_method message_type do |payload|
59
- event message_type, payload
63
+ define_method(message_type) do |payload|
64
+ event(message_type, payload)
60
65
  end
61
66
  end
62
67
 
@@ -81,18 +86,17 @@ class Flashover
81
86
  encrypt JSON.generate(payload)
82
87
  end
83
88
 
84
-
85
89
  def redis_message_types
86
90
  @redis_message_types ||= MESSAGE_TYPES.map do |message_type|
87
91
  "flashover:pubsub:#{environment}:#{message_type.to_s}"
88
92
  end
89
93
  end
90
94
 
91
- def convert_channel_to_symbol channel
95
+ def convert_channel_to_symbol(channel)
92
96
  channel.split(":").last.to_sym
93
97
  end
94
98
 
95
- def convert_symbol_to_channel symbol
99
+ def convert_symbol_to_channel(symbol)
96
100
  "flashover:pubsub:#{environment}:#{symbol.to_s}"
97
101
  end
98
102
 
@@ -119,7 +123,7 @@ class Flashover
119
123
  def encrypt plaintext
120
124
  encryptor = OpenSSL::Cipher::Cipher.new 'AES-256-CBC'
121
125
  encryptor.encrypt
122
- encryptor.pkcs5_keyivgen @passphrase, @salt
126
+ encryptor.pkcs5_keyivgen(@passphrase, @salt)
123
127
 
124
128
  encrypted = encryptor.update plaintext
125
129
  encrypted << encryptor.final
@@ -128,7 +132,7 @@ class Flashover
128
132
  def decrypt ciphertext
129
133
  decryptor = OpenSSL::Cipher::Cipher.new 'AES-256-CBC'
130
134
  decryptor.decrypt
131
- decryptor.pkcs5_keyivgen @passphrase, @salt
135
+ decryptor.pkcs5_keyivgen(@passphrase, @salt)
132
136
 
133
137
  decrypted = decryptor.update ciphertext
134
138
  decrypted << decryptor.final
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flashover
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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-02-06 00:00:00.000000000 Z
12
+ date: 2013-02-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redis
@@ -92,7 +92,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
92
  version: '0'
93
93
  segments:
94
94
  - 0
95
- hash: 635554720703059146
95
+ hash: -257198928624443543
96
96
  required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  none: false
98
98
  requirements: