rogerdpack-sane 0.0.8 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README +9 -7
  2. data/lib/sane.rb +23 -2
  3. metadata +1 -1
data/README CHANGED
@@ -1,22 +1,24 @@
1
- Collection of utilities to make ruby more user friendly.
1
+ Collection of utilities to make ruby ...more friendly from the get-go [really things that *should* have been added to core, because of immense convenience]
2
2
 
3
- Currently:
3
+ Currently this includes:
4
4
 
5
5
  require_rel glob
6
- * require a file relative to the current, i.e.
7
- require_rel 'lib/filename'
6
+ * require a file relative to the current file, i.e.
7
+ >> require_rel 'lib/filename'
8
8
 
9
9
  Object#in?
10
- 3.in? [1,2,3]
10
+ # ex:
11
+ >> 3.in? [1,2,3]
11
12
  => true
12
13
 
13
14
  println
14
15
  like print, but with a carriage return at the end:
15
- println 1,2,3
16
+ >> println 1,2,3
16
17
  (prints 123\n)
17
18
 
18
19
  enumerable-extra
19
20
  #new enumerable #map
20
- [1,2,3].map(:to_s) # applies it automatically! far less ugly than [1,2,3].map &:to_s
21
+ >> [1,2,3].map(:to_s) # applies it automatically! far less ugly than [1,2,3].map &:to_s
22
+ => ["1", "2", "3"]
21
23
 
22
24
  Don't leave home without these!
data/lib/sane.rb CHANGED
@@ -1,6 +1,25 @@
1
- require 'require_all' # require_all, require_rel
1
+ require 'require_all' # require_all, require_rel gem
2
2
  require_rel 'enumerable-extra' # for #map(:symbol)
3
3
 
4
+ # require 'facets/file' ===>
5
+ class File
6
+
7
+ # Writes the given data to the given path and closes the file. This is
8
+ # done in binary mode, complementing <tt>IO.read</tt> in standard Ruby.
9
+ #
10
+ # Returns the number of bytes written.
11
+ #
12
+ # CREDIT: Gavin Sinclair
13
+
14
+ def self.write(path, data)
15
+ File.open(path, "wb") do |file|
16
+ return file.write(data)
17
+ end
18
+ end unless self.respond_to?(:write)
19
+
20
+ end
21
+
22
+
4
23
  # a method like puts but all on one line--very much like java's println, quite useful
5
24
  def println *args
6
25
  print *args
@@ -23,6 +42,7 @@ class Object
23
42
  end
24
43
  end unless respond_to? :assert
25
44
 
45
+ # helper to bring up a debugger
26
46
  # for this to work in 1.9, please follow directions: http://wiki.github.com/mark-moseley/ruby-debug
27
47
  # for 1.8, run gem install ruby-debug
28
48
  def _dbg
@@ -38,11 +58,12 @@ if RUBY_VERSION < '1.9'
38
58
  end
39
59
 
40
60
  # taken from http://oldrcrs.rubypal.com/rcr/show/309
61
+
41
62
  module Kernel
42
63
  BASE_DIR = Dir.getwd
43
64
  def __DIR__
44
65
  dir = (/^(.+)?:\d+/ =~ caller[0]) ? File.expand_path(File.dirname($1), BASE_DIR) : nil
45
66
  dir += '/' if dir
46
67
  dir
47
- end
68
+ end unless defined?(__DIR__)
48
69
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rogerdpack-sane
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roger PacK