windirs 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/lib/windirs.rb +49 -2
- data/spec/windirs_spec.rb +11 -0
- data/windirs.gemspec +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2875a828eee836d39ddd080820de78e21a32cd95
|
4
|
+
data.tar.gz: 1f28a9a0e7ce8c4082be19e580cb8763dde8bbb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f41e4abd2743320c1a43d63a707b96daa6be618b9a5aa534b633e0024ad56a466e707a7a89ea4ae20210523ab42191cf987ad026153890c6c9134711add1a5b
|
7
|
+
data.tar.gz: 2c2a39ef5cfa4e387c76014e9586723f81a6bc899317404456797c64484fbd9078832ef38f82d7386ca59f56e2b86cb7cfc61b8039b6bda721125c9c9d61431e
|
data/lib/windirs.rb
CHANGED
@@ -114,11 +114,58 @@ module Windirs
|
|
114
114
|
fpath('\\'){ |drive| "#{@drive.upcase}:"}
|
115
115
|
end
|
116
116
|
|
117
|
+
##
|
118
|
+
# Return a new Windirs::Path with any Windows network mapped drives
|
119
|
+
# dereferenced to their UNC.
|
120
|
+
# Returns +self+ if not on Windows, or
|
121
|
+
# +self+ is not on a network mapped drive.
|
122
|
+
|
123
|
+
def win_deref
|
124
|
+
return self unless ENV['OS'] == 'Windows_NT'
|
125
|
+
|
126
|
+
# FIXME try to get path to net if on Cygwin and can't see net
|
127
|
+
net_use = `net use #{@drive}:`
|
128
|
+
return self unless $?.exitstatus == 0
|
129
|
+
remote_line = net_use.split("\r\n").select{|l| l =~ /^Remote name\s*/}
|
130
|
+
drive = @drive
|
131
|
+
drive = remote_line[0].sub(/^Remote name\s*/, '')
|
132
|
+
Path.new "#{drive}#{@dirs}"
|
133
|
+
end
|
134
|
+
|
135
|
+
# #FIXME will need to stub or mock this to test properly?
|
136
|
+
# def cyg_deref
|
137
|
+
#
|
138
|
+
## C:/cygwin/bin on /usr/bin type ntfs (binary,auto)
|
139
|
+
#
|
140
|
+
# return self if ENV['OS'] != 'Windows_NT'
|
141
|
+
#
|
142
|
+
# as_nix = self.nix
|
143
|
+
#
|
144
|
+
# #FIXME use mount similarly, with similar caveats to net use
|
145
|
+
# mounts = `mount`.split("\n")
|
146
|
+
# mh = Hash.new
|
147
|
+
# mounts.map do |l|
|
148
|
+
# l =~ /^(?<device>.*)\s+on\s+(?<mountpoint>.*)\s+type\s+.*$/
|
149
|
+
# m = Regexp.last_match
|
150
|
+
# mh[m[:device]] = m[:mountpoint]
|
151
|
+
# end
|
152
|
+
#
|
153
|
+
#
|
154
|
+
# sorted = mh.sort_by{|k,v| v.length}
|
155
|
+
#
|
156
|
+
# sorted.each do |el|
|
157
|
+
# #if el[1] matches as_nix, replace that with el[0]
|
158
|
+
# end
|
159
|
+
#
|
160
|
+
#
|
161
|
+
# end
|
162
|
+
#
|
163
|
+
|
117
164
|
private
|
118
165
|
|
119
|
-
def fpath
|
166
|
+
def fpath delim='/', prefix=''
|
120
167
|
drive = @drive ? "#{prefix}#{yield(@drive)}" : nil
|
121
|
-
"#{drive}#{@dirs}".gsub(/[\/\\\\]/,
|
168
|
+
"#{drive}#{@dirs}".gsub(/[\/\\\\]/, delim)
|
122
169
|
end
|
123
170
|
|
124
171
|
end
|
data/spec/windirs_spec.rb
CHANGED
@@ -29,6 +29,7 @@ describe Windirs do
|
|
29
29
|
@upaths = Hash.new
|
30
30
|
@uncs.map{|k, v| @upaths[k] = Windirs::Path.new(v)}
|
31
31
|
|
32
|
+
@cygwin_home = Windirs::Path.new('/home')
|
32
33
|
end
|
33
34
|
|
34
35
|
describe Windirs::Path do
|
@@ -61,6 +62,16 @@ describe Windirs do
|
|
61
62
|
end
|
62
63
|
end
|
63
64
|
|
65
|
+
it 'dereferences cygwin mounts' do
|
66
|
+
pending
|
67
|
+
@cygwin_home.cyg_deref.windows.should eq 'C:/cygwin/home'
|
68
|
+
end
|
69
|
+
|
70
|
+
# FIXME This is not much of a test...
|
71
|
+
it 'dereferences windows network mounts' do
|
72
|
+
@dpaths[:windows].win_deref.windows.should eq @drives[:windows]
|
73
|
+
end
|
74
|
+
|
64
75
|
end
|
65
76
|
|
66
77
|
end
|
data/windirs.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'windirs'
|
3
|
-
s.version = '0.0.
|
4
|
-
s.date = '2014-03-
|
3
|
+
s.version = '0.0.2'
|
4
|
+
s.date = '2014-03-24'
|
5
5
|
s.summary = "translate between Cygwin, Windows, and Unix file paths"
|
6
6
|
s.description = "Handy ways for dealing with directory paths when you are not
|
7
7
|
sure what platform your code will be running on, but you are
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: windirs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noah Birnel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |-
|
14
14
|
Handy ways for dealing with directory paths when you are not
|