writer 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/writer/version.rb +1 -1
- data/lib/writer.rb +2 -1
- data/spec/writer_spec.rb +6 -0
- metadata +3 -3
data/lib/writer/version.rb
CHANGED
data/lib/writer.rb
CHANGED
@@ -4,7 +4,8 @@ require "writer/version"
|
|
4
4
|
|
5
5
|
module Writer
|
6
6
|
class << self
|
7
|
-
def write!(name =
|
7
|
+
def write!(name = nil, content = nil)
|
8
|
+
name = default_filename if name.nil?
|
8
9
|
protect_from_overwrite(name)
|
9
10
|
create_file(content)
|
10
11
|
File.open(filename, 'r')
|
data/spec/writer_spec.rb
CHANGED
@@ -16,6 +16,11 @@ describe Writer do
|
|
16
16
|
file.read.should == "\n"
|
17
17
|
end
|
18
18
|
|
19
|
+
it "plays well with nils" do
|
20
|
+
file = Writer.write!(nil, nil)
|
21
|
+
file.read.should == "\n"
|
22
|
+
end
|
23
|
+
|
19
24
|
it "prevents overwriting" do
|
20
25
|
Writer.write!
|
21
26
|
Writer.write!
|
@@ -48,6 +53,7 @@ def cleanup_files
|
|
48
53
|
File.delete('2012-01Jan-03--2.md')
|
49
54
|
File.delete('2012-01Jan-03--3.md')
|
50
55
|
File.delete('2012-01Jan-03--4.md')
|
56
|
+
File.delete('2012-01Jan-03--5.md')
|
51
57
|
File.delete('.template')
|
52
58
|
File.delete('My custom filename.txt')
|
53
59
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: writer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-07-14 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70224064989180 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70224064989180
|
25
25
|
description: Easily start a new file to write in.
|
26
26
|
email:
|
27
27
|
- joe@joesak.com
|