atomsphere 0.1.10 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +8 -16
- data/atomsphere.gemspec +1 -1
- data/lib/atomsphere.rb +1 -1
- data/lib/atomsphere/query.rb +5 -0
- data/lib/atomsphere/query/builder.rb +34 -0
- data/lib/atomsphere/query/expression/simple_expression.rb +15 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c31438d4c2d2f7684ed44f1cfac54cd5077b186b140c46a9f99fa39a52f1ac66
|
4
|
+
data.tar.gz: 79c7d6193080ea557c9ba8498c5b167f5837a00346aa68641d4bbaa9104adfb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46918892bdb5c7d815657b71ff3c499bbf264dae88ea7b7c2bb8ea95cf4aded55df373d5e6fb40c67c76594bf4039576540b07393894a6644c43bfb02f032b39
|
7
|
+
data.tar.gz: 1f997e4482a3af6c93880f2328151f2702b105e637a15571561ccec218b35a9a983bab678ccebeaa70093ad02e598cc24800700b0e6dde27b3cb82851359e6b8
|
data/README.md
CHANGED
@@ -44,29 +44,21 @@ Alternatively, environment variables may be used:
|
|
44
44
|
|
45
45
|
### Querying
|
46
46
|
|
47
|
-
|
48
|
-
contain _"NetSuite"_ or _"Salesforce"_:
|
47
|
+
Using the query builder:
|
49
48
|
|
50
49
|
```ruby
|
51
|
-
query = Atomsphere.query(
|
52
|
-
group :
|
53
|
-
|
54
|
-
group :
|
55
|
-
|
56
|
-
|
50
|
+
query = Atomsphere.query(:atom) do
|
51
|
+
group :or do
|
52
|
+
date_installed.less_than '2018-12-01T00:00:00Z'
|
53
|
+
group :and do
|
54
|
+
status.not_equals :online
|
55
|
+
type.not_equals :cloud
|
57
56
|
end
|
58
57
|
end
|
59
58
|
end
|
60
59
|
```
|
61
60
|
|
62
|
-
|
63
|
-
|
64
|
-
```ruby
|
65
|
-
query = Atomsphere.query('Atom') do
|
66
|
-
status.equals 'ONLINE'
|
67
|
-
type.equals 'CLOUD'
|
68
|
-
end
|
69
|
-
```
|
61
|
+
See more examples at https://www.rubydoc.info/gems/atomsphere/Atomsphere.query
|
70
62
|
|
71
63
|
Inspect the query filter:
|
72
64
|
|
data/atomsphere.gemspec
CHANGED
data/lib/atomsphere.rb
CHANGED
data/lib/atomsphere/query.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'facets/string/camelcase'
|
2
|
+
require 'facets/string/snakecase'
|
3
|
+
|
1
4
|
module Atomsphere
|
2
5
|
|
3
6
|
# @attr [String] object_type name of the object to query
|
@@ -17,6 +20,8 @@ module Atomsphere
|
|
17
20
|
case params
|
18
21
|
when String
|
19
22
|
params = {object_type: params}
|
23
|
+
when Symbol
|
24
|
+
params = {object_type: params.to_s.upper_camelcase}
|
20
25
|
end
|
21
26
|
|
22
27
|
params = {
|
@@ -1,5 +1,9 @@
|
|
1
1
|
module Atomsphere
|
2
2
|
class Query
|
3
|
+
|
4
|
+
# DSL for onstructing an {Atomsphere::Query}
|
5
|
+
# @see Atomsphere#query
|
6
|
+
# @attr_reader [Atomsphere::Query] query output query object
|
3
7
|
class Builder
|
4
8
|
attr_reader :query
|
5
9
|
|
@@ -7,6 +11,9 @@ module Atomsphere
|
|
7
11
|
@query = object_type.nil? ? Query.new : Query.new(object_type)
|
8
12
|
end
|
9
13
|
|
14
|
+
# Define a {GroupingExpression} at the top level of the query. If called
|
15
|
+
# more than once, subsequent calls create a grouping expression within
|
16
|
+
# the first created {GroupingExpression}.
|
10
17
|
def group operator, &block
|
11
18
|
new_group = GroupingExpression.new(operator)
|
12
19
|
Group.new(new_group).instance_eval(&block)
|
@@ -18,6 +25,9 @@ module Atomsphere
|
|
18
25
|
end
|
19
26
|
end
|
20
27
|
|
28
|
+
# Allows for defining of {SimpleExpression}s at the top level of the
|
29
|
+
# query. Creates a top level {GroupingExpression} if none yet exists
|
30
|
+
# to contain it.
|
21
31
|
def method_missing m, *args, &block
|
22
32
|
@query.filter = GroupingExpression.new(:and) unless @query.filter
|
23
33
|
Group.new(@query.filter).instance_eval do
|
@@ -27,6 +37,30 @@ module Atomsphere
|
|
27
37
|
end
|
28
38
|
end
|
29
39
|
|
40
|
+
# Invoke the DSL for constructing an {Atomsphere::Query}
|
41
|
+
#
|
42
|
+
# @example without an expression, returns all possible results
|
43
|
+
# Atomsphere.query(:process)
|
44
|
+
#
|
45
|
+
# @example a simple query expression for online Atoms
|
46
|
+
# Atomsphere.query(:atom) { status.equals :online }
|
47
|
+
#
|
48
|
+
# @example a query expression for online cloud Atoms (implied `and` group)
|
49
|
+
# Atomsphere.query(:atom) do
|
50
|
+
# status.equals :online
|
51
|
+
# type.equals :cloud
|
52
|
+
# end
|
53
|
+
#
|
54
|
+
# @example a more complex example with nested group expressions
|
55
|
+
# Atomsphere.query(:atom) do
|
56
|
+
# group :or do
|
57
|
+
# date_installed.less_than '2018-12-01T00:00:00Z'
|
58
|
+
# group :and do
|
59
|
+
# status.not_equals :online
|
60
|
+
# type.not_equals :cloud
|
61
|
+
# end
|
62
|
+
# end
|
63
|
+
# end
|
30
64
|
def self.query(object_type=nil, &block)
|
31
65
|
q = Query::Builder.new(object_type)
|
32
66
|
q.instance_eval(&block) if block_given?
|
@@ -34,10 +34,24 @@ module Atomsphere
|
|
34
34
|
}.merge(params)
|
35
35
|
|
36
36
|
%w(operator property argument).each do |v|
|
37
|
-
|
37
|
+
send :"#{v}=", params[v.to_sym]
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
def property= arg
|
42
|
+
instance_variable_set :@property,
|
43
|
+
case arg
|
44
|
+
when String
|
45
|
+
arg
|
46
|
+
when Symbol
|
47
|
+
arg.to_s.lower_camelcase
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def argument= arg
|
52
|
+
instance_variable_set :@argument, arg.map(&:to_s)
|
53
|
+
end
|
54
|
+
|
41
55
|
# run all `validate_*!` private methods to ensure validity of expression parameters
|
42
56
|
# @return [true, false]
|
43
57
|
def validate!
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atomsphere
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Warren Guy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rotp
|