active_fedora-noid 1.0.1 → 1.0.2

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: c19bc92adee3e3f65792c9c8a3d06fff8c3e334f
4
- data.tar.gz: b9ddf9a82a9989b270867472363897801d88c108
3
+ metadata.gz: 7bd89b0820e29801ab139ee09443af8923c1555c
4
+ data.tar.gz: 471b61afe7180057c9ee56e10b6cf37a1c2ab601
5
5
  SHA512:
6
- metadata.gz: 9b2b10510a8ae40a4cc4d4518d577dd26f5642903460cbdbc5f1ab87fa4a66347adb8492dc28cec50ac3d4ca6a8424437d98bbeadf9ef207d11270289c6ca57b
7
- data.tar.gz: ea939be13d5d4582ed33052b4abd70e249ee48f46dd559308c2ab705cef14671935c64fc477a160b6a2450b9de6d0fc0bdf2f013ce97a731f7472eded2b68366
6
+ metadata.gz: 339cf5a5e562170ad083e43735479717bda1d549bf8ac4fc3f18dc3f6965064d6bb060e35dbb68e9ecef27755a872104fec65dcecd7d89f6f31a996cae28da64
7
+ data.tar.gz: 0c0905dd30112fbf3cccbf4ff1547361ba3c8bf1d9dca360584108a859b10f44196ec0efe502c89ab766d5035060731dedf16c59bd67ad2495b598ba707593ff
@@ -40,16 +40,19 @@ module ActiveFedora
40
40
 
41
41
  def next_id
42
42
  id = ''
43
- ::File.open(statefile, ::File::RDWR|::File::CREAT, 0644) do |f|
43
+ ::File.open(statefile, 'a+b', 0644) do |f|
44
44
  f.flock(::File::LOCK_EX)
45
+ # Files opened in append mode seek to end of file
46
+ f.rewind
45
47
  state = state_for(f)
46
48
  minter = ::Noid::Minter.new(state)
49
+
47
50
  id = minter.mint
48
- f.rewind
51
+
52
+ # Wipe prior contents so the new state can be written from the beginning of the file
53
+ f.truncate(0)
49
54
  new_state = Marshal.dump(minter.dump)
50
55
  f.write(new_state)
51
- f.flush
52
- f.truncate(f.pos)
53
56
  end
54
57
  id
55
58
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveFedora
2
2
  module Noid
3
- VERSION = '1.0.1'
3
+ VERSION = '1.0.2'
4
4
  end
5
5
  end
@@ -9,19 +9,18 @@ namespace :active_fedora do
9
9
  statefile = ENV.fetch('AFNOID_STATEFILE', ActiveFedora::Noid.config.statefile)
10
10
  raise "File not found: #{statefile}\nAborting" unless File.exist?(statefile)
11
11
  puts "Migrating #{statefile} from YAML to Marshal serialization..."
12
- File.open(statefile, File::RDWR | File::CREAT, 0644) do |f|
12
+ File.open(statefile, 'a+b', 0644) do |f|
13
13
  f.flock(File::LOCK_EX)
14
+ f.rewind
14
15
  begin
15
16
  yaml_state = YAML.load(f)
16
17
  rescue Psych::SyntaxError
17
18
  raise "File not valid YAML: #{statefile}\nAborting."
18
19
  end
19
20
  minter = Noid::Minter.new(yaml_state)
20
- f.rewind
21
+ f.truncate(0)
21
22
  new_state = Marshal.dump(minter.dump)
22
23
  f.write(new_state)
23
- f.flush
24
- f.truncate(f.pos)
25
24
  end
26
25
  puts "Done!"
27
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_fedora-noid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael J. Giarlo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-06 00:00:00.000000000 Z
11
+ date: 2015-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active-fedora
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  version: '0'
131
131
  requirements: []
132
132
  rubyforge_project:
133
- rubygems_version: 2.4.5
133
+ rubygems_version: 2.4.8
134
134
  signing_key:
135
135
  specification_version: 4
136
136
  summary: Noid identifier services for ActiveFedora-based applications
@@ -140,4 +140,3 @@ test_files:
140
140
  - spec/unit/noid_spec.rb
141
141
  - spec/unit/service_spec.rb
142
142
  - spec/unit/synchronized_minter_spec.rb
143
- has_rdoc: