kinetic_sdk 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/GettingStarted.md +64 -0
- data/README.md +383 -0
- data/bin/console +12 -0
- data/bin/setup +8 -0
- data/gems/kontena-websocket-client-0.1.1/Gemfile +4 -0
- data/gems/kontena-websocket-client-0.1.1/LICENSE +190 -0
- data/gems/kontena-websocket-client-0.1.1/README.md +138 -0
- data/gems/kontena-websocket-client-0.1.1/Rakefile +6 -0
- data/gems/kontena-websocket-client-0.1.1/benchmark/benchmark-client.rb +45 -0
- data/gems/kontena-websocket-client-0.1.1/benchmark/benchmark-em.rb +66 -0
- data/gems/kontena-websocket-client-0.1.1/benchmark/benchmark.rb +161 -0
- data/gems/kontena-websocket-client-0.1.1/benchmark/benchmark.sh +17 -0
- data/gems/kontena-websocket-client-0.1.1/benchmark/websocket-echo-server.go +207 -0
- data/gems/kontena-websocket-client-0.1.1/examples/websocket-echo-client.rb +80 -0
- data/gems/kontena-websocket-client-0.1.1/kontena-websocket-client.gemspec +24 -0
- data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/client/connection.rb +119 -0
- data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/client/version.rb +13 -0
- data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/client.rb +848 -0
- data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/error.rb +81 -0
- data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb +55 -0
- data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/openssl_patch.rb +10 -0
- data/gems/kontena-websocket-client-0.1.1/lib/kontena-websocket-client.rb +15 -0
- data/gems/mime-types-3.1/Code-of-Conduct.rdoc +74 -0
- data/gems/mime-types-3.1/Contributing.rdoc +130 -0
- data/gems/mime-types-3.1/History.rdoc +658 -0
- data/gems/mime-types-3.1/Licence.rdoc +25 -0
- data/gems/mime-types-3.1/Manifest.txt +31 -0
- data/gems/mime-types-3.1/README.rdoc +202 -0
- data/gems/mime-types-3.1/Rakefile +254 -0
- data/gems/mime-types-3.1/lib/mime/type/columnar.rb +55 -0
- data/gems/mime-types-3.1/lib/mime/type.rb +573 -0
- data/gems/mime-types-3.1/lib/mime/types/_columnar.rb +135 -0
- data/gems/mime-types-3.1/lib/mime/types/cache.rb +56 -0
- data/gems/mime-types-3.1/lib/mime/types/columnar.rb +1 -0
- data/gems/mime-types-3.1/lib/mime/types/container.rb +30 -0
- data/gems/mime-types-3.1/lib/mime/types/deprecations.rb +32 -0
- data/gems/mime-types-3.1/lib/mime/types/full.rb +17 -0
- data/gems/mime-types-3.1/lib/mime/types/loader.rb +148 -0
- data/gems/mime-types-3.1/lib/mime/types/logger.rb +37 -0
- data/gems/mime-types-3.1/lib/mime/types/registry.rb +81 -0
- data/gems/mime-types-3.1/lib/mime/types.rb +228 -0
- data/gems/mime-types-3.1/lib/mime-types.rb +1 -0
- data/gems/mime-types-3.1/test/bad-fixtures/malformed +9 -0
- data/gems/mime-types-3.1/test/fixture/json.json +1 -0
- data/gems/mime-types-3.1/test/fixture/old-data +9 -0
- data/gems/mime-types-3.1/test/fixture/yaml.yaml +55 -0
- data/gems/mime-types-3.1/test/minitest_helper.rb +13 -0
- data/gems/mime-types-3.1/test/test_mime_type.rb +603 -0
- data/gems/mime-types-3.1/test/test_mime_types.rb +161 -0
- data/gems/mime-types-3.1/test/test_mime_types_cache.rb +109 -0
- data/gems/mime-types-3.1/test/test_mime_types_class.rb +155 -0
- data/gems/mime-types-3.1/test/test_mime_types_lazy.rb +43 -0
- data/gems/mime-types-3.1/test/test_mime_types_loader.rb +32 -0
- data/gems/mime-types-data-3.2016.0521/Code-of-Conduct.md +75 -0
- data/gems/mime-types-data-3.2016.0521/Contributing.md +157 -0
- data/gems/mime-types-data-3.2016.0521/History.md +351 -0
- data/gems/mime-types-data-3.2016.0521/Licence.md +25 -0
- data/gems/mime-types-data-3.2016.0521/Manifest.txt +18 -0
- data/gems/mime-types-data-3.2016.0521/README.md +61 -0
- data/gems/mime-types-data-3.2016.0521/Rakefile +80 -0
- data/gems/mime-types-data-3.2016.0521/data/mime-types.json +1 -0
- data/gems/mime-types-data-3.2016.0521/data/mime.content_type.column +1964 -0
- data/gems/mime-types-data-3.2016.0521/data/mime.docs.column +1964 -0
- data/gems/mime-types-data-3.2016.0521/data/mime.encoding.column +1964 -0
- data/gems/mime-types-data-3.2016.0521/data/mime.flags.column +1964 -0
- data/gems/mime-types-data-3.2016.0521/data/mime.friendly.column +1964 -0
- data/gems/mime-types-data-3.2016.0521/data/mime.pext.column +1964 -0
- data/gems/mime-types-data-3.2016.0521/data/mime.use_instead.column +1964 -0
- data/gems/mime-types-data-3.2016.0521/data/mime.xrefs.column +1964 -0
- data/gems/mime-types-data-3.2016.0521/lib/mime/types/data.rb +21 -0
- data/gems/mime-types-data-3.2016.0521/lib/mime-types-data.rb +3 -0
- data/gems/multipart-post-2.0.0/Gemfile +14 -0
- data/gems/multipart-post-2.0.0/History.txt +60 -0
- data/gems/multipart-post-2.0.0/Manifest.txt +9 -0
- data/gems/multipart-post-2.0.0/README.md +77 -0
- data/gems/multipart-post-2.0.0/Rakefile +9 -0
- data/gems/multipart-post-2.0.0/lib/composite_io.rb +108 -0
- data/gems/multipart-post-2.0.0/lib/multipart_post.rb +9 -0
- data/gems/multipart-post-2.0.0/lib/multipartable.rb +29 -0
- data/gems/multipart-post-2.0.0/lib/net/http/post/multipart.rb +27 -0
- data/gems/multipart-post-2.0.0/lib/parts.rb +96 -0
- data/gems/multipart-post-2.0.0/multipart-post.gemspec +22 -0
- data/gems/multipart-post-2.0.0/test/multibyte.txt +1 -0
- data/gems/multipart-post-2.0.0/test/net/http/post/test_multipart.rb +110 -0
- data/gems/multipart-post-2.0.0/test/test_composite_io.rb +115 -0
- data/gems/multipart-post-2.0.0/test/test_parts.rb +86 -0
- data/gems/parallel-1.12.1/MIT-LICENSE.txt +20 -0
- data/gems/parallel-1.12.1/lib/parallel/processor_count.rb +93 -0
- data/gems/parallel-1.12.1/lib/parallel/version.rb +3 -0
- data/gems/parallel-1.12.1/lib/parallel.rb +500 -0
- data/gems/ruby-progressbar-1.9.0/LICENSE.txt +19 -0
- data/gems/ruby-progressbar-1.9.0/README.md +38 -0
- data/gems/ruby-progressbar-1.9.0/Rakefile +2 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/base.rb +183 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/calculators/length.rb +99 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/calculators/running_average.rb +9 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/bar.rb +96 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/percentage.rb +29 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/rate.rb +43 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/time.rb +107 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/title.rb +13 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components.rb +5 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/errors/invalid_progress_error.rb +4 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/format/formatter.rb +27 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/format/molecule.rb +59 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/format/string.rb +36 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/format.rb +3 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/output.rb +68 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/outputs/non_tty.rb +47 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/outputs/null.rb +33 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/outputs/tty.rb +32 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/progress.rb +118 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements/enumerator.rb +25 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements.rb +1 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/throttle.rb +25 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/time.rb +30 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/timer.rb +72 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/version.rb +3 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar.rb +18 -0
- data/gems/slugify-1.0.7/README +18 -0
- data/gems/slugify-1.0.7/lib/slugify.rb +1012 -0
- data/gems/slugify-1.0.7/lib/slugify_string.rb +11 -0
- data/gems/slugify-1.0.7/tests/slugify_test.rb +116 -0
- data/gems/slugify-1.0.7/tests/string_slugify_test.rb +23 -0
- data/gems/websocket-driver-0.6.5/CHANGELOG.md +123 -0
- data/gems/websocket-driver-0.6.5/LICENSE.md +22 -0
- data/gems/websocket-driver-0.6.5/README.md +369 -0
- data/gems/websocket-driver-0.6.5/examples/tcp_server.rb +28 -0
- data/gems/websocket-driver-0.6.5/ext/websocket-driver/Makefile +264 -0
- data/gems/websocket-driver-0.6.5/ext/websocket-driver/WebsocketMaskService.java +55 -0
- data/gems/websocket-driver-0.6.5/ext/websocket-driver/extconf.rb +4 -0
- data/gems/websocket-driver-0.6.5/ext/websocket-driver/websocket_mask.bundle +0 -0
- data/gems/websocket-driver-0.6.5/ext/websocket-driver/websocket_mask.c +41 -0
- data/gems/websocket-driver-0.6.5/ext/websocket-driver/websocket_mask.o +0 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/client.rb +140 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/draft75.rb +102 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/draft76.rb +96 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/event_emitter.rb +54 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/headers.rb +45 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/hybi/frame.rb +20 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/hybi/message.rb +31 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/hybi.rb +406 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/proxy.rb +68 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/server.rb +80 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/stream_reader.rb +55 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver.rb +199 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/http/headers.rb +112 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/http/request.rb +45 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/http/response.rb +29 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/http.rb +15 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/mask.rb +14 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/websocket_mask.rb +2 -0
- data/gems/websocket-driver-0.6.5/lib/websocket_mask.bundle +0 -0
- data/gems/websocket-driver-0.6.5-java/CHANGELOG.md +123 -0
- data/gems/websocket-driver-0.6.5-java/LICENSE.md +22 -0
- data/gems/websocket-driver-0.6.5-java/README.md +369 -0
- data/gems/websocket-driver-0.6.5-java/examples/tcp_server.rb +28 -0
- data/gems/websocket-driver-0.6.5-java/ext/websocket-driver/WebsocketMaskService.java +55 -0
- data/gems/websocket-driver-0.6.5-java/ext/websocket-driver/extconf.rb +4 -0
- data/gems/websocket-driver-0.6.5-java/ext/websocket-driver/websocket_mask.c +41 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/client.rb +140 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/draft75.rb +102 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/draft76.rb +96 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/event_emitter.rb +54 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/headers.rb +45 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/hybi/frame.rb +20 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/hybi/message.rb +31 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/hybi.rb +406 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/proxy.rb +68 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/server.rb +80 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/stream_reader.rb +55 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver.rb +199 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/http/headers.rb +112 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/http/request.rb +45 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/http/response.rb +29 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/http.rb +15 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/mask.rb +14 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/websocket_mask.rb +2 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket_mask.jar +0 -0
- data/gems/websocket-extensions-0.1.3/CHANGELOG.md +15 -0
- data/gems/websocket-extensions-0.1.3/LICENSE.md +20 -0
- data/gems/websocket-extensions-0.1.3/README.md +313 -0
- data/gems/websocket-extensions-0.1.3/lib/websocket/extensions/parser.rb +111 -0
- data/gems/websocket-extensions-0.1.3/lib/websocket/extensions.rb +181 -0
- data/lib/kinetic-sdk.rb +1 -0
- data/lib/kinetic_sdk/bridgehub/bridgehub-sdk.rb +80 -0
- data/lib/kinetic_sdk/bridgehub/lib/access_keys.rb +67 -0
- data/lib/kinetic_sdk/bridgehub/lib/bridge.rb +69 -0
- data/lib/kinetic_sdk/discussions/discussions-sdk.rb +165 -0
- data/lib/kinetic_sdk/discussions/lib/discussions.rb +107 -0
- data/lib/kinetic_sdk/discussions/lib/invitations.rb +120 -0
- data/lib/kinetic_sdk/discussions/lib/messages.rb +190 -0
- data/lib/kinetic_sdk/discussions/lib/meta.rb +14 -0
- data/lib/kinetic_sdk/discussions/lib/participants.rb +64 -0
- data/lib/kinetic_sdk/discussions/lib/related_items.rb +54 -0
- data/lib/kinetic_sdk/discussions/lib/websockets.rb +96 -0
- data/lib/kinetic_sdk/filehub/filehub-sdk.rb +80 -0
- data/lib/kinetic_sdk/filehub/lib/access_keys.rb +67 -0
- data/lib/kinetic_sdk/filehub/lib/filestores.rb +67 -0
- data/lib/kinetic_sdk/request_ce/lib/attribute_definitions.rb +153 -0
- data/lib/kinetic_sdk/request_ce/lib/bridges.rb +66 -0
- data/lib/kinetic_sdk/request_ce/lib/categories.rb +34 -0
- data/lib/kinetic_sdk/request_ce/lib/datastore_form.rb +110 -0
- data/lib/kinetic_sdk/request_ce/lib/datastore_submissions.rb +157 -0
- data/lib/kinetic_sdk/request_ce/lib/form.rb +99 -0
- data/lib/kinetic_sdk/request_ce/lib/form_types.rb +51 -0
- data/lib/kinetic_sdk/request_ce/lib/jwt.rb +55 -0
- data/lib/kinetic_sdk/request_ce/lib/kapp.rb +93 -0
- data/lib/kinetic_sdk/request_ce/lib/meta.rb +14 -0
- data/lib/kinetic_sdk/request_ce/lib/oauth.rb +37 -0
- data/lib/kinetic_sdk/request_ce/lib/security_policy_definitions.rb +157 -0
- data/lib/kinetic_sdk/request_ce/lib/space.rb +89 -0
- data/lib/kinetic_sdk/request_ce/lib/submissions.rb +215 -0
- data/lib/kinetic_sdk/request_ce/lib/system_api.rb +69 -0
- data/lib/kinetic_sdk/request_ce/lib/teams.rb +113 -0
- data/lib/kinetic_sdk/request_ce/lib/users.rb +245 -0
- data/lib/kinetic_sdk/request_ce/lib/webhook_jobs.rb +142 -0
- data/lib/kinetic_sdk/request_ce/lib/webhooks.rb +192 -0
- data/lib/kinetic_sdk/request_ce/request-ce-sdk.rb +153 -0
- data/lib/kinetic_sdk/task/lib/access_keys.rb +94 -0
- data/lib/kinetic_sdk/task/lib/categories.rb +190 -0
- data/lib/kinetic_sdk/task/lib/config.rb +202 -0
- data/lib/kinetic_sdk/task/lib/engine.rb +42 -0
- data/lib/kinetic_sdk/task/lib/environment.rb +14 -0
- data/lib/kinetic_sdk/task/lib/errors.rb +165 -0
- data/lib/kinetic_sdk/task/lib/groups.rb +112 -0
- data/lib/kinetic_sdk/task/lib/handlers.rb +105 -0
- data/lib/kinetic_sdk/task/lib/health.rb +28 -0
- data/lib/kinetic_sdk/task/lib/license.rb +52 -0
- data/lib/kinetic_sdk/task/lib/policy_rules.rb +166 -0
- data/lib/kinetic_sdk/task/lib/setup.rb +56 -0
- data/lib/kinetic_sdk/task/lib/sources.rb +134 -0
- data/lib/kinetic_sdk/task/lib/tasks.rb +17 -0
- data/lib/kinetic_sdk/task/lib/trees.rb +274 -0
- data/lib/kinetic_sdk/task/lib/users.rb +75 -0
- data/lib/kinetic_sdk/task/task-sdk.rb +92 -0
- data/lib/kinetic_sdk/utils/kinetic-http-headers.rb +150 -0
- data/lib/kinetic_sdk/utils/kinetic-http-response.rb +75 -0
- data/lib/kinetic_sdk/utils/kinetic-http.rb +552 -0
- data/lib/kinetic_sdk/utils/logger.rb +70 -0
- data/lib/kinetic_sdk/utils/random.rb +30 -0
- data/lib/kinetic_sdk/version.rb +7 -0
- data/lib/kinetic_sdk.rb +57 -0
- metadata +414 -0
@@ -0,0 +1,115 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2007-2013 Nick Sieger.
|
3
|
+
# See the file README.txt included with the distribution for
|
4
|
+
# software license details.
|
5
|
+
#++
|
6
|
+
|
7
|
+
require 'composite_io'
|
8
|
+
require 'stringio'
|
9
|
+
require 'test/unit'
|
10
|
+
require 'timeout'
|
11
|
+
|
12
|
+
class CompositeReadIOTest < Test::Unit::TestCase
|
13
|
+
def setup
|
14
|
+
@io = CompositeReadIO.new(CompositeReadIO.new(StringIO.new('the '), StringIO.new('quick ')),
|
15
|
+
StringIO.new('brown '), StringIO.new('fox'))
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_full_read_from_several_ios
|
19
|
+
assert_equal 'the quick brown fox', @io.read
|
20
|
+
end
|
21
|
+
|
22
|
+
unless RUBY_VERSION < '1.9'
|
23
|
+
def test_read_from_multibyte
|
24
|
+
utf8 = File.open(File.dirname(__FILE__)+'/multibyte.txt')
|
25
|
+
binary = StringIO.new("\x86")
|
26
|
+
@io = CompositeReadIO.new(binary,utf8)
|
27
|
+
|
28
|
+
expect = "\x86\xE3\x83\x95\xE3\x82\xA1\xE3\x82\xA4\xE3\x83\xAB\n"
|
29
|
+
expect.force_encoding('BINARY') if expect.respond_to?(:force_encoding)
|
30
|
+
assert_equal expect, @io.read
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_partial_read
|
35
|
+
assert_equal 'the quick', @io.read(9)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_partial_read_to_boundary
|
39
|
+
assert_equal 'the quick ', @io.read(10)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_read_with_size_larger_than_available
|
43
|
+
assert_equal 'the quick brown fox', @io.read(32)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_read_into_buffer
|
47
|
+
buf = ''
|
48
|
+
@io.read(nil, buf)
|
49
|
+
assert_equal 'the quick brown fox', buf
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_multiple_reads
|
53
|
+
assert_equal 'the ', @io.read(4)
|
54
|
+
assert_equal 'quic', @io.read(4)
|
55
|
+
assert_equal 'k br', @io.read(4)
|
56
|
+
assert_equal 'own ', @io.read(4)
|
57
|
+
assert_equal 'fox', @io.read(4)
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_read_after_end
|
61
|
+
@io.read
|
62
|
+
assert_equal "", @io.read
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_read_after_end_with_amount
|
66
|
+
@io.read(32)
|
67
|
+
assert_equal nil, @io.read(32)
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_second_full_read_after_rewinding
|
71
|
+
@io.read
|
72
|
+
@io.rewind
|
73
|
+
assert_equal 'the quick brown fox', @io.read
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_convert_error
|
77
|
+
assert_raises(ArgumentError) {
|
78
|
+
UploadIO.convert!('tmp.txt', 'text/plain', 'tmp.txt', 'tmp.txt')
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
## FIXME excluding on JRuby due to
|
83
|
+
## http://jira.codehaus.org/browse/JRUBY-7109
|
84
|
+
if IO.respond_to?(:copy_stream) && !defined?(JRUBY_VERSION)
|
85
|
+
def test_compatible_with_copy_stream
|
86
|
+
target_io = StringIO.new
|
87
|
+
Timeout.timeout(1) do
|
88
|
+
IO.copy_stream(@io, target_io)
|
89
|
+
end
|
90
|
+
assert_equal "the quick brown fox", target_io.string
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_empty
|
95
|
+
io = CompositeReadIO.new
|
96
|
+
assert_equal "", io.read
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_empty_limited
|
100
|
+
io = CompositeReadIO.new
|
101
|
+
assert_nil io.read(1)
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_empty_parts
|
105
|
+
io = CompositeReadIO.new(StringIO.new, StringIO.new('the '), StringIO.new, StringIO.new('quick'))
|
106
|
+
assert_equal "the", io.read(3)
|
107
|
+
assert_equal " qu", io.read(3)
|
108
|
+
assert_equal "ick", io.read(4)
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_all_empty_parts
|
112
|
+
io = CompositeReadIO.new(StringIO.new, StringIO.new)
|
113
|
+
assert_nil io.read(1)
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2007-2012 Nick Sieger.
|
3
|
+
# See the file README.txt included with the distribution for
|
4
|
+
# software license details.
|
5
|
+
#++
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
|
9
|
+
require 'parts'
|
10
|
+
require 'stringio'
|
11
|
+
require 'composite_io'
|
12
|
+
require 'tempfile'
|
13
|
+
|
14
|
+
|
15
|
+
MULTIBYTE = File.dirname(__FILE__)+'/multibyte.txt'
|
16
|
+
TEMP_FILE = "temp.txt"
|
17
|
+
|
18
|
+
module AssertPartLength
|
19
|
+
def assert_part_length(part)
|
20
|
+
bytes = part.to_io.read
|
21
|
+
bytesize = bytes.respond_to?(:bytesize) ? bytes.bytesize : bytes.length
|
22
|
+
assert_equal bytesize, part.length
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class PartTest < Test::Unit::TestCase
|
27
|
+
def setup
|
28
|
+
@string_with_content_type = Class.new(String) do
|
29
|
+
def content_type; 'application/data'; end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_file_with_upload_io
|
34
|
+
assert Parts::Part.file?(UploadIO.new(__FILE__, "text/plain"))
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_file_with_modified_string
|
38
|
+
assert !Parts::Part.file?(@string_with_content_type.new("Hello"))
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_new_with_modified_string
|
42
|
+
assert_kind_of Parts::ParamPart,
|
43
|
+
Parts::Part.new("boundary", "multibyte", @string_with_content_type.new("Hello"))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class FilePartTest < Test::Unit::TestCase
|
48
|
+
include AssertPartLength
|
49
|
+
|
50
|
+
def setup
|
51
|
+
File.open(TEMP_FILE, "w") {|f| f << "1234567890"}
|
52
|
+
io = UploadIO.new(TEMP_FILE, "text/plain")
|
53
|
+
@part = Parts::FilePart.new("boundary", "afile", io)
|
54
|
+
end
|
55
|
+
|
56
|
+
def teardown
|
57
|
+
File.delete(TEMP_FILE) rescue nil
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_correct_length
|
61
|
+
assert_part_length @part
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_multibyte_file_length
|
65
|
+
assert_part_length Parts::FilePart.new("boundary", "multibyte", UploadIO.new(MULTIBYTE, "text/plain"))
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_multibyte_filename
|
69
|
+
name = File.read(MULTIBYTE, 300)
|
70
|
+
file = Tempfile.new(name.respond_to?(:force_encoding) ? name.force_encoding("UTF-8") : name)
|
71
|
+
assert_part_length Parts::FilePart.new("boundary", "multibyte", UploadIO.new(file, "text/plain"))
|
72
|
+
file.close
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
class ParamPartTest < Test::Unit::TestCase
|
77
|
+
include AssertPartLength
|
78
|
+
|
79
|
+
def setup
|
80
|
+
@part = Parts::ParamPart.new("boundary", "multibyte", File.read(MULTIBYTE))
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_correct_length
|
84
|
+
assert_part_length @part
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (C) 2013 Michael Grosser <michael@grosser.it>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,93 @@
|
|
1
|
+
if RUBY_VERSION.to_f >= 2.2
|
2
|
+
require 'etc'
|
3
|
+
end
|
4
|
+
|
5
|
+
module Parallel
|
6
|
+
module ProcessorCount
|
7
|
+
# Number of processors seen by the OS and used for process scheduling.
|
8
|
+
#
|
9
|
+
# * AIX: /usr/sbin/pmcycles (AIX 5+), /usr/sbin/lsdev
|
10
|
+
# * BSD: /sbin/sysctl
|
11
|
+
# * Cygwin: /proc/cpuinfo
|
12
|
+
# * Darwin: /usr/bin/hwprefs, /usr/sbin/sysctl
|
13
|
+
# * HP-UX: /usr/sbin/ioscan
|
14
|
+
# * IRIX: /usr/sbin/sysconf
|
15
|
+
# * Linux: /proc/cpuinfo
|
16
|
+
# * Minix 3+: /proc/cpuinfo
|
17
|
+
# * Solaris: /usr/sbin/psrinfo
|
18
|
+
# * Tru64 UNIX: /usr/sbin/psrinfo
|
19
|
+
# * UnixWare: /usr/sbin/psrinfo
|
20
|
+
#
|
21
|
+
def processor_count
|
22
|
+
@processor_count ||= begin
|
23
|
+
if defined?(Etc) && Etc.respond_to?(:nprocessors)
|
24
|
+
Etc.nprocessors
|
25
|
+
else
|
26
|
+
os_name = RbConfig::CONFIG["target_os"]
|
27
|
+
if os_name =~ /mingw|mswin/
|
28
|
+
require 'win32ole'
|
29
|
+
result = WIN32OLE.connect("winmgmts://").ExecQuery(
|
30
|
+
"select NumberOfLogicalProcessors from Win32_Processor")
|
31
|
+
result.to_enum.collect(&:NumberOfLogicalProcessors).reduce(:+)
|
32
|
+
elsif File.readable?("/proc/cpuinfo")
|
33
|
+
IO.read("/proc/cpuinfo").scan(/^processor/).size
|
34
|
+
elsif File.executable?("/usr/bin/hwprefs")
|
35
|
+
IO.popen("/usr/bin/hwprefs thread_count").read.to_i
|
36
|
+
elsif File.executable?("/usr/sbin/psrinfo")
|
37
|
+
IO.popen("/usr/sbin/psrinfo").read.scan(/^.*on-*line/).size
|
38
|
+
elsif File.executable?("/usr/sbin/ioscan")
|
39
|
+
IO.popen("/usr/sbin/ioscan -kC processor") do |out|
|
40
|
+
out.read.scan(/^.*processor/).size
|
41
|
+
end
|
42
|
+
elsif File.executable?("/usr/sbin/pmcycles")
|
43
|
+
IO.popen("/usr/sbin/pmcycles -m").read.count("\n")
|
44
|
+
elsif File.executable?("/usr/sbin/lsdev")
|
45
|
+
IO.popen("/usr/sbin/lsdev -Cc processor -S 1").read.count("\n")
|
46
|
+
elsif File.executable?("/usr/sbin/sysconf") and os_name =~ /irix/i
|
47
|
+
IO.popen("/usr/sbin/sysconf NPROC_ONLN").read.to_i
|
48
|
+
elsif File.executable?("/usr/sbin/sysctl")
|
49
|
+
IO.popen("/usr/sbin/sysctl -n hw.ncpu").read.to_i
|
50
|
+
elsif File.executable?("/sbin/sysctl")
|
51
|
+
IO.popen("/sbin/sysctl -n hw.ncpu").read.to_i
|
52
|
+
else
|
53
|
+
$stderr.puts "Unknown platform: " + RbConfig::CONFIG["target_os"]
|
54
|
+
$stderr.puts "Assuming 1 processor."
|
55
|
+
1
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Number of physical processor cores on the current system.
|
62
|
+
#
|
63
|
+
def physical_processor_count
|
64
|
+
@physical_processor_count ||= begin
|
65
|
+
ppc = case RbConfig::CONFIG["target_os"]
|
66
|
+
when /darwin1/
|
67
|
+
IO.popen("/usr/sbin/sysctl -n hw.physicalcpu").read.to_i
|
68
|
+
when /linux/
|
69
|
+
cores = {} # unique physical ID / core ID combinations
|
70
|
+
phy = 0
|
71
|
+
IO.read("/proc/cpuinfo").scan(/^physical id.*|^core id.*/) do |ln|
|
72
|
+
if ln.start_with?("physical")
|
73
|
+
phy = ln[/\d+/]
|
74
|
+
elsif ln.start_with?("core")
|
75
|
+
cid = phy + ":" + ln[/\d+/]
|
76
|
+
cores[cid] = true if not cores[cid]
|
77
|
+
end
|
78
|
+
end
|
79
|
+
cores.count
|
80
|
+
when /mswin|mingw/
|
81
|
+
require 'win32ole'
|
82
|
+
result_set = WIN32OLE.connect("winmgmts://").ExecQuery(
|
83
|
+
"select NumberOfCores from Win32_Processor")
|
84
|
+
result_set.to_enum.collect(&:NumberOfCores).reduce(:+)
|
85
|
+
else
|
86
|
+
processor_count
|
87
|
+
end
|
88
|
+
# fall back to logical count if physical info is invalid
|
89
|
+
ppc > 0 ? ppc : processor_count
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|