micro-max-tool 0.0.1

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.
Files changed (64) hide show
  1. checksums.yaml +7 -0
  2. data/httparty-0.24.2/CONTRIBUTING.md +23 -0
  3. data/httparty-0.24.2/Changelog.md +624 -0
  4. data/httparty-0.24.2/Gemfile +27 -0
  5. data/httparty-0.24.2/Guardfile +17 -0
  6. data/httparty-0.24.2/MIT-LICENSE +20 -0
  7. data/httparty-0.24.2/README.md +79 -0
  8. data/httparty-0.24.2/Rakefile +10 -0
  9. data/httparty-0.24.2/bin/httparty +123 -0
  10. data/httparty-0.24.2/cucumber.yml +1 -0
  11. data/httparty-0.24.2/docs/README.md +223 -0
  12. data/httparty-0.24.2/examples/README.md +90 -0
  13. data/httparty-0.24.2/examples/aaws.rb +36 -0
  14. data/httparty-0.24.2/examples/basic.rb +28 -0
  15. data/httparty-0.24.2/examples/body_stream.rb +14 -0
  16. data/httparty-0.24.2/examples/crack.rb +19 -0
  17. data/httparty-0.24.2/examples/custom_parsers.rb +68 -0
  18. data/httparty-0.24.2/examples/delicious.rb +37 -0
  19. data/httparty-0.24.2/examples/google.rb +16 -0
  20. data/httparty-0.24.2/examples/headers_and_user_agents.rb +10 -0
  21. data/httparty-0.24.2/examples/idn.rb +10 -0
  22. data/httparty-0.24.2/examples/logging.rb +36 -0
  23. data/httparty-0.24.2/examples/microsoft_graph.rb +52 -0
  24. data/httparty-0.24.2/examples/multipart.rb +35 -0
  25. data/httparty-0.24.2/examples/nokogiri_html_parser.rb +19 -0
  26. data/httparty-0.24.2/examples/party_foul_mode.rb +90 -0
  27. data/httparty-0.24.2/examples/peer_cert.rb +9 -0
  28. data/httparty-0.24.2/examples/rescue_json.rb +17 -0
  29. data/httparty-0.24.2/examples/rubyurl.rb +14 -0
  30. data/httparty-0.24.2/examples/stackexchange.rb +24 -0
  31. data/httparty-0.24.2/examples/stream_download.rb +26 -0
  32. data/httparty-0.24.2/examples/tripit_sign_in.rb +44 -0
  33. data/httparty-0.24.2/examples/twitter.rb +31 -0
  34. data/httparty-0.24.2/examples/whoismyrep.rb +10 -0
  35. data/httparty-0.24.2/httparty.gemspec +32 -0
  36. data/httparty-0.24.2/lib/httparty/connection_adapter.rb +237 -0
  37. data/httparty-0.24.2/lib/httparty/cookie_hash.rb +23 -0
  38. data/httparty-0.24.2/lib/httparty/decompressor.rb +102 -0
  39. data/httparty-0.24.2/lib/httparty/exceptions.rb +66 -0
  40. data/httparty-0.24.2/lib/httparty/hash_conversions.rb +71 -0
  41. data/httparty-0.24.2/lib/httparty/headers_processor.rb +32 -0
  42. data/httparty-0.24.2/lib/httparty/logger/apache_formatter.rb +47 -0
  43. data/httparty-0.24.2/lib/httparty/logger/curl_formatter.rb +93 -0
  44. data/httparty-0.24.2/lib/httparty/logger/logger.rb +30 -0
  45. data/httparty-0.24.2/lib/httparty/logger/logstash_formatter.rb +62 -0
  46. data/httparty-0.24.2/lib/httparty/module_inheritable_attributes.rb +56 -0
  47. data/httparty-0.24.2/lib/httparty/net_digest_auth.rb +135 -0
  48. data/httparty-0.24.2/lib/httparty/parser.rb +157 -0
  49. data/httparty-0.24.2/lib/httparty/request/body.rb +125 -0
  50. data/httparty-0.24.2/lib/httparty/request/multipart_boundary.rb +13 -0
  51. data/httparty-0.24.2/lib/httparty/request/streaming_multipart_body.rb +190 -0
  52. data/httparty-0.24.2/lib/httparty/request.rb +466 -0
  53. data/httparty-0.24.2/lib/httparty/response/headers.rb +35 -0
  54. data/httparty-0.24.2/lib/httparty/response.rb +156 -0
  55. data/httparty-0.24.2/lib/httparty/response_fragment.rb +21 -0
  56. data/httparty-0.24.2/lib/httparty/text_encoder.rb +72 -0
  57. data/httparty-0.24.2/lib/httparty/utils.rb +13 -0
  58. data/httparty-0.24.2/lib/httparty/version.rb +5 -0
  59. data/httparty-0.24.2/lib/httparty.rb +699 -0
  60. data/httparty-0.24.2/script/release +42 -0
  61. data/httparty-0.24.2/website/css/common.css +47 -0
  62. data/httparty-0.24.2/website/index.html +73 -0
  63. data/micro-max-tool.gemspec +11 -0
  64. metadata +102 -0
