提交 00bcb6f2 编写于 作者: M Mislav Marohnić

Avoid loading FileUtils; reimplement `mkdir_p`

Loading FileUtils can take more than 10 ms on Ruby 2.0.0, making the
require extremely wasteful for the purpose of just using a single method.
上级 f2421405
require 'forwardable'
require 'fileutils'
module Hub
# Client for the GitHub v3 API.
......@@ -381,10 +380,18 @@ module Hub
end
def save
FileUtils.mkdir_p File.dirname(@filename)
mkdir_p File.dirname(@filename)
File.open(@filename, 'w', 0600) {|f| f << yaml_dump(@data) }
end
def mkdir_p(dir)
dir.split('/').inject do |parent, name|
d = File.join(parent, name)
Dir.mkdir(d) unless File.exist?(d)
d
end
end
def yaml_load(string)
hash = {}
host = nil
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册