stitches 4.0.0.RC1 → 4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d181adb5b8ed9642468e2a8c75ab5ed2cbb01756458885410c8538c0b0a51890
4
- data.tar.gz: 95a4105d911e4e4ebbf927d2bf87efb8bc6dfb1d2537e4f0ebc42caf8569c44d
3
+ metadata.gz: 3ea8633778064ab7646860c9a0682a7290bfbea3d6f3f091c290f50d22f97de2
4
+ data.tar.gz: 0eb1d04f15fc37ab0b0484ae6a73f953426cc5dd1b9efd056e42300caa4c2d04
5
5
  SHA512:
6
- metadata.gz: 442b3c89184c500c7036bb06a355c0df478ea16089777d920aefc62c94dedb37ad0be40a4a46dc558509148b0f08feb335cece9e8e79ac732482977876931d99
7
- data.tar.gz: aeaf701f19b4e8962227cccd7421f3452bf7e2dde77bfa2e7ecce735883adade7903a3392009d351e48258d2b6f231f36d36190a8e65c184e8ad5b9681d94f7f
6
+ metadata.gz: f854d4c3feca2e48b6edfde3174564112b2c0c1d6cb6b93bed960985cc779c1119bcf5ddb65d43d85d3c349d9f440b61e14b1cef27aa6f8c1701768ab5ac1dd5
7
+ data.tar.gz: b19d1b967d4a5e0dc57265475683bbfd8e9f255d15ee0af1a8130832d16e73e54b52b7e34fc025fe170a4322cb30cbddb6f2e631f7c81521953e4e48514bb547
data/README.md CHANGED
@@ -117,6 +117,24 @@ See [the wiki](https://github.com/stitchfix/stitches/wiki/Setup) for how to setu
117
117
  - Acceptance tests that can produce API documentation as they test your app.
118
118
  - Stitches provides [testing support](https://github.com/stitchfix/stitches/wiki/Testing)
119
119
 
120
+ ## API Key Caching
121
+
122
+ Since version 4.0.0, stitches now has the ability to cache API keys in
123
+ memory for a configurable amount of time. This may be an improvement for
124
+ some applications.
125
+
126
+ You must configure the API Cache for it be used.
127
+
128
+ ```ruby
129
+ Stitches.configure do |config|
130
+ config.max_cache_ttl = 5 # seconds
131
+ config.max_cache_size = 100 # how many keys to cache
132
+ end
133
+ ```
134
+
135
+ Your cache size should be
136
+ larger then the number of consumer keys your service has.
137
+
120
138
  ## Developing
121
139
 
122
140
  Although `Stitches.configuration` is global, do not depend directly on that in your logic. Instead, allow all classes to receive a configuration object in their constructor. This makes the classes easier to deal with and change, without incurring much of a real cost to development. Global symbols suck, but are convenient. This is how you make the most of it.
@@ -27,11 +27,6 @@ class Stitches::Configuration
27
27
  @allowlist_regexp = new_allowlist_regexp
28
28
  end
29
29
 
30
- def whitelist_regexp=(new_allowlist_regexp)
31
- self.allowlist_regexp = new_allowlist_regexp
32
- warn("⚠️ 'whitelist' is deprecated in stitches configuration, please use 'allowlist' or auto-update with:\n\n bin/rails g stitches:update_configuration\n\n⚠️ 'whitelist' will be removed in 4.0")
33
- end
34
-
35
30
  # The name of your custom http auth scheme. This must be set, and has no default
36
31
  def custom_http_auth_scheme
37
32
  @custom_http_auth_scheme.to_s
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stitches
4
- VERSION = '4.0.0.RC1'
4
+ VERSION = '4.0.0'
5
5
  end
@@ -14,7 +14,6 @@ require 'stitches/errors'
14
14
  require 'stitches/api_generator'
15
15
  require 'stitches/add_deprecation_generator'
16
16
  require 'stitches/add_enabled_to_api_clients_generator'
17
- require 'stitches/update_configuration_generator'
18
17
  require 'stitches/api_version_constraint'
19
18
  require 'stitches/api_key'
20
19
  require 'stitches/deprecation'
@@ -146,20 +146,4 @@ describe Stitches::Configuration do
146
146
  }.to raise_error(/max_cache_size must be an Integer, not a NilClass/)
147
147
  end
148
148
  end
149
-
150
- context "deprecated options we want to support for backwards compatibility" do
151
-
152
- let(:logger) { double("logger") }
153
- before do
154
- allow(Rails).to receive(:logger).and_return(logger)
155
- allow(logger).to receive(:info)
156
- end
157
-
158
- it "'whitelist' still works for allowlist" do
159
- Stitches.configure do |config|
160
- config.whitelist_regexp = /foo/
161
- end
162
- expect(Stitches.configuration.allowlist_regexp).to eq(/foo/)
163
- end
164
- end
165
149
  end
@@ -109,35 +109,6 @@ RSpec.describe "Adding Stitches to a New Rails App", :integration do
109
109
  expect(include_line).to_not be_nil,lines.inspect
110
110
  end
111
111
 
112
- it "inserts can update old configuration" do
113
- run "bin/rails generate stitches:api"
114
-
115
- initializer = rails_root / "config" / "initializers" / "stitches.rb"
116
-
117
- initializer_contents = File.read(initializer).split(/\n/)
118
- found_initializer = false
119
- File.open(initializer,"w") do |file|
120
- initializer_contents.each do |line|
121
- if line =~ /allowlist/
122
- line = line.gsub("allowlist","whitelist")
123
- found_initializer = true
124
- end
125
- file.puts line
126
- end
127
- end
128
-
129
- raise "Didn't find 'allowlist' in the initializer?!" if !found_initializer
130
-
131
- run "bin/rails generate stitches:update_configuration"
132
-
133
- lines = File.read(initializer).split(/\n/)
134
- include_line = lines.detect { |line|
135
- line =~ /whitelist/
136
- }
137
-
138
- expect(include_line).to be_nil,lines.inspect
139
- end
140
-
141
112
  class RoutesFileAnalysis
142
113
  attr_reader :routes_file
143
114
  def initialize(routes_file, namespace: nil, module_scope: nil, resource: nil, mounted_engine: nil)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stitches
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.RC1
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stitch Fix Engineering
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2020-07-22 00:00:00.000000000 Z
14
+ date: 2020-07-27 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
@@ -162,10 +162,8 @@ files:
162
162
  - lib/stitches/spec/have_api_error.rb
163
163
  - lib/stitches/spec/show_deprecation.rb
164
164
  - lib/stitches/spec/test_headers.rb
165
- - lib/stitches/update_configuration_generator.rb
166
165
  - lib/stitches/valid_mime_type.rb
167
166
  - lib/stitches/version.rb
168
- - lib/stitches/whitelisting_middleware.rb
169
167
  - lib/stitches_norailtie.rb
170
168
  - owners.json
171
169
  - spec/api_client_access_wrapper_spec.rb
@@ -197,9 +195,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
197
195
  version: '0'
198
196
  required_rubygems_version: !ruby/object:Gem::Requirement
199
197
  requirements:
200
- - - ">"
198
+ - - ">="
201
199
  - !ruby/object:Gem::Version
202
- version: 1.3.1
200
+ version: '0'
203
201
  requirements: []
204
202
  rubygems_version: 3.1.2
205
203
  signing_key:
@@ -1,16 +0,0 @@
1
- require 'rails/generators'
2
-
3
- module Stitches
4
- class UpdateConfigurationGenerator < Rails::Generators::Base
5
- include Rails::Generators::Migration
6
-
7
- source_root(File.expand_path(File.join(File.dirname(__FILE__),"generator_files")))
8
-
9
- desc "Change your configuration to use 'allowlist' so you'll be ready for 4.x"
10
- def update_to_allowlist
11
- gsub_file "config/initializers/stitches.rb", /whitelist/, "allowlist"
12
- puts "🎉 You are now good to go!"
13
- end
14
-
15
- end
16
- end
@@ -1,5 +0,0 @@
1
- require_relative "allowlist_middleware"
2
-
3
- module Stitches
4
- WhitelistingMiddleware = AllowlistMiddleware
5
- end