Skip to content

Commit

Permalink
Merge pull request #9 from oreillymedia/ruby-3-compatibility
Browse files Browse the repository at this point in the history
Ruby 3 compatibility
  • Loading branch information
nadamsoreilly authored Nov 18, 2022
2 parents 7927739 + af3ea28 commit f3a4d4a
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 45 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
tests:
name: Run test suite
runs-on: ubuntu-latest

strategy:
matrix:
ruby-version: ['3.2', '3.1', '3.0', '2.7']

steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Install dependencies
run: bundle install
- name: Run tests
run: bundle exec rspec spec/atlas-api/client_spec.rb
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ spec/reports
test/tmp
test/version_tmp
tmp
coverage
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
source 'https://rubygems.org'

gem "rake", "~> 13.0.1"
gem "simplecov"

gemspec
50 changes: 30 additions & 20 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,40 +1,49 @@
PATH
remote: .
specs:
atlas-api (0.1.2)
faraday (~> 0.15.4)
atlas-api (0.2.0)
faraday (~> 2.7.0)
hashie (~> 3.6.0)

GEM
remote: https://rubygems.org/
specs:
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
addressable (2.8.1)
public_suffix (>= 2.0.2, < 6.0)
crack (0.4.5)
rexml
diff-lcs (1.5.0)
faraday (0.15.4)
multipart-post (>= 1.2, < 3)
docile (1.4.0)
faraday (2.7.0)
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-net_http (3.0.2)
hashdiff (1.0.1)
hashie (3.6.0)
multipart-post (2.1.1)
public_suffix (4.0.7)
public_suffix (5.0.0)
rake (13.0.6)
rexml (3.2.5)
rspec (3.11.0)
rspec-core (~> 3.11.0)
rspec-expectations (~> 3.11.0)
rspec-mocks (~> 3.11.0)
rspec-core (3.11.0)
rspec-support (~> 3.11.0)
rspec-expectations (3.11.0)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.0)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-mocks (3.11.1)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-support (3.11.0)
webmock (3.14.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.0)
ruby2_keywords (0.0.5)
simplecov (0.21.2)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
webmock (3.18.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
Expand All @@ -46,6 +55,7 @@ DEPENDENCIES
atlas-api!
rake (~> 13.0.1)
rspec
simplecov
webmock

BUNDLED WITH
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ $ atlas build ATLAS_TOKEN PROJECT FORMATS BRANCH
A real world example of this would look something like this:

```bash
$ atlas build abcdefg oreillymedia/atlas_book_skeleton pdf,epub,html master
$ atlas build abcdefg oreillymedia/atlas_book_skeleton pdf,epub,html main
```
6 changes: 3 additions & 3 deletions atlas-api.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ require 'atlas-api/version'
Gem::Specification.new do |gem|
gem.name = "atlas-api"
gem.version = Atlas::Api::VERSION
gem.authors = ["Rune Skjoldborg Madsen"]
gem.email = ["rune@runemadsen.com"]
gem.authors = ["O'Reilly Media Tools Team"]
gem.email = ["toolsreq@oreilly.com"]
gem.description = "Gem to interact with the O'Reilly Media Atlas API"
gem.summary = "Gem to interact with the O'Reilly Media Atlas API"
gem.homepage = ""
Expand All @@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.require_paths = ["lib"]

gem.add_dependency "faraday", "~> 0.15.4"
gem.add_dependency "faraday", "~> 2.7.0"
gem.add_dependency "hashie", "~> 3.6.0"
gem.add_development_dependency "rspec"
gem.add_development_dependency "webmock"
Expand Down
6 changes: 1 addition & 5 deletions lib/atlas-api/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ def put(path, options = {})
request :put, path, options
end

def delete(path, options = {})
request :delete, path, options
end

def agent
@agent ||= Faraday.new(url: @api_endpoint, params: { auth_token: @auth_token })
@agent
Expand All @@ -74,7 +70,7 @@ def agent
private

def request(method, path, options)
@last_response = response = agent.send(method, URI.encode(path), options)
@last_response = response = agent.send(method, path, options)
Hashie::Mash.new(JSON.parse(response.body))
end

Expand Down
2 changes: 1 addition & 1 deletion lib/atlas-api/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Atlas
module Api
VERSION = "0.1.2"
VERSION = "0.2.0"
end
end
8 changes: 4 additions & 4 deletions spec/atlas-api/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def stub_request_with_token(method, path, body, query = {})

before(:each) do
@token = "abcdefg"
@endpoint = "http://www.runemadsen.com"
@endpoint = "http://atlas.oreilly.com"
@body = { message: "Success!" }
@client = Atlas::Api::Client.new(
auth_token: @token,
Expand All @@ -32,7 +32,7 @@ def stub_request_with_token(method, path, body, query = {})
end

it "should combine paths from endpoint and path" do
@endpoint = "http://www.runemadsen.com/api"
@endpoint = "http://atlas.oreilly.com/api"
client = Atlas::Api::Client.new(
auth_token: @token,
api_endpoint: @endpoint
Expand All @@ -54,7 +54,7 @@ def stub_request_with_token(method, path, body, query = {})
query = {
:project => "atlasservers/basic-sample",
:formats => "pdf,html",
:branch => "master",
:branch => "main",
:pingback_url => "http://www.someurl.com"
}

Expand Down Expand Up @@ -115,7 +115,7 @@ def stub_request_with_token(method, path, body, query = {})
query = {
:project => "atlasservers/basic-sample",
:formats => "pdf,html",
:branch => "master",
:branch => "main",
:pingback_url => "http://www.someurl.com"
}
stub = stub_request_with_token(:post, "builds", @body.to_json, query)
Expand Down
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
require 'simplecov'
SimpleCov.start
require 'atlas-api'
require 'webmock/rspec'

0 comments on commit f3a4d4a

Please sign in to comment.