okay 11.0.0 → 12.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 644512c8f6e9711f699eb2dcc1b140afb21942035549aaf78c6324205d17ca42
4
- data.tar.gz: 5401ca57ba69b8a35b3e37acbf52645cb9571aa0fa0a3608be07b160952550db
3
+ metadata.gz: d440392d2c9d86cd93c694b618d46f18935339c70897e5b6869a8b556ed17953
4
+ data.tar.gz: 63cb6c74cacfa7985707ae8bae9213b680ec5b097c184d588199ed7b7f5d6a21
5
5
  SHA512:
6
- metadata.gz: 6f41a2ede17a3af2d5c8dae9e3f26747c3c3739a3be23f619d934247eac3a8a2600125561224d9b263d23f49c633afc40dfc588ff9307ce273edf6221472b9f9
7
- data.tar.gz: d9b54ddcd04277369c0aa0ea80c23a1157c84d9f8c3555314446f1a981abf0eba2245968dc5ed16cfb4cd36b220be5c7c140f5fb08ff9edfbe70f8cb743f685c
6
+ metadata.gz: f45cc9fe3188a53c2492459b1e4c614ab0d7400a0b891a5b1324304b0d34c5650e9a6f048c71427c770bc7205fd283f167e537244efd31df299454445ddfb477
7
+ data.tar.gz: e6d44d3186e410d8e9f95050534c4e1f13f7c86a53d6b0e4eb6197d0e3e053ba7184251166d21495b537b86bde07ea757fc37d0f246950f4027a734a103467c8
data/.cirrus.yml ADDED
@@ -0,0 +1,23 @@
1
+ # Allow compute credits usage by collaborators and bors.
2
+ use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' || $CIRRUS_BRANCH == 'master' || $CIRRUS_BRANCH == 'staging' || $CIRRUS_BRANCH == 'trying'
3
+
4
+ Linux_task:
5
+ container:
6
+ matrix:
7
+ - image: ruby:2.6-slim
8
+ - image: ruby:2.7-slim
9
+ - image: ruby:3.0-slim
10
+ install_script:
11
+ # git is installed since the gemspec uses it.
12
+ - apt-get update && apt-get install -y git
13
+ - gem install bundler
14
+ - bundle install
15
+ script:
16
+ - ruby --version
17
+ - bundle exec rake spec
18
+
19
+ task:
20
+ name: CI Success
21
+ container: {image: "busybox"}
22
+ depends_on:
23
+ - Linux
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
data/Gemfile CHANGED
@@ -2,5 +2,14 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
+ # Okay only supports Ruby versions under "normal maintenance".
6
+ # This number should be updated when a Ruby version goes into security
7
+ # maintenance.
8
+ #
9
+ # Ruby maintenance info: https://www.ruby-lang.org/en/downloads/branches/
10
+ #
11
+ # NOTE: Update how_is.gemspec when this is updated!
12
+ ruby ">= 2.6"
13
+
5
14
  # Specify your gem's dependencies in okay.gemspec
6
15
  gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,40 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ okay (11.0.0)
5
+ cacert
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ cacert (0.6.0)
11
+ diff-lcs (1.4.4)
12
+ rake (12.3.3)
13
+ rspec (3.10.0)
14
+ rspec-core (~> 3.10.0)
15
+ rspec-expectations (~> 3.10.0)
16
+ rspec-mocks (~> 3.10.0)
17
+ rspec-core (3.10.1)
18
+ rspec-support (~> 3.10.0)
19
+ rspec-expectations (3.10.1)
20
+ diff-lcs (>= 1.2.0, < 2.0)
21
+ rspec-support (~> 3.10.0)
22
+ rspec-mocks (3.10.2)
23
+ diff-lcs (>= 1.2.0, < 2.0)
24
+ rspec-support (~> 3.10.0)
25
+ rspec-support (3.10.2)
26
+
27
+ PLATFORMS
28
+ x86_64-freebsd-13
29
+
30
+ DEPENDENCIES
31
+ bundler (~> 2.0)
32
+ okay!
33
+ rake (~> 12.3)
34
+ rspec (~> 3.8)
35
+
36
+ RUBY VERSION
37
+ ruby 3.0.1p64
38
+
39
+ BUNDLED WITH
40
+ 2.2.15
data/README.md CHANGED
@@ -43,7 +43,7 @@ Or install it yourself as:
43
43
  ### HTTP
