fun_with_files 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +15 -0
  2. data/Gemfile +3 -3
  3. data/README.rdoc +61 -1
  4. data/VERSION +1 -1
  5. data/lib/fun_with/files/core_extensions/array.rb +5 -0
  6. data/lib/fun_with/files/core_extensions/false.rb +5 -0
  7. data/lib/fun_with/files/core_extensions/hash.rb +5 -0
  8. data/lib/fun_with/files/core_extensions/nil.rb +5 -0
  9. data/lib/fun_with/files/core_extensions/object.rb +9 -0
  10. data/lib/fun_with/files/core_extensions/string.rb +5 -0
  11. data/lib/fun_with/files/digest_methods.rb +9 -0
  12. data/lib/{files → fun_with/files}/directory_builder.rb +4 -48
  13. data/lib/{files → fun_with/files}/downloader.rb +0 -0
  14. data/lib/fun_with/files/errors.rb +5 -0
  15. data/lib/fun_with/files/file_manipulation_methods.rb +134 -0
  16. data/lib/{files → fun_with/files}/file_orderer.rb +0 -0
  17. data/lib/{files → fun_with/files}/file_path.rb +16 -6
  18. data/lib/fun_with/files/file_permission_methods.rb +22 -0
  19. data/lib/{files → fun_with/files}/pathname_extensions.rb +0 -0
  20. data/lib/{files → fun_with/files}/remote_path.rb +0 -0
  21. data/lib/{files → fun_with/files}/root_path.rb +0 -0
  22. data/lib/{files → fun_with/files}/string_behavior.rb +4 -0
  23. data/lib/{files → fun_with/files}/string_extensions.rb +0 -0
  24. data/lib/{files → fun_with/files}/xdg_extensions.rb +0 -0
  25. data/lib/fun_with_files.rb +18 -16
  26. data/test/data/gsub1.txt +0 -0
  27. data/test/data/gsub2.txt +0 -0
  28. data/test/test_copying.rb +52 -0
  29. data/test/test_file_manipulation.rb +24 -0
  30. data/test/test_file_path.rb +43 -3
  31. data/test/test_fun_with_files.rb +15 -0
  32. metadata +34 -50
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YTg3ZGQzMDAxYTczMjBjNTc5NjU2ZDA0MDRlNzQ0YTc5MzBjMmE2OQ==
5
+ data.tar.gz: !binary |-
6
+ NTBhOGNkNTcyZGRlNGNjYTFjNzMyYzVhYzhmNWE0NmU3ODMwODFjMw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ M2VhMTIwMDRjNDRiODQ3MTcwNDJiYmJlYmExODA3ZmVlOTQwYzI3ODFkNGI4
10
+ MTNkZGUxYTRkNjE5ZmZjYjMwYzUyNDdkYjNmN2MxNjU3NmY5YmVlMTQ5NzZj
11
+ NzY5ODZlNWIyMGU4MjI4MDI4ZGM2MTRkZDg4NzEzMThlY2FmMjU=
12
+ data.tar.gz: !binary |-
13
+ YzI5ZGYyZDgwYzQ0ODg0MjNjNjVhYTI4OGEzZDcwODk4MjI0OGZlNmMzZWRi
14
+ ZGQyZjUwN2M0MjBmYzQzMTY3YWZhYmNhNDdhNGE5M2NhM2MyNzYxZGQ3NDA3
15
+ YjRjNWM5NWRiZGUxODc2MTFlM2ZmMGZlNGJlZDZjNjQ0ODJjMDk=
data/Gemfile CHANGED
@@ -9,9 +9,9 @@ source "http://rubygems.org"
9
9
  group :development do
10
10
  gem "shoulda", ">= 3.5"
11
11
  gem "rdoc", "~> 3.12"
12
- gem "bundler", "~> 1.3.5"
13
- gem "jeweler", "~> 1.8.7"
12
+ gem "bundler", "~> 1.5"
13
+ gem "jeweler", "~> 2.0"
14
+ # gem "debugger", "~> 1.6"
14
15
  end
15
16
 
16
17
  gem "xdg"
17
- gem "debugger"
@@ -34,7 +34,67 @@ To the code!
34
34
 
35
35
  # whole buchcha other goodies, yet to be documented.
36
36
 
37
-
37
+ == DirectoryBuilder
38
+
39
+ DirectoryBuilder is a class for defining and populating a file hierarchy with relative ease. DirectoryBuilder is probably most easily demonstrated by example. Sample code:
40
+
41
+ # starts by creating directory. If parent
42
+ # directories don't exist, they will soon.
43
+ DirectoryBuilder.create( '~/project' ) do |b|
44
+ b.dir("images") do # creates subdirectory "images", which gets populated within the block
45
+ for img in src_dir.entries.select{|img| img.extension == ".png"}
46
+ b.copy( src_dir.join( img.filename ) ) # copies a bunch of files from another directory
47
+ end # rises back to the initial '~/project directory
48
+
49
+ b.copy( src_dir.join( "rorshach.xml" ) ) # Copies a file from a source file.
50
+ b.download( "dest.bash", "http://get.rvm.io" ) # downloads file directly beneath '~/project'
51
+ # maybe someday, though
52
+
53
+ b.dir("text", "scenes") do # creates ~/project/text/scenes subdir (creating two new directories text/ and text/scene/)
54
+ b.file( "adventure_time.txt" ) do |f|
55
+ f << "Fill this in later"
56
+ end
57
+
58
+ # calling .file without feeding it a block leaves it open for writing,
59
+ # until either the enclosing block terminates, or b.file is called again
60
+ # with a filename argument. While it's open, b.file can be treated like
61
+ # any IO object.
62
+ b.file( "another_brick.txt" )
63
+ b.file << "Hey, you!"
64
+ b.file << "Yes, you!"
65
+ b.file.push "Stand still, laddie!"
66
+
67
+
68
+ # TODO: Make sure this works.
69
+ #
70
+ # Set a bunch of vars to apply to the template. Template gets copied into DirectoryBuilder's current
71
+ # directory, with the template's filename (minus the .template extension).
72
+ #
73
+ # Inside the templates, you can use Ruby code in the usual ERB style. The vars you declare will be
74
+ # available within the template as (see example below) @fname, @lname, @graduated, etc.
75
+ #
76
+ # See FunWith::Templates for a better understanding of templates. You must require the 'fun_with_templates'
77
+ # gem to use the template function.
78
+ b.template( templates_dir.join("blue_template.txt.template") ) do |t|
79
+ # t is a VarCollector, which is just a hash with a couple of added methods, shown here.
80
+ # I recommend sticking to t.var and t.vars for setting variables, in case the interface
81
+ # changes.
82
+ t.var(:fname, "John")
83
+ t.vars(graduated: "2003", blackmailed: "2004") # set multiple variables at a time
84
+ t[:lname] = "Macey"
85
+ t.var(:state, "Ohio")
86
+ t.vars(quot: "That wasn't my duck.", photo: "john.png", css: "font-family: arial")
87
+ end
88
+
89
+ b.copy( [src_dir.join("abba.txt"), "baab.txt"] ) # contents of abba.txt copied into baab.txt
90
+
91
+
92
+ b.file( ".lockfile" ) # creates an empty file, closing it to further writing at the end of the block.
93
+ end
94
+ end
95
+
96
+
97
+
38
98
 
39
99
 
40
100
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
@@ -0,0 +1,5 @@
1
+ class Array
2
+ def fwf_blank?
3
+ self.length == 0
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class FalseClass
2
+ def fwf_blank?
3
+ true
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class Hash
2
+ def fwf_blank?
3
+ self.length == 0
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class NilClass
2
+ def fwf_blank?
3
+ true
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ class Object
2
+ def fwf_blank?
3
+ false
4
+ end
5
+
6
+ def fwf_present?
7
+ ! self.fwf_blank?
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ class String
2
+ def fwf_blank?
3
+ self.strip.length == 0
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ module FunWith
2
+ module Files
3
+ module DigestMethods
4
+ def md5
5
+ self.file? ? Digest::MD5.hexdigest( self.read ) : ""
6
+ end
7
+ end
8
+ end
9
+ end
@@ -88,6 +88,10 @@ module FunWith
88
88
  puts "No current file to append #{url} to."
