Skip to content

Commit

Permalink
Remove MultiHTTParty, and use HTTParty directly (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zane Williamson committed Feb 4, 2019
1 parent 8709c4f commit b80e9fd
Show file tree
Hide file tree
Showing 20 changed files with 78 additions and 75 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Expand Up @@ -17,9 +17,10 @@ after_script:
- rake docker_show_logs

rvm:
- 2.1.10
- 2.2.5
- 2.3.1
- 2.3.8
- 2.4.5
- 2.5.3
- 2.6.1

deploy:
provider: rubygems
Expand Down
1 change: 0 additions & 1 deletion README.md
Expand Up @@ -257,4 +257,3 @@ rake test # Run tests

- [ruby-aptly](https://github.com/ryanuber/ruby-aptly) - Ruby client library
- [aptly-web-ui](https://github.com/sdumetz/aptly-web-ui) - Web interface for aptly (JavaScript, React, Redux)
- [debweb](https://github.com/AutogrowSystems/debweb) - Another web interface (Ruby on Rails)
3 changes: 1 addition & 2 deletions aptly_cli.gemspec
Expand Up @@ -32,7 +32,6 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "simplecov"
spec.add_development_dependency "rubocop"

spec.add_dependency "httmultiparty", "~> 0.3.16"
spec.add_dependency "httparty", "~> 0.13.0"
spec.add_dependency('httparty', '>= 0.16.2')
spec.add_dependency "commander", "~> 4.3"
end
2 changes: 1 addition & 1 deletion bin/aptly-cli
Expand Up @@ -501,7 +501,7 @@ command :graph do |c|
c.syntax = 'aptly-cli graph [options]'
c.summary = 'Download an svg or png graph of repository layout'
c.description = 'Download a graph of repository layout. Current options are "svg" and "png"'
c.example 'description', 'aptly-cli graph png > ~/repo_graph.png'
c.example 'description', 'aptly-cli graph --type png > ~/repo_graph.png'
c.option '--type GRAPH_TYPE', String, 'Type of graph to download, present options are png or svg'
c.action do |args, options|
config = AptlyCli::AptlyLoad.new.configure_with($config_file)
Expand Down
2 changes: 1 addition & 1 deletion lib/aptly_cli.rb
@@ -1,5 +1,5 @@
require 'aptly_cli/version'
require 'httmultiparty'
require 'httparty'

# Initializing
module AptlyCli
Expand Down
2 changes: 1 addition & 1 deletion lib/aptly_cli/version.rb
@@ -1,3 +1,3 @@
module AptlyCli
VERSION = '0.4.2'.freeze
VERSION = '0.5.0'.freeze
end
2 changes: 1 addition & 1 deletion lib/aptly_command.rb
@@ -1,6 +1,6 @@
module AptlyCli
class AptlyCommand
include HTTMultiParty
include HTTParty

attr_accessor :config
def initialize(config, options = nil)
Expand Down
19 changes: 12 additions & 7 deletions lib/aptly_file.rb
@@ -1,7 +1,7 @@
require 'aptly_cli/version'
require 'aptly_command'
require 'aptly_load'
require 'httmultiparty'
require 'httparty'

module AptlyCli
# Uploading file into Aptly
Expand All @@ -10,7 +10,8 @@ class AptlyFile < AptlyCommand

def file_dir
uri = '/files'
self.class.get uri
response = self.class.get uri
response.parsed_response
end

def file_get(file_uri)
Expand All @@ -19,20 +20,24 @@ def file_get(file_uri)
else
'/files/' + file_uri
end
self.class.get uri
response = self.class.get uri
response.parsed_response
end

def file_delete(file_uri)
uri = '/files' + file_uri
self.class.delete uri
response = self.class.delete uri
response.parsed_response
end

def file_post(post_options = {})
api_file_uri = '/files' + post_options[:file_uri].to_s
self.class.post(api_file_uri,
query: {
response = self.class.post(api_file_uri,
body: {
package: post_options[:package],
file: File.new(post_options[:local_file]) })
file: File.new(post_options[:local_file])
})
response.parsed_response
end
end
end
7 changes: 4 additions & 3 deletions lib/aptly_misc.rb
@@ -1,13 +1,13 @@
require 'aptly_cli/version'
require 'aptly_command'
require 'aptly_load'
require 'httmultiparty'
require 'httparty'
require 'json'

module AptlyCli
# Misc Aptly Class
class AptlyMisc < AptlyCommand
include HTTMultiParty
include HTTParty

def get_graph(extension)
uri = "/graph.#{extension}"
Expand All @@ -16,7 +16,8 @@ def get_graph(extension)

def get_version
uri = '/version'
self.class.get(uri)
response = self.class.get(uri)
response.parsed_response
end
end
end
4 changes: 2 additions & 2 deletions lib/aptly_package.rb
@@ -1,13 +1,13 @@
require 'aptly_cli/version'
require 'aptly_command'
require 'aptly_load'
require 'httmultiparty'
require 'httparty'
require 'json'

module AptlyCli
# Aptly Package API
class AptlyPackage < AptlyCommand
include HTTMultiParty
include HTTParty

def package_show(package_key)
uri = "/packages/#{package_key}"
Expand Down
12 changes: 6 additions & 6 deletions lib/aptly_publish.rb
@@ -1,13 +1,13 @@
require 'aptly_cli/version'
require 'aptly_command'
require 'aptly_load'
require 'httmultiparty'
require 'httparty'
require 'json'

module AptlyCli
# :nodoc:
class AptlyPublish < AptlyCommand
include HTTMultiParty
include HTTParty

@@available_gpg_options = [:skip, :batch, :gpgKey, :keyring, :secretKeyring,
:passphrase, :passphraseFile]
Expand Down Expand Up @@ -92,8 +92,8 @@ def publish_repo(names, publish_options={})

@body_json = @body.to_json

self.class.post(uri, headers: { 'Content-Type' => 'application/json' },
body: @body_json)
self.class.post(uri, :headers => { 'Content-Type' => 'application/json' },
:body => @body_json)
end

def publish_update(publish_options={})
Expand All @@ -118,8 +118,8 @@ def publish_update(publish_options={})
uri += "/#{publish_options[:distribution]}"

@body_json = @body.to_json
self.class.put(uri, headers: { 'Content-Type' => 'application/json' },
body: @body_json)
self.class.put(uri, :headers => { 'Content-Type' => 'application/json' },
:body => @body_json)
end
end
end
20 changes: 10 additions & 10 deletions lib/aptly_repo.rb
@@ -1,14 +1,14 @@
require 'aptly_cli/version'
require 'aptly_command'
require 'aptly_load'
require 'httmultiparty'
require 'httparty'
require 'json'
require 'uri'

module AptlyCli
# Aptly class to work with Repo API
class AptlyRepo < AptlyCommand
include HTTMultiParty
include HTTParty

def repo_create(repo_options = { name: nil,
comment: nil,
Expand All @@ -20,11 +20,11 @@ def repo_create(repo_options = { name: nil,
default_distribution = repo_options[:DefaultDistribution]
default_component = repo_options[:DefaultComponent]
self.class.post(uri,
query:
:body =>
{ 'Name' => name, 'Comment' => comment,
'DefaultDistribution' => default_distribution,
'DefaultComponent' => default_component }.to_json,
headers: { 'Content-Type' => 'application/json' })
:headers => { 'Content-Type' => 'application/json' })
end

def repo_delete(repo_options = { name: nil, force: nil })
Expand All @@ -42,8 +42,8 @@ def repo_edit(name, repo_options = { k => v })
repo_value = v
end

self.class.put(uri, query: { repo_option => repo_value }.to_json,
headers: { 'Content-Type' => 'application/json' })
self.class.put(uri, :body => { repo_option => repo_value }.to_json,
:headers => { 'Content-Type' => 'application/json' })
end

def repo_list
Expand All @@ -59,8 +59,8 @@ def repo_package_add(repo_options, packages)
uri = '/repos/' + repo_options[:name] + '/packages'
self.class.post(
uri,
body: { PackageRefs: packages }.to_json,
headers: { 'Content-Type' => 'application/json' }
:body => { PackageRefs: packages }.to_json,
:headers => { 'Content-Type' => 'application/json' }
)
end

Expand All @@ -72,8 +72,8 @@ def repo_package_delete(repo_options, packages)
uri = '/repos/' + repo_options[:name] + '/packages'
self.class.delete(
uri,
body: { PackageRefs: packages }.to_json,
headers: { 'Content-Type' => 'application/json' }
:body => { PackageRefs: packages }.to_json,
:headers => { 'Content-Type' => 'application/json' }
)
end

Expand Down
14 changes: 7 additions & 7 deletions lib/aptly_snapshot.rb
@@ -1,13 +1,13 @@
require 'aptly_cli/version'
require 'aptly_command'
require 'aptly_load'
require 'httmultiparty'
require 'httparty'
require 'json'

module AptlyCli
# Aptly class to work with Snapshot API
class AptlySnapshot < AptlyCommand
include HTTMultiParty
include HTTParty

def snapshot_delete(name, force=nil)
uri = "/snapshots/#{name}"
Expand All @@ -25,21 +25,21 @@ def snapshot_create(name, repo, description=nil)
# Build uri to create snapshot, requires name of snap and name of repo
uri = "/repos/#{repo}/" + 'snapshots'

self.class.post(uri, query:
self.class.post(uri, :body =>
{ 'Name' => name,
'Description' => description }.to_json,
headers: { 'Content-Type' => 'application/json' })
:headers => { 'Content-Type' => 'application/json' })
end

def snapshot_create_ref(name, description=nil,
sourcesnapshots=[], packagerefs=[])
uri = '/snapshots'
begin
self.class.post(uri,
query: { 'Name' => name, 'Description' => description,
:body => { 'Name' => name, 'Description' => description,
'SourceSnapshots' => sourcesnapshots,
'PackageRefs' => packagerefs }.to_json,
headers: { 'Content-Type' => 'application/json' })
:headers => { 'Content-Type' => 'application/json' })
rescue HTTParty::Error => e
return e
end
Expand Down Expand Up @@ -83,7 +83,7 @@ def snapshot_update(name, new_name, description=nil)
@query[:Description] = description unless description.nil?
@query_json = @query.to_json
begin
self.class.put(uri, query: @query_json, headers:
self.class.put(uri, :body => @query_json, :headers =>
{ 'Content-Type' => 'application/json' })
rescue HTTParty::Error => e
puts e
Expand Down
4 changes: 1 addition & 3 deletions test/test_aptly_command.rb
@@ -1,5 +1,3 @@


require 'minitest_helper.rb'
require 'minitest/autorun'

Expand Down Expand Up @@ -48,7 +46,7 @@ def password(_prompt)
cmd.config[:port].must_equal 9000
cmd.config[:username].must_equal 'me'
cmd.config[:password].must_equal 'secret'
cmd.config[:debug].must_equal nil
assert_nil cmd.config[:debug]
end

it 'handles the "debug" option' do
Expand Down
8 changes: 4 additions & 4 deletions test/test_aptly_file.rb
Expand Up @@ -14,7 +14,7 @@ def post_test_file(location)

describe AptlyCli::AptlyFile do
it 'must include httparty methods' do
AptlyCli::AptlyFile.must_include HTTMultiParty
AptlyCli::AptlyFile.must_include HTTParty
end

it 'must have a default server API URL endpoint defined' do
Expand All @@ -36,9 +36,9 @@ def test_file_get
end

def test_file_get_no_file_uri
assert_equal '200', file_api.file_get('/').code.to_s
assert_includes file_api.file_get('/'), "testdirfile"
ensure
assert_equal '200', file_api.file_dir.code.to_s
assert_includes file_api.file_dir, "testdirfile"
end
end

Expand Down Expand Up @@ -72,7 +72,7 @@ def test_file_delete
end

it 'must parse the api response from JSON to Array' do
api_file.file_get('test').must_be_instance_of Array
api_file.file_get('test').must_be_instance_of Array
end

it 'must parse the api response from JSON to Array' do
Expand Down
2 changes: 1 addition & 1 deletion test/test_aptly_misc.rb
Expand Up @@ -5,7 +5,7 @@

describe AptlyCli::AptlyMisc do
it 'must include httparty methods' do
AptlyCli::AptlyMisc.must_include HTTMultiParty
AptlyCli::AptlyMisc.must_include HTTParty
end

describe 'Test if config contains username' do
Expand Down
2 changes: 1 addition & 1 deletion test/test_aptly_package.rb
Expand Up @@ -5,7 +5,7 @@

describe AptlyCli::AptlyPackage do
it "must include httparty methods" do
AptlyCli::AptlyPackage.must_include HTTMultiParty
AptlyCli::AptlyPackage.must_include HTTParty
end

describe "API List Package" do
Expand Down

0 comments on commit b80e9fd

Please sign in to comment.