moab-versioning 1.4.7 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d610d09deb8aac429420a3ef3b65b93e1152605b
4
- data.tar.gz: '03924426fb01ee11ad442e02743eedcae4be3c35'
3
+ metadata.gz: fc968b3f2a7ec6e2062d2deb950cf760201ed978
4
+ data.tar.gz: 78964058caf89d2cda709cb61fdab039dfff3fac
5
5
  SHA512:
6
- metadata.gz: 99438bec608cdd06619ab1376c03a232464f02841c1c85a09d004b10049aee105bb56d39d357549f37b40200ac183ea8708da1152aabf8ab5bed412a8d828204
7
- data.tar.gz: 03ccab8bdda6f3b879d9a406c142102406863e4c9d5a44cec79c9cd7fccc382d391f38942e0f89dc3837bd244ed36bc9d1e3cf828cb8aea306a34071b55327ad
6
+ metadata.gz: 125858b5eeb23be2f7e1d0fd4eea84bf7d864d91f223db916a1d8f7ea4832b3ceaf58c013da0a5e2afe175382f5ccbce43a5980087b43fb06e5d2806b5f79808
7
+ data.tar.gz: 9a3af9b77af753dddc5c82a8f8a51d74eb9e053656c7b91d43e1de2cbcf7d76528e110dac58dfa9a5740c04874733a04c6b26b284795c50b7c5f8144d75408a0
data/lib/moab.rb CHANGED
@@ -35,6 +35,7 @@ require 'serializer'
35
35
  include Serializer
36
36
  require 'confstruct/configuration'
37
37
  require 'moab/config'
38
+ require 'moab/utc_time'
38
39
  require 'moab/file_signature'
39
40
  require 'moab/file_instance'
40
41
  require 'moab/file_manifestation'
@@ -34,11 +34,11 @@ module Moab
34
34
  attribute :datetime, String
35
35
 
36
36
  def datetime=(event_datetime)
37
- @datetime=UtcTime.input(event_datetime)
37
+ @datetime=Moab::UtcTime.input(event_datetime)
38
38
  end
39
39
 
40
40
  def datetime
41
- UtcTime.output(@datetime)
41
+ Moab::UtcTime.output(@datetime)
42
42
  end
43
43
 
44
44
 
@@ -64,11 +64,11 @@ module Moab
64
64
  attribute :inventory_datetime, String, :tag => 'inventoryDatetime'
65
65
 
66
66
  def inventory_datetime=(datetime)
67
- @inventory_datetime=UtcTime.input(datetime)
67
+ @inventory_datetime=Moab::UtcTime.input(datetime)
68
68
  end
69
69
 
70
70
  def inventory_datetime
71
- UtcTime.output(@inventory_datetime)
71
+ Moab::UtcTime.output(@inventory_datetime)
72
72
  end
73
73
 
74
74
  # @attribute
@@ -55,11 +55,11 @@ module Moab
55
55
  attribute :report_datetime, String, :tag => 'reportDatetime'
56
56
 
57
57
  def report_datetime=(datetime)
58
- @report_datetime=UtcTime.input(datetime)
58
+ @report_datetime=Moab::UtcTime.input(datetime)
59
59
  end
60
60
 
61
61
  def report_datetime
62
- UtcTime.output(@report_datetime)
62
+ Moab::UtcTime.output(@report_datetime)
63
63
  end
64
64
 
65
65
  # @attribute
@@ -56,11 +56,11 @@ module Moab
56
56
  attribute :catalog_datetime, Time, :tag => 'catalogDatetime'
57
57
 
58
58
  def catalog_datetime=(datetime)
59
- @catalog_datetime=UtcTime.input(datetime)
59
+ @catalog_datetime=Moab::UtcTime.input(datetime)
60
60
  end
61
61
 
62
62
  def catalog_datetime
63
- UtcTime.output(@catalog_datetime)
63
+ Moab::UtcTime.output(@catalog_datetime)
64
64
  end
65
65
 
66
66
  # @attribute
