cloudfuji 0.0.43 → 0.0.44

Sign up to get free protection for your applications and to get access to all the features.
@@ -44,13 +44,38 @@ module Cloudfuji
44
44
  # can be more quickly caught for the developer
45
45
  return StandardError("Cloudfuji::Event format incorrect, please make sure you're using the correct structure for sending events") unless !options[:name].nil? && !options[:category].nil? && !options[:data].nil?
46
46
 
47
- payload = {}
48
- payload[:category] = options[:category]
49
- payload[:name] = options[:name]
50
- payload[:data] = options[:data]
47
+ publish_locally(options) and return if ENV['CLOUDFUJI_LOCAL_APPS'].present?
48
+
49
+ payload = {
50
+ :category => options[:category],
51
+ :name => options[:name],
52
+ :data => options[:data]
53
+ }
51
54
 
52
55
  Cloudfuji::Command.post_command(events_url, payload)
53
56
  end
57
+
58
+ # During development, allow developers to configure a list of local
59
+ # ports & keys to post Cloudfuji events
60
+ # e.g. CLOUDFUJI_LOCAL_APPS=3000:abcdef,3001:abcdef
61
+ def publish_locally(options)
62
+ payload = {
63
+ :category => options[:category],
64
+ :event => options[:name], # Cloudfuji client uses :event key
65
+ :data => options[:data],
66
+ 'auth_token' => '' # Cloudfuji client uses 'key' instead of 'auth_token'
67
+ }
68
+
69
+ ENV['CLOUDFUJI_LOCAL_APPS'].split(',').each do |app|
70
+ port, key = app.split(":")
71
+ unless port && key
72
+ raise "ENV['CLOUDFUJI_LOCAL_APPS'] not formatted correctly, expecting: CLOUDFUJI_LOCAL_APPS=3000:abcdef,3001:abcdef"
73
+ end
74
+ payload[:key] = key
75
+ url = "localhost:#{port.strip}/cloudfuji/data"
76
+ Cloudfuji::Command.post_command(url, payload)
77
+ end
78
+ end
54
79
  end
55
80
 
56
81
  def initialize(options={})
@@ -1,4 +1,4 @@
1
1
  module Cloudfuji
2
2
  # Current version of the Cloudfuji gem
3
- VERSION = "0.0.43"
3
+ VERSION = "0.0.44"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudfuji
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.43
4
+ version: 0.0.44
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-05-28 00:00:00.000000000 Z
13
+ date: 2012-05-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rest-client
@@ -269,7 +269,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
269
269
  version: '0'
270
270
  segments:
271
271
  - 0
272
- hash: -3993018565100804292
272
+ hash: 957748079068696331
273
273
  required_rubygems_version: !ruby/object:Gem::Requirement
274
274
  none: false
275
275
  requirements:
@@ -278,7 +278,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
278
278
  version: '0'
279
279
  segments:
280
280
  - 0
281
- hash: -3993018565100804292
281
+ hash: 957748079068696331
282
282
  requirements: []
283
283
  rubyforge_project: cloudfuji
284
284
  rubygems_version: 1.8.24