Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
14cdff07
Commit
14cdff07
authored
Nov 22, 2015
by
Tomoyuki Sahara
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #48 from takahashim/file-path
add File.path
parents
828551f8
44473fec
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
mrblib/file.rb
mrblib/file.rb
+10
-0
test/file.rb
test/file.rb
+9
-0
No files found.
mrblib/file.rb
View file @
14cdff07
...
@@ -170,4 +170,14 @@ class File < IO
...
@@ -170,4 +170,14 @@ class File < IO
ext
=
fname
.
split
(
'.'
).
last
ext
=
fname
.
split
(
'.'
).
last
ext
.
empty?
?
''
:
".
#{
ext
}
"
ext
.
empty?
?
''
:
".
#{
ext
}
"
end
end
def
self
.
path
(
filename
)
if
filename
.
kind_of?
(
String
)
filename
elsif
filename
.
respond_to?
(
:to_path
)
filename
.
to_path
else
raise
TypeError
,
"no implicit conversion of
#{
filename
.
class
}
into String"
end
end
end
end
test/file.rb
View file @
14cdff07
...
@@ -106,3 +106,12 @@ assert('File.expand_path (with ENV)') do
...
@@ -106,3 +106,12 @@ assert('File.expand_path (with ENV)') do
assert_equal
"
#{
ENV
[
'HOME'
]
}
/user"
,
File
.
expand_path
(
"user"
,
ENV
[
'HOME'
]),
"relative with base_dir"
assert_equal
"
#{
ENV
[
'HOME'
]
}
/user"
,
File
.
expand_path
(
"user"
,
ENV
[
'HOME'
]),
"relative with base_dir"
end
end
assert
(
'File.path'
)
do
assert_equal
""
,
File
.
path
(
""
)
assert_equal
"a/b/c"
,
File
.
path
(
"a/b/c"
)
assert_equal
"a/../b/./c"
,
File
.
path
(
"a/../b/./c"
)
assert_raise
(
TypeError
)
{
File
.
path
(
nil
)
}
assert_raise
(
TypeError
)
{
File
.
path
(
123
)
}
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment