atlas-api 0.0.1

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.
Binary file
@@ -0,0 +1,16 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ InstalledFiles
7
+ _yardoc
8
+ coverage
9
+ doc/
10
+ lib/bundler/man
11
+ pkg
12
+ rdoc
13
+ spec/reports
14
+ test/tmp
15
+ test/version_tmp
16
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --order random
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ notifications:
6
+ campfire:
7
+ rooms:
8
+ - secure: "nay0jqTm7naZ7JKI6q9uG9Au4DfnRP94q1uaiJ+YW9jdV2ygzaB7GmI7fILo7uwCuoy0QIN8KQ/3PhdVeDoSweULs5PaoC7qlO+IX8scBcDMzsykY9JuTiO9cuSQeV0OFwKrStgTsX5a8lt7ryCd+zQXaHdo+FO6mnjy44YXoyI="
9
+ template:
10
+ - ":construction_worker: %{repository} (%{commit}) : %{message} %{foo} "
11
+ - "Build details: %{build_url}"
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem "rake", "~> 10.1.0"
4
+
5
+ gemspec
@@ -0,0 +1,40 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ atlas-api (0.0.1)
5
+ faraday (~> 0.8.8)
6
+ hashie (~> 2.0.5)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.3.5)
12
+ crack (0.4.1)
13
+ safe_yaml (~> 0.9.0)
14
+ diff-lcs (1.2.4)
15
+ faraday (0.8.8)
16
+ multipart-post (~> 1.2.0)
17
+ hashie (2.0.5)
18
+ multipart-post (1.2.0)
19
+ rake (10.1.0)
20
+ rspec (2.14.1)
21
+ rspec-core (~> 2.14.0)
22
+ rspec-expectations (~> 2.14.0)
23
+ rspec-mocks (~> 2.14.0)
24
+ rspec-core (2.14.4)
25
+ rspec-expectations (2.14.0)
26
+ diff-lcs (>= 1.1.3, < 2.0)
27
+ rspec-mocks (2.14.2)
28
+ safe_yaml (0.9.5)
29
+ webmock (1.13.0)
30
+ addressable (>= 2.2.7)
31
+ crack (>= 0.3.2)
32
+
33
+ PLATFORMS
34
+ ruby
35
+
36
+ DEPENDENCIES
37
+ atlas-api!
38
+ rake (~> 10.1.0)
39
+ rspec
40
+ webmock
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Rune Skjoldborg Madsen
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ # Atlas::Api
2
+
3
+ Gem to interact with the O'Reilly Media Atlas API. See tests for coverage.
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :test => :spec
7
+ task :default => :spec
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'atlas-api/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "atlas-api"
8
+ gem.version = Atlas::Api::VERSION
9
+ gem.authors = ["Rune Skjoldborg Madsen"]
10
+ gem.email = ["rune@runemadsen.com"]
11
+ gem.description = "Gem to interact with the O'Reilly Media Atlas API"
12
+ gem.summary = "Gem to interact with the O'Reilly Media Atlas API"
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency "faraday", "~> 0.8.8"
21
+ gem.add_dependency "hashie", "~> 2.0.5"
22
+ gem.add_development_dependency "rspec"
23
+ gem.add_development_dependency "webmock"
24
+ end
@@ -0,0 +1,2 @@
1
+ require "atlas-api/version"
2
+ require "atlas-api/client"
@@ -0,0 +1,68 @@
1
+ require 'faraday'
2
+ require 'json'
3
+ require 'hashie'
4
+
5
+ module Atlas
6
+ module Api
7
+ class Client
8
+
9
+ def initialize(options = {})
10
+ @api_endpoint = options[:api_endpoint]
11
+ @auth_token = options[:auth_token]
12
+ end
13
+
14
+ # Builds
15
+ # ------------------------------------------------------------------------
16
+
17
+ def builds(options = {})
18
+ get("/builds", options)
19
+ end
20
+
21
+ def build(id, options = {})
22
+ get("/builds/#{id}", options)
23
+ end
24
+
25
+ def create_build(options)
26
+ post("/builds", options)
27
+ end
28
+
29
+ # Build Formats
30
+ # ------------------------------------------------------------------------
31
+
32
+ def update_build_format(uuid, options = {})
33
+ put("/build_formats/#{uuid}", options)
34
+ end
35
+
36
+ # HTTP methods
37
+ # ------------------------------------------------------------------------
38
+
39
+ def get(path, options = {})
40
+ request :get, path, options
41
+ end
42
+
43
+ def post(path, options = {})
44
+ request :post, path, options
45
+ end
46
+
47
+ def put(path, options = {})
48
+ request :put, path, options
49
+ end
50
+
51
+ def delete(path, options = {})
52
+ request :delete, path, options
53
+ end
54
+
55
+ def agent
56
+ @agent ||= Faraday.new(@api_endpoint, { params: { auth_token: @auth_token }})
57
+ end
58
+
59
+ private
60
+
61
+ def request(method, path, options)
62
+ @last_response = response = agent.send(method, URI.encode(path), options)
63
+ Hashie::Mash.new(JSON.parse(response.body))
64
+ end
65
+
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,5 @@
1
+ module Atlas
2
+ module Api
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,83 @@
1
+ require 'spec_helper'
2
+
3
+ describe Atlas::Api::Client do
4
+
5
+ def stub_request_with_token(method, path, body, query = {})
6
+ stub_request(method, "#{@endpoint}#{path}?auth_token=#{@token}").with(:body => query).to_return(:body => body)
7
+ end
8
+
9
+ before(:each) do
10
+ @token = "abcdefg"
11
+ @endpoint = "http://www.runemadsen.com"
12
+ @body = { message: "Success!" }
13
+ @client = Atlas::Api::Client.new(
14
+ auth_token: @token,
15
+ api_endpoint: @endpoint
16
+ )
17
+ end
18
+
19
+ describe "Configuration" do
20
+
21
+ it "should set options as instance vars" do
22
+ @client.instance_variable_get("@auth_token").should == @token
23
+ @client.instance_variable_get("@api_endpoint").should == @endpoint
24
+ end
25
+
26
+ it "should use auth_token and api_endpoint in calls and return hashie" do
27
+ stub = stub_request_with_token(:get, "/fake", @body.to_json)
28
+ res = @client.get("/fake")
29
+ stub.should have_been_requested
30
+ res.should be_instance_of(Hashie::Mash)
31
+ res.message.should == @body[:message]
32
+ end
33
+
34
+ end
35
+
36
+ describe "Builds" do
37
+
38
+ it "#create_build" do
39
+ query = {
40
+ :project => "atlasservers/basic-sample",
41
+ :formats => "pdf,html",
42
+ :branch => "master",
43
+ :pingback_url => "http://www.someurl.com"
44
+ }
45
+ stub = stub_request_with_token(:post, "/builds", @body.to_json, query)
46
+ @client.create_build(query)
47
+ stub.should have_been_requested
48
+ end
49
+
50
+ it "#build" do
51
+ stub = stub_request_with_token(:get, "/builds/1", @body.to_json)
52
+ @client.build(1)
53
+ stub.should have_been_requested
54
+ end
55
+
56
+ it "#builds" do
57
+ stub = stub_request_with_token(:get, "/builds", @body.to_json)
58
+ @client.builds
59
+ stub.should have_been_requested
60
+ end
61
+
62
+ end
63
+
64
+ describe "Build Format" do
65
+
66
+ before(:each) do
67
+ @uuid = "123bgsf"
68
+ end
69
+
70
+ it "#update_build_format" do
71
+ query = {
72
+ :message => "hello",
73
+ :download_url => "http://www.someurl.com",
74
+ :status => "success"
75
+ }
76
+ stub = stub_request_with_token(:put, "/build_formats/#{@uuid}", @body.to_json, query)
77
+ @client.update_build_format(@uuid, query)
78
+ stub.should have_been_requested
79
+ end
80
+
81
+ end
82
+
83
+ end
@@ -0,0 +1,2 @@
1
+ require 'atlas-api'
2
+ require 'webmock/rspec'
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: atlas-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Rune Skjoldborg Madsen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-08-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: faraday
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.8.8
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.8.8
30
+ - !ruby/object:Gem::Dependency
31
+ name: hashie
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 2.0.5
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 2.0.5
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: webmock
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: Gem to interact with the O'Reilly Media Atlas API
79
+ email:
80
+ - rune@runemadsen.com
81
+ executables: []
82
+ extensions: []
83
+ extra_rdoc_files: []
84
+ files:
85
+ - .DS_Store
86
+ - .gitignore
87
+ - .rspec
88
+ - .travis.yml
89
+ - Gemfile
90
+ - Gemfile.lock
91
+ - LICENSE.txt
92
+ - README.md
93
+ - Rakefile
94
+ - atlas-api.gemspec
95
+ - lib/atlas-api.rb
96
+ - lib/atlas-api/client.rb
97
+ - lib/atlas-api/version.rb
98
+ - spec/atlas-api/client_spec.rb
99
+ - spec/spec_helper.rb
100
+ homepage: ''
101
+ licenses: []
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 1.8.24
121
+ signing_key:
122
+ specification_version: 3
123
+ summary: Gem to interact with the O'Reilly Media Atlas API
124
+ test_files:
125
+ - spec/atlas-api/client_spec.rb
126
+ - spec/spec_helper.rb
127
+ has_rdoc: