jess 0.1.0 → 0.2.0
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/.travis.yml +5 -4
- data/CHANGELOG.md +6 -1
- data/README.md +18 -1
- data/jess.gemspec +1 -0
- data/lib/jess/extension_attributes.rb +9 -2
- data/lib/jess/http_client/error_decorator.rb +2 -0
- data/lib/jess/resource.rb +6 -2
- data/lib/jess/version.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1c4ee12ab3f054a1313667831afa2936b55abaa
|
4
|
+
data.tar.gz: a87377cb5dec69ab89e41e0a875625539d07b410
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cef11b0d500e5817ecb713166f92ebe1a9682665a8ebc53e093c7e26cf47a07a3eb07e2bcb708136858bfec257caa4928f3e6ba080796e3259c7662615a4924
|
7
|
+
data.tar.gz: 6c40232501f9bef0f63580266243bc700eed446acc75aeabc5bc2eceb934240655fc0cec38c39f0addf85bb6e6a928aa407aa35a8d4fe59dc007e23e94d7fd36
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -8,9 +8,14 @@ Jess is in a pre-1.0 state. This means that its APIs and behavior are subject to
|
|
8
8
|
|
9
9
|
* Your contribution here!
|
10
10
|
|
11
|
+
## [0.2.0][] (2017-01-21)
|
12
|
+
|
13
|
+
* Improved support for using jess in irb with `awesome_print` by implementing `to_hash` on resources
|
14
|
+
|
11
15
|
## 0.1.0 (2016-10-03)
|
12
16
|
|
13
17
|
* Initial release
|
14
18
|
|
15
19
|
[Semver]: http://semver.org
|
16
|
-
[Unreleased]: https://github.com/mattbrictson/
|
20
|
+
[Unreleased]: https://github.com/mattbrictson/jess/compare/v0.2.0...HEAD
|
21
|
+
[0.2.0]: https://github.com/mattbrictson/jess/compare/v0.1.0...v0.2.0
|
data/README.md
CHANGED
@@ -91,10 +91,27 @@ If you ever need access to the raw JSON data of any object, use the `_json` meth
|
|
91
91
|
computer.extension_attributes._json # => [{ ... }]
|
92
92
|
```
|
93
93
|
|
94
|
+
## Gotchas
|
95
|
+
|
96
|
+
Beware of these gotchas due to limitations of the JSS JSON API.
|
97
|
+
|
98
|
+
### Timestamps
|
99
|
+
|
94
100
|
Jess does not perform any type conversions. For example, timestamps are provided exactly as returned in the original JSON; they are not converted to Ruby DateTime objects.
|
95
101
|
|
96
102
|
```ruby
|
97
|
-
computer.purchasing.po_date_utc
|
103
|
+
computer.purchasing.po_date_utc # => "2016-03-18T00:00:00.000-0500"
|
104
|
+
computer.purchasing.po_date_epoch # => 1399698000000
|
105
|
+
```
|
106
|
+
|
107
|
+
### Unspecified values
|
108
|
+
|
109
|
+
JSS does a poor job of indicating unspecified values. For example, a computer where the bus speed cannot be determined will return `0` rather that `null` for the `bus_speed` JSON value. Likewise, unspecified string values are `""`, and unspecified timestamps are `""` or `0` instead of `null`. Jess passes these values straight through without any interpretation, so be aware that just because an attribute is *truthy* does not mean it has a useful value.
|
110
|
+
|
111
|
+
```ruby
|
112
|
+
# A computer without warranty information
|
113
|
+
computer.purchasing.warranty_expires # => ""
|
114
|
+
computer.purchasing.warranty_expires_epoch # => 0
|
98
115
|
```
|
99
116
|
|
100
117
|
## Why not ruby-jss?
|
data/jess.gemspec
CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_development_dependency "rake", "~> 11.0"
|
31
31
|
spec.add_development_dependency "minitest", "~> 5.0"
|
32
32
|
spec.add_development_dependency "minitest-reporters", "~>1.1"
|
33
|
+
spec.add_development_dependency "rainbow", "~> 2.1.0"
|
33
34
|
spec.add_development_dependency "rubocop", "~> 0.43"
|
34
35
|
spec.add_development_dependency "webmock", "~> 2.1"
|
35
36
|
end
|
@@ -3,16 +3,23 @@ require "forwardable"
|
|
3
3
|
module Jess
|
4
4
|
# A Hash-like wrapper around the extension attributes that facilitates easy
|
5
5
|
# key/value access.
|
6
|
-
class ExtensionAttributes
|
6
|
+
class ExtensionAttributes
|
7
7
|
extend Forwardable
|
8
8
|
def_delegators :@values, :[], :fetch, :key?, :keys, :size, :length, :to_h
|
9
9
|
|
10
10
|
def initialize(json)
|
11
|
-
super
|
12
11
|
@values = json.each_with_object({}) do |attr, hash|
|
13
12
|
hash[attr.name] = attr.value
|
14
13
|
end
|
15
14
|
@values.freeze
|
16
15
|
end
|
16
|
+
|
17
|
+
# Explicitly delegate instead of using def_delegators in order to be
|
18
|
+
# compatible with awesome_print. The original Hash#to_hash method is
|
19
|
+
# implemented in C, which means it has an arity of -1. This confuses
|
20
|
+
# awesome_print.
|
21
|
+
def to_hash
|
22
|
+
@values.to_hash
|
23
|
+
end
|
17
24
|
end
|
18
25
|
end
|
@@ -25,6 +25,7 @@ module Jess
|
|
25
25
|
raise Error, res.message
|
26
26
|
end
|
27
27
|
|
28
|
+
# rubocop:disable Lint/EmptyWhen
|
28
29
|
def handle_exception(e, req)
|
29
30
|
case e
|
30
31
|
when IOError, Timeout::Error
|
@@ -39,6 +40,7 @@ module Jess
|
|
39
40
|
e.http_method = req.method
|
40
41
|
raise e
|
41
42
|
end
|
43
|
+
# rubocop:enable Lint/EmptyWhen
|
42
44
|
end
|
43
45
|
end
|
44
46
|
end
|
data/lib/jess/resource.rb
CHANGED
@@ -11,6 +11,10 @@ module Jess
|
|
11
11
|
@_json = json.freeze
|
12
12
|
end
|
13
13
|
|
14
|
+
def to_hash
|
15
|
+
_json
|
16
|
+
end
|
17
|
+
|
14
18
|
private
|
15
19
|
|
16
20
|
def method_missing(symbol, *args)
|
@@ -30,9 +34,9 @@ module Jess
|
|
30
34
|
when Hash
|
31
35
|
Resource.new(json)
|
32
36
|
when Array
|
33
|
-
json.map(&method(:_as_resource))
|
37
|
+
json.map(&method(:_as_resource)).freeze
|
34
38
|
else
|
35
|
-
json
|
39
|
+
json.freeze
|
36
40
|
end
|
37
41
|
end
|
38
42
|
end
|
data/lib/jess/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jess
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Brictson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '1.1'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rainbow
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 2.1.0
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 2.1.0
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: rubocop
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -190,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
204
|
version: '0'
|
191
205
|
requirements: []
|
192
206
|
rubyforge_project:
|
193
|
-
rubygems_version: 2.6.
|
207
|
+
rubygems_version: 2.6.8
|
194
208
|
signing_key:
|
195
209
|
specification_version: 4
|
196
210
|
summary: Lightweight, unofficial client for the JAMF Software Server (JSS) API
|