euca 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.ruby-version +1 -0
- data/euca.gemspec +4 -1
- data/lib/euca.rb +20 -4
- data/lib/euca/model.rb +26 -21
- data/lib/euca/version.rb +1 -1
- data/spec/model_spec.rb +12 -4
- data/spec/support/minitest_helper.rb +0 -2
- metadata +56 -14
- data/lib/euca/core_ext/kernel.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OWVkMGViOGIzNTU3NzgzNGVlZDVmMmI0NWI1ZGIzNzk4NDgwMDExYw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YmJmZjlhYzUyYWIwMDk5NzhjMzBkYmNlYTM0ZTVlMmY2NDczNjUyOA==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MWVlNzZiZTk1YTlkMzI0N2I1YTRlOTM1ZTM5NGVkYWUwYTIzODkyOTljZTIy
|
10
|
+
MDE2MzFlNGRiN2M0MzI5N2EyMTU5MjNjOGFjNmJlNzY1NjY4NGIzMzA0YTcx
|
11
|
+
Yjc0MGM1NGU0MjQ0NDQ5ZjE3ZWJhZGE3MTM0ZDI5YWZiOTY4NzY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MTMzOTY1MDM5MzlhZGZjMzlkZGUyNTVkMGJiMmUzMmM4YzBlMzkzODhmNjc0
|
14
|
+
NTZmNWY4ZTAwM2M2ZjI5Y2YzYWY0MjhlYWQ0Y2YyMDg4ODAwYjY5ODZiZDFj
|
15
|
+
ZWYxMjg1MDM2MzI0MDU4Y2JmNGU3ODQ3MjdlNTlkZTdmOTIzZjk=
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.9.3-p484
|
data/euca.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Euca::VERSION
|
9
9
|
spec.authors = ["Onur Uyar"]
|
10
10
|
spec.email = ["me@onuruyar.com"]
|
11
|
-
spec.summary = %q{Ultra thin
|
11
|
+
spec.summary = %q{Ultra thin Ruby wrapper for euca2ools command line tools}
|
12
12
|
spec.homepage = ""
|
13
13
|
spec.license = "MIT"
|
14
14
|
|
@@ -20,4 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.add_development_dependency "bundler", "~> 1.5"
|
21
21
|
spec.add_development_dependency "rake"
|
22
22
|
spec.add_development_dependency "minitest"
|
23
|
+
spec.add_dependency 'pult', '~> 0.0.4'
|
24
|
+
spec.add_dependency 'vhs', '~> 0.0.1'
|
25
|
+
spec.add_dependency 'activesupport', '~> 4.0.2'
|
23
26
|
end
|
data/lib/euca.rb
CHANGED
@@ -1,9 +1,25 @@
|
|
1
|
-
require '
|
1
|
+
require 'pult'
|
2
|
+
require 'vhs'
|
2
3
|
require "euca/version"
|
3
|
-
require
|
4
|
+
require "euca/model"
|
4
5
|
|
5
6
|
module Euca
|
6
|
-
|
7
|
-
|
7
|
+
BIN_NAME="euca2ools".freeze
|
8
|
+
BIN_VERSION="euca-version".freeze
|
9
|
+
|
10
|
+
def self.has_cli?
|
11
|
+
!(self.version =~ /\d+\.\d+\.\d+/).nil?
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.version
|
15
|
+
sh(BIN_VERSION).gsub(/#{BIN_NAME} /,"")
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.api_methods
|
19
|
+
@@api_methods ||= sh("ls -1 #{self.exec_path}/euca-*").gsub(/#{self.exec_path}\/euca-/m,"").split("\n")
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.exec_path
|
23
|
+
@@euca_home ||= sh("dirname $(which euca-version)")
|
8
24
|
end
|
9
25
|
end
|
data/lib/euca/model.rb
CHANGED
@@ -1,36 +1,37 @@
|
|
1
1
|
require 'euca'
|
2
2
|
require 'euca/wrapper'
|
3
|
-
|
3
|
+
require 'active_support/inflector'
|
4
4
|
module Euca
|
5
5
|
module Model
|
6
6
|
|
7
7
|
module ClassMethods
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
WRAPPER = "@@wrapper"
|
12
|
-
|
13
|
-
def columns names = nil
|
14
|
-
unless names.nil?
|
15
|
-
class_variable_set(COLUMNS,names)
|
16
|
-
end
|
17
|
-
class_variable_get(COLUMNS)
|
9
|
+
def wrapper
|
10
|
+
@wrapper ||= Wrapper.new(self::TYPE_ID, self::TYPE_ATTRS)
|
18
11
|
end
|
19
12
|
|
20
|
-
def
|
21
|
-
|
13
|
+
def all
|
14
|
+
describe
|
22
15
|
end
|
23
|
-
|
24
|
-
|
25
|
-
class_variable_set(TYPE_ID,type_id)
|
16
|
+
def where *args
|
17
|
+
describe "--filter", *args
|
26
18
|
end
|
19
|
+
def find_by *args
|
20
|
+
where(*args).first
|
21
|
+
end
|
22
|
+
def find id
|
23
|
+
describe(id).first
|
24
|
+
end
|
25
|
+
def describe *args
|
26
|
+
euca("describe-#{self.describer}",*args)
|
27
|
+
end
|
27
28
|
|
28
|
-
def
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
def describer; @describer ||= self::TYPE_ID.tableize; end
|
30
|
+
def create; nil end
|
31
|
+
def destroy; nil end
|
32
|
+
|
33
|
+
def euca api, *args
|
34
|
+
self.wrapper.run api, *args
|
34
35
|
end
|
35
36
|
|
36
37
|
end
|
@@ -39,6 +40,10 @@ module Euca
|
|
39
40
|
base.extend ClassMethods
|
40
41
|
end
|
41
42
|
|
43
|
+
def persisted?
|
44
|
+
self.class.find(self.id)
|
45
|
+
end
|
46
|
+
|
42
47
|
def euca api, *args
|
43
48
|
wrapper.run api, *args
|
44
49
|
end
|
data/lib/euca/version.rb
CHANGED
data/spec/model_spec.rb
CHANGED
@@ -2,11 +2,19 @@ require 'support/minitest_helper'
|
|
2
2
|
require 'euca/model'
|
3
3
|
|
4
4
|
describe Euca::Model do
|
5
|
+
|
6
|
+
before do
|
7
|
+
|
8
|
+
class Api
|
9
|
+
include Euca::Model
|
10
|
+
TYPE_ATTRS= %w(type id name)
|
11
|
+
TYPE_ID = "image"
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
5
16
|
it "implements wrapper" do
|
6
|
-
|
7
|
-
Api.send :include, Euca::Model
|
8
|
-
Api.columns %w(type id name)
|
9
|
-
Api.type_id = "image"
|
17
|
+
|
10
18
|
api = Api.new
|
11
19
|
|
12
20
|
wrapper = MiniTest::Mock.new
|
metadata
CHANGED
@@ -1,57 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: euca
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Onur Uyar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.5'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ! '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ! '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pult
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.0.4
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.0.4
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: vhs
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.0.1
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.0.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: activesupport
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 4.0.2
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 4.0.2
|
55
97
|
description:
|
56
98
|
email:
|
57
99
|
- me@onuruyar.com
|
@@ -59,14 +101,14 @@ executables: []
|
|
59
101
|
extensions: []
|
60
102
|
extra_rdoc_files: []
|
61
103
|
files:
|
62
|
-
-
|
104
|
+
- .gitignore
|
105
|
+
- .ruby-version
|
63
106
|
- Gemfile
|
64
107
|
- LICENSE.txt
|
65
108
|
- README.md
|
66
109
|
- Rakefile
|
67
110
|
- euca.gemspec
|
68
111
|
- lib/euca.rb
|
69
|
-
- lib/euca/core_ext/kernel.rb
|
70
112
|
- lib/euca/model.rb
|
71
113
|
- lib/euca/version.rb
|
72
114
|
- lib/euca/wrapper.rb
|
@@ -84,20 +126,20 @@ require_paths:
|
|
84
126
|
- lib
|
85
127
|
required_ruby_version: !ruby/object:Gem::Requirement
|
86
128
|
requirements:
|
87
|
-
- -
|
129
|
+
- - ! '>='
|
88
130
|
- !ruby/object:Gem::Version
|
89
131
|
version: '0'
|
90
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
133
|
requirements:
|
92
|
-
- -
|
134
|
+
- - ! '>='
|
93
135
|
- !ruby/object:Gem::Version
|
94
136
|
version: '0'
|
95
137
|
requirements: []
|
96
138
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.2.
|
139
|
+
rubygems_version: 2.2.2
|
98
140
|
signing_key:
|
99
141
|
specification_version: 4
|
100
|
-
summary: Ultra thin
|
142
|
+
summary: Ultra thin Ruby wrapper for euca2ools command line tools
|
101
143
|
test_files:
|
102
144
|
- spec/fixtures/images.yml
|
103
145
|
- spec/model_spec.rb
|
data/lib/euca/core_ext/kernel.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'stringio'
|
2
|
-
|
3
|
-
module ::Kernel
|
4
|
-
|
5
|
-
def called_from(level=1)
|
6
|
-
arrs = caller((level||1)+1) or return
|
7
|
-
arrs[0] =~ /:(\d+)(?::in `(.*)')?/ ? [$`, $1.to_i, $2] : nil
|
8
|
-
end
|
9
|
-
|
10
|
-
def sh cmd
|
11
|
-
output = StringIO.new
|
12
|
-
|
13
|
-
Euca.logger.debug "[sh] #{cmd}"
|
14
|
-
|
15
|
-
IO.popen(cmd) do |pipe|
|
16
|
-
pipe.each do |line|
|
17
|
-
output.puts line
|
18
|
-
Euca.logger.debug line.chomp
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
output.string.chomp
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|