89
89
  end
90
90
  end
91
+
92
+ def template( *args )
93
+ raise "DirectoryBuilder cannot use template() function. require 'fun_with_templates' to enable."
94
+ end
91
95
 
92
96
  protected
93
97
  def make_path
@@ -129,51 +133,3 @@ module FunWith
129
133
  end
130
134
  end
131
135
 
132
-
133
- # sample code
134
- #
135
- # DirBuilder.create( '~/project' ) do |b| # starts by creating directory. If parent
136
- # # directories don't exist, they will soon.
137
- # # if you use DirBuilder.tmp('~/project'), a tempdir
138
- # # is created, and its contents relocated to ~/project when the
139
- # # block terminates.
140
- # b.dir("images") do # creates subdirectory "images"
141
- # for img in src_dir.entries.select{|img| img.extension == ".png"}
142
- # b.copy( src_dir.join( img.filename ) ) # copies a bunch of files from another directory
143
- # end # rises back to the initial '~/project directory
144
- #
145
- # b.copy( src_dir.join( "rorshach.xml" ) )
146
- # b.download( "dest.bash", "http://get.rvm.io" ) # downloads file directly beneath '~/project'
147
- # # maybe someday, though
148
- #
149
- # b.dir("text", "scenes") do # creates ~/project/text/scenes subdir
150
- # b.file( "adventure_time.txt" ) do |f|
151
- # f << "Fill this in later"
152
- # end
153
- #
154
- # # calling .file without feeding it a block leaves it open for writing,
155
- # # until either the enclosing block terminates or .file is called
156
- # # again with a string argument.
157
- # b.file( "another_brick.txt" )
158
- # b.file << "Hey, you!"
159
- # b.file << "Yes, you!"
160
- # b.file.push "Stand still, laddie!"
161
- #
162
- # b.template(templates_dir.join("blue_template.txt")) do |t|
163
- # t.var(:fname, "John")
164
- # t.var(:lname, "Macey")
165
- # t.var(:state, "Ohio")
166
- # t.vars(graduated: "2003")
167
- # t.vars(quot: "That wasn't my duck.", photo: "john.png", css: "font-family: arial")
168
- # end
169
- #
170
- # b.copy( [src_dir.join("abba.txt"), "baab.txt"] ) # contents of abba.txt copied into baab.txt
171
- #
172
- #
173
- # b.file( ".lockfile" ) # creates an empty file
174
- # end
175
- #
176
- # b.
177
- # end
178
- #
179
-
@@ -0,0 +1,5 @@
1
+ module FunWith
2
+ module Files
3
+ class NoSuchFile < Exception; end
4
+ end
5
+ end
@@ -0,0 +1,134 @@
1
+ module FunWith
2
+ module Files
3
+ # Mostly just convenience methods for FileUtils
4
+ module FileManipulationMethods
5
+ # cd(dir, options)
6
+ # cd(dir, options) {|dir| .... }
7
+ # pwd()
8
+ # mkdir(dir, options)
9
+ # mkdir(list, options)
10
+ # mkdir_p(dir, options)
11
+ # mkdir_p(list, options)
12
+ # ln(old, new, options)
13
+ # ln(list, destdir, options)
14
+ # ln_s(old, new, options)
15
+ # ln_s(list, destdir, options)
16
+ # ln_sf(src, dest, options)
17
+
18
+ def cp( *args )
19
+ self.destination_and_options( args ) do |dest, opts|
20
+ FileUtils.cp_r( self, dest, opts )
21
+ dest.fwf_filepath
22
+ end
23
+ end
24
+
25
+ alias :copy :cp
26
+
27
+ # self is the target, link is the thing linking to self
28
+ # returns filepath of the new link. Will fall back to symbolic
29
+ # link if self is a directory
30
+ def ln( *args )
31
+ self.destination_and_options( args ) do |link, opts|
32
+ symlink = self.directory? || opts[:symbolic] || opts[:sym] || opts[:soft]
33
+
34
+ if symlink
35
+ FileUtils.ln_s( self, link, opts )
36
+ else
37
+ FileUtils.ln( self, link, opts )
38
+ end
39
+
40
+ link.fwf_filepath
41
+ end
42
+ end
43
+
44
+ def ln_s( link, options = {} )
45
+ FileUtils.ln_s( self, link, options )
46
+ link.fwf_filepath
47
+ end
48
+
49
+ def file_gsub( *args, &block )
50
+ lines = []
51
+ self.each_line do |line|
52
+ lines << line.gsub( *args, &block )
53
+ end
54
+
55
+ lines.compact.join( "" )
56
+ end
57
+
58
+ def file_gsub!( *args, &block )
59
+ self.write( self.file_gsub(*args,&block) )
60
+ end
61
+
62
+ protected
63
+ def destination_and_options( args, &block )
64
+ options = args.last.is_a?(Hash) ? args.pop : {}
65
+ destination = self.find_destination_from_args( args )
66
+
67
+ if block_given?
68
+ yield [destination, options]
69
+ else
70
+ [destination, options]
71
+ end
72
+ end
73
+
74
+
75
+
76
+ # logic should be shared by various manipulators
77
+ def find_destination_from_args( args )
78
+ if args.first.is_a?(Pathname)
79
+ dest = args.first
80
+ elsif self.directory?
81
+ # what if they're trying to define an absolute dest, but being splitty?
82
+ dest = self.join( *args )
83
+ else
84
+ # ......
85
+ dest = self.dirname.join( *args )
86
+ dest = dest.join( self.basename ) if dest.directory?
87
+ end
88
+ end
89
+
90
+ # rm(list, options)
91
+ # rm_r(list, options)
92
+ # rm_rf(list, options)
93
+ # rmdir(dir, options)
94
+ # rmdir(list, options)
95
+
96
+
97
+ # def cp( dest, options = {} )
98
+ # raise NoSuchFile.new( "No such file as #{self} to copy" ) unless self.exist?
99
+ #
100
+ # dest = dest.fwf_filepath.expand
101
+ #
102
+ # if self.directory?
103
+ # # touch dest directory?
104
+ # FileUtils.cp_r( self, dest, options)
105
+ # else
106
+ # dest = dest.join( self.basename ) if dest.directory?
107
+ # dest_dir = dest.up.touch_dir
108
+ #
109
+ # raise NotWritable.new( "Could not create directory or directory not writable: #{dest_dir}" ) unless dest_dir.directory? && dest_dir.writable?
110
+ #
111
+ # FileUtils.cp( self, dest, options ) unless dest.exist? && options[:safe]
112
+ # end
113
+ #
114
+ # dest
115
+ # end
116
+ #
117
+ #
118
+
119
+ # cp_r(src, dest, options)
120
+ # cp_r(list, dir, options)
121
+
122
+
123
+
124
+ # mv(src, dest, options)
125
+ # mv(list, dir, options)
126
+ # install(src, dest, mode = <src's>, options)
127
+ # chmod(mode, list, options)
128
+ # chmod_R(mode, list, options)
129
+ # chown(user, group, list, options)
130
+ # chown_R(user, group, list, options)
131
+ # touch(list, options)
132
+ end
133
+ end
134
+ end
@@ -33,10 +33,6 @@ module FunWith
33
33
  Dir.home.fwf_filepath.join( *args )
