file_series 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.4.0
data/file_series.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "file_series"
8
- s.version = "0.3.0"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Alex Dean"]
12
- s.date = "2012-10-26"
12
+ s.date = "2013-08-26"
13
13
  s.description = "Automatically start writing to a new file every X seconds without any locking or file moving/renaming."
14
14
  s.email = "alex@crackpot.org"
15
15
  s.extra_rdoc_files = [
data/lib/file_series.rb CHANGED
@@ -37,6 +37,7 @@ class FileSeries
37
37
  @rotate_freq = options[:rotate_every] || DEFAULT_FREQ #seconds
38
38
  @binary_mode = options[:binary]
39
39
  @separator = options[:separator] || DEFAULT_SEPARATOR
40
+ @sync = options[:sync] || false
40
41
  end
41
42
 
42
43
  # write something to the current log file.
@@ -68,6 +69,7 @@ class FileSeries
68
69
  ts ||= this_period
69
70
  @file.close if @file
70
71
  @file = File.open(filename(ts), "a#{'b' if @binary_mode}")
72
+ @file.sync = @sync
71
73
  @current_ts = ts
72
74
  end
73
75
 
@@ -50,6 +50,25 @@ describe "FileSeries" do
50
50
  # Writing in binary mode works fine. How to reproduce that more simply for a test?
51
51
  end
52
52
 
53
+ describe "#new" do
54
+ it "should set sync to false by default" do
55
+ fs = FileSeries.new
56
+ fs.write 'blah'
57
+ fs.file.sync.should eq false
58
+ end
59
+
60
+ it "should allow control of sync behavior" do
61
+ fs = FileSeries.new(:sync => true)
62
+ fs.write 'blah'
63
+ fs.file.sync.should eq true
64
+
65
+ fs = FileSeries.new(:sync => false)
66
+ fs.write 'blah'
67
+ fs.file.sync.should eq false
68
+ end
69
+ end
70
+
71
+
53
72
  describe "#write" do
54
73
  it "should call log_file.write with message and separator" do
55
74
  fs = FileSeries.new(:separator=>'...')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: file_series
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
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-10-26 00:00:00.000000000 Z
12
+ date: 2013-08-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: autotest-standalone
@@ -176,7 +176,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
176
176
  version: '0'
177
177
  segments:
178
178
  - 0
179
- hash: 2396804050019200525
179
+ hash: 2297086619280588333
180
180
  required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  none: false
182
182
  requirements: