active_model_archive 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "active_model_archive"
5
- s.version = '1.1.1'
5
+ s.version = '1.1.2'
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.authors = ["Grant Rodgers"]
8
8
  s.email = ["grantr@gmail.com"]
@@ -26,11 +26,15 @@ module ActiveModelArchive
26
26
 
27
27
  def create_file
28
28
  self.file_number += 1
29
+
30
+ if items_per_file == UNLIMITED_PER_FILE
31
+ filename = base_filename
32
+ else
33
+ extension = File.extname(base_filename)
34
+ filename = "#{base_filename.chomp(extension)}.#{file_number}#{extension}"
35
+ end
29
36
 
30
- filename = items_per_file == UNLIMITED_PER_FILE ? base_filename : "#{base_filename}.#{file_number}"
31
- file = File.open(filename, "w")
32
-
33
- file
37
+ File.open(filename, "w")
34
38
  end
35
39
 
36
40
  def flush
@@ -19,7 +19,7 @@ class ActiveModelArchive::FileManagerTest < MiniTest::Spec
19
19
  assert_equal object.to_archive, File.read('tmp/wtf')
20
20
  end
21
21
 
22
- def test_items_per_file
22
+ def test_items_per_file_without_extension
23
23
  file_manager = ActiveModelArchive::FileManager.new('tmp/wtf', 2) do |file_manager|
24
24
  file_manager.add(TestModel.new)
25
25
  file_manager.add(TestModel.new)
@@ -28,4 +28,14 @@ class ActiveModelArchive::FileManagerTest < MiniTest::Spec
28
28
 
29
29
  assert_equal ["tmp/wtf.1", "tmp/wtf.2"], Dir.glob('tmp/wtf*')
30
30
  end
31
+
32
+ def test_items_per_file_with_extension
33
+ file_manager = ActiveModelArchive::FileManager.new('tmp/wtf.csv', 2) do |file_manager|
34
+ file_manager.add(TestModel.new)
35
+ file_manager.add(TestModel.new)
36
+ file_manager.add(TestModel.new)
37
+ end
38
+
39
+ assert_equal ["tmp/wtf.1.csv", "tmp/wtf.2.csv"], Dir.glob('tmp/wtf*')
40
+ end
31
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_model_archive
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-11 00:00:00.000000000 Z
12
+ date: 2012-05-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  version: '0'
91
91
  requirements: []
92
92
  rubyforge_project: active_model_archive
93
- rubygems_version: 1.8.21
93
+ rubygems_version: 1.8.24
94
94
  signing_key:
95
95
  specification_version: 3
96
96
  summary: Dump and restore activemodel objects