34
34
  end
35
35
 
36
- def self.template( src, dest, vars = {} )
37
- raise "require 'fun_with_templates' to use this method"
38
- end
39
-
40
36
  def join( *args, &block )
41
37
  if block_given?
42
38
  yield self.class.new( super(*args) )
@@ -197,7 +193,7 @@ module FunWith
197
193
  if self.file?
198
194
  File.size( self ) == 0
199
195
  elsif self.directory?
200
- self.glob( "**", "*" ).length == 0
196
+ self.glob( "**", "*" ).fwf_blank?
201
197
  end
202
198
  end
203
199
 
@@ -292,11 +288,25 @@ module FunWith
292
288
  end
293
289
 
294
290
 
291
+ def specifier( str )
292
+ str = str.to_s
293
+ chunks = self.to_s.split(".")
294
+
295
+ if chunks.length == 1
296
+ chunks << str
297
+ else
298
+ chunks = chunks[0..-2] + [str] + [chunks[-1]]
299
+ end
300
+
301
+ chunks.join(".").fwf_filepath
302
+ end
303
+
295
304
  # TODO: succession : enumerates a sequence of files that get passed
296
305
  # to a block in order.
297
306
  def succession( opts = { digit_count: SUCC_DIGIT_COUNT, timestamp: false } )
