ruby-jss 0.11.0b1 → 0.11.0b2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ruby-jss might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad7f8bb660801869ee8f70a9ae78a872c7b99296
4
- data.tar.gz: 9a06851981b20938d10811b002821bfff9e5fa4d
3
+ metadata.gz: 21217657188ce815a99fe4f834e1fd3c1947c2d9
4
+ data.tar.gz: bb5e45fd335ad1daec3b127fa040a6ba83db894b
5
5
  SHA512:
6
- metadata.gz: a61ae7382fa4ff8eba62f55b6ac31d46b9f6950e221563bcbb9ffd33ec36cdde578000e6bf73ccda72ff069da60737d41adb274a9e5bb74b007f115d368ea6e9
7
- data.tar.gz: 40500cab943728f7b057583cb62501f8049307a0b17afc774cf62c4f9ed1eb4e2b41fd72d912501588de0253f3981321b28f05d6b2ad4273ba73916f10caa4af
6
+ metadata.gz: d9f866cfed958d91457513f2708be6b33e2272464496c8fd843affabedd07449fea5c8501eb4565110b409625e1fdee5ccbb6a05cc54a764b06b1091ab8e623f
7
+ data.tar.gz: 3d7e231badb3980b793801a58117784fdfdc407fb42aa5cc4671ee2593a9963e4f4101272a6c237fb02e39805cd33b1ecc2a92866ce7aae6becc8bd7f484ea50
data/CHANGES.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## v 0.11.0b1, 2018-02-19
4
4
 
5
+ - Fix: Creatable Extendable objects have their empty extension attributes initialized properly so you can set the values before calling #create/#save. Thanks @mylescarrick for reporting this one.
6
+
5
7
  - Improvement: Updated general attributes for computers and mobile devices
6
8
 
7
9
  - Improvement: Computers and MobileDevices are now Creatable. Use the .make class method to create an unsaved instance, then .create/.save instance method to create the JSS record. Note: Mobile Devices need both a unique serial number and unique udid to be accepted by the API.
@@ -85,20 +85,14 @@ module JSS
85
85
 
86
86
  # Populate @extension_attributes (the Array of Hashes that comes from the API)
87
87
  # and @ext_attr_names, which is a Hash mapping the EA names to their
88
- # index in the @extension_attributes Array.
89
- #
90
- # Classes including this module should call this in #initialize
88
+ # values. This is called during initialization for all objects
89
+ # that mix in this module
91
90
  #
92
91
  # @return [void]
93
92
  #
94
93
  def parse_ext_attrs
95
- unless @init_data[:extension_attributes]
96
- @extension_attributes = []
97
- @ext_attrs = {}
98
- return
99
- end
100
-
101
94
  @extension_attributes = @init_data[:extension_attributes]
95
+ @extension_attributes ||= []
102
96
  @ext_attrs = {}
103
97
 
104
98
  @extension_attributes.each do |ea|
@@ -108,6 +102,7 @@ module JSS
108
102
  begin # if there's random non-date data, the parse will fail
109
103
  ea[:value] = JSS.parse_datetime ea[:value]
110
104
  rescue
105
+ true
111
106
  end
112
107
 
113
108
  when *NUMERIC_TYPES
@@ -142,9 +137,6 @@ module JSS
142
137
  # @return [void]
143
138
  #
144
139
  def set_ext_attr(name, value)
145
- # if we don't currently have any need to update(cuz we have recently), reset the list of changes to push
146
- @changed_eas = [] unless @need_to_update
147
-
148
140
  # this will raise an exception if the name doesn't exist
149
141
  ea_def = self.class::EXT_ATTRIB_CLASS.fetch name: name, api: api
150
142
 
@@ -163,8 +155,14 @@ module JSS
163
155
  end # case
164
156
  end # unless blank
165
157
 
158
+ been_set = false
166
159
  @extension_attributes.each do |ea|
167
- ea[:value] = value if ea[:name] == name
160
+ next unless ea[:name] == name
161
+ ea[:value] = value
162
+ been_set = true
163
+ end
164
+ unless been_set
165
+ @extension_attributes << { id: ea_def.id, name: name, type: ea_def.data_type, value: value }
168
166
  end
169
167
 
170
168
  @ext_attrs[name] = value
@@ -205,7 +203,7 @@ module JSS
205
203
  ea_el.add_element('value').text = ea[:value].to_s
206
204
  end
207
205
  else
208
- ea_el.add_element('value').text = ea[:value]
206
+ ea_el.add_element('value').text = ea[:value].to_s
209
207
  end # if
210
208
  end # each do ea
211
209
 
@@ -483,7 +483,6 @@ module JSS
483
483
  new args
484
484
  end
485
485
 
486
-
487
486
  # Delete one or more API objects by jss_id without instantiating them.
488
487
  # Non-existent id's are skipped and an array of skipped ids is returned.
489
488
  #
@@ -505,7 +504,7 @@ module JSS
505
504
  case victims
506
505
  when Integer
507
506
  victims = [victims]
508
- when Fixnum
507
+ when Integer
509
508
  victims = [victims]
510
509
  when Array
511
510
  victims.uniq!
@@ -632,16 +631,14 @@ module JSS
632
631
  elsif args[:id] == :new
633
632
  validate_init_for_creation(args)
634
633
  setup_object_for_creation(args)
635
-
636
- return
637
-
634
+ @need_to_update = true
638
635
  ###### Look up the data via the API
639
636
  else
640
637
  @init_data = look_up_object_data(args)
638
+ @need_to_update = false
641
639
  end ## end arg parsing
642
640
 
643
641
  parse_init_data
644
- @need_to_update = false
645
642
  end # init
646
643
 
647
644
  # Public Instance Methods
@@ -968,10 +965,16 @@ module JSS
968
965
 
969
966
  # Find the "main" subset which contains :id and :name
970
967
  @main_subset = find_main_subset
971
-
972
- @id = @main_subset[:id]
973
968
  @name = @main_subset[:name]
974
- @in_jss = true
969
+
970
+ if @main_subset[:id] == :new
971
+ @id = 0
972
+ @in_jss = false
973
+ else
974
+ @id = @main_subset[:id]
975
+ @in_jss = true
976
+ end
977
+
975
978
  @rest_rsrc = "#{self.class::RSRC_BASE}/id/#{@id}"
976
979
 
977
980
  # many things have a :site
data/lib/jss/version.rb CHANGED
@@ -27,6 +27,6 @@
27
27
  module JSS
28
28
 
29
29
  ### The version of the JSS ruby gem
30
- VERSION = '0.11.0b1'.freeze
30
+ VERSION = '0.11.0b2'.freeze
31
31
 
32
32
  end # module
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-jss
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0b1
4
+ version: 0.11.0b2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Lasell
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-02-19 00:00:00.000000000 Z
12
+ date: 2018-03-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: plist