path_operator 1.0.1

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.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in path_operator.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem 'rspec', '~> 2.6'
8
+ end
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Elia Schito
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,35 @@
1
+ # PathOperator
2
+
3
+ With PathOperator you can do this too:
4
+
5
+ ``` ruby
6
+ require 'path_operator'
7
+ PathOperator.include!
8
+
9
+ '~' / :elia / 'Code' / 'path_operator' # => '~/elia/Code/path_operator'
10
+
11
+ ```
12
+
13
+
14
+ ### Copyright
15
+
16
+ Copyright (c) 2011 Elia Schito
17
+
18
+ Permission is hereby granted, free of charge, to any person obtaining
19
+ a copy of this software and associated documentation files (the
20
+ "Software"), to deal in the Software without restriction, including
21
+ without limitation the rights to use, copy, modify, merge, publish,
22
+ distribute, sublicense, and/or sell copies of the Software, and to
23
+ permit persons to whom the Software is furnished to do so, subject to
24
+ the following conditions:
25
+
26
+ The above copyright notice and this permission notice shall be
27
+ included in all copies or substantial portions of the Software.
28
+
29
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
30
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
31
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
32
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
33
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
34
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
35
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,37 @@
1
+ require 'pathname'
2
+ require 'path_operator/version'
3
+
4
+ module PathOperator
5
+ module Stringish
6
+ def / *others
7
+ File.join self.to_s, *others.map(&:to_s)
8
+ end
9
+
10
+ def as_path
11
+ Pathname.new(self.to_s)
12
+ end
13
+ end
14
+
15
+ module Pathnameish
16
+ def / *others
17
+ join *others.map(&:to_s)
18
+ end
19
+
20
+ def from other_path
21
+ self.relative_path_from( other_path.to_path )
22
+ end
23
+
24
+ def absolute
25
+ "/#{self}".to_path
26
+ end
27
+
28
+ def as_path
29
+ self
30
+ end
31
+ end
32
+
33
+ def self.load!
34
+ ::String.send :include, PathOperator::Stringish
35
+ ::Pathname.send :include, PathOperator::Pathnameish
36
+ end
37
+ end
@@ -0,0 +1,3 @@
1
+ module PathOperator
2
+ VERSION = '1.0.1'
3
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'path_operator/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'path_operator'
7
+ s.version = PathOperator::VERSION
8
+ s.authors = ['Elia Schito']
9
+ s.email = ['perlelia@gmail.com']
10
+ s.homepage = ''
11
+ s.summary = %q{Adds the / operator to String, Symbol and Pathname}
12
+ s.description = %q{Adds the / operator to String, Symbol and Pathname}
13
+ s.license = 'MIT'
14
+
15
+ s.rubyforge_project = 'path_operator'
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ['lib']
21
+ end
@@ -0,0 +1,17 @@
1
+ $:.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'path_operator'
3
+
4
+ describe PathOperator do
5
+ before { PathOperator.load! }
6
+
7
+ it 'should join strings as paths' do
8
+ ('a' / 'b').should == 'a/b'
9
+ end
10
+
11
+ it 'should transform strings and symbols to paths' do
12
+ [:asdf, 'asdf', Pathname.new('asdf')].each do |s|
13
+ s.as_path.should == Pathname.new(s.to_s)
14
+ end
15
+ end
16
+ end
17
+
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: path_operator
3
+ version: !ruby/object:Gem::Version
4
+ hash: 21
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 1
10
+ version: 1.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Elia Schito
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-07-01 00:00:00 Z
19
+ dependencies: []
20
+
21
+ description: Adds the / operator to String, Symbol and Pathname
22
+ email:
23
+ - perlelia@gmail.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - .gitignore
32
+ - Gemfile
33
+ - MIT-LICENSE
34
+ - README.md
35
+ - Rakefile
36
+ - lib/path_operator.rb
37
+ - lib/path_operator/version.rb
38
+ - path_operator.gemspec
39
+ - spec/path_operator_spec.rb
40
+ homepage: ""
41
+ licenses:
42
+ - MIT
43
+ post_install_message:
44
+ rdoc_options: []
45
+
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ hash: 3
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 3
63
+ segments:
64
+ - 0
65
+ version: "0"
66
+ requirements: []
67
+
68
+ rubyforge_project: path_operator
69
+ rubygems_version: 1.8.5
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: Adds the / operator to String, Symbol and Pathname
73
+ test_files:
74
+ - spec/path_operator_spec.rb