miasma 0.2.38 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/miasma/types/api.rb +2 -0
- data/lib/miasma/types/collection.rb +22 -10
- data/lib/miasma/types/model.rb +16 -3
- data/lib/miasma/utils.rb +1 -0
- data/lib/miasma/utils/api_methoding.rb +19 -0
- data/lib/miasma/version.rb +1 -1
- data/miasma.gemspec +2 -5
- metadata +8 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7c89af4200f0f9b301ab945ba9463907b2d5f15
|
4
|
+
data.tar.gz: 437d01b09762f3310318c5d62918296cd75b2c2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7681c24d0285ba51ee49e4645ba8658e0b000f6ae8f42f24d7d42d705122dc96622fa2cdb87396b830e8dd92ba6f844b8b6eed440931dd9416a8a2aa84f93a64
|
7
|
+
data.tar.gz: 1f0e9c36d3015859f290e91c42a2823e0a4ae01175cca6fad2f2afd13b6b5041e22d85bc8de6c86451c17be88ff6c46eda425433bf683e4ef58029fdf1ab4a53
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# v0.3.0
|
2
|
+
* Automatically check for API provided methods
|
3
|
+
* Remove provider specific dependencies
|
4
|
+
|
5
|
+
_NOTE: Provider specific libraries are not longer
|
6
|
+
automatically included and must be explicitly defined._
|
7
|
+
|
1
8
|
# v0.2.38
|
2
9
|
* Fix cassette naming within spec abstracts
|
3
10
|
|
data/lib/miasma/types/api.rb
CHANGED
@@ -7,13 +7,13 @@ module Miasma
|
|
7
7
|
class Collection
|
8
8
|
|
9
9
|
include Utils::Memoization
|
10
|
+
include Utils::ApiMethoding
|
10
11
|
|
11
12
|
# @return [Miasma::Api] underlying service API
|
12
13
|
attr_reader :api
|
13
14
|
|
14
15
|
def initialize(api)
|
15
16
|
@api = api
|
16
|
-
@collection = nil
|
17
17
|
end
|
18
18
|
|
19
19
|
# @return [Array<Model>]
|
@@ -102,25 +102,37 @@ module Miasma
|
|
102
102
|
# @param ident [String, Symbol] model identifier
|
103
103
|
# @return [Model, NilClass]
|
104
104
|
def perform_get(ident)
|
105
|
-
|
106
|
-
|
107
|
-
|
105
|
+
if(m_name = api_method_for(:get))
|
106
|
+
api.send(m_name, ident)
|
107
|
+
else
|
108
|
+
all.detect do |obj|
|
109
|
+
obj.id == ident ||
|
110
|
+
(obj.respond_to?(:name) && !obj.name.nil? && obj.name == ident)
|
111
|
+
end
|
108
112
|
end
|
109
113
|
end
|
110
114
|
|
111
115
|
# @return [Array<Model>]
|
112
116
|
def perform_population
|
113
|
-
|
117
|
+
if(m_name = api_method_for(:all))
|
118
|
+
api.send(m_name)
|
119
|
+
else
|
120
|
+
raise NotImplementedError
|
121
|
+
end
|
114
122
|
end
|
115
123
|
|
116
124
|
# @return [Array<Model>]
|
117
125
|
def perform_filter(args)
|
118
|
-
if(
|
119
|
-
|
120
|
-
item.name.start_with?(args[:prefix])
|
121
|
-
end
|
126
|
+
if(m_name = api_method_for(:filter))
|
127
|
+
api.send(m_name, args)
|
122
128
|
else
|
123
|
-
|
129
|
+
if(args[:prefix])
|
130
|
+
all.find_all do |item|
|
131
|
+
item.name.start_with?(args[:prefix])
|
132
|
+
end
|
133
|
+
else
|
134
|
+
all
|
135
|
+
end
|
124
136
|
end
|
125
137
|
end
|
126
138
|
|
data/lib/miasma/types/model.rb
CHANGED
@@ -7,6 +7,7 @@ module Miasma
|
|
7
7
|
class Model < Data
|
8
8
|
|
9
9
|
include Utils::Memoization
|
10
|
+
include Utils::ApiMethoding
|
10
11
|
|
11
12
|
attribute :custom, Smash, :coerce => lambda{|v| v.to_smash}, :default => Smash.new
|
12
13
|
|
@@ -100,7 +101,11 @@ module Miasma
|
|
100
101
|
# @return [TrueClass, FalseClass] performed remote action
|
101
102
|
# @raises [Miasma::Error::Save]
|
102
103
|
def perform_save
|
103
|
-
|
104
|
+
if(m_name = api_method_for(:save))
|
105
|
+
api.send(m_name, self)
|
106
|
+
else
|
107
|
+
raise NotImplementedError.new 'Remote API save has not been implemented'
|
108
|
+
end
|
104
109
|
end
|
105
110
|
|
106
111
|
# Reload model state from remote API
|
@@ -108,7 +113,11 @@ module Miasma
|
|
108
113
|
# @return [TrueClass, FalseClass] performed remote action
|
109
114
|
# @raises [Miasma::Error::Save]
|
110
115
|
def perform_reload
|
111
|
-
|
116
|
+
if(m_name = api_method_for(:reload))
|
117
|
+
api.send(m_name, self)
|
118
|
+
else
|
119
|
+
raise NotImplementedError.new 'Remote API reload has not been implemented'
|
120
|
+
end
|
112
121
|
end
|
113
122
|
|
114
123
|
# Destroy model from remote API
|
@@ -116,7 +125,11 @@ module Miasma
|
|
116
125
|
# @return [TrueClass, FalseClass] performed remote action
|
117
126
|
# @raises [Miasma::Error::Save]
|
118
127
|
def perform_destroy
|
119
|
-
|
128
|
+
if(m_name = api_method_for(:destroy))
|
129
|
+
api.send(m_name, self)
|
130
|
+
else
|
131
|
+
raise NotImplementedError.new 'Remote API destroy has not been implemented'
|
132
|
+
end
|
120
133
|
end
|
121
134
|
|
122
135
|
end
|
data/lib/miasma/utils.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'miasma'
|
2
|
+
|
3
|
+
module Miasma
|
4
|
+
module Utils
|
5
|
+
|
6
|
+
module ApiMethoding
|
7
|
+
|
8
|
+
# Generate the supported API method for
|
9
|
+
# a given action
|
10
|
+
def api_method_for(action)
|
11
|
+
klass = self.respond_to?(:model) ? model : self.class
|
12
|
+
m_name = "#{Bogo::Utility.snake(klass.name.split('::').last)}_#{action}"
|
13
|
+
self.api.respond_to?(m_name) ? m_name : nil
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
data/lib/miasma/version.rb
CHANGED
data/miasma.gemspec
CHANGED
@@ -15,11 +15,8 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.add_runtime_dependency 'multi_xml'
|
16
16
|
s.add_runtime_dependency 'xml-simple'
|
17
17
|
s.add_runtime_dependency 'bogo', '>= 0.1.30', '< 1.0'
|
18
|
-
# Include provider libs that do not have outside deps
|
19
|
-
s.add_runtime_dependency 'miasma-aws'
|
20
|
-
s.add_runtime_dependency 'miasma-open-stack'
|
21
|
-
s.add_runtime_dependency 'miasma-rackspace'
|
22
|
-
# Include development dependencies for running tests
|
23
18
|
s.add_development_dependency 'pry'
|
19
|
+
s.add_development_dependency 'rake'
|
20
|
+
s.add_development_dependency 'minitest'
|
24
21
|
s.files = Dir['{bin,lib}/**/*'] + %w(miasma.gemspec README.md CHANGELOG.md LICENSE)
|
25
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: miasma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -93,27 +93,13 @@ dependencies:
|
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '1.0'
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
|
-
name:
|
97
|
-
requirement: !ruby/object:Gem::Requirement
|
98
|
-
requirements:
|
99
|
-
- - ">="
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: '0'
|
102
|
-
type: :runtime
|
103
|
-
prerelease: false
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
requirements:
|
106
|
-
- - ">="
|
107
|
-
- !ruby/object:Gem::Version
|
108
|
-
version: '0'
|
109
|
-
- !ruby/object:Gem::Dependency
|
110
|
-
name: miasma-open-stack
|
96
|
+
name: pry
|
111
97
|
requirement: !ruby/object:Gem::Requirement
|
112
98
|
requirements:
|
113
99
|
- - ">="
|
114
100
|
- !ruby/object:Gem::Version
|
115
101
|
version: '0'
|
116
|
-
type: :
|
102
|
+
type: :development
|
117
103
|
prerelease: false
|
118
104
|
version_requirements: !ruby/object:Gem::Requirement
|
119
105
|
requirements:
|
@@ -121,13 +107,13 @@ dependencies:
|
|
121
107
|
- !ruby/object:Gem::Version
|
122
108
|
version: '0'
|
123
109
|
- !ruby/object:Gem::Dependency
|
124
|
-
name:
|
110
|
+
name: rake
|
125
111
|
requirement: !ruby/object:Gem::Requirement
|
126
112
|
requirements:
|
127
113
|
- - ">="
|
128
114
|
- !ruby/object:Gem::Version
|
129
115
|
version: '0'
|
130
|
-
type: :
|
116
|
+
type: :development
|
131
117
|
prerelease: false
|
132
118
|
version_requirements: !ruby/object:Gem::Requirement
|
133
119
|
requirements:
|
@@ -135,7 +121,7 @@ dependencies:
|
|
135
121
|
- !ruby/object:Gem::Version
|
136
122
|
version: '0'
|
137
123
|
- !ruby/object:Gem::Dependency
|
138
|
-
name:
|
124
|
+
name: minitest
|
139
125
|
requirement: !ruby/object:Gem::Requirement
|
140
126
|
requirements:
|
141
127
|
- - ">="
|
@@ -198,6 +184,7 @@ files:
|
|
198
184
|
- lib/miasma/types/thin_model.rb
|
199
185
|
- lib/miasma/utils.rb
|
200
186
|
- lib/miasma/utils/animal_strings.rb
|
187
|
+
- lib/miasma/utils/api_methoding.rb
|
201
188
|
- lib/miasma/utils/immutable.rb
|
202
189
|
- lib/miasma/utils/lazy.rb
|
203
190
|
- lib/miasma/utils/memoization.rb
|