epath 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -9,6 +9,10 @@ Paths are naturally the subject of their methods and even if they are simple Str
9
9
 
10
10
  Also, using a path library like this avoid to remember in which class the functionality is implemented, everything is in one place (if not, please open an issue!).
11
11
 
12
+ ## Installation
13
+
14
+ gem install epath
15
+
12
16
  ## Links
13
17
 
14
18
  * [GitHub](https://github.com/eregon/epath)
@@ -1,3 +1,5 @@
1
+ require File.expand_path('../lib/epath/version', __FILE__)
2
+
1
3
  Gem::Specification.new do |s|
2
4
  s.name = 'epath'
3
5
  s.summary = 'a Path manipulation library'
@@ -5,7 +7,7 @@ Gem::Specification.new do |s|
5
7
  s.email = 'eregontp@gmail.com'
6
8
  s.homepage = 'https://github.com/eregon/epath'
7
9
  s.files = Dir['lib/**/*.rb'] + %w[README.md LICENSE epath.gemspec]
8
- s.version = '0.1.0'
10
+ s.version = Path::VERSION
9
11
 
10
12
  s.add_development_dependency 'rspec'
11
13
  end
@@ -33,6 +33,15 @@ class Path
33
33
  self
34
34
  end
35
35
 
36
+ def cp(to)
37
+ FileUtils.cp(@path, to)
38
+ end
39
+ alias copy cp
40
+
41
+ def cp_r(to)
42
+ FileUtils.cp_r(@path, to)
43
+ end
44
+
36
45
  def touch
37
46
  FileUtils.touch(@path)
38
47
  self
@@ -20,11 +20,21 @@ class Path
20
20
  path.to_s.dup
21
21
  end
22
22
 
23
- validate(@path)
23
+ init
24
+ end
24
25
 
25
- taint if @path.tainted?
26
- @path.freeze
27
- freeze
26
+ def yaml_initialize(tag, ivars)
27
+ @path = ivars['path']
28
+ init
29
+ end
30
+
31
+ def marshal_dump
32
+ @path
33
+ end
34
+
35
+ def marshal_load path
36
+ @path = path
37
+ init
28
38
  end
29
39
 
30
40
  # Returns clean path of +self+ with consecutive slashes and useless dots removed.
@@ -137,6 +147,14 @@ class Path
137
147
 
138
148
  private
139
149
 
150
+ def init
151
+ validate(@path)
152
+
153
+ taint if @path.tainted?
154
+ @path.freeze
155
+ freeze
156
+ end
157
+
140
158
  def validate(path)
141
159
  raise ArgumentError, "path contains a null byte: #{path.inspect}" if path.include? "\0"
142
160
  path.gsub!(File::ALT_SEPARATOR, '/') if File::ALT_SEPARATOR
@@ -0,0 +1,3 @@
1
+ class Path
2
+ VERSION = '0.1.1'
3
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epath
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - eregon
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-16 00:00:00 Z
18
+ date: 2012-03-18 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rspec
@@ -53,6 +53,7 @@ files:
53
53
  - lib/epath/parts.rb
54
54
  - lib/epath/predicates.rb
55
55
  - lib/epath/require_tree.rb
56
+ - lib/epath/version.rb
56
57
  - lib/epath.rb
57
58
  - README.md
58
59
  - LICENSE