orca 0.3.6 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- orca (0.3.6)
4
+ orca (0.4.0)
5
5
  colored
6
6
  net-sftp
7
7
  net-ssh
8
8
  thor
9
+ tilt
9
10
 
10
11
  GEM
11
12
  remote: https://rubygems.org/
@@ -17,9 +18,10 @@ GEM
17
18
  metaclass (~> 0.0.1)
18
19
  net-sftp (2.1.2)
19
20
  net-ssh (>= 2.6.5)
20
- net-ssh (2.6.7)
21
+ net-ssh (2.6.8)
21
22
  rake (10.0.4)
22
23
  thor (0.18.1)
24
+ tilt (1.4.1)
23
25
 
24
26
  PLATFORMS
25
27
  ruby
@@ -1,6 +1,5 @@
1
1
  require 'rubygems'
2
2
  require 'colored'
3
- require 'thor'
4
3
 
5
4
  module Orca
6
5
  def verbose(val=nil)
@@ -46,6 +45,7 @@ require_relative "./orca/group"
46
45
  require_relative "./orca/runner"
47
46
  require_relative "./orca/trigger_runner"
48
47
  require_relative "./orca/resolver"
48
+ require_relative "./orca/template"
49
49
  require_relative "./orca/execution_context"
50
50
  require_relative "./orca/local_file"
51
51
  require_relative "./orca/remote_file"
@@ -1,3 +1,5 @@
1
+ require 'thor'
2
+
1
3
  class Orca::Cli < Thor
2
4
  include Thor::Actions
3
5
 
@@ -44,7 +46,7 @@ class Orca::Cli < Thor
44
46
  suite = Orca::Suite.new(options)
45
47
  suite.load_file(orca_file)
46
48
  suite.run(group, package, cmd)
47
- rescue => e
49
+ rescue Exception => e
48
50
  err = e
49
51
  ensure
50
52
  $stdout.print "Disconnecting...".green
@@ -61,6 +61,10 @@ class Orca::ExecutionContext
61
61
  Orca::RemoteFile.new(self, path)
62
62
  end
63
63
 
64
+ def template(path)
65
+ Orca::Template.new(@node, path)
66
+ end
67
+
64
68
  def trigger(action_ref, *args)
65
69
  pkg_name, action_name = *action_ref.split(':', 2)
66
70
  pkg = Orca::PackageIndex.default.get(pkg_name)
@@ -11,7 +11,7 @@ class Orca::FileSync
11
11
  @parent = parent
12
12
  @config = config
13
13
  @after_apply = blk
14
- raise ArgumentError.new('A file :source must be provided') unless local_path
14
+ raise ArgumentError.new('A file :source or template must be provided') unless local_path or template_path
15
15
  raise ArgumentError.new('A file :destination must be provided') unless remote_path
16
16
  end
17
17
 
@@ -19,6 +19,15 @@ class Orca::FileSync
19
19
  @config[:source]
20
20
  end
21
21
 
22
+ def template_path
23
+ @config[:template]
24
+ end
25
+
26
+ def local_path_for_node(node)
27
+ return local_path if local_path
28
+ Orca::Template.new(node, template_path).render_to_tempfile
29
+ end
30
+
22
31
  def remote_path
23
32
  @config[:destination]
24
33
  end
@@ -62,7 +71,7 @@ class Orca::FileSync
62
71
  sudo("mkdir -p #{mk_dir}")
63
72
  sudo("chown #{fs.user}:#{fs.group || fs.user} #{mk_dir}") if fs.user
64
73
  end
65
- local_file = local(fs.local_path)
74
+ local_file = local(fs.local_path_for_node(node))
66
75
  tmp_path = "orca-upload-#{local_file.hash}"
67
76
  local_file.copy_to(remote(tmp_path))
68
77
  sudo("mv #{tmp_path} #{fs.remote_path}")
@@ -74,7 +83,7 @@ class Orca::FileSync
74
83
  end
75
84
 
76
85
  package.command :validate do
77
- local(fs.local_path).matches?(remote(fs.remote_path))
86
+ local(fs.local_path_for_node(node)).matches?(remote(fs.remote_path))
78
87
  end
79
88
  end
80
89
  end
@@ -0,0 +1,32 @@
1
+ require 'erb'
2
+ require 'tilt'
3
+
4
+ class Orca::Template
5
+ def initialize(node, path)
6
+ @node = node
7
+ @path = resolve(path)
8
+ @template = Tilt.new(@path)
9
+ end
10
+
11
+ def render(locals={})
12
+ @template.render(@node, locals)
13
+ end
14
+
15
+ def render_to_tempfile(locals={})
16
+ basename = File.basename(@path).gsub('.', '-')
17
+ file = Tempfile.new(basename)
18
+ file.write render(locals)
19
+ file.close
20
+ file.path
21
+ end
22
+
23
+ private
24
+
25
+ def resolve(path)
26
+ if path =~ /^\//
27
+ path
28
+ else
29
+ File.join(Orca.root, path)
30
+ end
31
+ end
32
+ end
@@ -10,9 +10,10 @@ Gem::Specification.new do |gem|
10
10
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
11
11
  gem.name = "orca"
12
12
  gem.require_paths = ["lib"]
13
- gem.version = '0.3.6'
13
+ gem.version = '0.4.0'
14
14
  gem.add_dependency('colored')
15
15
  gem.add_dependency('net-ssh')
16
16
  gem.add_dependency('net-sftp')
17
17
  gem.add_dependency('thor')
18
+ gem.add_dependency('tilt')
18
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orca
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.4.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-07-05 00:00:00.000000000 Z
12
+ date: 2013-07-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colored
@@ -75,6 +75,22 @@ dependencies:
75
75
  - - ! '>='
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: tilt
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
78
94
  description: Orca is a super simple way to build and configure servers
79
95
  email:
80
96
  - andy.kent@me.com
@@ -108,6 +124,7 @@ files:
108
124
  - lib/orca/resolver.rb
109
125
  - lib/orca/runner.rb
110
126
  - lib/orca/suite.rb
127
+ - lib/orca/template.rb
111
128
  - lib/orca/trigger_runner.rb
112
129
  - orca.gemspec
113
130
  - test/dsl_test.rb
@@ -133,7 +150,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
150
  version: '0'
134
151
  segments:
135
152
  - 0
136
- hash: -796320942601903817
153
+ hash: -951848962071421734
137
154
  required_rubygems_version: !ruby/object:Gem::Requirement
138
155
  none: false
139
156
  requirements:
@@ -142,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
159
  version: '0'
143
160
  segments:
144
161
  - 0
145
- hash: -796320942601903817
162
+ hash: -951848962071421734
146
163
  requirements: []
147
164
  rubyforge_project:
148
165
  rubygems_version: 1.8.23