rails-sunset 0.1.0.pre.alpha1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,192 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ we-call (0.5.4)
5
+ faraday (>= 0.9.0, < 1.0)
6
+ faraday-sunset (~> 0.1.0)
7
+ faraday_middleware (~> 0)
8
+ rails (>= 4.2)
9
+ ruby_decorators (~> 0.0)
10
+ typhoeus (~> 1.3)
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ actioncable (5.1.0)
16
+ actionpack (= 5.1.0)
17
+ nio4r (~> 2.0)
18
+ websocket-driver (~> 0.6.1)
19
+ actionmailer (5.1.0)
20
+ actionpack (= 5.1.0)
21
+ actionview (= 5.1.0)
22
+ activejob (= 5.1.0)
23
+ mail (~> 2.5, >= 2.5.4)
24
+ rails-dom-testing (~> 2.0)
25
+ actionpack (5.1.0)
26
+ actionview (= 5.1.0)
27
+ activesupport (= 5.1.0)
28
+ rack (~> 2.0)
29
+ rack-test (~> 0.6.3)
30
+ rails-dom-testing (~> 2.0)
31
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
32
+ actionview (5.1.0)
33
+ activesupport (= 5.1.0)
34
+ builder (~> 3.1)
35
+ erubi (~> 1.4)
36
+ rails-dom-testing (~> 2.0)
37
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
38
+ activejob (5.1.0)
39
+ activesupport (= 5.1.0)
40
+ globalid (>= 0.3.6)
41
+ activemodel (5.1.0)
42
+ activesupport (= 5.1.0)
43
+ activerecord (5.1.0)
44
+ activemodel (= 5.1.0)
45
+ activesupport (= 5.1.0)
46
+ arel (~> 8.0)
47
+ activesupport (5.1.0)
48
+ concurrent-ruby (~> 1.0, >= 1.0.2)
49
+ i18n (~> 0.7)
50
+ minitest (~> 5.1)
51
+ tzinfo (~> 1.1)
52
+ appraisal (2.2.0)
53
+ bundler
54
+ rake
55
+ thor (>= 0.14.0)
56
+ arel (8.0.0)
57
+ builder (3.2.3)
58
+ concurrent-ruby (1.0.5)
59
+ coveralls (0.7.1)
60
+ multi_json (~> 1.3)
61
+ rest-client
62
+ simplecov (>= 0.7)
63
+ term-ansicolor
64
+ thor
65
+ diff-lcs (1.3)
66
+ docile (1.1.5)
67
+ domain_name (0.5.20170404)
68
+ unf (>= 0.0.5, < 1.0.0)
69
+ erubi (1.6.0)
70
+ ethon (0.11.0)
71
+ ffi (>= 1.3.0)
72
+ faraday (0.13.1)
73
+ multipart-post (>= 1.2, < 3)
74
+ faraday-sunset (0.1.1)
75
+ faraday (>= 0.9.0, < 0.14)
76
+ faraday_middleware (0.12.2)
77
+ faraday (>= 0.7.4, < 1.0)
78
+ ffi (1.9.18)
79
+ globalid (0.4.0)
80
+ activesupport (>= 4.2.0)
81
+ hashie (3.5.5)
82
+ http-cookie (1.0.3)
83
+ domain_name (~> 0.5)
84
+ i18n (0.8.1)
85
+ json (2.1.0)
86
+ loofah (2.0.3)
87
+ nokogiri (>= 1.5.9)
88
+ mail (2.6.5)
89
+ mime-types (>= 1.16, < 4)
90
+ method_source (0.8.2)
91
+ mime-types (3.1)
92
+ mime-types-data (~> 3.2015)
93
+ mime-types-data (3.2016.0521)
94
+ mini_portile2 (2.1.0)
95
+ minitest (5.10.1)
96
+ multi_json (1.12.1)
97
+ multipart-post (2.0.0)
98
+ netrc (0.11.0)
99
+ nio4r (2.0.0)
100
+ nokogiri (1.7.1)
101
+ mini_portile2 (~> 2.1.0)
102
+ rack (2.0.1)
103
+ rack-test (0.6.3)
104
+ rack (>= 1.0)
105
+ rails (5.1.0)
106
+ actioncable (= 5.1.0)
107
+ actionmailer (= 5.1.0)
108
+ actionpack (= 5.1.0)
109
+ actionview (= 5.1.0)
110
+ activejob (= 5.1.0)
111
+ activemodel (= 5.1.0)
112
+ activerecord (= 5.1.0)
113
+ activesupport (= 5.1.0)
114
+ bundler (>= 1.3.0, < 2.0)
115
+ railties (= 5.1.0)
116
+ sprockets-rails (>= 2.0.0)
117
+ rails-dom-testing (2.0.2)
118
+ activesupport (>= 4.2.0, < 6.0)
119
+ nokogiri (~> 1.6)
120
+ rails-html-sanitizer (1.0.3)
121
+ loofah (~> 2.0)
122
+ railties (5.1.0)
123
+ actionpack (= 5.1.0)
124
+ activesupport (= 5.1.0)
125
+ method_source
126
+ rake (>= 0.8.7)
127
+ thor (>= 0.18.1, < 2.0)
128
+ rake (12.0.0)
129
+ rest-client (2.0.2)
130
+ http-cookie (>= 1.0.2, < 2.0)
131
+ mime-types (>= 1.16, < 4.0)
132
+ netrc (~> 0.8)
133
+ rspec (3.6.0)
134
+ rspec-core (~> 3.6.0)
135
+ rspec-expectations (~> 3.6.0)
136
+ rspec-mocks (~> 3.6.0)
137
+ rspec-core (3.6.0)
138
+ rspec-support (~> 3.6.0)
139
+ rspec-expectations (3.6.0)
140
+ diff-lcs (>= 1.2.0, < 2.0)
141
+ rspec-support (~> 3.6.0)
142
+ rspec-mocks (3.6.0)
143
+ diff-lcs (>= 1.2.0, < 2.0)
144
+ rspec-support (~> 3.6.0)
145
+ rspec-support (3.6.0)
146
+ ruby_decorators (0.0.3)
147
+ simplecov (0.15.0)
148
+ docile (~> 1.1.0)
149
+ json (>= 1.8, < 3)
150
+ simplecov-html (~> 0.10.0)
151
+ simplecov-html (0.10.2)
152
+ sprockets (3.7.1)
153
+ concurrent-ruby (~> 1.0)
154
+ rack (> 1, < 3)
155
+ sprockets-rails (3.2.0)
156
+ actionpack (>= 4.0)
157
+ activesupport (>= 4.0)
158
+ sprockets (>= 3.0.0)
159
+ term-ansicolor (1.6.0)
160
+ tins (~> 1.0)
161
+ thor (0.19.4)
162
+ thread_safe (0.3.6)
163
+ tins (1.15.0)
164
+ typhoeus (1.3.0)
165
+ ethon (>= 0.9.0)
166
+ tzinfo (1.2.3)
167
+ thread_safe (~> 0.1)
168
+ unf (0.1.4)
169
+ unf_ext
170
+ unf_ext (0.0.7.4)
171
+ vcr (3.0.3)
172
+ websocket-driver (0.6.5)
173
+ websocket-extensions (>= 0.1.0)
174
+ websocket-extensions (0.1.2)
175
+
176
+ PLATFORMS
177
+ ruby
178
+
179
+ DEPENDENCIES
180
+ appraisal (~> 2)
181
+ bundler (~> 1.14)
182
+ coveralls (~> 0.7)
183
+ hashie (~> 3.5)
184
+ rails (~> 5.1.0)
185
+ rake (~> 12.0)
186
+ rspec (~> 3.5)
187
+ simplecov (~> 0.15)
188
+ vcr (~> 3)
189
+ we-call!
190
+
191
+ BUNDLED WITH
192
+ 1.14.6
@@ -0,0 +1,4 @@
1
+ module RailsSunset
2
+ require 'rails_sunset/controller'
3
+ require 'rails_sunset/railtie'
4
+ end
@@ -0,0 +1,52 @@
1
+ module RailsSunset
2
+ module Controller
3
+ extend ActiveSupport::Concern
4
+
5
+ module ClassMethods
6
+ def sunset_method(method, datetime, link: nil)
7
+ sunset(datetime, link: link, only: [method])
8
+ end
9
+
10
+ def sunset(datetime, link: nil, only: nil)
11
+ after_action(only: only) do |controller|
12
+ datetime = normalize_datetime(datetime)
13
+ link = normalize_link(link, params)
14
+
15
+ # Shove a deprecation warning into the console or wherever it goes
16
+ klass = controller.class
17
+ method = params['action']
18
+ ActiveSupport::Deprecation.warn("#{klass}##{method} is deprecated for removal on #{datetime.iso8601}")
19
+
20
+ # Shove a Sunset header into HTTP Response for clients to sniff on
21
+ # https://tools.ietf.org/html/draft-wilde-sunset-header-03
22
+ response.headers['Sunset'] = datetime.httpdate
23
+
24
+ if link.present?
25
+ sunset_link_header = sprintf('<%s>; rel="sunset";', link)
26
+ if response.headers['Link'].present?
27
+ response.headers['Link'] += (', ' + sunset_link_header)
28
+ else
29
+ response.headers['Link'] = sunset_link_header
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ protected
37
+
38
+ def normalize_datetime(datetime)
39
+ datetime = DateTime.parse(datetime) if datetime.is_a? String
40
+ datetime = datetime.to_datetime if datetime.respond_to? :to_datetime
41
+ return datetime if datetime.respond_to? :httpdate
42
+ raise TypeError, 'The date should be a Date, DateTime, Time or string containing a valid date and time'
43
+ end
44
+
45
+ def normalize_link(link, _params)
46
+ link = link.call(_params) if link.respond_to? :call
47
+ return if link.nil?
48
+ return link if link.is_a? String
49
+ raise TypeError, 'The link should be a string, or a lambda that returns a string'
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,9 @@
1
+ module RailsSunset
2
+ class Railtie < Rails::Railtie
3
+ initializer "rails-sunset.action_controller" do
4
+ ActiveSupport.on_load(:action_controller) do
5
+ include RailsSunset::Controller
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module RailsSunset
2
+ VERSION = "0.1.0-alpha1"
3
+ end
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rails_sunset/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rails-sunset"
8
+ spec.version = RailsSunset::VERSION
9
+ spec.authors = ["WeWork Engineering"]
10
+ spec.email = ["engineering@wework.com"]
11
+
12
+ spec.summary = "Take out your trash endpoints"
13
+ spec.description = "Deprecate those endpoints you don't need anymore, without randomly deleting them and making everyone upset."
14
+ spec.homepage = "https://github.com/wework/rails-sunset-gem"
15
+ spec.licenses = ['MIT']
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(spec)/})
19
+ end
20
+ spec.bindir = "bin"
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_dependency "rails", ">= 4.2"
24
+ spec.add_dependency "activesupport"
25
+
26
+ spec.add_development_dependency "appraisal", "~> 2"
27
+ spec.add_development_dependency "coveralls", '~> 0.7'
28
+ spec.add_development_dependency "bundler", ">= 1.14"
29
+ spec.add_development_dependency "rake", "~> 12.0"
30
+ spec.add_development_dependency "rspec", ">= 3.6"
31
+ spec.add_development_dependency "rspec-rails"
32
+ spec.add_development_dependency "byebug"
33
+ spec.add_development_dependency "simplecov", '~> 0.15'
34
+ spec.add_development_dependency "sqlite3" # i dont even want a db ffs rails
35
+ end
metadata ADDED
@@ -0,0 +1,233 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-sunset
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.pre.alpha1
5
+ platform: ruby
6
+ authors:
7
+ - WeWork Engineering
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-11-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: appraisal
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: coveralls
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '1.14'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '1.14'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '12.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '12.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '3.6'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '3.6'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec-rails
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: byebug
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0.15'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '0.15'
153
+ - !ruby/object:Gem::Dependency
154
+ name: sqlite3
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ description: Deprecate those endpoints you don't need anymore, without randomly deleting
168
+ them and making everyone upset.
169
+ email:
170
+ - engineering@wework.com
171
+ executables: []
172
+ extensions: []
173
+ extra_rdoc_files: []
174
+ files:
175
+ - ".gitignore"
176
+ - Appraisals
177
+ - CHANGELOG.md
178
+ - Gemfile
179
+ - LICENSE
180
+ - README.md
181
+ - Rakefile
182
+ - bin/console
183
+ - bin/setup
184
+ - gemfiles/.bundle/config
185
+ - gemfiles/faraday_0.10.gemfile
186
+ - gemfiles/faraday_0.10.gemfile.lock
187
+ - gemfiles/faraday_0.11.gemfile
188
+ - gemfiles/faraday_0.11.gemfile.lock
189
+ - gemfiles/faraday_0.12.gemfile
190
+ - gemfiles/faraday_0.12.gemfile.lock
191
+ - gemfiles/faraday_0.13.gemfile
192
+ - gemfiles/faraday_0.13.gemfile.lock
193
+ - gemfiles/faraday_0.8.gemfile
194
+ - gemfiles/faraday_0.8.gemfile.lock
195
+ - gemfiles/faraday_0.9.gemfile
196
+ - gemfiles/faraday_0.9.gemfile.lock
197
+ - gemfiles/faraday_5.1.gemfile
198
+ - gemfiles/rails_4.2.gemfile
199
+ - gemfiles/rails_4.2.gemfile.lock
200
+ - gemfiles/rails_5.0.gemfile
201
+ - gemfiles/rails_5.0.gemfile.lock
202
+ - gemfiles/rails_5.1.gemfile
203
+ - gemfiles/rails_5.1.gemfile.lock
204
+ - lib/rails-sunset.rb
205
+ - lib/rails_sunset/controller.rb
206
+ - lib/rails_sunset/railtie.rb
207
+ - lib/rails_sunset/version.rb
208
+ - rails-sunset.gemspec
209
+ homepage: https://github.com/wework/rails-sunset-gem
210
+ licenses:
211
+ - MIT
212
+ metadata: {}
213
+ post_install_message:
214
+ rdoc_options: []
215
+ require_paths:
216
+ - lib
217
+ required_ruby_version: !ruby/object:Gem::Requirement
218
+ requirements:
219
+ - - ">="
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
222
+ required_rubygems_version: !ruby/object:Gem::Requirement
223
+ requirements:
224
+ - - ">"
225
+ - !ruby/object:Gem::Version
226
+ version: 1.3.1
227
+ requirements: []
228
+ rubyforge_project:
229
+ rubygems_version: 2.6.8
230
+ signing_key:
231
+ specification_version: 4
232
+ summary: Take out your trash endpoints
233
+ test_files: []