epm 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/epm/create.rb +9 -1
- data/lib/epm/deploy.rb +76 -1
- data/lib/epm/query.rb +9 -1
- data/lib/epm/transact.rb +9 -1
- data/lib/epm/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8529b3bdc6d678cc4c49a2d81f4787805b224444
|
4
|
+
data.tar.gz: 40af244123b867e235026dae2ac15ff5b2277399
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b23d927440b7415b9e128710d1bb7726110f277398dcc63c4ef0f7c9c76ac787e6137c3c27e997b88f0686a6267ea3616e92462a5aefe6819aa6d56a99d70b4
|
7
|
+
data.tar.gz: 1920863e7e289945a13c56cc81eb66b6e326bb96173533d12a57baab2489905d039eb3aa6f59c0106629f8a2ac36818897ed202c41e6b1900b6f685b4f830a9c
|
data/lib/epm/create.rb
CHANGED
@@ -5,7 +5,7 @@ module EPM
|
|
5
5
|
def initialize file, settings={}
|
6
6
|
if file
|
7
7
|
@uri = URI.parse "http://localhost:#{settings['json-port']}"
|
8
|
-
|
8
|
+
setup settings
|
9
9
|
@contract = EPM::Compile.new(file, @settings).compile
|
10
10
|
end
|
11
11
|
end
|
@@ -31,5 +31,13 @@ module EPM
|
|
31
31
|
end
|
32
32
|
return EPM::Server.http_post_request @uri, post_body
|
33
33
|
end
|
34
|
+
|
35
|
+
def setup settings
|
36
|
+
unless settings.empty?
|
37
|
+
@settings = settings
|
38
|
+
else
|
39
|
+
@settings = EPM::Settings.check
|
40
|
+
end
|
41
|
+
end
|
34
42
|
end
|
35
43
|
end
|
data/lib/epm/deploy.rb
CHANGED
@@ -5,13 +5,15 @@ module EPM
|
|
5
5
|
def initialize def_file, settings={}
|
6
6
|
@dirname = File.dirname(File.absolute_path(def_file))
|
7
7
|
@log_file = File.join(ENV['HOME'], '.epm', 'deployed-log.csv')
|
8
|
-
|
8
|
+
setup settings
|
9
9
|
@brain = {}
|
10
10
|
@def_file = def_file
|
11
11
|
end
|
12
12
|
|
13
13
|
def deploy_package
|
14
|
+
get_remote_if_remote
|
14
15
|
if @def_file
|
16
|
+
p "Deploying: #{@def_file}."
|
15
17
|
commands = File.readlines @def_file
|
16
18
|
commands = commands.reject{|cmd| cmd[/\A#/] || cmd[/\A$/]}.map{|cmd| cmd.gsub("\n",'')}
|
17
19
|
commands = commands.inject([]) do |arr,ele|
|
@@ -122,5 +124,78 @@ module EPM
|
|
122
124
|
p "Setting #{key} to #{value}"
|
123
125
|
@brain[key] = value
|
124
126
|
end
|
127
|
+
|
128
|
+
def get_remote_if_remote
|
129
|
+
if is_it_a_remote_file?
|
130
|
+
begin
|
131
|
+
p "Cloning into Remote."
|
132
|
+
tmp = Tempfile.new 'epm'
|
133
|
+
Dir.chdir File.dirname tmp.path
|
134
|
+
unless File.directory? 'cloned'
|
135
|
+
Dir.mkdir 'cloned'
|
136
|
+
end
|
137
|
+
Dir.chdir 'cloned'
|
138
|
+
begin
|
139
|
+
`git clone #{@def_file}`
|
140
|
+
end
|
141
|
+
dir = Dir.glob('*')[0]
|
142
|
+
dir = File.dirname(tmp.path) + '/cloned/' + dir
|
143
|
+
Dir.chdir dir
|
144
|
+
def_files = Dir.glob('*').select {|f| File.extname(f) == '.package-definition'}
|
145
|
+
if def_files.empty?
|
146
|
+
dirs = Dir.glob('*').select {|f| File.directory? f}
|
147
|
+
dirs.each do |d|
|
148
|
+
Dir.chdir d
|
149
|
+
def_files << Dir.glob('*').inject([]) do |arr,f|
|
150
|
+
if File.extname(f) == '.package-definition'
|
151
|
+
arr << d + '/' + f
|
152
|
+
end
|
153
|
+
arr
|
154
|
+
end
|
155
|
+
Dir.chdir dir
|
156
|
+
end
|
157
|
+
end
|
158
|
+
def_files.flatten!
|
159
|
+
def_files.each do |df|
|
160
|
+
this_def_dir = File.dirname df
|
161
|
+
this_def_file = File.basename df
|
162
|
+
Dir.chdir this_def_dir
|
163
|
+
EPM::Deploy.new(this_def_file, @settings).deploy_package
|
164
|
+
Dir.chdir dir
|
165
|
+
end
|
166
|
+
rescue Exception => e
|
167
|
+
p "There was an error during that deploy."
|
168
|
+
puts e.message
|
169
|
+
ensure
|
170
|
+
remote_cleanup tmp
|
171
|
+
tmp.unlink
|
172
|
+
exit 0
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def is_it_a_remote_file?
|
178
|
+
@remote = false
|
179
|
+
if @def_file[/https*:\/\//] || @def_file[/gits*:\/\//] || @def_file[/.+@.+\..+:/]
|
180
|
+
@remote = true
|
181
|
+
return true
|
182
|
+
end
|
183
|
+
false
|
184
|
+
end
|
185
|
+
|
186
|
+
def remote_cleanup tmp
|
187
|
+
if @remote
|
188
|
+
Dir.chdir File.dirname tmp.path
|
189
|
+
FileUtils.rm_rf 'cloned'
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def setup settings
|
194
|
+
unless settings.empty?
|
195
|
+
@settings = settings
|
196
|
+
else
|
197
|
+
@settings = EPM::Settings.check
|
198
|
+
end
|
199
|
+
end
|
125
200
|
end
|
126
201
|
end
|
data/lib/epm/query.rb
CHANGED
@@ -4,7 +4,7 @@ module EPM
|
|
4
4
|
class Query
|
5
5
|
def initialize address, position, settings={}
|
6
6
|
@uri = URI.parse "http://localhost:#{settings['json-port']}"
|
7
|
-
|
7
|
+
setup settings
|
8
8
|
@address = EPM::HexData.hex_guard address
|
9
9
|
@position = EPM::HexData.hex_guard position
|
10
10
|
end
|
@@ -25,5 +25,13 @@ module EPM
|
|
25
25
|
end
|
26
26
|
return EPM::Server.http_post_request @uri, post_body
|
27
27
|
end
|
28
|
+
|
29
|
+
def setup settings
|
30
|
+
unless settings.empty?
|
31
|
+
@settings = settings
|
32
|
+
else
|
33
|
+
@settings = EPM::Settings.check
|
34
|
+
end
|
35
|
+
end
|
28
36
|
end
|
29
37
|
end
|
data/lib/epm/transact.rb
CHANGED
@@ -4,7 +4,7 @@ module EPM
|
|
4
4
|
class Transact
|
5
5
|
def initialize recipient, data, settings={}
|
6
6
|
@uri = URI.parse "http://localhost:#{settings['json-port']}"
|
7
|
-
|
7
|
+
setup settings
|
8
8
|
@recipient = EPM::HexData.hex_guard recipient
|
9
9
|
@data = EPM::HexData.construct_data data
|
10
10
|
end
|
@@ -32,5 +32,13 @@ module EPM
|
|
32
32
|
end
|
33
33
|
return EPM::Server.http_post_request @uri, post_body
|
34
34
|
end
|
35
|
+
|
36
|
+
def setup settings
|
37
|
+
unless settings.empty?
|
38
|
+
@settings = settings
|
39
|
+
else
|
40
|
+
@settings = EPM::Settings.check
|
41
|
+
end
|
42
|
+
end
|
35
43
|
end
|
36
44
|
end
|
data/lib/epm/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
VERSION = "0.3.
|
1
|
+
VERSION = "0.3.6"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Casey Kuhlman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|