lg_pod_plugin 1.0.8 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/lg +5 -0
- data/lib/command/cache.rb +22 -18
- data/lib/command/command.rb +27 -35
- data/lib/command/install.rb +52 -0
- data/lib/command/update.rb +39 -0
- data/lib/lg_pod_plugin/downloader.rb +12 -17
- data/lib/lg_pod_plugin/git_util.rb +150 -106
- data/lib/lg_pod_plugin/install.rb +74 -88
- data/lib/lg_pod_plugin/l_cache.rb +11 -77
- data/lib/lg_pod_plugin/l_util.rb +6 -2
- data/lib/lg_pod_plugin/request.rb +90 -82
- data/lib/lg_pod_plugin/version.rb +1 -1
- data/lib/lg_pod_plugin.rb +9 -5
- metadata +57 -118
- data/lib/git/author.rb +0 -14
- data/lib/git/base/factory.rb +0 -101
- data/lib/git/base.rb +0 -670
- data/lib/git/branch.rb +0 -126
- data/lib/git/branches.rb +0 -71
- data/lib/git/config.rb +0 -22
- data/lib/git/diff.rb +0 -155
- data/lib/git/encoding_utils.rb +0 -33
- data/lib/git/escaped_path.rb +0 -77
- data/lib/git/index.rb +0 -5
- data/lib/git/lib.rb +0 -1215
- data/lib/git/log.rb +0 -135
- data/lib/git/object.rb +0 -312
- data/lib/git/path.rb +0 -31
- data/lib/git/remote.rb +0 -36
- data/lib/git/repository.rb +0 -6
- data/lib/git/stash.rb +0 -27
- data/lib/git/stashes.rb +0 -55
- data/lib/git/status.rb +0 -199
- data/lib/git/url.rb +0 -127
- data/lib/git/version.rb +0 -5
- data/lib/git/working_directory.rb +0 -4
- data/lib/git/worktree.rb +0 -38
- data/lib/git/worktrees.rb +0 -47
- data/lib/git.rb +0 -326
- data/lib/rchardet/big5freq.rb +0 -927
- data/lib/rchardet/big5prober.rb +0 -42
- data/lib/rchardet/chardistribution.rb +0 -250
- data/lib/rchardet/charsetgroupprober.rb +0 -110
- data/lib/rchardet/charsetprober.rb +0 -70
- data/lib/rchardet/codingstatemachine.rb +0 -67
- data/lib/rchardet/constants.rb +0 -42
- data/lib/rchardet/escprober.rb +0 -90
- data/lib/rchardet/escsm.rb +0 -245
- data/lib/rchardet/eucjpprober.rb +0 -88
- data/lib/rchardet/euckrfreq.rb +0 -597
- data/lib/rchardet/euckrprober.rb +0 -42
- data/lib/rchardet/euctwfreq.rb +0 -431
- data/lib/rchardet/euctwprober.rb +0 -42
- data/lib/rchardet/gb18030freq.rb +0 -474
- data/lib/rchardet/gb18030prober.rb +0 -42
- data/lib/rchardet/hebrewprober.rb +0 -289
- data/lib/rchardet/jisfreq.rb +0 -571
- data/lib/rchardet/jpcntx.rb +0 -229
- data/lib/rchardet/langbulgarianmodel.rb +0 -229
- data/lib/rchardet/langcyrillicmodel.rb +0 -330
- data/lib/rchardet/langgreekmodel.rb +0 -227
- data/lib/rchardet/langhebrewmodel.rb +0 -202
- data/lib/rchardet/langhungarianmodel.rb +0 -226
- data/lib/rchardet/langthaimodel.rb +0 -201
- data/lib/rchardet/latin1prober.rb +0 -147
- data/lib/rchardet/mbcharsetprober.rb +0 -89
- data/lib/rchardet/mbcsgroupprober.rb +0 -47
- data/lib/rchardet/mbcssm.rb +0 -542
- data/lib/rchardet/sbcharsetprober.rb +0 -122
- data/lib/rchardet/sbcsgroupprober.rb +0 -58
- data/lib/rchardet/sjisprober.rb +0 -88
- data/lib/rchardet/universaldetector.rb +0 -179
- data/lib/rchardet/utf8prober.rb +0 -87
- data/lib/rchardet/version.rb +0 -3
- data/lib/rchardet.rb +0 -67
- data/lib/zip/central_directory.rb +0 -212
- data/lib/zip/compressor.rb +0 -9
- data/lib/zip/constants.rb +0 -115
- data/lib/zip/crypto/decrypted_io.rb +0 -40
- data/lib/zip/crypto/encryption.rb +0 -11
- data/lib/zip/crypto/null_encryption.rb +0 -43
- data/lib/zip/crypto/traditional_encryption.rb +0 -99
- data/lib/zip/decompressor.rb +0 -31
- data/lib/zip/deflater.rb +0 -34
- data/lib/zip/dos_time.rb +0 -53
- data/lib/zip/entry.rb +0 -719
- data/lib/zip/entry_set.rb +0 -88
- data/lib/zip/errors.rb +0 -19
- data/lib/zip/extra_field/generic.rb +0 -44
- data/lib/zip/extra_field/ntfs.rb +0 -94
- data/lib/zip/extra_field/old_unix.rb +0 -46
- data/lib/zip/extra_field/universal_time.rb +0 -77
- data/lib/zip/extra_field/unix.rb +0 -39
- data/lib/zip/extra_field/zip64.rb +0 -70
- data/lib/zip/extra_field/zip64_placeholder.rb +0 -15
- data/lib/zip/extra_field.rb +0 -103
- data/lib/zip/file.rb +0 -468
- data/lib/zip/filesystem.rb +0 -643
- data/lib/zip/inflater.rb +0 -54
- data/lib/zip/input_stream.rb +0 -180
- data/lib/zip/ioextras/abstract_input_stream.rb +0 -122
- data/lib/zip/ioextras/abstract_output_stream.rb +0 -43
- data/lib/zip/ioextras.rb +0 -36
- data/lib/zip/null_compressor.rb +0 -15
- data/lib/zip/null_decompressor.rb +0 -19
- data/lib/zip/null_input_stream.rb +0 -10
- data/lib/zip/output_stream.rb +0 -198
- data/lib/zip/pass_thru_compressor.rb +0 -23
- data/lib/zip/pass_thru_decompressor.rb +0 -31
- data/lib/zip/streamable_directory.rb +0 -15
- data/lib/zip/streamable_stream.rb +0 -52
- data/lib/zip/version.rb +0 -3
- data/lib/zip.rb +0 -72
data/lib/git/branch.rb
DELETED
@@ -1,126 +0,0 @@
|
|
1
|
-
require 'git/path'
|
2
|
-
|
3
|
-
module Git
|
4
|
-
|
5
|
-
class Branch < Path
|
6
|
-
|
7
|
-
attr_accessor :full, :remote, :name
|
8
|
-
|
9
|
-
def initialize(base, name)
|
10
|
-
@full = name
|
11
|
-
@base = base
|
12
|
-
@gcommit = nil
|
13
|
-
@stashes = nil
|
14
|
-
@remote, @name = parse_name(name)
|
15
|
-
end
|
16
|
-
|
17
|
-
def gcommit
|
18
|
-
@gcommit ||= @base.gcommit(@full)
|
19
|
-
@gcommit
|
20
|
-
end
|
21
|
-
|
22
|
-
def stashes
|
23
|
-
@stashes ||= Git::Stashes.new(@base)
|
24
|
-
end
|
25
|
-
|
26
|
-
def checkout
|
27
|
-
check_if_create
|
28
|
-
@base.checkout(@full)
|
29
|
-
end
|
30
|
-
|
31
|
-
def archive(file, opts = {})
|
32
|
-
@base.lib.archive(@full, file, opts)
|
33
|
-
end
|
34
|
-
|
35
|
-
# g.branch('new_branch').in_branch do
|
36
|
-
# # create new file
|
37
|
-
# # do other stuff
|
38
|
-
# return true # auto commits and switches back
|
39
|
-
# end
|
40
|
-
def in_branch(message = 'in branch work')
|
41
|
-
old_current = @base.lib.branch_current
|
42
|
-
checkout
|
43
|
-
if yield
|
44
|
-
@base.commit_all(message)
|
45
|
-
else
|
46
|
-
@base.reset_hard
|
47
|
-
end
|
48
|
-
@base.checkout(old_current)
|
49
|
-
end
|
50
|
-
|
51
|
-
def create
|
52
|
-
check_if_create
|
53
|
-
end
|
54
|
-
|
55
|
-
def delete
|
56
|
-
@base.lib.branch_delete(@name)
|
57
|
-
end
|
58
|
-
|
59
|
-
def current
|
60
|
-
determine_current
|
61
|
-
end
|
62
|
-
|
63
|
-
def contains?(commit)
|
64
|
-
!@base.lib.branch_contains(commit, self.name).empty?
|
65
|
-
end
|
66
|
-
|
67
|
-
def merge(branch = nil, message = nil)
|
68
|
-
if branch
|
69
|
-
in_branch do
|
70
|
-
@base.merge(branch, message)
|
71
|
-
false
|
72
|
-
end
|
73
|
-
# merge a branch into this one
|
74
|
-
else
|
75
|
-
# merge this branch into the current one
|
76
|
-
@base.merge(@name)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def update_ref(commit)
|
81
|
-
@base.lib.update_ref(@full, commit)
|
82
|
-
end
|
83
|
-
|
84
|
-
def to_a
|
85
|
-
[@full]
|
86
|
-
end
|
87
|
-
|
88
|
-
def to_s
|
89
|
-
@full
|
90
|
-
end
|
91
|
-
|
92
|
-
private
|
93
|
-
|
94
|
-
def check_if_create
|
95
|
-
@base.lib.branch_new(@name) rescue nil
|
96
|
-
end
|
97
|
-
|
98
|
-
def determine_current
|
99
|
-
@base.lib.branch_current == @name
|
100
|
-
end
|
101
|
-
|
102
|
-
# Given a full branch name return an Array containing the remote and branch names.
|
103
|
-
#
|
104
|
-
# Removes 'remotes' from the beggining of the name (if present).
|
105
|
-
# Takes the second part (splittign by '/') as the remote name.
|
106
|
-
# Takes the rest as the repo name (can also hold one or more '/').
|
107
|
-
#
|
108
|
-
# Example:
|
109
|
-
# parse_name('master') #=> [nil, 'master']
|
110
|
-
# parse_name('origin/master') #=> ['origin', 'master']
|
111
|
-
# parse_name('remotes/origin/master') #=> ['origin', 'master']
|
112
|
-
# parse_name('origin/master/v2') #=> ['origin', 'master/v2']
|
113
|
-
#
|
114
|
-
# param [String] name branch full name.
|
115
|
-
# return [<Git::Remote,NilClass,String>] an Array containing the remote and branch names.
|
116
|
-
def parse_name(name)
|
117
|
-
if name.match(/^(?:remotes)?\/([^\/]+)\/(.+)/)
|
118
|
-
return [Git::Remote.new(@base, $1), $2]
|
119
|
-
end
|
120
|
-
|
121
|
-
return [nil, name]
|
122
|
-
end
|
123
|
-
|
124
|
-
end
|
125
|
-
|
126
|
-
end
|
data/lib/git/branches.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
module Git
|
2
|
-
|
3
|
-
# object that holds all the available branches
|
4
|
-
class Branches
|
5
|
-
|
6
|
-
include Enumerable
|
7
|
-
|
8
|
-
def initialize(base)
|
9
|
-
@branches = {}
|
10
|
-
|
11
|
-
@base = base
|
12
|
-
|
13
|
-
@base.lib.branches_all.each do |b|
|
14
|
-
@branches[b[0]] = Git::Branch.new(@base, b[0])
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def local
|
19
|
-
self.select { |b| !b.remote }
|
20
|
-
end
|
21
|
-
|
22
|
-
def remote
|
23
|
-
self.select { |b| b.remote }
|
24
|
-
end
|
25
|
-
|
26
|
-
# array like methods
|
27
|
-
|
28
|
-
def size
|
29
|
-
@branches.size
|
30
|
-
end
|
31
|
-
|
32
|
-
def each(&block)
|
33
|
-
@branches.values.each(&block)
|
34
|
-
end
|
35
|
-
|
36
|
-
# Returns the target branch
|
37
|
-
#
|
38
|
-
# Example:
|
39
|
-
# Given (git branch -a):
|
40
|
-
# master
|
41
|
-
# remotes/working/master
|
42
|
-
#
|
43
|
-
# g.branches['master'].full #=> 'master'
|
44
|
-
# g.branches['working/master'].full => 'remotes/working/master'
|
45
|
-
# g.branches['remotes/working/master'].full => 'remotes/working/master'
|
46
|
-
#
|
47
|
-
# @param [#to_s] branch_name the target branch name.
|
48
|
-
# @return [Git::Branch] the target branch.
|
49
|
-
def [](branch_name)
|
50
|
-
@branches.values.inject(@branches) do |branches, branch|
|
51
|
-
branches[branch.full] ||= branch
|
52
|
-
|
53
|
-
# This is how Git (version 1.7.9.5) works.
|
54
|
-
# Lets you ignore the 'remotes' if its at the beginning of the branch full name (even if is not a real remote branch).
|
55
|
-
branches[branch.full.sub('remotes/', '')] ||= branch if branch.full =~ /^remotes\/.+/
|
56
|
-
|
57
|
-
branches
|
58
|
-
end[branch_name.to_s]
|
59
|
-
end
|
60
|
-
|
61
|
-
def to_s
|
62
|
-
out = ''
|
63
|
-
@branches.each do |k, b|
|
64
|
-
out << (b.current ? '* ' : ' ') << b.to_s << "\n"
|
65
|
-
end
|
66
|
-
out
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
data/lib/git/config.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
module Git
|
2
|
-
|
3
|
-
class Config
|
4
|
-
|
5
|
-
attr_writer :binary_path, :git_ssh
|
6
|
-
|
7
|
-
def initialize
|
8
|
-
@binary_path = nil
|
9
|
-
@git_ssh = nil
|
10
|
-
end
|
11
|
-
|
12
|
-
def binary_path
|
13
|
-
@binary_path || ENV['GIT_PATH'] && File.join(ENV['GIT_PATH'], 'git') || 'git'
|
14
|
-
end
|
15
|
-
|
16
|
-
def git_ssh
|
17
|
-
@git_ssh || ENV['GIT_SSH']
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
data/lib/git/diff.rb
DELETED
@@ -1,155 +0,0 @@
|
|
1
|
-
module Git
|
2
|
-
|
3
|
-
# object that holds the last X commits on given branch
|
4
|
-
class Diff
|
5
|
-
include Enumerable
|
6
|
-
|
7
|
-
def initialize(base, from = nil, to = nil)
|
8
|
-
@base = base
|
9
|
-
@from = from && from.to_s
|
10
|
-
@to = to && to.to_s
|
11
|
-
|
12
|
-
@path = nil
|
13
|
-
@full_diff = nil
|
14
|
-
@full_diff_files = nil
|
15
|
-
@stats = nil
|
16
|
-
end
|
17
|
-
attr_reader :from, :to
|
18
|
-
|
19
|
-
def name_status
|
20
|
-
cache_name_status
|
21
|
-
end
|
22
|
-
|
23
|
-
def path(path)
|
24
|
-
@path = path
|
25
|
-
return self
|
26
|
-
end
|
27
|
-
|
28
|
-
def size
|
29
|
-
cache_stats
|
30
|
-
@stats[:total][:files]
|
31
|
-
end
|
32
|
-
|
33
|
-
def lines
|
34
|
-
cache_stats
|
35
|
-
@stats[:total][:lines]
|
36
|
-
end
|
37
|
-
|
38
|
-
def deletions
|
39
|
-
cache_stats
|
40
|
-
@stats[:total][:deletions]
|
41
|
-
end
|
42
|
-
|
43
|
-
def insertions
|
44
|
-
cache_stats
|
45
|
-
@stats[:total][:insertions]
|
46
|
-
end
|
47
|
-
|
48
|
-
def stats
|
49
|
-
cache_stats
|
50
|
-
@stats
|
51
|
-
end
|
52
|
-
|
53
|
-
# if file is provided and is writable, it will write the patch into the file
|
54
|
-
def patch(file = nil)
|
55
|
-
cache_full
|
56
|
-
@full_diff
|
57
|
-
end
|
58
|
-
alias_method :to_s, :patch
|
59
|
-
|
60
|
-
# enumerable methods
|
61
|
-
|
62
|
-
def [](key)
|
63
|
-
process_full
|
64
|
-
@full_diff_files.assoc(key)[1]
|
65
|
-
end
|
66
|
-
|
67
|
-
def each(&block) # :yields: each Git::DiffFile in turn
|
68
|
-
process_full
|
69
|
-
@full_diff_files.map { |file| file[1] }.each(&block)
|
70
|
-
end
|
71
|
-
|
72
|
-
class DiffFile
|
73
|
-
attr_accessor :patch, :path, :mode, :src, :dst, :type
|
74
|
-
@base = nil
|
75
|
-
NIL_BLOB_REGEXP = /\A0{4,40}\z/.freeze
|
76
|
-
|
77
|
-
def initialize(base, hash)
|
78
|
-
@base = base
|
79
|
-
@patch = hash[:patch]
|
80
|
-
@path = hash[:path]
|
81
|
-
@mode = hash[:mode]
|
82
|
-
@src = hash[:src]
|
83
|
-
@dst = hash[:dst]
|
84
|
-
@type = hash[:type]
|
85
|
-
@binary = hash[:binary]
|
86
|
-
end
|
87
|
-
|
88
|
-
def binary?
|
89
|
-
!!@binary
|
90
|
-
end
|
91
|
-
|
92
|
-
def blob(type = :dst)
|
93
|
-
if type == :src && !NIL_BLOB_REGEXP.match(@src)
|
94
|
-
@base.object(@src)
|
95
|
-
elsif !NIL_BLOB_REGEXP.match(@dst)
|
96
|
-
@base.object(@dst)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
private
|
102
|
-
|
103
|
-
def cache_full
|
104
|
-
@full_diff ||= @base.lib.diff_full(@from, @to, {:path_limiter => @path})
|
105
|
-
end
|
106
|
-
|
107
|
-
def process_full
|
108
|
-
return if @full_diff_files
|
109
|
-
cache_full
|
110
|
-
@full_diff_files = process_full_diff
|
111
|
-
end
|
112
|
-
|
113
|
-
def cache_stats
|
114
|
-
@stats ||= @base.lib.diff_stats(@from, @to, {:path_limiter => @path})
|
115
|
-
end
|
116
|
-
|
117
|
-
def cache_name_status
|
118
|
-
@name_status ||= @base.lib.diff_name_status(@from, @to, {:path => @path})
|
119
|
-
end
|
120
|
-
|
121
|
-
# break up @diff_full
|
122
|
-
def process_full_diff
|
123
|
-
defaults = {
|
124
|
-
:mode => '',
|
125
|
-
:src => '',
|
126
|
-
:dst => '',
|
127
|
-
:type => 'modified'
|
128
|
-
}
|
129
|
-
final = {}
|
130
|
-
current_file = nil
|
131
|
-
@full_diff.split("\n").each do |line|
|
132
|
-
if m = %r{\Adiff --git ("?)a/(.+?)\1 ("?)b/(.+?)\3\z}.match(line)
|
133
|
-
current_file = Git::EscapedPath.new(m[2]).unescape
|
134
|
-
final[current_file] = defaults.merge({:patch => line, :path => current_file})
|
135
|
-
else
|
136
|
-
if m = /^index ([0-9a-f]{4,40})\.\.([0-9a-f]{4,40})( ......)*/.match(line)
|
137
|
-
final[current_file][:src] = m[1]
|
138
|
-
final[current_file][:dst] = m[2]
|
139
|
-
final[current_file][:mode] = m[3].strip if m[3]
|
140
|
-
end
|
141
|
-
if m = /^([[:alpha:]]*?) file mode (......)/.match(line)
|
142
|
-
final[current_file][:type] = m[1]
|
143
|
-
final[current_file][:mode] = m[2]
|
144
|
-
end
|
145
|
-
if m = /^Binary files /.match(line)
|
146
|
-
final[current_file][:binary] = true
|
147
|
-
end
|
148
|
-
final[current_file][:patch] << "\n" + line
|
149
|
-
end
|
150
|
-
end
|
151
|
-
final.map { |e| [e[0], DiffFile.new(@base, e[1])] }
|
152
|
-
end
|
153
|
-
|
154
|
-
end
|
155
|
-
end
|
data/lib/git/encoding_utils.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'rubygems'
|
3
|
-
require 'rchardet'
|
4
|
-
|
5
|
-
module Git
|
6
|
-
# Method that can be used to detect and normalize string encoding
|
7
|
-
module EncodingUtils
|
8
|
-
def self.default_encoding
|
9
|
-
__ENCODING__.name
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.best_guess_encoding
|
13
|
-
# Encoding::ASCII_8BIT.name
|
14
|
-
Encoding::UTF_8.name
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.detected_encoding(str)
|
18
|
-
CharDet.detect(str)['encoding'] || best_guess_encoding
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.encoding_options
|
22
|
-
{ invalid: :replace, undef: :replace }
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.normalize_encoding(str)
|
26
|
-
return str if str.valid_encoding? && str.encoding.name == default_encoding
|
27
|
-
|
28
|
-
return str.encode(default_encoding, str.encoding, **encoding_options) if str.valid_encoding?
|
29
|
-
|
30
|
-
str.encode(default_encoding, detected_encoding(str), **encoding_options)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/lib/git/escaped_path.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Git
|
4
|
-
# Represents an escaped Git path string
|
5
|
-
#
|
6
|
-
# Git commands that output paths (e.g. ls-files, diff), will escape usual
|
7
|
-
# characters in the path with backslashes in the same way C escapes control
|
8
|
-
# characters (e.g. \t for TAB, \n for LF, \\ for backslash) or bytes with values
|
9
|
-
# larger than 0x80 (e.g. octal \302\265 for "micro" in UTF-8).
|
10
|
-
#
|
11
|
-
# @example
|
12
|
-
# Git::GitPath.new('\302\265').unescape # => "µ"
|
13
|
-
#
|
14
|
-
class EscapedPath
|
15
|
-
UNESCAPES = {
|
16
|
-
'a' => 0x07,
|
17
|
-
'b' => 0x08,
|
18
|
-
't' => 0x09,
|
19
|
-
'n' => 0x0a,
|
20
|
-
'v' => 0x0b,
|
21
|
-
'f' => 0x0c,
|
22
|
-
'r' => 0x0d,
|
23
|
-
'e' => 0x1b,
|
24
|
-
'\\' => 0x5c,
|
25
|
-
'"' => 0x22,
|
26
|
-
"'" => 0x27
|
27
|
-
}.freeze
|
28
|
-
|
29
|
-
attr_reader :path
|
30
|
-
|
31
|
-
def initialize(path)
|
32
|
-
@path = path
|
33
|
-
end
|
34
|
-
|
35
|
-
# Convert an escaped path to an unescaped path
|
36
|
-
def unescape
|
37
|
-
bytes = escaped_path_to_bytes(path)
|
38
|
-
str = bytes.pack('C*')
|
39
|
-
str.force_encoding(Encoding::UTF_8)
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
def extract_octal(path, index)
|
45
|
-
[path[index + 1..index + 4].to_i(8), 4]
|
46
|
-
end
|
47
|
-
|
48
|
-
def extract_escape(path, index)
|
49
|
-
[UNESCAPES[path[index + 1]], 2]
|
50
|
-
end
|
51
|
-
|
52
|
-
def extract_single_char(path, index)
|
53
|
-
[path[index].ord, 1]
|
54
|
-
end
|
55
|
-
|
56
|
-
def next_byte(path, index)
|
57
|
-
if path[index] == '\\' && path[index + 1] >= '0' && path[index + 1] <= '7'
|
58
|
-
extract_octal(path, index)
|
59
|
-
elsif path[index] == '\\' && UNESCAPES.include?(path[index + 1])
|
60
|
-
extract_escape(path, index)
|
61
|
-
else
|
62
|
-
extract_single_char(path, index)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def escaped_path_to_bytes(path)
|
67
|
-
index = 0
|
68
|
-
[].tap do |bytes|
|
69
|
-
while index < path.length
|
70
|
-
byte, chars_used = next_byte(path, index)
|
71
|
-
bytes << byte
|
72
|
-
index += chars_used
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|