lg_pod_plugin 1.0.4 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/lib/git/author.rb +14 -0
  3. data/lib/git/base/factory.rb +101 -0
  4. data/lib/git/base.rb +670 -0
  5. data/lib/git/branch.rb +126 -0
  6. data/lib/git/branches.rb +71 -0
  7. data/lib/git/config.rb +22 -0
  8. data/lib/git/diff.rb +155 -0
  9. data/lib/git/encoding_utils.rb +33 -0
  10. data/lib/git/escaped_path.rb +77 -0
  11. data/lib/git/index.rb +5 -0
  12. data/lib/git/lib.rb +1215 -0
  13. data/lib/git/log.rb +135 -0
  14. data/lib/git/object.rb +312 -0
  15. data/lib/git/path.rb +31 -0
  16. data/lib/git/remote.rb +36 -0
  17. data/lib/git/repository.rb +6 -0
  18. data/lib/git/stash.rb +27 -0
  19. data/lib/git/stashes.rb +55 -0
  20. data/lib/git/status.rb +199 -0
  21. data/lib/git/url.rb +127 -0
  22. data/lib/git/version.rb +5 -0
  23. data/lib/git/working_directory.rb +4 -0
  24. data/lib/git/worktree.rb +38 -0
  25. data/lib/git/worktrees.rb +47 -0
  26. data/lib/git.rb +326 -0
  27. data/lib/lg_pod_plugin/database.rb +104 -104
  28. data/lib/lg_pod_plugin/{download.rb → downloader.rb} +1 -1
  29. data/lib/lg_pod_plugin/file_path.rb +1 -1
  30. data/lib/lg_pod_plugin/git_util.rb +154 -50
  31. data/lib/lg_pod_plugin/install.rb +27 -21
  32. data/lib/lg_pod_plugin/l_cache.rb +13 -14
  33. data/lib/lg_pod_plugin/l_util.rb +39 -0
  34. data/lib/lg_pod_plugin/request.rb +9 -10
  35. data/lib/lg_pod_plugin/version.rb +1 -1
  36. data/lib/lg_pod_plugin.rb +1 -3
  37. data/lib/rchardet/big5freq.rb +927 -0
  38. data/lib/rchardet/big5prober.rb +42 -0
  39. data/lib/rchardet/chardistribution.rb +250 -0
  40. data/lib/rchardet/charsetgroupprober.rb +110 -0
  41. data/lib/rchardet/charsetprober.rb +70 -0
  42. data/lib/rchardet/codingstatemachine.rb +67 -0
  43. data/lib/rchardet/constants.rb +42 -0
  44. data/lib/rchardet/escprober.rb +90 -0
  45. data/lib/rchardet/escsm.rb +245 -0
  46. data/lib/rchardet/eucjpprober.rb +88 -0
  47. data/lib/rchardet/euckrfreq.rb +597 -0
  48. data/lib/rchardet/euckrprober.rb +42 -0
  49. data/lib/rchardet/euctwfreq.rb +431 -0
  50. data/lib/rchardet/euctwprober.rb +42 -0
  51. data/lib/rchardet/gb18030freq.rb +474 -0
  52. data/lib/rchardet/gb18030prober.rb +42 -0
  53. data/lib/rchardet/hebrewprober.rb +289 -0
  54. data/lib/rchardet/jisfreq.rb +571 -0
  55. data/lib/rchardet/jpcntx.rb +229 -0
  56. data/lib/rchardet/langbulgarianmodel.rb +229 -0
  57. data/lib/rchardet/langcyrillicmodel.rb +330 -0
  58. data/lib/rchardet/langgreekmodel.rb +227 -0
  59. data/lib/rchardet/langhebrewmodel.rb +202 -0
  60. data/lib/rchardet/langhungarianmodel.rb +226 -0
  61. data/lib/rchardet/langthaimodel.rb +201 -0
  62. data/lib/rchardet/latin1prober.rb +147 -0
  63. data/lib/rchardet/mbcharsetprober.rb +89 -0
  64. data/lib/rchardet/mbcsgroupprober.rb +47 -0
  65. data/lib/rchardet/mbcssm.rb +542 -0
  66. data/lib/rchardet/sbcharsetprober.rb +122 -0
  67. data/lib/rchardet/sbcsgroupprober.rb +58 -0
  68. data/lib/rchardet/sjisprober.rb +88 -0
  69. data/lib/rchardet/universaldetector.rb +179 -0
  70. data/lib/rchardet/utf8prober.rb +87 -0
  71. data/lib/rchardet/version.rb +3 -0
  72. data/lib/rchardet.rb +67 -0
  73. data/lib/zip/central_directory.rb +212 -0
  74. data/lib/zip/compressor.rb +9 -0
  75. data/lib/zip/constants.rb +115 -0
  76. data/lib/zip/crypto/decrypted_io.rb +40 -0
  77. data/lib/zip/crypto/encryption.rb +11 -0
  78. data/lib/zip/crypto/null_encryption.rb +43 -0
  79. data/lib/zip/crypto/traditional_encryption.rb +99 -0
  80. data/lib/zip/decompressor.rb +31 -0
  81. data/lib/zip/deflater.rb +34 -0
  82. data/lib/zip/dos_time.rb +53 -0
  83. data/lib/zip/entry.rb +719 -0
  84. data/lib/zip/entry_set.rb +88 -0
  85. data/lib/zip/errors.rb +19 -0
  86. data/lib/zip/extra_field/generic.rb +44 -0
  87. data/lib/zip/extra_field/ntfs.rb +94 -0
  88. data/lib/zip/extra_field/old_unix.rb +46 -0
  89. data/lib/zip/extra_field/universal_time.rb +77 -0
  90. data/lib/zip/extra_field/unix.rb +39 -0
  91. data/lib/zip/extra_field/zip64.rb +70 -0
  92. data/lib/zip/extra_field/zip64_placeholder.rb +15 -0
  93. data/lib/zip/extra_field.rb +103 -0
  94. data/lib/zip/file.rb +468 -0
  95. data/lib/zip/filesystem.rb +643 -0
  96. data/lib/zip/inflater.rb +54 -0
  97. data/lib/zip/input_stream.rb +180 -0
  98. data/lib/zip/ioextras/abstract_input_stream.rb +122 -0
  99. data/lib/zip/ioextras/abstract_output_stream.rb +43 -0
  100. data/lib/zip/ioextras.rb +36 -0
  101. data/lib/zip/null_compressor.rb +15 -0
  102. data/lib/zip/null_decompressor.rb +19 -0
  103. data/lib/zip/null_input_stream.rb +10 -0
  104. data/lib/zip/output_stream.rb +198 -0
  105. data/lib/zip/pass_thru_compressor.rb +23 -0
  106. data/lib/zip/pass_thru_decompressor.rb +31 -0
  107. data/lib/zip/streamable_directory.rb +15 -0
  108. data/lib/zip/streamable_stream.rb +52 -0
  109. data/lib/zip/version.rb +3 -0
  110. data/lib/zip.rb +72 -0
  111. metadata +103 -31
data/lib/git/branch.rb ADDED
@@ -0,0 +1,126 @@
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
@@ -0,0 +1,71 @@
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 ADDED
@@ -0,0 +1,22 @@
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 ADDED
@@ -0,0 +1,155 @@
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
@@ -0,0 +1,33 @@
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
@@ -0,0 +1,77 @@
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
data/lib/git/index.rb ADDED
@@ -0,0 +1,5 @@
1
+ module Git
2
+ class Index < Git::Path
3
+
4
+ end
5
+ end