Skip to content
This repository was archived by the owner on Sep 21, 2021. It is now read-only.

Commit cbb99f2

Browse files
authored
Merge pull request #5 from wework/feature/instance-exec
Execute link proc in instance scope
2 parents e6d1909 + afa11c8 commit cbb99f2

36 files changed

+321
-1633
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
/tmp/
1010
/spec/test_app/log/
1111
.byebug_history
12+
.ruby-version
1213
Gemfile.lock
13-
*.sqlite3

.travis.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
language: ruby
2+
before_install:
3+
- gem install bundler
4+
script:
5+
- bundle exec rspec
6+
gemfile:
7+
- gemfiles/rails_4.2.gemfile
8+
- gemfiles/rails_5.0.gemfile
9+
- gemfiles/rails_5.1.gemfile
10+
rvm:
11+
- 2.2
12+
- 2.3
13+
- 2.4
14+
# - ruby-head
15+
16+
matrix:
17+
fast_finish: true
18+
allow_failures:
19+
- rvm: 2.4
20+
gemfile: gemfiles/rails_4.2.gemfile
21+
- rvm: ruby-head
22+
gemfile: gemfiles/rails_4.2.gemfile

Appraisals

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,14 @@
1-
appraise "faraday-0.13" do
2-
gem "faraday", "~> 0.13.0"
3-
end
4-
5-
appraise "faraday-0.12" do
6-
gem "faraday", "~> 0.12.0"
7-
end
8-
9-
appraise "faraday-0.11" do
10-
gem "faraday", "~> 0.11.0"
11-
end
12-
13-
appraise "faraday-0.10" do
14-
gem "faraday", "~> 0.10.0"
15-
end
16-
17-
appraise "faraday-0.9" do
18-
gem "faraday", "~> 0.9.0"
19-
end
20-
211
appraise "rails-5.1" do
222
gem "rails", "~> 5.1.0"
3+
gem "activesupport", "~> 5.1.0"
234
end
245

256
appraise "rails-5.0" do
267
gem "rails", "~> 5.0.0"
8+
gem "activesupport", "~> 5.0.0"
279
end
2810

2911
appraise "rails-4.2" do
3012
gem "rails", "~> 4.2.0"
13+
gem "activesupport", "~> 4.2.0"
3114
end

CHANGELOG.md

Lines changed: 4 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -5,70 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8-
## v0.6.1
9-
### Fixed
10-
- Required typhoeus in We::Call instead of connection, which loads it early enough for NewRelic tracing to kick in if you use that
11-
12-
### Changed
13-
- Reduced open timeout default to 1 second
14-
15-
## v0.6.0
16-
### Changed
17-
- Use typhoeus instead of NetHTTP for a [series of reasons]
18-
19-
[typhoeus]: https://github.com/typhoeus/typhoeus
20-
[series of reasons]: https://github.com/wework/we-call-gem/pull/7
21-
22-
## v0.5.4
23-
### Fixed
24-
- Connection checks `Rails.env` instead of `ENV['RAILS_ENV']` as most people dont have RAILS_ENV in their `.env` file
25-
26-
## v0.5.3
27-
28-
### Fixed
29-
- Deprecations were calling a private method and failing
30-
31-
## v0.5.2
32-
33-
### Fixed
34-
- Made Annotations require "ruby_decorators"
35-
36-
## v0.5.1
37-
8+
## [v0.1.0] - 2017-10-09
389
### Changed
39-
- Switched `config.detect_deprecations` from bool to expect `:active_support` or logger instance
40-
- Moved `We::Call::Middleware::Client::DetectDeprecations` into its own [faraday-sunset] gem (no BC breaks)
41-
42-
[faraday-sunset]: https://github.com/philsturgeon/faraday-sunset
43-
44-
## v0.5.0
45-
46-
### Added
47-
- Configurable `We::Call.configure` which accepts a config block
48-
- Config option `config.app_name` to avoid providing `app:` in every connection initializer
49-
- Added the concept of Annotations. Simply `extend We::Call::Annotations` in a base controller to get cool stuff
50-
- First annotation: `We::Call::Deprecated` added to mark controller methods as deprecated
51-
- Added `We::Call::Middleware::Client::DetectDeprecations` that automatically registers as a faraday response middleware to report deprecated endpoints
52-
53-
### Changed
54-
- Defaults to setting `X-App-Name` instead of `X-WeWork-App` (override with config.app_name_header)
55-
- Defaults to setting `X-App-Env` instead of `X-WeWork-Env` (override with config.app_env_header)
56-
57-
### Fixed
58-
- Switched from manually requiring to using module autoload to reduce memory footprint
59-
60-
## v0.4.2
61-
62-
### Fixed
63-
- Manually setting `conn.adapter` would result in double adapters (two requests made!)
64-
65-
## v0.4.1
66-
67-
### Fixed
68-
- Improved support for Faraday 0.8 - 0.9.
69-
70-
## v0.4.0
10+
- link lambda/proc/whatever is now called in the scope of the instance, so any instance methods, params, etc will be available. E.g: `link: -> { foo_url(params['id']) }`
7111

12+
## [v0.1.0-alpha1] - 2017-10-07
7213
### Added
73-
- `We::Call::Connection.new` requires `timeout: 1` where 1 is seconds.
74-
- `We::Call::Connection.new` accepts `open_timeout: 1` where 1 is seconds.
14+
- Initial version. Pretty basic, but adds a `sunset` method to mark things as deprecated

Gemfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
source 'https://rubygems.org'
22

3-
# Specify your gem's dependencies in we-call.gemspec
43
gemspec
4+
5+
group :development, :test do
6+
gem "appraisal"
7+
gem "wwtd"
8+
end

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class FooController
3838
sunset_method :create, DateTime.new(2019, 1, 1)
3939

4040
# Use a lambda instead of a string to inject params
41-
sunset_method :destroy, DateTime.new(2019, 1, 1), link: lambda { |params| "https://api.example.com/v3/companies/#{params['id']}" }
41+
sunset_method :destroy, DateTime.new(2019, 1, 1), link: -> { v3_company_url(params['id']) }
4242
end
4343
```
4444

@@ -52,7 +52,7 @@ Literring your controllers with all those dates certainly doesn't seem ideal, it
5252

5353
One approach would be to make a `config/initializer/deprecations.rb` with some "milestones" like this:
5454

55-
```
55+
``` ruby
5656
# config/initializer/deprecations.rb
5757

5858
SUNSET_MILESTONES = {
@@ -74,11 +74,15 @@ Call em what you want, but something like this should keep things on track.
7474
- **Ruby:** v2.2 - v2.4
7575
- **Rails:** v4.2 - v5.2
7676

77+
_**Note:** Although we support Ruby v2.4 and Rails v4.2, they [don't really like each other][it-is-known] all that much. As such, expect failures on Travis for that combination._
78+
79+
[it-is-known]: https://stackoverflow.com/questions/41504106/ruby-2-4-and-rails-4-stack-level-too-deep-systemstackerror
80+
7781
## Testing
7882

7983
To run tests and modify locally, you'll want to `bundle install` in this directory.
8084

81-
```
85+
``` shell
8286
bundle exec appraisal rspec
8387
```
8488

Rakefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
require "bundler/gem_tasks"
1+
require "rubygems"
2+
require "bundler/setup"
23
require "rspec/core/rake_task"
34

45
RSpec::Core::RakeTask.new(:spec)
56

6-
task :default => :spec
7+
task default: :spec

gemfiles/.bundle/config

Lines changed: 0 additions & 2 deletions
This file was deleted.

gemfiles/faraday_0.10.gemfile

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)