@@ -0,0 +1,39 @@
1
+ require 'time'
2
+
3
+ module Moab
4
+ # Timestamp conversion methods.
5
+ class UtcTime
6
+
7
+ # @param datetime [Time,String,Nil] The input datetime
8
+ # @return [void] Convert input datetime to a Time object, or nil if input is empty.
9
+ def self.input(datetime)
10
+ case datetime
11
+ when nil
12
+ nil
13
+ when ""
14
+ nil
15
+ when String
16
+ Time.parse(datetime)
17
+ when Time
18
+ datetime
19
+ else
20
+ raise "unknown time format #{datetime.inspect}"
21
+ end
22
+ end
23
+
24
+ # @param datetime [Time,String,Nil] The datetime value to output
25
+ # @return [String] Convert the datetime into a ISO 8601 formatted string
26
+ def self.output(datetime)
27
+ case datetime
28
+ when nil, ""
29
+ ""
30
+ when String
31
+ Time.parse(datetime).utc.iso8601
32
+ when Time
33
+ datetime.utc.iso8601
34
+ else
35
+ raise "unknown time format #{datetime.inspect}"
36
+ end
37
+ end
38
+ end
39
+ end
@@ -35,11 +35,11 @@ module Moab
35
35
  attribute :datetime, String
36
36
 
37
37
  def datetime=(event_datetime)
38
- @datetime=UtcTime.input(event_datetime)
38
+ @datetime=Moab::UtcTime.input(event_datetime)
39
39
  end
40
40
 
41
41
  def datetime
42
- UtcTime.output(@datetime)
42
+ Moab::UtcTime.output(@datetime)
43
43
  end
44
44
 
45
45
  end
data/lib/serializer.rb CHANGED
@@ -24,7 +24,6 @@ require 'time'
24
24
  require 'digest/md5'
25
25
  require 'digest/sha1'
26
26
 
27
- require 'monkey_patches'
28
27
  require 'serializer/serializable'
29
28
  require 'serializer/manifest'
30
29
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moab-versioning
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.7
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darren Weber
@@ -207,12 +207,12 @@ files:
207
207
  - lib/moab/storage_object_version.rb
208
208
  - lib/moab/storage_repository.rb
209
209
  - lib/moab/storage_services.rb
210
+ - lib/moab/utc_time.rb
210
211
  - lib/moab/verification_result.rb
211
212
  - lib/moab/version_metadata.rb
212
213
  - lib/moab/version_metadata_entry.rb
213
214
  - lib/moab/version_metadata_event.rb
214
215
  - lib/moab_stanford.rb
215
- - lib/monkey_patches.rb
216
216
  - lib/serializer.rb
217
217
  - lib/serializer/manifest.rb
218
218
  - lib/serializer/serializable.rb
@@ -1,63 +0,0 @@
1
- require 'time'
2
-
3
- # monkey-patch to fix JSON_pure
4
- # @see http://prettystatemachine.blogspot.com/2010/09/typeerrors-in-tojson-make-me-briefly.html
5
- #noinspection RubyUnusedLocalVariable
6
- class Fixnum
7
- # @return [String] The string value of the number
8
- def to_json(options = nil)
9
- to_s
10
- end
11
- end
12
-
13
- # Timestamp conversion methods.
14
- class UtcTime
15
-
16
- # @param datetime [Time,String,Nil] The input datetime
17
- # @return [void] Convert input datetime to a Time object, or nil if input is empty.
18
- def self.input(datetime)
19
- case datetime
20
- when nil
21
- nil
22
- when ""
23
- nil
24
- when String
25
- Time.parse(datetime)
26
- when Time
27
- datetime
28
- else
29
- raise "unknown time format #{datetime.inspect}"
30
- end
31
- end
32
-
33
- # @param datetime [Time,String,Nil] The datetime value to output
34
- # @return [String] Convert the datetime into a ISO 8601 formatted string
35
- def self.output(datetime)
36
- case datetime
37
- when nil, ""
38
- ""
39
- when String
40
- Time.parse(datetime).utc.iso8601
41
- when Time
42
- datetime.utc.iso8601
43
- else
44
- raise "unknown time format #{datetime.inspect}"
45
- end
46
- end
47
-
48
- end
49
-
50
- # Add methods to Array so that one attribute of a class can be treated as a unique key
51
- class Array
52
- # @return [Array<Object>] An array containing the key fields from a collection of objects
53
- def keys
54
- self.collect { |e| e.key }
55
- end
56
-
57
- # @param key [Object] The key value to search for
58
- # @return [Object] The object from the array that has the specified key value
59
- def keyfind(key)
60
- self.each { |e| return e if key == e.key }
61
- nil
62
- end
63
- end