populus 0.0.3 → 0.0.4

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: e1b404b1feb1d96fc1de40bb3806a202f8f2eb37
4
- data.tar.gz: 1cf98167ae0480f6003f10026b9307c04f58b774
3
+ metadata.gz: ee4c83fd76f437d2fedee3e9079655a2e0b7c420
4
+ data.tar.gz: 674f5e3e39eedfa5c42e9db13f0cc5a2ae623588
5
5
  SHA512:
6
- metadata.gz: afc2e559d6b522b0c9773fe429183fa167d71b8051b44bcbd186673a31a00473bc3a7f67beae154d4f68612cc23d15c6a31aee5d4b958d0dcf9aeb01aa12cddf
7
- data.tar.gz: 76ae2b3f08db7cfa45b27edbd37d1e5be19dfa8fd133a6ff23096a80aec385e4419fab212460cc6e9eee271902cd410cad9975d9a5b2093053007697d1ec26f4
6
+ metadata.gz: aac3ab29d5b0f6702d54b56e331b00bd4dd8fe24e9e8aac2ec74c9e474bf426985f0a2954ca8eac923fe0bf3104486a8447ccde551952bf3af4c12c459d88333
7
+ data.tar.gz: c595120a3771cb62d3796fc78c7b5958f8c87a7fd7cfe3608655000d3187396833a4db04bc0e3006cd75b42ce1f639bc9e5bc1fc9e39ef3d4ed7a7435dd8d734
data/examples/echo.popl CHANGED
@@ -6,12 +6,16 @@ Populus.config do
6
6
  end
7
7
 
8
8
  Populus.watch :event, name: "sample" do
9
- cond {|data| data.any?{|d| d.has_key?('Payload')} }
9
+ cond {|data| data.any?{|d| !d['Payload'].nil? } }
10
10
  runs do |data|
11
- event = data.find{|d| d.has_key?('Payload')}
11
+ event = data.find{|d| !d['Payload'].nil? }
12
12
  Populus.logger.info "From populus!!!"
13
13
  Populus.logger.info Base64.decode64(event['Payload'])
14
14
 
15
- notify_to_slack("Hello!!!\nConsul event payload:\n>>> `#{event.inspect}`", channel: '#bot_test', username: "Populus")
15
+ notify_to_slack(<<-EOF, channel: '#bot_test', username: "Populus")
16
+ Hello!!!
17
+ Consul event payload:
18
+ >>> `#{event.inspect}`"
19
+ EOF
16
20
  end
17
21
  end
@@ -32,7 +32,7 @@ module Populus
32
32
  end
33
33
 
34
34
  def on(hostname, &run_it)
35
- be = Node.registory[hostname]
35
+ be = Node.registry[hostname]
36
36
  if be
37
37
  RemoteRunner.new(be, &run_it)
38
38
  else
data/lib/populus/node.rb CHANGED
@@ -3,12 +3,12 @@ require 'specinfra'
3
3
  module Populus
4
4
  class Node
5
5
  class << self
6
- def registory
6
+ def registry
7
7
  @nodes ||= {}
8
8
  end
9
9
 
10
10
  def register_host(hostname)
11
- registory[hostname] = gen_host(hostname)
11
+ registry[hostname] = gen_host(hostname)
12
12
  end
13
13
 
14
14
  private
@@ -1,4 +1,7 @@
1
1
  require 'specinfra'
2
+ require 'erb'
3
+ require 'tempfile'
4
+ require 'fileutils'
2
5
 
3
6
  module Populus
4
7
  class RemoteRunner
@@ -15,5 +18,28 @@ module Populus
15
18
  Populus.logger.debug("stderr:\n%s" % res.stderr)
16
19
  Populus.logger.info("Command exited: %d" % res.exit_status)
17
20
  end
21
+
22
+ def create_file(path, template="", context=nil)
23
+ file = Tempfile.new(".populus-tmp")
24
+ content = ERB.new(template).result(context || binding)
25
+ file.write content
26
+ file.close
27
+ @backend.send_file(file.path, path)
28
+ Populus.logger.info("Created Successfully: %s" % path)
29
+
30
+ FileUtils.rm_f(file.path)
31
+ end
32
+
33
+ def upload_file(to_path, local: nil)
34
+ raise ArgumentError unless local
35
+ @backend.send_file(local, to_path)
36
+ Populus.logger.info("Upload Successfully: %s to %s" % [local, to_path])
37
+ end
38
+
39
+ def upload_dir(to_dir, local: nil)
40
+ raise ArgumentError unless local
41
+ @backend.send_directory(local, to_dir)
42
+ Populus.logger.info("Upload Directory Successfully: %s to %s" % [local, to_dir])
43
+ end
18
44
  end
19
45
  end
@@ -1,3 +1,3 @@
1
1
  module Populus
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: populus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uchio, KONDO
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-17 00:00:00.000000000 Z
11
+ date: 2015-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: specinfra