diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..59fcf7c --- /dev/null +++ b/.github/workflows/ci.yaml @@ -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 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 735b4d5..14b512d 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ spec/reports test/tmp test/version_tmp tmp +coverage diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index fc8dd63..0000000 --- a/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: ruby -rvm: - - 1.9.3 - - 2.0.0 -notifications: - campfire: - rooms: - - secure: "nay0jqTm7naZ7JKI6q9uG9Au4DfnRP94q1uaiJ+YW9jdV2ygzaB7GmI7fILo7uwCuoy0QIN8KQ/3PhdVeDoSweULs5PaoC7qlO+IX8scBcDMzsykY9JuTiO9cuSQeV0OFwKrStgTsX5a8lt7ryCd+zQXaHdo+FO6mnjy44YXoyI=" - template: - - ":construction_worker: %{repository} (%{commit}) : %{message} %{foo} " - - "Build details: %{build_url}" diff --git a/Gemfile b/Gemfile index 64df509..8e04d61 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,6 @@ source 'https://rubygems.org' gem "rake", "~> 13.0.1" +gem "simplecov" gemspec \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index ff54f50..ec23ad5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -46,6 +55,7 @@ DEPENDENCIES atlas-api! rake (~> 13.0.1) rspec + simplecov webmock BUNDLED WITH diff --git a/README.md b/README.md index fbacd12..26d4ac0 100644 --- a/README.md +++ b/README.md @@ -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 ``` \ No newline at end of file diff --git a/atlas-api.gemspec b/atlas-api.gemspec index d32f6fa..9279a14 100644 --- a/atlas-api.gemspec +++ b/atlas-api.gemspec @@ -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 = "" @@ -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" diff --git a/lib/atlas-api/client.rb b/lib/atlas-api/client.rb index 4bf2ee3..0ae0e4e 100644 --- a/lib/atlas-api/client.rb +++ b/lib/atlas-api/client.rb @@ -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 @@ -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 diff --git a/lib/atlas-api/version.rb b/lib/atlas-api/version.rb index 420659a..c6e73cc 100644 --- a/lib/atlas-api/version.rb +++ b/lib/atlas-api/version.rb @@ -1,5 +1,5 @@ module Atlas module Api - VERSION = "0.1.2" + VERSION = "0.2.0" end end diff --git a/spec/atlas-api/client_spec.rb b/spec/atlas-api/client_spec.rb index adca5b9..96059da 100644 --- a/spec/atlas-api/client_spec.rb +++ b/spec/atlas-api/client_spec.rb @@ -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, @@ -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 @@ -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" } @@ -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) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 679b3a0..54fef43 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,2 +1,4 @@ +require 'simplecov' +SimpleCov.start require 'atlas-api' require 'webmock/rspec' \ No newline at end of file