298
307
  if opts[:timestamp]
299
- timestamp = Time.now.strftime("%Y%m%d%H%M%S%L")
308
+ opts[:timestamp_format] ||= "%Y%m%d%H%M%S%L"
309
+ timestamp = Time.now.strftime( opts[:timestamp_format] )
300
310
  digit_count = timestamp.length
301
311
  else
302
312
  timestamp = false
@@ -0,0 +1,22 @@
1
+ module FunWith
2
+ module Files
3
+ # view and change file permissions
4
+ module FilePermissionMethods
5
+ def readable?
6
+ File.readable?( self )
7
+ end
8
+
9
+ def writable?
10
+ File.writable?( self )
11
+ end
12
+
13
+ def executable?
14
+ File.executable?( self )
15
+ end
16
+
17
+ def chmod( mode, options )
18
+ FileUtils.chmod( mode, self, options = {} )
19
+ end
20
+ end
21
+ end
22
+ end
@@ -19,6 +19,10 @@ module FunWith
19
19
  def gsub!( *args )
20
20
  @path = @path.gsub(*args)
21
21
  end
22
+
23
+ def scan( *args, &block )
24
+ @path.scan( *args, &block )
25
+ end
22
26
  end
23
27
  end
24
28
  end
@@ -1,22 +1,24 @@
1
- require 'pathname' #stdlib
1
+ require 'digest/md5' # stdlib
2
+ require 'pathname' # stdlib
2
3
  require 'tmpdir'
3
- require 'debugger'
4
4
 
5
- for file in %w(directory_builder
6
- downloader
7
- file_orderer
8
- file_path
9
- root_path
10
- remote_path
11
- string_extensions
12
- string_behavior
13
- pathname_extensions
14
- xdg_extensions)
15
-
16
- require_relative File.join("files", file)
5
+ files = Dir.glob( File.join( File.dirname(__FILE__), "fun_with", "**", "*.rb" ) )
6
+
7
+ for file in files.map{ |f| f.gsub(/\.rb$/, '') }
8
+ require file
17
9
  end
18
10
 
19
11
  FunWith::Files::RootPath.rootify( FunWith::Files, __FILE__.fwf_filepath.dirname.up )
20
- FunWith::Files::VERSION = FunWith::Files.root("VERSION").read
21
12
 
