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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3ba4716ea02efd8b3125dd57ede1c75fafc26de9
4
- data.tar.gz: 03f2507e70f5ca75b2bfac60e61be5e8d12a1b68
3
+ metadata.gz: c1c4ee12ab3f054a1313667831afa2936b55abaa
4
+ data.tar.gz: a87377cb5dec69ab89e41e0a875625539d07b410
5
5
  SHA512:
6
- metadata.gz: 6a8519484aa74c44671a609ec1e9acab79eeba09d1094b4ed22c988f459c0671287c39eac8ff94ca999cf4708ef638c5f20e157de8c697dc268c3c0d726dabb0
7
- data.tar.gz: 2e0a4267865b068782beb774541741cd636bc925a46bd31532f3f5d7351d0582b37c60978192eb2b74c77cbbdf394fb83725cd41c68836ca4f1913564fa03c83
6
+ metadata.gz: 7cef11b0d500e5817ecb713166f92ebe1a9682665a8ebc53e093c7e26cf47a07a3eb07e2bcb708136858bfec257caa4928f3e6ba080796e3259c7662615a4924
7
+ data.tar.gz: 6c40232501f9bef0f63580266243bc700eed446acc75aeabc5bc2eceb934240655fc0cec38c39f0addf85bb6e6a928aa407aa35a8d4fe59dc007e23e94d7fd36
@@ -1,7 +1,8 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.1
5
- - 2.2
6
- - 2.3.1
7
- before_install: gem install bundler -v 1.13.1
4
+ - 2.1.10
5
+ - 2.2.6
6
+ - 2.3.3
7
+ - 2.4.0
8
+ before_install: gem install bundler -v '~> 1.14' --conservative
@@ -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/chandler/compare/v0.1.0...HEAD
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 # => "2016-03-18T00:00:00.000-0500"
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?
@@ -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 < Resource
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Jess
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.2.0".freeze
3
3
  end
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.1.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: 2016-10-04 00:00:00.000000000 Z
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.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