borrower 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,10 +18,9 @@ module Borrower
18
18
  raise "nothing exists at the provided path '#{path}'"
19
19
  end
20
20
 
21
- def put content, destination, args
21
+ def put content, destination
22
22
  FileUtils.mkdir_p( File.dirname(destination) )
23
23
  File.open( destination, 'w', internal_encoding: content.encoding ) do |file|
24
- content = Borrower.merge(content) if args[0].fetch(:merge) { false }
25
24
  file.write content
26
25
  end
27
26
  end
@@ -16,8 +16,8 @@ module Borrower
16
16
  # @param [String] content content for the file
17
17
  # @param [String] to path to write contents to
18
18
  # @return [Void]
19
- def put content, to, *args
20
- Borrower::Content.put content, to, args
19
+ def put content, to
20
+ Borrower::Content.put content, to
21
21
  end
22
22
 
23
23
  # parse through the content and merge
@@ -1,3 +1,3 @@
1
1
  module Borrower
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
data/lib/borrower.rb CHANGED
@@ -29,17 +29,18 @@ module Borrower::DSL
29
29
  # end
30
30
  #
31
31
  # @param [String] path
32
- # @param [Hash] args
33
- # @option args [String] :to the destination path
34
- # @option args [Boolean] :merge wether to merge or not, defaults to `false`
32
+ # @param [Hash] options
33
+ # @option options [String] :to the destination path
34
+ # @option options [Boolean] :merge wether to merge or not, defaults to `false`
35
35
  # @return [Void]
36
- def borrow path, args={}, &block
37
- destination = args.delete(:to) { raise ArgumentError, "missing 'to:' argument" }
36
+ def borrow path, options={}, &block
37
+ destination = options.delete(:to) { raise ArgumentError, "missing 'to:' argument" }
38
38
  content = Borrower.take(path)
39
+ content = Borrower.merge(content) if options.fetch(:merge) { false }
39
40
  if block_given?
40
41
  content = yield content
41
42
  end
42
- Borrower.put content, destination, args
43
+ Borrower.put content, destination
43
44
  end
44
45
 
45
46
  end
@@ -38,6 +38,11 @@ describe Borrower do
38
38
  Borrower.take( File.join( TMP, "remote.txt" ) ).should == "Hello I'm a file"
39
39
  end
40
40
 
41
+ it "doesn't merge file if merge is not set" do
42
+ borrow merge_file, to: file_destination
43
+ Borrower.take( file_destination ).should == "#= borrow '#{File.join( TMP, 'file.txt')}'"
44
+ end
45
+
41
46
  it "merges files if merge is set to true" do
42
47
  borrow merge_file, to: file_destination, merge: true
43
48
  Borrower.take( file_destination ).should == "Hi I'm a file"
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'rspec'
2
- require 'borrower'
3
2
  require 'fileutils'
4
3
 
5
4
  TMP = File.join( Dir.pwd, "tmp" )
@@ -29,4 +28,9 @@ end
29
28
 
30
29
  def cleanup_tmp
31
30
  `rm -rf #{TMP}`
32
- end
31
+ end
32
+
33
+ require 'coveralls'
34
+ Coveralls.wear!
35
+
36
+ require 'borrower'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: borrower
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.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: 2013-07-24 00:00:00.000000000 Z
12
+ date: 2013-07-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: net-ssh
@@ -43,7 +43,6 @@ files:
43
43
  - lib/borrower.rb
44
44
  - spec/borrower/manifest_spec.rb
45
45
  - spec/borrower/merge_spec.rb
46
- - spec/borrower/transport_spec.rb
47
46
  - spec/borrower_spec.rb
48
47
  - spec/spec_helper.rb
49
48
  homepage: http://github.com/stevenosloan/borrower
@@ -75,7 +74,6 @@ summary: For borrowing little snippets of the web, or files, or really any snipp
75
74
  test_files:
76
75
  - spec/borrower/manifest_spec.rb
77
76
  - spec/borrower/merge_spec.rb
78
- - spec/borrower/transport_spec.rb
79
77
  - spec/borrower_spec.rb
80
78
  - spec/spec_helper.rb
81
79
  has_rdoc:
@@ -1,48 +0,0 @@
1
- # require 'spec_helper'
2
- # require 'borrower/transport'
3
-
4
- # describe Borrower::Transport do
5
- # include Borrower::Transport
6
-
7
- # before :each do
8
- # given_file "file.txt", "Hi I'm a file"
9
- # end
10
-
11
- # after :each do
12
- # cleanup_tmp
13
- # end
14
-
15
- # let (:local_file) { File.join( TMP, 'file.txt' ) }
16
- # let (:destination_path) { File.join( TMP, 'destination/file.txt' ) }
17
-
18
-
19
- # describe "#take" do
20
- # it "returns the correct contents" do
21
- # take( local_file ).should == "Hi I'm a file"
22
- # end
23
- # end
24
-
25
- # describe "#put" do
26
-
27
- # it "puts a string to a file" do
28
- # put "hello", destination_path
29
- # take( destination_path ).should == "hello"
30
- # end
31
- # end
32
-
33
- # describe "#move" do
34
-
35
- # it "moves the file" do
36
- # move( local_file, destination_path )
37
- # take( destination_path ).should == "Hi I'm a file"
38
- # end
39
-
40
- # it "overwrites an existing file" do
41
- # put "hello", destination_path
42
- # take( destination_path ).should == "hello" # just to make sure it was written to begin with
43
- # move( local_file, destination_path )
44
- # take( destination_path ).should == "Hi I'm a file"
45
- # end
46
- # end
47
-
48
- # end