ey_resolver 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ey_resolver/app_env_resolver.rb +15 -2
- data/lib/ey_resolver/environment_resolver.rb +12 -8
- data/lib/ey_resolver/query.rb +3 -0
- data/lib/ey_resolver/version.rb +1 -1
- metadata +52 -75
@@ -6,8 +6,21 @@ class EY::Resolver
|
|
6
6
|
end
|
7
7
|
|
8
8
|
class AppEnvResolver < AbstractResolver
|
9
|
+
|
10
|
+
def self.association
|
11
|
+
if Object.const_defined?(:AppDeployment)
|
12
|
+
:app_deployments
|
13
|
+
else
|
14
|
+
:app_environments
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
9
18
|
def self.model
|
10
|
-
|
19
|
+
if Object.const_defined?(:AppDeployment)
|
20
|
+
::AppDeployment
|
21
|
+
else
|
22
|
+
::AppEnvironment
|
23
|
+
end
|
11
24
|
end
|
12
25
|
|
13
26
|
def matches
|
@@ -20,7 +33,7 @@ class EY::Resolver
|
|
20
33
|
dm_query[model.environment.name.like] = "%#{query.environment_name}%" if query.environment_name
|
21
34
|
dm_query[model.app.account.name.like] = "%#{query.account_name}%" if query.account_name
|
22
35
|
|
23
|
-
candidates = user.accounts.apps.
|
36
|
+
candidates = user.accounts.apps.send(self.class.association).all(dm_query)
|
24
37
|
best_matches filter_by_remotes(candidates)
|
25
38
|
end
|
26
39
|
|
@@ -16,9 +16,9 @@ class EY::Resolver
|
|
16
16
|
end
|
17
17
|
|
18
18
|
dm_query = {}
|
19
|
-
dm_query[:name.like]
|
20
|
-
dm_query[model.account.name.like]
|
21
|
-
dm_query[model.
|
19
|
+
dm_query[:name.like] = "%#{query.environment_name}%" if query.environment_name
|
20
|
+
dm_query[model.account.name.like] = "%#{query.account_name}%" if query.account_name
|
21
|
+
dm_query[model.apps.name.like] = "%#{query.app_name}%" if query.app_name
|
22
22
|
|
23
23
|
candidates = user.accounts.environments.all(dm_query)
|
24
24
|
|
@@ -43,18 +43,22 @@ class EY::Resolver
|
|
43
43
|
|
44
44
|
private
|
45
45
|
|
46
|
+
# cache app uris since we might use it twice
|
47
|
+
def app_uris(env)
|
48
|
+
@app_uris ||= {}
|
49
|
+
@app_uris[env] ||= env.apps.map { |app| app.gitable_uri }.flatten
|
50
|
+
end
|
51
|
+
|
46
52
|
def equivalent_remote?(env, uri)
|
47
|
-
app_uris
|
48
|
-
app_uris.any? { |app_uri| app_uri.equivalent?(uri) }
|
53
|
+
app_uris(env).any? { |app_uri| app_uri.equivalent?(uri) }
|
49
54
|
end
|
50
55
|
|
51
56
|
def exact_match?(env, key, val)
|
52
57
|
case key.to_sym
|
53
58
|
when :remotes
|
54
|
-
|
55
|
-
val.any? { |uri| app_uris.any? { |app_uri| app_uri.equivalent?(uri) } }
|
59
|
+
val.any? { |uri| equivalent_remote?(env, uri) }
|
56
60
|
when :app_name
|
57
|
-
env.
|
61
|
+
env.apps.any? { |app| app.name.downcase == val.downcase }
|
58
62
|
when :environment_name
|
59
63
|
env.name.downcase == val.downcase
|
60
64
|
when :account_name
|
data/lib/ey_resolver/query.rb
CHANGED
data/lib/ey_resolver/version.rb
CHANGED
metadata
CHANGED
@@ -1,77 +1,57 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ey_resolver
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 0
|
10
|
-
version: 0.1.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Martin Emde
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
type: :runtime
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
12
|
+
date: 2012-02-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: gitable
|
16
|
+
requirement: &70106287480080 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
18
|
+
requirements:
|
26
19
|
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 17
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
- 2
|
32
|
-
- 3
|
20
|
+
- !ruby/object:Gem::Version
|
33
21
|
version: 0.2.3
|
34
|
-
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
22
|
+
type: :runtime
|
37
23
|
prerelease: false
|
38
|
-
|
39
|
-
|
40
|
-
none: false
|
41
|
-
requirements:
|
42
|
-
- - ">="
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
hash: 3
|
45
|
-
segments:
|
46
|
-
- 0
|
47
|
-
version: "0"
|
24
|
+
version_requirements: *70106287480080
|
25
|
+
- !ruby/object:Gem::Dependency
|
48
26
|
name: rake
|
49
|
-
|
50
|
-
|
51
|
-
|
27
|
+
requirement: &70106287479660 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
52
33
|
type: :development
|
53
|
-
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70106287479660
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec
|
38
|
+
requirement: &70106287479120 !ruby/object:Gem::Requirement
|
54
39
|
none: false
|
55
|
-
requirements:
|
40
|
+
requirements:
|
56
41
|
- - ~>
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
description: Resolves apps, environments, app_environments and accounts using a set of constraints
|
66
|
-
email:
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '2.0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70106287479120
|
47
|
+
description: Resolves apps, environments, app_environments and accounts using a set
|
48
|
+
of constraints
|
49
|
+
email:
|
67
50
|
- martin.emde@gmail.com
|
68
51
|
executables: []
|
69
|
-
|
70
52
|
extensions: []
|
71
|
-
|
72
53
|
extra_rdoc_files: []
|
73
|
-
|
74
|
-
files:
|
54
|
+
files:
|
75
55
|
- .gitignore
|
76
56
|
- Gemfile
|
77
57
|
- README.md
|
@@ -98,40 +78,37 @@ files:
|
|
98
78
|
- spec/app_resolver_spec.rb
|
99
79
|
- spec/environment_resolver_spec.rb
|
100
80
|
- spec/spec_helper.rb
|
101
|
-
homepage:
|
81
|
+
homepage: ''
|
102
82
|
licenses: []
|
103
|
-
|
104
83
|
post_install_message:
|
105
84
|
rdoc_options: []
|
106
|
-
|
107
|
-
require_paths:
|
85
|
+
require_paths:
|
108
86
|
- lib
|
109
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
88
|
none: false
|
111
|
-
requirements:
|
112
|
-
- -
|
113
|
-
- !ruby/object:Gem::Version
|
114
|
-
|
115
|
-
segments:
|
89
|
+
requirements:
|
90
|
+
- - ! '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
segments:
|
116
94
|
- 0
|
117
|
-
|
118
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
hash: 960271519958005982
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
97
|
none: false
|
120
|
-
requirements:
|
121
|
-
- -
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
|
124
|
-
segments:
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
segments:
|
125
103
|
- 0
|
126
|
-
|
104
|
+
hash: 960271519958005982
|
127
105
|
requirements: []
|
128
|
-
|
129
106
|
rubyforge_project: ey_resolver
|
130
107
|
rubygems_version: 1.8.15
|
131
108
|
signing_key:
|
132
109
|
specification_version: 3
|
133
110
|
summary: Resolves awsm models given constraints
|
134
|
-
test_files:
|
111
|
+
test_files:
|
135
112
|
- spec/account_resolver_spec.rb
|
136
113
|
- spec/app_env_resolver_spec.rb
|
137
114
|
- spec/app_resolver_spec.rb
|