22
- FunWith::Files::FilePath.send( :include, FunWith::Files::StringBehavior )
13
+ module FunWith
14
+ module Files
15
+ class FilePath
16
+ for mod in [ StringBehavior,
17
+ FileManipulationMethods,
18
+ FilePermissionMethods,
19
+ DigestMethods ]
20
+ include mod
21
+ end
22
+ end
23
+ end
24
+ end
File without changes
File without changes
@@ -0,0 +1,52 @@
1
+ require 'helper'
2
+
3
+ class TestCopying < FunWith::Files::TestCase
4
+ context "inside a tmpdir" do
5
+ setup do
6
+ @dir = FilePath.tmpdir
7
+ assert @dir.exist?
8
+ end
9
+
10
+ teardown do
11
+ @dir.rm
12
+ assert_equal false, @dir.directory?
13
+ end
14
+
15
+ should "copy a single file" do
16
+ outdir = @dir.join( "down", "down", "down", "to", "the", "depths" )
17
+ assert !outdir.exist?
18
+ outdir.touch_dir
19
+ assert outdir.exist?
20
+
21
+ infile = FunWith::Files.root( "test", "helper.rb" )
22
+ assert infile.exist?
23
+
24
+ outfile = outdir.join("copy_of_helper.rb")
25
+ assert !outfile.exist?
26
+
27
+ infile.cp( outdir )
28
+ assert outdir.join("helper.rb").exist?
29
+
30
+ infile.cp( outfile )
31
+ assert outfile.exist?
32
+ end
33
+
34
+ should "copy a directory structure" do
35
+ outdir = @dir.join( "down", "down", "abandon", "all", "hope" )
36
+ indir = FunWith::Files.root( "test" )
37
+ outdir.touch_dir
38
+ indir.cp( outdir )
39
+
40
+ assert outdir.exist?
41
+ helper_file = outdir.join( "test", "helper.rb" )
42
+ assert helper_file.exist?
43
+ assert_equal indir.join( "helper.rb" ).grep( /FunWith::Files/ ).length, helper_file.grep( /FunWith::Files/ ).length
44
+
45
+ assert_equal indir.glob(:all).length, outdir.join("test").glob(:all).length
46
+ end
47
+
48
+ should "symlink masterfully" do
49
+
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,24 @@
1
+ require 'helper'
2
+
3
+ class TestFileManipulation < FunWith::Files::TestCase
4
+ context "testing gsubs" do
5
+ setup do
6
+ @license = FunWith::Files.root("LICENSE.txt")
7
+ end
8
+
9
+ should "copy LICENSE.txt" do
10
+ copied = @license.cp( "test", "tmp" )
11
+ assert_match /LICENSE\.txt/, copied.to_s
12
+ assert copied.exist?
13
+ assert copied.read.length > 0
14
+ end
15
+
16
+ should "gsub copy of license.txt" do
17
+ copied = @license.cp( "test", "tmp" )
18
+ copied.file_gsub!( /Bryce Anderson/, "Wilford Brimley" )
19
+ assert copied.size > 1000
20
+
21
+ assert_equal 1, copied.grep("Wilford Brimley").length
22
+ end
23
+ end
24
+ end
@@ -12,7 +12,7 @@ class TestFilePath < FunWith::Files::TestCase
12
12
  assert f1.exist?
13
13
  assert f2.exist?
14
14
  end
15
-
15
+
16
16
  should "go up/down when asked" do
17
17
  f1 = FilePath.new( "/", "home", "users", "monkeylips", "ask_for_floyd" )
18
18
  f2 = FilePath.new( "/", "home", "users" )
@@ -60,9 +60,9 @@ class TestFilePath < FunWith::Files::TestCase
60
60
 
61
61
  should "glob items in test/data directory" do
62
62
  files = @data_dir.glob(:all)
63
- assert_equal 3, files.length
63
+ assert_equal 5, files.length
64
64
  files = @data_dir.glob(:all, :flags => [File::FNM_DOTMATCH])
65
- assert_equal 7, files.length
65
+ assert_equal 9, files.length
66
66
  end
67
67
 
68
68
  should "glob with case insensitive flag" do
@@ -139,4 +139,44 @@ class TestFilePath < FunWith::Files::TestCase
139
139
  assert_equal file_name_strings[1..-1], file_name_strings[1..-1].sort
140
140
  end
141
141
  end
142
+
143
+ context "test specify()" do
144
+ should "just friggin' work" do
145
+ fil = "resume.doc".fwf_filepath
146
+
147
+ test_data = [ [:cyberdyne, "resume.cyberdyne.doc"],
148
+ [:administrative, "resume.cyberdyne.administrative.doc"],
149
+ [:v2, "resume.cyberdyne.administrative.v2.doc"],
150
+ [:gratuitous_use_of_specifier, "resume.cyberdyne.administrative.v2.gratuitous_use_of_specifier.doc"]
151
+ ]
152
+
153
+ for key, result in test_data
154
+ fil = fil.specifier( key )
155
+ assert_equal result, fil.to_s
156
+ end
157
+ end
158
+ end
159
+
160
+ context "test digest functions" do
161
+ setup do
162
+ @tmp_dir = FunWith::Files.root( 'test', 'tmp' )
163
+ end
164
+
165
+ teardown do
166
+ `rm -rf #{@tmp_dir.join('*')}`
167
+ end
168
+
169
+ should "md5hash a file" do
170
+ nilhash = "d41d8cd98f00b204e9800998ecf8427e"
171
+ nilhashhash = "74be16979710d4c4e7c6647856088456"
172
+
173
+ empty = @tmp_dir.join("empty.dat")
174
+ empty.touch
175
+ assert_equal( nilhash, empty.md5 )
176
+
177
+ file = @tmp_dir.join( "#{nilhash}.dat" )
178
+ file.write( nilhash )
179
+ assert_equal( nilhashhash, file.md5 )
180
+ end
181
+ end
142
182
  end