44
44
 
45
45
  * `GET` and `POST` requests supported.
46
- * TLS is supported, using [`openssl/better_defaults`](https://github.com/duckinator/openssl-better_defaults/) to improve security on old Ruby versions.
46
+ * TLS is used automatically for HTTPS URLs.
47
47
  * Does not handle HTTP 307 redirects correctly. (Because it changes it to a GET
48
48
  request.)
49
49
 
data/bin/httpbin ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ docker run -p 80:80 kennethreitz/httpbin
data/bors.toml ADDED
@@ -0,0 +1,5 @@
1
+ status = ["CI Success"]
2
+
3
+ # Uncomment this to use a two hour timeout.
4
+ # The default is one hour.
5
+ #timeout_sec = 7200
data/lib/okay/graphql.rb CHANGED
@@ -17,7 +17,9 @@ module Okay
17
17
  # login
18
18
  # }
19
19
  # }
20
- # response = request.submit!(:github, {bearer_token: ENV["DEMO_GITHUB_TOKEN"]})
20
+ #
21
+ # token = ENV["DEMO_GITHUB_TOKEN"]
22
+ # response = request.submit!(:github, {bearer_token: token})
21
23
  # pp JSON.parse(response.body)
22
24
  class GraphQL
23
25
  Container = Struct.new(:value) do
@@ -36,6 +38,7 @@ module Okay
36
38
  instance_exec(&query)
37
39
  end
38
40
 
41
+ # rubocop:disable Metrics/AbcSize
39
42
  def method_missing(name, *args, **kwargs, &block)
40
43
  query_part = @indent_str + name.to_s
41
44
  if !args.empty? || !kwargs.empty?
@@ -59,6 +62,7 @@ module Okay
59
62
 
60
63
  @query += "#{query_part}\n"
61
64
  end
65
+ # rubocop:enable Metrics/AbcSize
62
66
 
63
67
  def to_s
64
68
  @query
data/lib/okay/http.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "okay/version"
4
- require "openssl/better_defaults"
5
4
  require "net/https"
6
5
  require "cacert"
7
6
 
@@ -66,7 +65,8 @@ module Okay
66
65
  # were a form.
67
66
  def self.post(url, data: nil, form_data: nil, headers: {})
68
67
  if !data.nil? && !form_data.nil?
69
- raise ArgumentError, "cannot specify data and form_data arguments simultaneously."
68
+ raise ArgumentError,
69
+ "cannot specify data and form_data arguments simultaneously."
70
70
  end
71
71
 
72
72
  if form_data.nil?
@@ -78,6 +78,8 @@ module Okay
78
78
  send_request(:Post, url, nil, body, headers)
79
79
  end
80
80
 
81
+ # rubocop:disable Metrics/AbcSize
82
+
81
83
  # Helper method for actually creating a request.
82
84
  #
83
85
  # @param http_method [Symbol] A symbol representing the class name for
@@ -86,7 +88,8 @@ module Okay
86
88
  # @param parameters [Hash, nil] Request parameters (for the query string).
87
89
  # @param body [String, nil] Request body.
88
90
  # @param redirect_limit [Numeric] The maximum number of redirects allowed.
89
- def self.send_request(http_method, url, parameters, body, headers, redirect_limit = DEFAULT_REDIRECT_LIMIT)
91
+ def self.send_request(http_method, url, parameters, body, headers,
92
+ redirect_limit = DEFAULT_REDIRECT_LIMIT)
90
93
  if redirect_limit <= 0
91
94
  raise RedirectLimitError, "request exceeded redirect limit"
92
95
  end
@@ -95,7 +98,9 @@ module Okay
95
98
  uri = URI.parse(url)
96
99
 
97
100
  # Set the query string for the request.
98
- uri.query = URI.encode_www_form(parameters) unless parameters.nil?
101
+ unless parameters.nil? || parameters.empty?
102
+ uri.query = URI.encode_www_form(parameters)
103
+ end
99
104
 
100
105
  options = {
101
106
  # If the URI starts with "https://", enable SSL/TLS.
@@ -127,13 +132,26 @@ module Okay
127
132
  # Follow a redirect.
128
133
  # Decrements +redirect_limit+ while doing so, to avoid redirect loops.
129
134
  # NOTE: Does not handle HTTP 307. https://httpstatuses.com/307
130
- send_request(:Get, response["location"], parameters, body, headers, redirect_limit - 1)
135
+ new_url = response["location"]
136
+ if new_url.start_with?("/")
137
+ new_uri = uri.dup
138
+ new_uri.path = response["location"]
139
+ new_url = new_uri.to_s
140
+ elsif new_url.start_with?(".")
141
+ new_uri = uri.dup
142
+ new_uri.path += "/" + response["location"]
143
+ new_url = new_uri.to_s
144
+ end
145
+ send_request(:Get, new_url, parameters, body, headers,
146
+ redirect_limit - 1)
131
147
  else
132
148
  response
133
149
  end
134
150
  end
135
151
  end
136
152
 
153
+ # rubocop:enable Metrics/AbcSize
154
+
137
155
  # Make +send_request+ a private method.
138
156
  private_class_method :send_request
139
157
  end
data/lib/okay/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Okay
4
- VERSION = "11.0.0"
4
+ VERSION = "12.0.0"
5
5
  end
data/okay.gemspec CHANGED
@@ -23,11 +23,18 @@ Gem::Specification.new do |spec|
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = ["lib"]
25
25
 
26
- spec.add_runtime_dependency "openssl-better_defaults"
26
+ # Okay only supports Ruby versions under "normal maintenance".
27
+ # This number should be updated when a Ruby version goes into security
28
+ # maintenance.
29
+ #
30
+ # Ruby maintenance info: https://www.ruby-lang.org/en/downloads/branches/
31
+ #
32
+ # NOTE: Update Gemfile when this is updated!
33
+ spec.required_ruby_version = ">= 2.6"
34
+
27
35
  spec.add_runtime_dependency "cacert"
28
36
 
29
37
  spec.add_development_dependency "bundler", "~> 2.0"
30
38
  spec.add_development_dependency "rake", "~> 12.3"
31
39
  spec.add_development_dependency "rspec", "~> 3.8"
32
- spec.add_development_dependency "rubocop", "~> 0.49.1"
33
40
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: okay
3
3
  version: !ruby/object:Gem::Version
4
- version: 11.0.0
4
+ version: 12.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ellen Marie Dash
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-02 00:00:00.000000000 Z
11
+ date: 2021-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: openssl-better_defaults
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: cacert
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -80,20 +66,6 @@ dependencies:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
68
  version: '3.8'
83
- - !ruby/object:Gem::Dependency
84
- name: rubocop
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 0.49.1
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 0.49.1
97
69
  description: Okay, minimalist implementations of common utilities in Ruby. E.g., HTTP
98
70
  fetchers.
99
71
  email:
@@ -102,18 +74,19 @@ executables: []
102
74
  extensions: []
103
75
  extra_rdoc_files: []
104
76
  files:
105
- - ".github_changelog_generator"
77
+ - ".cirrus.yml"
106
78
  - ".gitignore"
107
79
  - ".rspec"
108
- - ".rubocop.yml"
109
- - ".travis.yml"
110
80
  - CODE_OF_CONDUCT.md
111
81
  - Gemfile
82
+ - Gemfile.lock
112
83
  - LICENSE.txt
113
84
  - README.md
114
85
  - Rakefile
115
86
  - bin/console
87
+ - bin/httpbin
116
88
  - bin/setup
89
+ - bors.toml
117
90
  - examples/github-graphql-example.rb
118
91
  - examples/github-graphql-intentional-failure-example.rb
119
92
  - lib/okay.rb
@@ -129,7 +102,7 @@ homepage: https://github.com/duckinator/okay
129
102
  licenses:
130
103
  - MIT
131
104
  metadata: {}
132
- post_install_message:
105
+ post_install_message:
133
106
  rdoc_options: []
134
107
  require_paths:
135
108
  - lib
@@ -137,15 +110,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
137
110
  requirements:
138
111
  - - ">="
139
112
  - !ruby/object:Gem::Version
140
- version: '0'
113
+ version: '2.6'
141
114
  required_rubygems_version: !ruby/object:Gem::Requirement
142
115
  requirements:
143
116
  - - ">="
144
117
  - !ruby/object:Gem::Version
145
118
  version: '0'
146
119
  requirements: []
147
- rubygems_version: 3.0.2
148
- signing_key:
120
+ rubygems_version: 3.2.15
121
+ signing_key:
149
122
  specification_version: 4
150
123
  summary: Okay, minimalist implementations of common utilities.
151
124
  test_files: []
@@ -1,2 +0,0 @@
1
- user=how-is
2
- project=how_is
data/.rubocop.yml DELETED
@@ -1,223 +0,0 @@
1
- AllCops:
2
- DisplayCopNames: true
3
- DisplayStyleGuide: true
4
- TargetRubyVersion: 2.4
5
- Exclude:
6
- - 'okay.gemspec'
7
- - 'bin/*'
8
- - 'examples/*'
9
- - '**/*~'
10
- - 'spec/capture_warnings.rb'
11
-
12
- # Exceptions should inherit from StandardError.
13
- # (RuboCop default is to inherit from RuntimeError.)
14
- Lint/InheritException:
15
- EnforcedStyle: standard_error
16
-
17
- Metrics/AbcSize:
18
- Max: 17
19
-
20
- Metrics/BlockLength:
21
- Exclude:
22
- - 'spec/**/*_spec.rb'
23
-
24
-
25
- # Getting this back to the default of 100 would be nice,
26
- # but the few cases that exceed it don't seem overly concerning.
27
- Metrics/ClassLength:
28
- Max: 120
29
-
30
- # Still try for 80, but we'll allow 110 because there's a not-insignificant
31
- # number of cases where we have long lines.
32
- #
33
- # It may be worth revisiting this in the future and refactoring those lines.
34
- Metrics/LineLength:
35
- Max: 120
36
- AllowHeredoc: true
37
-
38
- # Too short methods lead to extraction of single-use methods, which can make
39
- # the code easier to read (by naming things), but can also clutter the class
40
- Metrics/MethodLength:
41
- Max: 25
42
-
43
- Metrics/ParameterLists:
44
- Max: 6
45
-
46
- Style/Alias:
47
- EnforcedStyle: prefer_alias_method
48
-
49
- # Most readable form.
50
- Layout/AlignHash:
51
- EnforcedHashRocketStyle: table
52
- EnforcedColonStyle: table
53
- # Disable because it wound up conflicting with a lot of things like:
54
- # foo('bar',
55
- # baz: 'asdf',
56
- # beep: 'boop')
57
- #
58
- # I suspect these'll disappear when overarching architectural issues are
59
- # addressed.
60
- Enabled: false
61
-
62
- Layout/AlignParameters:
63
- # See Style/AlignedHash.
64
- Enabled: false
65
-
66
- # This codebase may be English, but some English words contain diacritics.
67
- Style/AsciiComments:
68
- Enabled: false
69
-
70
- # Despite the fact that some English words contain diacritics, we want all
71
- # method names to be writable by people who don't have an easy way to type
72
- # words with diacritics.
73
- Style/AsciiIdentifiers:
74
- Enabled: true
75
-
76
- # { ... } for multi-line blocks is okay, follow Weirichs rule instead:
77
- # https://web.archive.org/web/20140221124509/http://onestepback.org/index.cgi/Tech/Ruby/BraceVsDoEnd.rdoc
78
- Style/BlockDelimiters:
79
- Enabled: false
80
-
81
- # There's more nuance around this than RuboCop seems capable of.
82
- Style/BracesAroundHashParameters:
83
- Enabled: false
84
-
85
- # Don't force use of Time or Date; DateTime is okay.
86
- Style/DateTime:
87
- Enabled: false
88
-
89
- # Unicode is good, mkay?
90
- Style/Encoding:
91
- Enabled: true
92
-
93
- Style/RedundantSelf:
94
- Enabled: false
95
-
96
- # Force Unix line endings.
97
- Layout/EndOfLine:
98
- Enabled: true
99
- EnforcedStyle: lf
100
-
101
- # A lot of the approaches I use for making things readable makes this angry.
102
- # E.g., formatting multiple consecutive assignments so that the equal signs
103
- # and values line up.
104
- #
105
- # foobar = 'blah'
106
- # baz = 'asdf'
107
- # beep = 'boop'
108
- Layout/ExtraSpacing:
109
- Enabled: false
110
-
111
- # # bad
112
- #
113
- # format('%<greeting>s', greeting: 'Hello')
114
- # format('%s', 'Hello')
115
- #
116
- # # good
117
- #
118
- # format('%{greeting}', greeting: 'Hello')
119
- Style/FormatStringToken:
120
- EnforcedStyle: template
121
-
122
- # Freeze string literals to future-proof the code.
123
- Style/FrozenStringLiteralComment:
124
- Enabled: true
125
- EnforcedStyle: always
126
-
127
- # Mixing hash styles just looks silly.
128
- # http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/HashSyntax
129
- Style/HashSyntax:
130
- EnforcedStyle: no_mixed_keys
131
-
132
- Layout/IndentHash:
133
- Enabled: true
134
- EnforcedStyle: consistent
135
-
136
- Layout/IndentArray:
137
- Enabled: true
138
- EnforcedStyle: consistent
139
-
140
- Style/ConditionalAssignment:
141
- Enabled: false
142
-
143
- # I deplore assignments in conditions and never want them in any codebase
144
- # I have direct control over.
145
- Style/ParenthesesAroundCondition:
146
- AllowSafeAssignment: false
147
- Lint/AssignmentInCondition:
148
- AllowSafeAssignment: false
149
-
150
- # Use [] for `%`-literal delimiters (e.g. for %q[]) that RuboCop doesn't define
151
- # anything for. (E.g., %q[].)
152
- #
153
- # The reason I prefer [] instead of () is that most of the time I use
154
- # `%`-literals is inside of function calls, and using () makes it blend in too
155
- # much.
156
- Style/PercentLiteralDelimiters:
157
- Enabled: true
158
- PreferredDelimiters:
159
- default: "[]"
160
- '%w': '[]'
161
- '%W': '[]'
162
-
163
- # `has_key?` and `has_value?` are clearer than `key?` and `value?`.
164
- Style/PreferredHashMethods:
165
- Enabled: true
166
- EnforcedStyle: verbose
167
-
168
- # do / end blocks should be used for side effects,
169
- # methods that run a block for side effects and have
170
- # a useful return value are rare, assign the return
171
- # value to a local variable for those cases.
172
- Style/MethodCalledOnDoEndBlock:
173
- Enabled: true
174
-
175
- # Indent method calls relative to the receiver, e.g.:
176
- # foo \
177
- # .bar \
178
- # .baz \
179
- # .asdf
180
- Layout/MultilineMethodCallIndentation:
181
- EnforcedStyle: indented_relative_to_receiver
182
-
183
- # Indenting the chained dots beneath each other is not supported by this cop,
184
- # see https://github.com/bbatsov/rubocop/issues/1633
185
- Layout/MultilineOperationIndentation:
186
- Enabled: false
187
-
188
- # {'foo' => 'bar'} not { 'foo' => 'bar' }
189
- Layout/SpaceInsideHashLiteralBraces:
190
- Enabled: true
191
- EnforcedStyle: no_space
192
-
193
- # I find "foo > 0" more readable than "foo.positive?" personally.
194
- Style/NumericPredicate:
195
- Enabled: false
196
-
197
- # https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/RegexpLiteral
198
- Style/RegexpLiteral:
199
- Enabled: false
200
-
201
- # Use double quotes everywhere by default.
202
- Style/StringLiterals:
203
- EnforcedStyle: double_quotes
204
-
205
- # Prefer [:foo, :bar] over %i[foo bar].
206
- Style/SymbolArray:
207
- Enabled: true
208
- EnforcedStyle: brackets
209
-
210
- # Prefer ["foo", "bar"] over %w[foo bar].
211
- Style/WordArray:
212
- Enabled: true
213
- EnforcedStyle: brackets
214
-
215
- # Require parentheses around complex ternary conditions.
216
- Style/TernaryParentheses:
217
- Enabled: true
218
- EnforcedStyle: require_parentheses_when_complex
219
-
220
- # Require a comma after the last item in an array or hash if each item is on
221
- # its own line.
222
- Style/TrailingCommaInLiteral:
223
- EnforcedStyleForMultiline: comma
data/.travis.yml DELETED
@@ -1,25 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.4
5
- - 2.5
6
- - 2.6
7
- - ruby-head
8
-
9
- matrix:
10
- allow_failures:
11
- - rvm:
12
- - ruby-head
13
-
14
- before_install:
15
- - gem install bundler
16
-
17
- # See https://bors.tech/documentation/getting-started/
18
- branches:
19
- only:
20
- # This is where pull requests from "bors r+" are built.
21
- - staging
22
- # This is where pull requests from "bors try" are built.
23
- - trying
24
- # Build pull requests.
25
- - master