@@ -0,0 +1,156 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HTTParty
4
+ class Response < Object
5
+ def self.underscore(string)
6
+ string.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').gsub(/([a-z])([A-Z])/, '\1_\2').downcase
7
+ end
8
+
9
+ def self._load(data)
10
+ req, resp, parsed_resp, resp_body = Marshal.load(data)
11
+
12
+ new(req, resp, -> { parsed_resp }, body: resp_body)
13
+ end
14
+
15
+ attr_reader :request, :response, :body, :headers
16
+
17
+ def initialize(request, response, parsed_block, options = {})
18
+ @request = request
19
+ @response = response
20
+ @body = options[:body] || response.body
21
+ @parsed_block = parsed_block
22
+ @headers = Headers.new(response.to_hash)
23
+
24
+ if request.options[:logger]
25
+ logger = ::HTTParty::Logger.build(
26
+ request.options[:logger],
27
+ request.options[:log_level],
28
+ request.options[:log_format]
29
+ )
30
+ logger.format(request, self)
31
+ end
32
+
33
+ throw_exception
34
+ end
35
+
36
+ def parsed_response
37
+ @parsed_response ||= @parsed_block.call
38
+ end
39
+
40
+ def code
41
+ response.code.to_i
42
+ end
43
+
44
+ def http_version
45
+ response.http_version
46
+ end
47
+
48
+ def tap
49
+ yield self
50
+ self
51
+ end
52
+
53
+ def inspect
54
+ inspect_id = ::Kernel::format '%x', (object_id * 2)
55
+ %(#<#{self.class}:0x#{inspect_id} parsed_response=#{parsed_response.inspect}, @response=#{response.inspect}, @headers=#{headers.inspect}>)
56
+ end
57
+
58
+ CODES_TO_OBJ = ::Net::HTTPResponse::CODE_CLASS_TO_OBJ.merge ::Net::HTTPResponse::CODE_TO_OBJ
59
+
60
+ CODES_TO_OBJ.each do |response_code, klass|
61
+ name = klass.name.sub('Net::HTTP', '')
62
+ name = "#{underscore(name)}?".to_sym
63
+
64
+ define_method(name) do
65
+ klass === response
66
+ end
67
+ end
68
+
69
+ # Support old multiple_choice? method from pre 2.0.0 era.
70
+ if ::RUBY_PLATFORM != 'java'
71
+ alias_method :multiple_choice?, :multiple_choices?
72
+ end
73
+
74
+ # Support old status codes method from pre 2.6.0 era.
75
+ if ::RUBY_PLATFORM != 'java'
76
+ alias_method :gateway_time_out?, :gateway_timeout?
77
+ alias_method :request_entity_too_large?, :payload_too_large?
78
+ alias_method :request_time_out?, :request_timeout?
79
+ alias_method :request_uri_too_long?, :uri_too_long?
80
+ alias_method :requested_range_not_satisfiable?, :range_not_satisfiable?
81
+ end
82
+
83
+ def nil?
84
+ warn_about_nil_deprecation
85
+ response.nil? || response.body.nil? || response.body.empty?
86
+ end
87
+
88
+ def to_s
89
+ if !response.nil? && !response.body.nil? && response.body.respond_to?(:to_s)
90
+ response.body.to_s
91
+ else
92
+ inspect
93
+ end
94
+ end
95
+
96
+ def pretty_print(pp)
97
+ if !parsed_response.nil? && parsed_response.respond_to?(:pretty_print)
98
+ parsed_response.pretty_print(pp)
99
+ else
100
+ super
101
+ end
102
+ end
103
+
104
+ def display(port=$>)
105
+ if !parsed_response.nil? && parsed_response.respond_to?(:display)
106
+ parsed_response.display(port)
107
+ elsif !response.nil? && !response.body.nil? && response.body.respond_to?(:display)
108
+ response.body.display(port)
109
+ else
110
+ port.write(inspect)
111
+ end
112
+ end
113
+
114
+ def respond_to_missing?(name, *args)
115
+ return true if super
116
+ parsed_response.respond_to?(name) || response.respond_to?(name)
117
+ end
118
+
119
+ def _dump(_level)
120
+ Marshal.dump([request, response, parsed_response, body])
121
+ end
122
+
123
+ protected
124
+
125
+ def method_missing(name, *args, &block)
126
+ if parsed_response.respond_to?(name)
127
+ parsed_response.send(name, *args, &block)
128
+ elsif response.respond_to?(name)
129
+ response.send(name, *args, &block)
130
+ else
131
+ super
132
+ end
133
+ end
134
+
135
+ def throw_exception
136
+ if @request.options[:raise_on].to_a.detect { |c| code.to_s.match(/#{c.to_s}/) }
137
+ ::Kernel.raise ::HTTParty::ResponseError.new(@response), "Code #{code} - #{body}"
138
+ end
139
+ end
140
+
141
+ private
142
+
143
+ def warn_about_nil_deprecation
144
+ trace_line = caller.reject { |line| line.include?('httparty') }.first
145
+ warning = "[DEPRECATION] HTTParty will no longer override `response#nil?`. " \
146
+ "This functionality will be removed in future versions. " \
147
+ "Please, add explicit check `response.body.nil? || response.body.empty?`. " \
148
+ "For more info refer to: https://github.com/jnunemaker/httparty/issues/568\n" \
149
+ "#{trace_line}"
150
+
151
+ warn(warning)
152
+ end
153
+ end
154
+ end
155
+
156
+ require 'httparty/response/headers'
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'delegate'
4
+
5
+ module HTTParty
6
+ # Allow access to http_response and code by delegation on fragment
7
+ class ResponseFragment < SimpleDelegator
8
+ attr_reader :http_response, :connection
9
+
10
+ def code
11
+ @http_response.code.to_i
12
+ end
13
+
14
+ def initialize(fragment, http_response, connection)
15
+ @fragment = fragment
16
+ @http_response = http_response
17
+ @connection = connection
18
+ super fragment
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HTTParty
4
+ class TextEncoder
5
+ attr_reader :text, :content_type, :assume_utf16_is_big_endian
6
+
7
+ def initialize(text, assume_utf16_is_big_endian: true, content_type: nil)
8
+ @text = +text
9
+ @content_type = content_type
10
+ @assume_utf16_is_big_endian = assume_utf16_is_big_endian
11
+ end
12
+
13
+ def call
14
+ if can_encode?
15
+ encoded_text
16
+ else
17
+ text
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def can_encode?
24
+ ''.respond_to?(:encoding) && charset
25
+ end
26
+
27
+ def encoded_text
28
+ if 'utf-16'.casecmp(charset) == 0
29
+ encode_utf_16
30
+ else
31
+ encode_with_ruby_encoding
32
+ end
33
+ end
34
+
35
+ def encode_utf_16
36
+ if text.bytesize >= 2
37
+ if text.getbyte(0) == 0xFF && text.getbyte(1) == 0xFE
38
+ return text.force_encoding('UTF-16LE')
39
+ elsif text.getbyte(0) == 0xFE && text.getbyte(1) == 0xFF
40
+ return text.force_encoding('UTF-16BE')
41
+ end
42
+ end
43
+
44
+ if assume_utf16_is_big_endian # option
45
+ text.force_encoding('UTF-16BE')
46
+ else
47
+ text.force_encoding('UTF-16LE')
48
+ end
49
+ end
50
+
51
+ def encode_with_ruby_encoding
52
+ # NOTE: This will raise an argument error if the
53
+ # charset does not exist
54
+ encoding = Encoding.find(charset)
55
+ text.force_encoding(encoding.to_s)
56
+ rescue ArgumentError
57
+ text
58
+ end
59
+
60
+ def charset
61
+ return nil if content_type.nil?
62
+
63
+ if (matchdata = content_type.match(/;\s*charset\s*=\s*([^=,;"\s]+)/i))
64
+ return matchdata.captures.first
65
+ end
66
+
67
+ if (matchdata = content_type.match(/;\s*charset\s*=\s*"((\\.|[^\\"])+)"/i))
68
+ return matchdata.captures.first.gsub(/\\(.)/, '\1')
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HTTParty
4
+ module Utils
5
+ def self.stringify_keys(hash)
6
+ return hash.transform_keys(&:to_s) if hash.respond_to?(:transform_keys)
7
+
8
+ hash.each_with_object({}) do |(key, value), new_hash|
9
+ new_hash[key.to_s] = value
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HTTParty
4
+ VERSION = '0.24.2'
5
+ end