debugger-ruby_core_source 1.0.0
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.
- data/LEGAL +534 -0
- data/LICENSE +23 -0
- data/LICENSE.txt +22 -0
- data/OLD_README +29 -0
- data/README.md +27 -0
- data/RUBY_LICENSE +56 -0
- data/Rakefile +32 -0
- data/debugger-ruby_core_source.gemspec +18 -0
- data/lib/contrib/progressbar.rb +237 -0
- data/lib/contrib/uri_ext.rb +289 -0
- data/lib/debugger/ruby_core_source.rb +7 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/debug.h +36 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/dln.h +41 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/encdb.h +163 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/eval_intern.h +232 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/gc.h +77 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/id.h +170 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/insns.inc +179 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/insns_info.inc +695 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/iseq.h +104 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/known_errors.inc +731 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/method.h +103 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/node.h +483 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/node_name.inc +208 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/opt_sc.inc +670 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/optinsn.inc +30 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/optunifs.inc +116 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/parse.h +187 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/regenc.h +211 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/regint.h +841 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/regparse.h +354 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/revision.h +1 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/thread_pthread.h +27 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/thread_win32.h +33 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/timev.h +21 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/transcode_data.h +109 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/transdb.h +179 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/version.h +55 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/vm.inc +3055 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/vm_core.h +707 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/vm_exec.h +184 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/vm_insnhelper.h +208 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/vm_opts.h +51 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/vmtc.inc +97 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/addr2line.h +21 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/atomic.h +56 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/constant.h +34 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/debug.h +41 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/dln.h +50 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/encdb.h +167 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/eval_intern.h +234 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/gc.h +98 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/id.h +175 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/insns.inc +179 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/insns_info.inc +695 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/internal.h +227 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/iseq.h +125 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/known_errors.inc +731 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/method.h +105 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/node.h +503 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/node_name.inc +208 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/opt_sc.inc +670 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/optinsn.inc +30 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/optunifs.inc +116 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/parse.h +186 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/regenc.h +219 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/regint.h +851 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/regparse.h +362 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/revision.h +1 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/thread_pthread.h +51 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/thread_win32.h +40 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/timev.h +21 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/transcode_data.h +117 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/transdb.h +189 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/version.h +52 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/vm.inc +3067 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/vm_core.h +756 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/vm_exec.h +184 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/vm_insnhelper.h +220 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/vm_opts.h +51 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/vmtc.inc +97 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/addr2line.h +21 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/atomic.h +56 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/constant.h +34 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/debug.h +41 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/dln.h +50 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/encdb.h +167 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/eval_intern.h +234 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/gc.h +98 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/id.h +175 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/insns.inc +179 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/insns_info.inc +695 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/internal.h +231 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/iseq.h +125 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/known_errors.inc +731 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/method.h +105 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/node.h +503 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/node_name.inc +208 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/opt_sc.inc +670 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/optinsn.inc +30 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/optunifs.inc +116 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/parse.h +186 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/regenc.h +219 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/regint.h +850 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/regparse.h +362 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/revision.h +1 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/thread_pthread.h +51 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/thread_win32.h +40 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/timev.h +21 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/transcode_data.h +117 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/transdb.h +189 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/version.h +52 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/vm.inc +3067 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/vm_core.h +756 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/vm_exec.h +184 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/vm_insnhelper.h +220 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/vm_opts.h +51 -0
- data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/vmtc.inc +97 -0
- data/lib/debugger/ruby_core_source/version.rb +5 -0
- data/lib/ruby_core_source.rb +62 -0
- metadata +198 -0
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
#
|
|
2
|
+
# I've striped down dependencies on Net::SSH and Facets to
|
|
3
|
+
# stay as simple as possible.
|
|
4
|
+
#
|
|
5
|
+
# Original code from Assaf Arkin, released under Apache License
|
|
6
|
+
# (http://buildr.rubyforge.org/license.html)
|
|
7
|
+
#
|
|
8
|
+
require 'cgi'
|
|
9
|
+
require 'uri'
|
|
10
|
+
require 'net/http'
|
|
11
|
+
require 'net/https'
|
|
12
|
+
require 'tempfile'
|
|
13
|
+
require 'fileutils'
|
|
14
|
+
|
|
15
|
+
# show progress of download
|
|
16
|
+
require File.join(File.dirname(__FILE__), 'progressbar')
|
|
17
|
+
|
|
18
|
+
# Not quite open-uri, but similar. Provides read and write methods for the resource represented by the URI.
|
|
19
|
+
# Currently supports reads for URI::HTTP and writes for URI::SFTP. Also provides convenience methods for
|
|
20
|
+
# downloads and uploads.
|
|
21
|
+
module URI
|
|
22
|
+
# Raised when trying to read/download a resource that doesn't exist.
|
|
23
|
+
class NotFoundError < RuntimeError; end
|
|
24
|
+
|
|
25
|
+
class << self
|
|
26
|
+
# :call-seq:
|
|
27
|
+
# read(uri, options?) => content
|
|
28
|
+
# read(uri, options?) { |chunk| ... }
|
|
29
|
+
#
|
|
30
|
+
# Reads from the resource behind this URI. The first form returns the content of the resource,
|
|
31
|
+
# the second form yields to the block with each chunk of content (usually more than one).
|
|
32
|
+
#
|
|
33
|
+
# For example:
|
|
34
|
+
# File.open "image.jpg", "w" do |file|
|
|
35
|
+
# URI.read("http://example.com/image.jpg") { |chunk| file.write chunk }
|
|
36
|
+
# end
|
|
37
|
+
# Shorter version:
|
|
38
|
+
# File.open("image.jpg", "w") { |file| file.write URI.read("http://example.com/image.jpg") }
|
|
39
|
+
#
|
|
40
|
+
# Supported options:
|
|
41
|
+
# * :modified -- Only download if file modified since this timestamp. Returns nil if not modified.
|
|
42
|
+
# * :progress -- Show the progress bar while reading.
|
|
43
|
+
def read(uri, options = nil, &block)
|
|
44
|
+
uri = URI.parse(uri.to_s) unless URI === uri
|
|
45
|
+
uri.read(options, &block)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# :call-seq:
|
|
49
|
+
# download(uri, target, options?)
|
|
50
|
+
#
|
|
51
|
+
# Downloads the resource to the target.
|
|
52
|
+
#
|
|
53
|
+
# The target may be a file name (string or task), in which case the file is created from the resource.
|
|
54
|
+
# The target may also be any object that responds to +write+, e.g. File, StringIO, Pipe.
|
|
55
|
+
#
|
|
56
|
+
# Use the progress bar when running in verbose mode.
|
|
57
|
+
def download(uri, target, options = nil)
|
|
58
|
+
uri = URI.parse(uri.to_s) unless URI === uri
|
|
59
|
+
uri.download(target, options)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# :call-seq:
|
|
63
|
+
# write(uri, content, options?)
|
|
64
|
+
# write(uri, options?) { |bytes| .. }
|
|
65
|
+
#
|
|
66
|
+
# Writes to the resource behind the URI. The first form writes the content from a string or an object
|
|
67
|
+
# that responds to +read+ and optionally +size+. The second form writes the content by yielding to the
|
|
68
|
+
# block. Each yield should return up to the specified number of bytes, the last yield returns nil.
|
|
69
|
+
#
|
|
70
|
+
# For example:
|
|
71
|
+
# File.open "killer-app.jar", "rb" do |file|
|
|
72
|
+
# write("sftp://localhost/jars/killer-app.jar") { |chunk| file.read(chunk) }
|
|
73
|
+
# end
|
|
74
|
+
# Or:
|
|
75
|
+
# write "sftp://localhost/jars/killer-app.jar", File.read("killer-app.jar")
|
|
76
|
+
#
|
|
77
|
+
# Supported options:
|
|
78
|
+
# * :progress -- Show the progress bar while reading.
|
|
79
|
+
def write(uri, *args, &block)
|
|
80
|
+
uri = URI.parse(uri.to_s) unless URI === uri
|
|
81
|
+
uri.write(*args, &block)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
class Generic
|
|
86
|
+
|
|
87
|
+
# :call-seq:
|
|
88
|
+
# read(options?) => content
|
|
89
|
+
# read(options?) { |chunk| ... }
|
|
90
|
+
#
|
|
91
|
+
# Reads from the resource behind this URI. The first form returns the content of the resource,
|
|
92
|
+
# the second form yields to the block with each chunk of content (usually more than one).
|
|
93
|
+
#
|
|
94
|
+
# For options, see URI::read.
|
|
95
|
+
def read(options = nil, &block)
|
|
96
|
+
fail "This protocol doesn't support reading (yet, how about helping by implementing it?)"
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# :call-seq:
|
|
100
|
+
# download(target, options?)
|
|
101
|
+
#
|
|
102
|
+
# Downloads the resource to the target.
|
|
103
|
+
#
|
|
104
|
+
# The target may be a file name (string or task), in which case the file is created from the resource.
|
|
105
|
+
# The target may also be any object that responds to +write+, e.g. File, StringIO, Pipe.
|
|
106
|
+
#
|
|
107
|
+
# Use the progress bar when running in verbose mode.
|
|
108
|
+
def download(target, options = {})
|
|
109
|
+
case target
|
|
110
|
+
when String
|
|
111
|
+
# If download breaks we end up with a partial file which is
|
|
112
|
+
# worse than not having a file at all, so download to temporary
|
|
113
|
+
# file and then move over.
|
|
114
|
+
modified = File.stat(target).mtime if File.exist?(target)
|
|
115
|
+
temp = nil
|
|
116
|
+
Tempfile.open(File.basename(target)) do |tf|
|
|
117
|
+
tf.binmode
|
|
118
|
+
read(options.merge(:modified => modified)) { |chunk| tf.write chunk }
|
|
119
|
+
temp = tf
|
|
120
|
+
end
|
|
121
|
+
FileUtils.mkpath(File.dirname(target))
|
|
122
|
+
FileUtils.move(temp.path, target)
|
|
123
|
+
when File
|
|
124
|
+
read(options.merge(:modified => target.mtime)) { |chunk| target.write chunk }
|
|
125
|
+
target.flush
|
|
126
|
+
else
|
|
127
|
+
raise ArgumentError, "Expecting a target that is either a file name (string, task) or object that responds to write (file, pipe)." unless target.respond_to?(:write)
|
|
128
|
+
read(options) { |chunk| target.write chunk }
|
|
129
|
+
target.flush
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# :call-seq:
|
|
134
|
+
# write(content, options?)
|
|
135
|
+
# write(options?) { |bytes| .. }
|
|
136
|
+
#
|
|
137
|
+
# Writes to the resource behind the URI. The first form writes the content from a string or an object
|
|
138
|
+
# that responds to +read+ and optionally +size+. The second form writes the content by yielding to the
|
|
139
|
+
# block. Each yield should return up to the specified number of bytes, the last yield returns nil.
|
|
140
|
+
#
|
|
141
|
+
# For options, see URI::write.
|
|
142
|
+
def write(*args, &block)
|
|
143
|
+
options = args.pop if Hash === args.last
|
|
144
|
+
options ||= {}
|
|
145
|
+
if String === args.first
|
|
146
|
+
ios = StringIO.new(args.first, "r")
|
|
147
|
+
write(options.merge(:size => args.first.size)) { |bytes| ios.read(bytes) }
|
|
148
|
+
elsif args.first.respond_to?(:read)
|
|
149
|
+
size = args.first.size rescue nil
|
|
150
|
+
write({ :size => size }.merge(options)) { |bytes| args.first.read(bytes) }
|
|
151
|
+
elsif args.empty? && block
|
|
152
|
+
write_internal(options, &block)
|
|
153
|
+
else
|
|
154
|
+
raise ArgumentError, "Either give me the content, or pass me a block, otherwise what would I upload?"
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
protected
|
|
159
|
+
|
|
160
|
+
# :call-seq:
|
|
161
|
+
# with_progress_bar(enable, file_name, size) { |progress| ... }
|
|
162
|
+
#
|
|
163
|
+
# Displays a progress bar while executing the block. The first argument must be true for the
|
|
164
|
+
# progress bar to show (TTY output also required), as a convenient for selectively using the
|
|
165
|
+
# progress bar from a single block.
|
|
166
|
+
#
|
|
167
|
+
# The second argument provides a filename to display, the third its size in bytes.
|
|
168
|
+
#
|
|
169
|
+
# The block is yielded with a progress object that implements a single method.
|
|
170
|
+
# Call << for each block of bytes down/uploaded.
|
|
171
|
+
def with_progress_bar(enable, file_name, size) #:nodoc:
|
|
172
|
+
if enable && $stdout.isatty
|
|
173
|
+
progress_bar = Console::ProgressBar.new(file_name, size)
|
|
174
|
+
# Extend the progress bar so we can display count/total.
|
|
175
|
+
class << progress_bar
|
|
176
|
+
def total()
|
|
177
|
+
convert_bytes(@total)
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
# Squeeze the filename into 30 characters.
|
|
181
|
+
if file_name.size > 30
|
|
182
|
+
base, ext = File.basename(file_name), File.extname(file_name)
|
|
183
|
+
truncated = "#{base[0..26-ext.to_s.size]}..#{ext}"
|
|
184
|
+
else
|
|
185
|
+
truncated = file_name
|
|
186
|
+
end
|
|
187
|
+
progress_bar.format = "#{CGI.unescape(truncated)}: %3d%% %s %s/%s %s"
|
|
188
|
+
progress_bar.format_arguments = [:percentage, :bar, :bytes, :total, :stat]
|
|
189
|
+
progress_bar.bar_mark = "o"
|
|
190
|
+
|
|
191
|
+
begin
|
|
192
|
+
class << progress_bar
|
|
193
|
+
def <<(bytes)
|
|
194
|
+
inc bytes.respond_to?(:size) ? bytes.size : bytes
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
yield progress_bar
|
|
198
|
+
ensure
|
|
199
|
+
progress_bar.finish
|
|
200
|
+
end
|
|
201
|
+
else
|
|
202
|
+
progress_bar = Object.new
|
|
203
|
+
class << progress_bar
|
|
204
|
+
def <<(bytes)
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
yield progress_bar
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
# :call-seq:
|
|
212
|
+
# proxy_uri() => URI?
|
|
213
|
+
#
|
|
214
|
+
# Returns the proxy server to use. Obtains the proxy from the relevant environment variable (e.g. HTTP_PROXY).
|
|
215
|
+
# Supports exclusions based on host name and port number from environment variable NO_PROXY.
|
|
216
|
+
def proxy_uri()
|
|
217
|
+
proxy = ENV["#{scheme.upcase}_PROXY"]
|
|
218
|
+
proxy = URI.parse(proxy) if String === proxy
|
|
219
|
+
excludes = (ENV["NO_PROXY"] || "").split(/\s*,\s*/).compact
|
|
220
|
+
excludes = excludes.map { |exclude| exclude =~ /:\d+$/ ? exclude : "#{exclude}:*" }
|
|
221
|
+
return proxy unless excludes.any? { |exclude| File.fnmatch(exclude, "#{host}:#{port}") }
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
def write_internal(options, &block) #:nodoc:
|
|
225
|
+
fail "This protocol doesn't support writing (yet, how about helping by implementing it?)"
|
|
226
|
+
end
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
class HTTP #:nodoc:
|
|
230
|
+
|
|
231
|
+
# See URI::Generic#read
|
|
232
|
+
def read(options = nil, &block)
|
|
233
|
+
options ||= {}
|
|
234
|
+
connect do |http|
|
|
235
|
+
puts "Requesting #{self}" #if verbose
|
|
236
|
+
headers = { 'If-Modified-Since' => CGI.rfc1123_date(options[:modified].utc) } if options[:modified]
|
|
237
|
+
request = Net::HTTP::Get.new(request_uri.empty? ? '/' : request_uri, headers)
|
|
238
|
+
request.basic_auth self.user, self.password if self.user
|
|
239
|
+
http.request request do |response|
|
|
240
|
+
case response
|
|
241
|
+
when Net::HTTPNotModified
|
|
242
|
+
# No modification, nothing to do.
|
|
243
|
+
puts 'Not modified since last download' #if verbose
|
|
244
|
+
return nil
|
|
245
|
+
when Net::HTTPRedirection
|
|
246
|
+
# Try to download from the new URI, handle relative redirects.
|
|
247
|
+
puts "Redirected to #{response['Location']}" #if verbose
|
|
248
|
+
return (self + URI.parse(response['location'])).read(options, &block)
|
|
249
|
+
when Net::HTTPOK
|
|
250
|
+
puts "Downloading #{self}" #if verbose
|
|
251
|
+
result = nil
|
|
252
|
+
with_progress_bar options[:progress], path.split('/').last, response.content_length do |progress|
|
|
253
|
+
if block
|
|
254
|
+
response.read_body do |chunk|
|
|
255
|
+
block.call chunk
|
|
256
|
+
progress << chunk
|
|
257
|
+
end
|
|
258
|
+
else
|
|
259
|
+
result = ''
|
|
260
|
+
response.read_body do |chunk|
|
|
261
|
+
result << chunk
|
|
262
|
+
progress << chunk
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
end
|
|
266
|
+
return result
|
|
267
|
+
when Net::HTTPNotFound
|
|
268
|
+
raise NotFoundError, "Looking for #{self} and all I got was a 404!"
|
|
269
|
+
else
|
|
270
|
+
raise RuntimeError, "Failed to download #{self}: #{response.message}"
|
|
271
|
+
end
|
|
272
|
+
end
|
|
273
|
+
end
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
private
|
|
277
|
+
|
|
278
|
+
def connect
|
|
279
|
+
if proxy = proxy_uri
|
|
280
|
+
proxy = URI.parse(proxy) if String === proxy
|
|
281
|
+
http = Net::HTTP.new(host, port, proxy.host, proxy.port, proxy.user, proxy.password)
|
|
282
|
+
else
|
|
283
|
+
http = Net::HTTP.new(host, port)
|
|
284
|
+
end
|
|
285
|
+
http.use_ssl = true if self.instance_of? URI::HTTPS
|
|
286
|
+
yield http
|
|
287
|
+
end
|
|
288
|
+
end
|
|
289
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
|
|
3
|
+
debug.h - YARV Debug function interface
|
|
4
|
+
|
|
5
|
+
$Author: akr $
|
|
6
|
+
created at: 04/08/25 02:33:49 JST
|
|
7
|
+
|
|
8
|
+
Copyright (C) 2004-2007 Koichi Sasada
|
|
9
|
+
|
|
10
|
+
**********************************************************************/
|
|
11
|
+
|
|
12
|
+
#ifndef RUBY_DEBUG_H
|
|
13
|
+
#define RUBY_DEBUG_H
|
|
14
|
+
|
|
15
|
+
#include "ruby/ruby.h"
|
|
16
|
+
#include "node.h"
|
|
17
|
+
|
|
18
|
+
#define dpv(h,v) ruby_debug_print_value(-1, 0, h, v)
|
|
19
|
+
#define dp(v) ruby_debug_print_value(-1, 0, "", v)
|
|
20
|
+
#define dpi(i) ruby_debug_print_id(-1, 0, "", i)
|
|
21
|
+
#define dpn(n) ruby_debug_print_node(-1, 0, "", n)
|
|
22
|
+
|
|
23
|
+
#define bp() ruby_debug_breakpoint()
|
|
24
|
+
|
|
25
|
+
VALUE ruby_debug_print_value(int level, int debug_level, const char *header, VALUE v);
|
|
26
|
+
ID ruby_debug_print_id(int level, int debug_level, const char *header, ID id);
|
|
27
|
+
NODE *ruby_debug_print_node(int level, int debug_level, const char *header, const NODE *node);
|
|
28
|
+
int ruby_debug_print_indent(int level, int debug_level, int indent_level);
|
|
29
|
+
void ruby_debug_breakpoint(void);
|
|
30
|
+
void ruby_debug_gc_check_func(void);
|
|
31
|
+
|
|
32
|
+
#ifdef RUBY_DEBUG_ENV
|
|
33
|
+
void ruby_set_debug_option(const char *str);
|
|
34
|
+
#endif
|
|
35
|
+
|
|
36
|
+
#endif /* RUBY_DEBUG_H */
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
|
|
3
|
+
dln.h -
|
|
4
|
+
|
|
5
|
+
$Author: akr $
|
|
6
|
+
created at: Wed Jan 19 16:53:09 JST 1994
|
|
7
|
+
|
|
8
|
+
Copyright (C) 1993-2007 Yukihiro Matsumoto
|
|
9
|
+
|
|
10
|
+
**********************************************************************/
|
|
11
|
+
|
|
12
|
+
#ifndef DLN_H
|
|
13
|
+
#define DLN_H
|
|
14
|
+
|
|
15
|
+
#ifdef __cplusplus
|
|
16
|
+
# ifndef HAVE_PROTOTYPES
|
|
17
|
+
# define HAVE_PROTOTYPES 1
|
|
18
|
+
# endif
|
|
19
|
+
# ifndef HAVE_STDARG_PROTOTYPES
|
|
20
|
+
# define HAVE_STDARG_PROTOTYPES 1
|
|
21
|
+
# endif
|
|
22
|
+
#endif
|
|
23
|
+
|
|
24
|
+
#undef _
|
|
25
|
+
#ifdef HAVE_PROTOTYPES
|
|
26
|
+
# define _(args) args
|
|
27
|
+
#else
|
|
28
|
+
# define _(args) ()
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
DEPRECATED(char *dln_find_exe(const char*,const char*));
|
|
32
|
+
DEPRECATED(char *dln_find_file(const char*,const char*));
|
|
33
|
+
char *dln_find_exe_r(const char*,const char*,char*,size_t);
|
|
34
|
+
char *dln_find_file_r(const char*,const char*,char*,size_t);
|
|
35
|
+
|
|
36
|
+
#ifdef USE_DLN_A_OUT
|
|
37
|
+
extern char *dln_argv0;
|
|
38
|
+
#endif
|
|
39
|
+
|
|
40
|
+
void *dln_load(const char*);
|
|
41
|
+
#endif
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
ENC_DEFINE("ASCII-8BIT");
|
|
2
|
+
ENC_DEFINE("Big5");
|
|
3
|
+
ENC_DEFINE("Big5-HKSCS");
|
|
4
|
+
ENC_DEFINE("Big5-UAO");
|
|
5
|
+
ENC_DEFINE("CP949");
|
|
6
|
+
ENC_DEFINE("Emacs-Mule");
|
|
7
|
+
ENC_DEFINE("EUC-JP");
|
|
8
|
+
ENC_DEFINE("EUC-KR");
|
|
9
|
+
ENC_DEFINE("EUC-TW");
|
|
10
|
+
ENC_DEFINE("GB18030");
|
|
11
|
+
ENC_DEFINE("GBK");
|
|
12
|
+
ENC_DEFINE("ISO-8859-1");
|
|
13
|
+
ENC_DEFINE("ISO-8859-2");
|
|
14
|
+
ENC_DEFINE("ISO-8859-3");
|
|
15
|
+
ENC_DEFINE("ISO-8859-4");
|
|
16
|
+
ENC_DEFINE("ISO-8859-5");
|
|
17
|
+
ENC_DEFINE("ISO-8859-6");
|
|
18
|
+
ENC_DEFINE("ISO-8859-7");
|
|
19
|
+
ENC_DEFINE("ISO-8859-8");
|
|
20
|
+
ENC_DEFINE("ISO-8859-9");
|
|
21
|
+
ENC_DEFINE("ISO-8859-10");
|
|
22
|
+
ENC_DEFINE("ISO-8859-11");
|
|
23
|
+
ENC_DEFINE("ISO-8859-13");
|
|
24
|
+
ENC_DEFINE("ISO-8859-14");
|
|
25
|
+
ENC_DEFINE("ISO-8859-15");
|
|
26
|
+
ENC_DEFINE("ISO-8859-16");
|
|
27
|
+
ENC_DEFINE("KOI8-R");
|
|
28
|
+
ENC_DEFINE("KOI8-U");
|
|
29
|
+
ENC_DEFINE("Shift_JIS");
|
|
30
|
+
ENC_DEFINE("US-ASCII");
|
|
31
|
+
ENC_DEFINE("UTF-8");
|
|
32
|
+
ENC_DEFINE("UTF-16BE");
|
|
33
|
+
ENC_DEFINE("UTF-16LE");
|
|
34
|
+
ENC_DEFINE("UTF-32BE");
|
|
35
|
+
ENC_DEFINE("UTF-32LE");
|
|
36
|
+
ENC_DEFINE("Windows-1251");
|
|
37
|
+
ENC_ALIAS("BINARY", "ASCII-8BIT");
|
|
38
|
+
ENC_REPLICATE("IBM437", "ASCII-8BIT");
|
|
39
|
+
ENC_ALIAS("CP437", "IBM437");
|
|
40
|
+
ENC_REPLICATE("IBM737", "ASCII-8BIT");
|
|
41
|
+
ENC_ALIAS("CP737", "IBM737");
|
|
42
|
+
ENC_REPLICATE("IBM775", "ASCII-8BIT");
|
|
43
|
+
ENC_ALIAS("CP775", "IBM775");
|
|
44
|
+
ENC_REPLICATE("CP850", "ASCII-8BIT");
|
|
45
|
+
ENC_ALIAS("IBM850", "CP850");
|
|
46
|
+
ENC_REPLICATE("IBM852", "ASCII-8BIT");
|
|
47
|
+
ENC_REPLICATE("CP852", "IBM852");
|
|
48
|
+
ENC_REPLICATE("IBM855", "ASCII-8BIT");
|
|
49
|
+
ENC_REPLICATE("CP855", "IBM855");
|
|
50
|
+
ENC_REPLICATE("IBM857", "ASCII-8BIT");
|
|
51
|
+
ENC_ALIAS("CP857", "IBM857");
|
|
52
|
+
ENC_REPLICATE("IBM860", "ASCII-8BIT");
|
|
53
|
+
ENC_ALIAS("CP860", "IBM860");
|
|
54
|
+
ENC_REPLICATE("IBM861", "ASCII-8BIT");
|
|
55
|
+
ENC_ALIAS("CP861", "IBM861");
|
|
56
|
+
ENC_REPLICATE("IBM862", "ASCII-8BIT");
|
|
57
|
+
ENC_ALIAS("CP862", "IBM862");
|
|
58
|
+
ENC_REPLICATE("IBM863", "ASCII-8BIT");
|
|
59
|
+
ENC_ALIAS("CP863", "IBM863");
|
|
60
|
+
ENC_REPLICATE("IBM864", "ASCII-8BIT");
|
|
61
|
+
ENC_ALIAS("CP864", "IBM864");
|
|
62
|
+
ENC_REPLICATE("IBM865", "ASCII-8BIT");
|
|
63
|
+
ENC_ALIAS("CP865", "IBM865");
|
|
64
|
+
ENC_REPLICATE("IBM866", "ASCII-8BIT");
|
|
65
|
+
ENC_ALIAS("CP866", "IBM866");
|
|
66
|
+
ENC_REPLICATE("IBM869", "ASCII-8BIT");
|
|
67
|
+
ENC_ALIAS("CP869", "IBM869");
|
|
68
|
+
ENC_REPLICATE("Windows-1258", "ASCII-8BIT");
|
|
69
|
+
ENC_ALIAS("CP1258", "Windows-1258");
|
|
70
|
+
ENC_REPLICATE("GB1988", "ASCII-8BIT");
|
|
71
|
+
ENC_REPLICATE("macCentEuro", "ASCII-8BIT");
|
|
72
|
+
ENC_REPLICATE("macCroatian", "ASCII-8BIT");
|
|
73
|
+
ENC_REPLICATE("macCyrillic", "ASCII-8BIT");
|
|
74
|
+
ENC_REPLICATE("macGreek", "ASCII-8BIT");
|
|
75
|
+
ENC_REPLICATE("macIceland", "ASCII-8BIT");
|
|
76
|
+
ENC_REPLICATE("macRoman", "ASCII-8BIT");
|
|
77
|
+
ENC_REPLICATE("macRomania", "ASCII-8BIT");
|
|
78
|
+
ENC_REPLICATE("macThai", "ASCII-8BIT");
|
|
79
|
+
ENC_REPLICATE("macTurkish", "ASCII-8BIT");
|
|
80
|
+
ENC_REPLICATE("macUkraine", "ASCII-8BIT");
|
|
81
|
+
ENC_ALIAS("CP950", "Big5");
|
|
82
|
+
ENC_SET_BASE("Big5-HKSCS", "Big5");
|
|
83
|
+
ENC_ALIAS("CP951", "Big5-HKSCS");
|
|
84
|
+
ENC_SET_BASE("Big5-UAO", "Big5");
|
|
85
|
+
ENC_REPLICATE("stateless-ISO-2022-JP", "Emacs-Mule");
|
|
86
|
+
ENC_ALIAS("eucJP", "EUC-JP") /* UI-OSF Application Platform Profile for Japanese Environment Version 1.1 */;
|
|
87
|
+
ENC_REPLICATE("eucJP-ms", "EUC-JP") /* TOG/JVC CDE/Motif Technical WG */;
|
|
88
|
+
ENC_ALIAS("euc-jp-ms", "eucJP-ms");
|
|
89
|
+
ENC_REPLICATE("CP51932", "EUC-JP");
|
|
90
|
+
ENC_ALIAS("eucKR", "EUC-KR");
|
|
91
|
+
ENC_ALIAS("eucTW", "EUC-TW");
|
|
92
|
+
ENC_ALIAS("EUC-CN", "GB2312");
|
|
93
|
+
ENC_ALIAS("eucCN", "GB2312");
|
|
94
|
+
ENC_REPLICATE("GB12345", "GB2312");
|
|
95
|
+
ENC_ALIAS("CP936", "GBK");
|
|
96
|
+
ENC_DUMMY("ISO-2022-JP");
|
|
97
|
+
ENC_ALIAS("ISO2022-JP", "ISO-2022-JP");
|
|
98
|
+
ENC_REPLICATE("ISO-2022-JP-2", "ISO-2022-JP");
|
|
99
|
+
ENC_ALIAS("ISO2022-JP2", "ISO-2022-JP-2");
|
|
100
|
+
ENC_REPLICATE("CP50220", "ISO-2022-JP");
|
|
101
|
+
ENC_REPLICATE("CP50221", "ISO-2022-JP");
|
|
102
|
+
ENC_ALIAS("ISO8859-1", "ISO-8859-1");
|
|
103
|
+
ENC_REPLICATE("Windows-1252", "ISO-8859-1");
|
|
104
|
+
ENC_ALIAS("CP1252", "Windows-1252");
|
|
105
|
+
ENC_ALIAS("ISO8859-2", "ISO-8859-2");
|
|
106
|
+
ENC_REPLICATE("Windows-1250", "ISO-8859-2");
|
|
107
|
+
ENC_ALIAS("CP1250", "Windows-1250");
|
|
108
|
+
ENC_ALIAS("ISO8859-3", "ISO-8859-3");
|
|
109
|
+
ENC_ALIAS("ISO8859-4", "ISO-8859-4");
|
|
110
|
+
ENC_ALIAS("ISO8859-5", "ISO-8859-5");
|
|
111
|
+
ENC_ALIAS("ISO8859-6", "ISO-8859-6");
|
|
112
|
+
ENC_REPLICATE("Windows-1256", "ISO-8859-6");
|
|
113
|
+
ENC_ALIAS("CP1256", "Windows-1256");
|
|
114
|
+
ENC_ALIAS("ISO8859-7", "ISO-8859-7");
|
|
115
|
+
ENC_REPLICATE("Windows-1253", "ISO-8859-7");
|
|
116
|
+
ENC_ALIAS("CP1253", "Windows-1253");
|
|
117
|
+
ENC_ALIAS("ISO8859-8", "ISO-8859-8");
|
|
118
|
+
ENC_REPLICATE("Windows-1255", "ISO-8859-8");
|
|
119
|
+
ENC_ALIAS("CP1255", "Windows-1255");
|
|
120
|
+
ENC_ALIAS("ISO8859-9", "ISO-8859-9");
|
|
121
|
+
ENC_REPLICATE("Windows-1254", "ISO-8859-9");
|
|
122
|
+
ENC_ALIAS("CP1254", "Windows-1254");
|
|
123
|
+
ENC_ALIAS("ISO8859-10", "ISO-8859-10");
|
|
124
|
+
ENC_ALIAS("ISO8859-11", "ISO-8859-11");
|
|
125
|
+
ENC_REPLICATE("TIS-620", "ISO-8859-11");
|
|
126
|
+
ENC_REPLICATE("Windows-874", "ISO-8859-11");
|
|
127
|
+
ENC_ALIAS("CP874", "Windows-874");
|
|
128
|
+
ENC_ALIAS("ISO8859-13", "ISO-8859-13");
|
|
129
|
+
ENC_REPLICATE("Windows-1257", "ISO-8859-13");
|
|
130
|
+
ENC_ALIAS("CP1257", "Windows-1257");
|
|
131
|
+
ENC_ALIAS("ISO8859-14", "ISO-8859-14");
|
|
132
|
+
ENC_ALIAS("ISO8859-15", "ISO-8859-15");
|
|
133
|
+
ENC_ALIAS("ISO8859-16", "ISO-8859-16");
|
|
134
|
+
ENC_ALIAS("CP878", "KOI8-R");
|
|
135
|
+
ENC_ALIAS("SJIS", "Shift_JIS");
|
|
136
|
+
ENC_REPLICATE("Windows-31J", "Shift_JIS");
|
|
137
|
+
ENC_ALIAS("CP932", "Windows-31J");
|
|
138
|
+
ENC_ALIAS("csWindows31J", "Windows-31J") /* IANA. IE6 don't accept Windows-31J but csWindows31J. */;
|
|
139
|
+
ENC_REPLICATE("MacJapanese", "Shift_JIS");
|
|
140
|
+
ENC_ALIAS("MacJapan", "MacJapanese");
|
|
141
|
+
ENC_ALIAS("ASCII", "US-ASCII");
|
|
142
|
+
ENC_ALIAS("ANSI_X3.4-1968", "US-ASCII");
|
|
143
|
+
ENC_ALIAS("646", "US-ASCII");
|
|
144
|
+
ENC_DUMMY("UTF-7");
|
|
145
|
+
ENC_ALIAS("CP65000", "UTF-7");
|
|
146
|
+
ENC_ALIAS("CP65001", "UTF-8");
|
|
147
|
+
ENC_REPLICATE("UTF8-MAC", "UTF-8");
|
|
148
|
+
ENC_ALIAS("UTF-8-MAC", "UTF8-MAC");
|
|
149
|
+
ENC_ALIAS("UTF-8-HFS", "UTF8-MAC") /* Emacs 23.2 */;
|
|
150
|
+
ENC_ALIAS("UCS-2BE", "UTF-16BE");
|
|
151
|
+
ENC_ALIAS("UCS-4BE", "UTF-32BE");
|
|
152
|
+
ENC_ALIAS("UCS-4LE", "UTF-32LE");
|
|
153
|
+
ENC_ALIAS("CP1251", "Windows-1251");
|
|
154
|
+
ENC_REPLICATE("UTF8-DoCoMo", "UTF-8");
|
|
155
|
+
ENC_REPLICATE("SJIS-DoCoMo", "Windows-31J");
|
|
156
|
+
ENC_REPLICATE("UTF8-KDDI", "UTF-8");
|
|
157
|
+
ENC_REPLICATE("SJIS-KDDI", "Windows-31J");
|
|
158
|
+
ENC_REPLICATE("ISO-2022-JP-KDDI", "ISO-2022-JP");
|
|
159
|
+
ENC_REPLICATE("stateless-ISO-2022-JP-KDDI", "stateless-ISO-2022-JP");
|
|
160
|
+
ENC_REPLICATE("UTF8-SoftBank", "UTF-8");
|
|
161
|
+
ENC_REPLICATE("SJIS-SoftBank", "Windows-31J");
|
|
162
|
+
|
|
163
|
+
#define ENCODING_COUNT 95
|