@@ -0,0 +1,15 @@
1
+ require 'helper'
2
+
3
+ class TestFunWithFiles < FunWith::Files::TestCase
4
+ context "testing basics" do
5
+ should "have core extensions working" do
6
+ assert [].fwf_blank?
7
+ assert false.fwf_blank?
8
+ assert Hash.new.fwf_blank?
9
+ assert "".fwf_blank?
10
+ assert " ".fwf_blank?
11
+ refute true.fwf_blank?
12
+ refute Object.new.fwf_blank?
13
+ end
14
+ end
15
+ end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fun_with_files
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
5
- prerelease:
4
+ version: 0.0.7
6
5
  platform: ruby
7
6
  authors:
8
7
  - Bryce Anderson
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-02-02 00:00:00.000000000 Z
11
+ date: 2014-04-04 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: xdg
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,23 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: debugger
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
23
  requirements:
43
24
  - - ! '>='
44
25
  - !ruby/object:Gem::Version
@@ -46,7 +27,6 @@ dependencies:
46
27
  - !ruby/object:Gem::Dependency
47
28
  name: shoulda
48
29
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
30
  requirements:
51
31
  - - ! '>='
52
32
  - !ruby/object:Gem::Version
@@ -54,7 +34,6 @@ dependencies:
54
34
  type: :development
55
35
  prerelease: false
56
36
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
37
  requirements:
59
38
  - - ! '>='
60
39
  - !ruby/object:Gem::Version
@@ -62,7 +41,6 @@ dependencies:
62
41
  - !ruby/object:Gem::Dependency
63
42
  name: rdoc
64
43
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
44
  requirements:
67
45
  - - ~>
68
46
  - !ruby/object:Gem::Version
@@ -70,7 +48,6 @@ dependencies:
70
48
  type: :development
71
49
  prerelease: false
72
50
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
51
  requirements:
75
52
  - - ~>
76
53
  - !ruby/object:Gem::Version
@@ -78,35 +55,31 @@ dependencies:
78
55
  - !ruby/object:Gem::Dependency
79
56
  name: bundler
80
57
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
58
  requirements:
83
59
  - - ~>
84
60
  - !ruby/object:Gem::Version
85
- version: 1.3.5
61
+ version: '1.5'
86
62
  type: :development
87
63
  prerelease: false
88
64
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
65
  requirements:
91
66
  - - ~>
92
67
  - !ruby/object:Gem::Version
93
- version: 1.3.5
68
+ version: '1.5'
94
69
  - !ruby/object:Gem::Dependency
95
70
  name: jeweler
96
71
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
72
  requirements:
99
73
  - - ~>
100
74
  - !ruby/object:Gem::Version
101
- version: 1.8.7
75
+ version: '2.0'
102
76
  type: :development
103
77
  prerelease: false
104
78
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
79
  requirements:
107
80
  - - ~>
108
81
  - !ruby/object:Gem::Version
109
- version: 1.8.7
82
+ version: '2.0'
110
83
  description: ! " A more intuitive syntax for performing a variety of file actions.
111
84
  Examples:\n \"/\".fwf_filepath.join('usr', 'bin', 'bash').touch\n FunWith::Files::FilePath.home(\"Music\").glob(:ext
112
85
  => \"mp3\", :recurse => true)\n home = FunWith::Files::FilePath.home\n home.touch(
@@ -121,20 +94,32 @@ extra_rdoc_files:
121
94
  - LICENSE.txt
122
95
  - README.rdoc
123
96
  files:
124
- - ./lib/files/directory_builder.rb
125
- - ./lib/files/downloader.rb
126
- - ./lib/files/file_orderer.rb
127
- - ./lib/files/file_path.rb
128
- - ./lib/files/pathname_extensions.rb
129
- - ./lib/files/remote_path.rb
130
- - ./lib/files/root_path.rb
131
- - ./lib/files/string_behavior.rb
132
- - ./lib/files/string_extensions.rb
133
- - ./lib/files/xdg_extensions.rb
97
+ - ./lib/fun_with/files/core_extensions/array.rb
98
+ - ./lib/fun_with/files/core_extensions/false.rb
99
+ - ./lib/fun_with/files/core_extensions/hash.rb
100
+ - ./lib/fun_with/files/core_extensions/nil.rb
101
+ - ./lib/fun_with/files/core_extensions/object.rb
102
+ - ./lib/fun_with/files/core_extensions/string.rb
103
+ - ./lib/fun_with/files/digest_methods.rb
104
+ - ./lib/fun_with/files/directory_builder.rb
105
+ - ./lib/fun_with/files/downloader.rb
106
+ - ./lib/fun_with/files/errors.rb
107
+ - ./lib/fun_with/files/file_manipulation_methods.rb
108
+ - ./lib/fun_with/files/file_orderer.rb
109
+ - ./lib/fun_with/files/file_path.rb
110
+ - ./lib/fun_with/files/file_permission_methods.rb
111
+ - ./lib/fun_with/files/pathname_extensions.rb
112
+ - ./lib/fun_with/files/remote_path.rb
113
+ - ./lib/fun_with/files/root_path.rb
114
+ - ./lib/fun_with/files/string_behavior.rb
115
+ - ./lib/fun_with/files/string_extensions.rb
116
+ - ./lib/fun_with/files/xdg_extensions.rb
134
117
  - ./lib/fun_with_files.rb
135
118
  - ./test/data/empty.txt
136
119
  - ./test/data/grep1.txt
137
120
  - ./test/data/grep2.txt
121
+ - ./test/data/gsub1.txt
122
+ - ./test/data/gsub2.txt
138
123
  - ./test/helper.rb
139
124
  - ./test/loadable_dir/dir1/file1.rb
140
125
  - ./test/loadable_dir/dir2/file2.rb
@@ -144,9 +129,12 @@ files:
144
129
  - ./test/loadable_dir/dir5/b.rb
145
130
  - ./test/loadable_dir/dir5/c.rb
146
131
  - ./test/loadable_dir/dir5/d.rb
132
+ - ./test/test_copying.rb
147
133
  - ./test/test_descent.rb
148
134
  - ./test/test_directory_builder.rb
135
+ - ./test/test_file_manipulation.rb
149
136
  - ./test/test_file_path.rb
137
+ - ./test/test_fun_with_files.rb
150
138
  - ./test/test_globbing.rb
151
139
  - ./test/test_loading.rb
152
140
  - ./test/test_root_path.rb
@@ -159,30 +147,26 @@ files:
159
147
  homepage: http://github.com/darthschmoo/fun_with_files
160
148
  licenses:
161
149
  - MIT
150
+ metadata: {}
162
151
  post_install_message:
163
152
  rdoc_options: []
164
153
  require_paths:
165
154
  - lib
166
155
  required_ruby_version: !ruby/object:Gem::Requirement
167
- none: false
168
156
  requirements:
169
157
  - - ! '>='
170
158
  - !ruby/object:Gem::Version
171
159
  version: '0'
172
- segments:
173
- - 0
174
- hash: 1257082353176487045
175
160
  required_rubygems_version: !ruby/object:Gem::Requirement
176
- none: false
177
161
  requirements:
178
162
  - - ! '>='
179
163
  - !ruby/object:Gem::Version
180
164
  version: '0'
181
165
  requirements: []
182
166
  rubyforge_project:
183
- rubygems_version: 1.8.25
167
+ rubygems_version: 2.2.2
184
168
  signing_key:
185
- specification_version: 3
169
+ specification_version: 4
186
170
  summary: A mashup of several File, FileUtils, and Dir class functions, with a peppy,
187
171
  fun-loving syntax
188
172
  test_files: []