diff --git a/.travis.yml b/.travis.yml index ed02fd86..a3231a02 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,6 @@ language: ruby rvm: - - 1.8.7 - - 1.9.2 - 1.9.3 - 2.0.0 - 2.1.0 -env: DNSIMPLE_TEST_CONFIG=spec/ci/.dnsimple.test COVERALL=1 - -matrix: - allow_failures: - - rvm: 1.8.7 +env: COVERALL=1 diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index c49ed87b..8df50519 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -1,5 +1,13 @@ # Changelog +#### master + +- CHANGED: Drop 1.8.7 support. + +- CHANGED: This package no longer provides a CLI. The CLI has been extracted to [aetrion/dnsimple-ruby-cli](https://github.com/aetrion/dnsimple-ruby-cli) + +- REMOVED: The library no longer provides built-in support for loading the credentials from a config file. + #### Release 1.7.1 - FIXED: Updated Certificate to match the serialized attributes (GH-53) diff --git a/LICENSE b/LICENSE index 664c26e5..a8a03074 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2010-2013 Aetrion LLC +Copyright (c) 2010-2014 Aetrion LLC MIT License diff --git a/README.markdown b/README.markdown index 9f690452..5594236f 100644 --- a/README.markdown +++ b/README.markdown @@ -8,10 +8,12 @@ A Ruby client for the [DNSimple API](http://developer.dnsimple.com/). [DNSimple](https://dnsimple.com/) provides DNS hosting and domain registration that is simple and friendly. We provide a full API and an easy-to-use web interface so you can get your domain registered and set up with a minimal amount of effort. + ## Installation $ gem install dnsimple-ruby + ## DNSimple Client This library provides a Ruby DNSimple client you can use to interact with the [DNSimple API](http://developer.dnsimple.com/). Here's a short example. @@ -75,85 +77,3 @@ DNSimple::Client.api_token = 'the-token' user = DNSimple::User.me ``` - - -## Credentials - -Create a file in your home directory called `.dnsimple`. - -In this file add the following: - - username: YOUR_USERNAME - password: YOUR_PASSWORD - -Or if using an API token - - username: YOUR_USERNAME - api_token: YOUR_API_TOKEN - -## Commands - -There are two ways to interact with the DNSimple Ruby wrapper. The first is -to use the command line utility that is included. The commands available -are as follows: - -For help: - -- dnsimple help - -The following commands are available for domains: - -- dnsimple list -- dnsimple describe domain.com -- dnsimple create domain.com -- dnsimple register domain.com registrant_id -- dnsimple transfer domain.com registrant_id [authinfo] -- dnsimple delete domain.com -- dnsimple apply domain.com template_short_name - -Please note that domain registration and transfer can only be done through the API for domains that do not require extended attributes. A future version of the API will add support for extended attributes. - -The following commands are available for records: - -- dnsimple record:create [--prio=priority] domain.com name type content [ttl] -- dnsimple record:list domain.com -- dnsimple record:delete domain.com record_id - -The following commands are available for custom templates: - -- dnsimple template:list -- dnsimple template:create name short_name [description] -- dnsimple template:delete short_name -- dnsimple template:list_records short_name -- dnsimple template:add_record short_name name type content [ttl] [prio] -- dnsimple template:delete_record short_name template_record_id - -The following commands are available for managing contacts: - -- dnsimple contact:list -- dnsimple contact:describe id -- dnsimple contact:create [name:value name:value ...] -- dnsimple contact:update id [name:value name:value ...] -- dnsimple contact:delete id - -The following commands are available for purchasing certificates: - -- dnsimple certificate:purchase domain.com name contact_id -- dnsimple certificate:submit id - -The contact name/value pairs are: - -- first_name -- last_name -- organization_name (optional) -- job_title (required if organization name is specified) -- address1 -- address2 (optional) -- city -- state_province (also aliased as state) -- postal_code -- country -- email -- phone -- phone_ext (optional) -- fax (optional) diff --git a/bin/dnsimple b/bin/dnsimple deleted file mode 100755 index 2e3e1345..00000000 --- a/bin/dnsimple +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env ruby - -require 'rubygems' -require File.dirname(__FILE__) + '/dnsimple' diff --git a/bin/dnsimple.rb b/bin/dnsimple.rb deleted file mode 100755 index 87338fae..00000000 --- a/bin/dnsimple.rb +++ /dev/null @@ -1,156 +0,0 @@ -#!/usr/bin/env ruby - -$:.unshift(File.dirname(__FILE__) + '/../lib') -require 'dnsimple' -require 'dnsimple/cli' - -cli = DNSimple::CLI.new - -require 'optparse' - -def usage - $stderr.puts < OptionParser.new do |opts| - opts.on("--template [ARG]") do |opt| - options[:template] = opt - end - end, - 'register' => OptionParser.new do |opts| - opts.on("--template [ARG]") do |opt| - options[:template] = opt - end - end, - 'record:create' => OptionParser.new do |opts| - opts.on("--prio [ARG]") do |prio| - options[:prio] = prio - end - end, - 'template:add_record' => OptionParser.new do |opts| - opts.on("--prio [ARG]") do |prio| - options[:prio] = prio - end - end, - } - - global.order! - command = ARGV.shift - if command.nil? || command == 'help' - usage - else - options_parser = subcommands[command] - options_parser.order! if options_parser - begin - cli.execute(command, ARGV, options) - rescue DNSimple::CommandNotFound => e - puts e.message - end - end - -end diff --git a/dnsimple-ruby.gemspec b/dnsimple-ruby.gemspec index ef2e7976..9c83b9d3 100644 --- a/dnsimple-ruby.gemspec +++ b/dnsimple-ruby.gemspec @@ -5,23 +5,22 @@ require 'dnsimple/version' Gem::Specification.new do |s| s.name = 'dnsimple-ruby' s.version = DNSimple::VERSION - s.authors = ['Anthony Eden'] - s.email = ['anthony.eden@dnsimple.com'] + s.authors = ['Anthony Eden', 'Simone Carletti'] + s.email = ['anthony.eden@dnsimple.com', 'simone.carletti@dnsimple.com'] s.homepage = 'http://github.com/aetrion/dnsimple-ruby' s.summary = 'A Ruby client for the DNSimple API' s.description = 'A Ruby client for the DNSimple API that also includes a command-line client.' + s.required_ruby_version = ">= 1.9.3" + s.require_paths = ['lib'] s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") s.extra_rdoc_files = %w( README.markdown CHANGELOG.markdown LICENSE ) - s.executables = `git ls-files -- bin/*`.split("\n").collect { |f| File.basename(f) } - s.add_dependency 'httparty', RUBY_VERSION < "1.9.3" ? [">= 0.10", "< 0.12"] : "~> 0.12" + s.add_dependency 'httparty' s.add_development_dependency 'rake' - s.add_development_dependency 'aruba' - s.add_development_dependency 'cucumber' s.add_development_dependency 'mocha' s.add_development_dependency 'rspec' s.add_development_dependency 'yard' diff --git a/features/README.md b/features/README.md deleted file mode 100644 index b72bfd0a..00000000 --- a/features/README.md +++ /dev/null @@ -1,9 +0,0 @@ -Before running the DNSimple Ruby Client cucumber feature files, you must do the following: - -1. If you haven't already go to https://sandbox.dnsimple.com and create an account. Activate your account to the Platinum level using the credit card number of "1". - -2. Create a file in your home directory called .dnsimple.test and include the following: - - username: YOUR_USERNAME - password: YOUR_PASSWORD - base_uri: https://api.sandbox.dnsimple.com/ diff --git a/features/cli/certificates/purchase_certificate.feature b/features/cli/certificates/purchase_certificate.feature deleted file mode 100644 index c8796f9e..00000000 --- a/features/cli/certificates/purchase_certificate.feature +++ /dev/null @@ -1,10 +0,0 @@ -Feature: purchase a certificate with the CLI - As a user - In order to purchase a certificate - I should be able to use the CLI for purchasing a certificate - - @announce-cmd @announce-stdout - Scenario: - Given I have set up my credentials - When I run `dnsimple certificate:purchase` with a domain I created - Then the output should show that a certificate was purchased diff --git a/features/cli/contacts/create_contact.feature b/features/cli/contacts/create_contact.feature deleted file mode 100644 index 7cc5db53..00000000 --- a/features/cli/contacts/create_contact.feature +++ /dev/null @@ -1,10 +0,0 @@ -Feature: create a contact with the CLI - As a user - In order to add a contact to my list of contacts - I should be able to use the CLI to create a contact - - @announce-cmd - Scenario: - Given I have set up my credentials - When I run `dnsimple contact:create first:John last:Smith address1:"Example Road" city:Anytown state:Florida postal_code:12345 country:US email:john.smith@example.com phone:12225051122 label:test-contact` - Then the output should contain "Created contact John Smith" diff --git a/features/cli/domains/check_domain.feature b/features/cli/domains/check_domain.feature deleted file mode 100644 index 130e5abf..00000000 --- a/features/cli/domains/check_domain.feature +++ /dev/null @@ -1,10 +0,0 @@ -Feature: check a domain with the CLI - As a user - In order to check if a domain is available for registration - I should be able to use the CLI to check domains - - @announce-cmd - Scenario: - Given I have set up my credentials - When I run `dnsimple check domain.com` - Then the output should contain "Check domain result for domain.com: registered" diff --git a/features/cli/domains/create_domain.feature b/features/cli/domains/create_domain.feature deleted file mode 100644 index 96926553..00000000 --- a/features/cli/domains/create_domain.feature +++ /dev/null @@ -1,10 +0,0 @@ -Feature: add a domain with the CLI - As a user - In order to add a domain to my account - I should be able to use the CLI to add domains - - @announce-cmd - Scenario: - Given I have set up my credentials - When I run `dnsimple create` with a new domain - Then the output should show that the domain was created diff --git a/features/cli/domains/delete_domain.feature b/features/cli/domains/delete_domain.feature deleted file mode 100644 index 0689c2b3..00000000 --- a/features/cli/domains/delete_domain.feature +++ /dev/null @@ -1,11 +0,0 @@ -Feature: delete a domain with the CLI - As a user - In order to remove a domain from my account - I should be able to use the CLI to delete domains - - @announce-cmd @skip-delete - Scenario: - Given I have set up my credentials - When I run `dnsimple delete` with a domain I created - Then the output should show that the domain was deleted - diff --git a/features/cli/domains/register_domain.feature b/features/cli/domains/register_domain.feature deleted file mode 100644 index 64e23507..00000000 --- a/features/cli/domains/register_domain.feature +++ /dev/null @@ -1,10 +0,0 @@ -Feature: register a domain with the CLI - As a user - In order to register a domain - I should be able to use the CLI for domain registration - - @announce-cmd @announce-stdout - Scenario: - Given I have set up my credentials - When I run `dnsimple register` with a new domain - Then the output should show that the domain was registered diff --git a/features/cli/records/create_ptr_record.feature b/features/cli/records/create_ptr_record.feature deleted file mode 100644 index 3156de66..00000000 --- a/features/cli/records/create_ptr_record.feature +++ /dev/null @@ -1,11 +0,0 @@ -Feature: add a PTR record with the CLI - As a user - In order to add a PTR record to a domain in my account - I should be able to use the CLI to add the PTR record - - @announce-cmd @announce-stdout - Scenario: - Given I have set up my credentials - When I run `dnsimple create` with a in-addr.arpa domain - And I run `dnsimple record:create` with the domain I added and the name "1" and the type "PTR" and the content "domain.com" - Then the output should show that the "PTR" record was created diff --git a/features/cli/records/create_record.feature b/features/cli/records/create_record.feature deleted file mode 100644 index 6a9fbb9d..00000000 --- a/features/cli/records/create_record.feature +++ /dev/null @@ -1,12 +0,0 @@ -Feature: add a record with the CLI - As a user - In order to add records to a domain in my account - I should be able to use the CLI to add records - - @announce-cmd @announce-stdout - Scenario: - Given I have set up my credentials - When I run `dnsimple create` with a new domain - And I run `dnsimple record:create` with the domain I added and no name and the type "A" and the content "1.2.3.4" - Then the output should show that the "A" record was created - And the output should include the record id diff --git a/features/cli/records/delete_record.feature b/features/cli/records/delete_record.feature deleted file mode 100644 index 7a9f6afb..00000000 --- a/features/cli/records/delete_record.feature +++ /dev/null @@ -1,14 +0,0 @@ -Feature: delete a record with the CLI - As a user - In order to remove a record from a domain in my account - I should be able to use the CLI to delete a record - - @announce-cmd @announce-stdout - Scenario: - Given I have set up my credentials - When I run `dnsimple create` with a new domain - And I run `dnsimple record:create` with the domain I added and no name and the type "A" and the content "1.2.3.4" - And I note the id of the record I added - And I run `dnsimple record:delete` with the id of the record - Then the output should show that the record was deleted - diff --git a/features/cli/templates/apply_template.feature b/features/cli/templates/apply_template.feature deleted file mode 100644 index 530237bb..00000000 --- a/features/cli/templates/apply_template.feature +++ /dev/null @@ -1,11 +0,0 @@ -Feature: apply a template to a domain - As a user - In order to apply a set of records to a domain at once - I should be able to use the CLI to apply a template - - Scenario: - Given I have set up my credentials - When I run `dnsimple create` with a new domain - And I run `dnsimple apply` with the domain and the template named "googleapps" - Then the output should show that the template was applied - And I the domain should have 13 records diff --git a/features/step_definitions/certificate_steps.rb b/features/step_definitions/certificate_steps.rb deleted file mode 100644 index 9008a513..00000000 --- a/features/step_definitions/certificate_steps.rb +++ /dev/null @@ -1,3 +0,0 @@ -Then /^the output should show that a certificate was purchased$/ do - steps %Q(Then the output should contain "Purchased certificate for #{@domain_name}") -end diff --git a/features/step_definitions/cli_steps.rb b/features/step_definitions/cli_steps.rb deleted file mode 100644 index fa8b1bb4..00000000 --- a/features/step_definitions/cli_steps.rb +++ /dev/null @@ -1,8 +0,0 @@ -Given /^I have set up my credentials$/ do - path = DNSimple::Client.config_path - File.exists?(File.expand_path(path)).should be_truthy, "Please set up your #{path} file to continue" - credentials = YAML.load(File.new(File.expand_path(path))) - expect(credentials['username']).to_not be_nil, "You must specify a username in your #{path} file" - expect(credentials['password']).to_not be_nil, "You must specify a password in your #{path} file" - expect(credentials['base_uri']).to_not be_nil, "For cucumber to run, you must specify a base_uri in your #{path} file" -end diff --git a/features/step_definitions/domain_steps.rb b/features/step_definitions/domain_steps.rb deleted file mode 100644 index d695056a..00000000 --- a/features/step_definitions/domain_steps.rb +++ /dev/null @@ -1,32 +0,0 @@ -When /^I run `(.*)` with a new domain$/ do |cmd| - @domain_name = "cli-test-#{Time.now.to_i}.com" - steps %Q(When I run `#{cmd} #{@domain_name}`) -end - -When /^I run `(.*)` with a in\-addr\.arpa domain$/ do |cmd| - @domain_name = '0.0.10.in-addr.arpa' - steps %Q(When I run `#{cmd} #{@domain_name}`) -end - -When /^I run `(.*)` with a domain I created$/ do |cmd| - steps %Q( - When I run `dnsimple create` with a new domain - ) - steps %Q( - And I run `#{cmd} #{@domain_name}` - ) -end - -Then /^the output should show that the domain was created$/ do - steps %Q(Then the output should contain "Created #{@domain_name}") -end - -Then /^the output should show that the domain was deleted$/ do - steps %Q(Then the output should contain "Deleted #{@domain_name}") -end - -Then /^the output should show that the domain was registered$/ do - steps %Q(Then the output should contain "Registered #{@domain_name}") -end - - diff --git a/features/step_definitions/record_steps.rb b/features/step_definitions/record_steps.rb deleted file mode 100644 index d9882778..00000000 --- a/features/step_definitions/record_steps.rb +++ /dev/null @@ -1,38 +0,0 @@ -When /^I run `(.*)` with the domain I added and no name and the type "([^\"]*)" and the content "([^\"]*)"$/ do |cmd, type, content| - steps %Q(When I run `#{cmd} #{@domain_name} '' #{type} #{content}`) -end - -When /^I run `(.*)` with the domain I added and the name "([^\"]*)" and the type "([^\"]*)" and the content "([^\"]*)"$/ do |cmd, name, type, content| - steps %Q(When I run `#{cmd} #{@domain_name} #{name} #{type} #{content}`) -end - -When /^I run `(.*)` with the id of the record$/ do |cmd| - steps %Q(When I run `#{cmd} #{@domain_name} #{@record_id}`) -end - -When /^I note the id of the record I added$/ do - ps = only_processes.last - fail "No last process" unless ps - m = ps.stdout.match(/id:(\d+)/) - fail "Unable to find ID of record" unless m - @record_id = m[1] -end - -Then /^the output should show that the "([^\"]*)" record was created$/ do |type| - steps %Q(Then the output should contain "Created #{type} record for #{@domain_name}") -end - -Then /^the output should include the record id$/ do - steps %Q(Then the output should match /id:(\\d+)/) -end - -Then /^the output should show that the record was deleted$/ do - steps %Q(Then the output should contain "Deleted #{@record_id} from #{@domain_name}") -end - -Then /^I the domain should have (\d+) records$/ do |n| - steps %Q( - When I run `dnsimple record:list #{@domain_name}` - Then the output should contain "Found #{n} records for #{@domain_name}" - ) -end diff --git a/features/step_definitions/template_steps.rb b/features/step_definitions/template_steps.rb deleted file mode 100644 index 67341c62..00000000 --- a/features/step_definitions/template_steps.rb +++ /dev/null @@ -1,9 +0,0 @@ -When /^I run `(.*)` with the domain and the template named "([^\"]*)"$/ do |cmd, template| - @template_name = template - steps %Q(When I run `#{cmd} #{@domain_name} #{template}`) -end - -Then /^the output should show that the template was applied$/ do - steps %Q(Then the output should contain "Applied template #{@template_name} to #{@domain_name}") -end - diff --git a/features/support/env.rb b/features/support/env.rb deleted file mode 100644 index e7b225d8..00000000 --- a/features/support/env.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'rubygems' -require 'bundler/setup' -require 'aruba/cucumber' - -$:.unshift(File.dirname(__FILE__) + '/lib') -require 'dnsimple' - -Before do - @aruba_timeout_seconds = 30 - ENV['DNSIMPLE_CONFIG'] = '~/.dnsimple.test' -end - -After do |scenario| - unless ENV['NODELETE'] || scenario.source_tag_names.include?('@skip-delete') - if @domain_name && (@domain_name =~ /^cli-/ || @domain_name =~ /in-addr\.arpa/) - steps %Q(When I run `dnsimple delete #{@domain_name}`) - end - end -end diff --git a/lib/dnsimple/cli.rb b/lib/dnsimple/cli.rb deleted file mode 100644 index f3389e47..00000000 --- a/lib/dnsimple/cli.rb +++ /dev/null @@ -1,121 +0,0 @@ -module DNSimple - - class CommandNotFound < RuntimeError - end - - class CLI - - def execute(command_name, args, options={}) - DNSimple::Client.load_credentials_if_necessary - command = commands[command_name] - if command - begin - command.new.execute(args, options) - rescue DNSimple::Error => e - puts "An error occurred: #{e.message}" - rescue RuntimeError => e - puts "An error occurred: #{e.message}" - end - else - raise CommandNotFound, "Unknown command: #{command_name}" - end - end - - def commands - { - 'info' => DNSimple::Commands::Me, - - 'list' => DNSimple::Commands::DomainList, - 'describe' => DNSimple::Commands::DomainDescribe, - 'check' => DNSimple::Commands::DomainCheck, - 'create' => DNSimple::Commands::DomainCreate, - 'register' => DNSimple::Commands::DomainRegister, - 'transfer' => DNSimple::Commands::DomainTransfer, - 'delete' => DNSimple::Commands::DomainDelete, - 'clear' => DNSimple::Commands::DomainClear, - 'apply' => DNSimple::Commands::DomainApplyTemplate, - - 'record:describe' => DNSimple::Commands::RecordDescribe, - 'record:create' => DNSimple::Commands::RecordCreate, - 'record:list' => DNSimple::Commands::RecordList, - 'record:update' => DNSimple::Commands::RecordUpdate, - 'record:delete' => DNSimple::Commands::RecordDelete, - - 'template:create' => DNSimple::Commands::TemplateCreate, - 'template:list' => DNSimple::Commands::TemplateList, - 'template:delete' => DNSimple::Commands::TemplateDelete, - - 'template:list_records' => DNSimple::Commands::TemplateRecordList, - 'template:add_record' => DNSimple::Commands::TemplateRecordCreate, - 'template:delete_record' => DNSimple::Commands::TemplateRecordDelete, - - 'contact:create' => DNSimple::Commands::ContactCreate, - 'contact:list' => DNSimple::Commands::ContactList, - 'contact:describe' => DNSimple::Commands::ContactDescribe, - 'contact:update' => DNSimple::Commands::ContactUpdate, - 'contact:delete' => DNSimple::Commands::ContactDelete, - - 'extended-attributes:list' => DNSimple::Commands::ExtendedAttributeList, - - 'service:list' => DNSimple::Commands::ServiceList, - 'service:describe' => DNSimple::Commands::ServiceDescribe, - - 'service:applied' => DNSimple::Commands::ServiceListApplied, - 'service:available' => DNSimple::Commands::ServiceListAvailable, - 'service:add' => DNSimple::Commands::ServiceAdd, - 'service:remove' => DNSimple::Commands::ServiceRemove, - - 'certificate:list' => DNSimple::Commands::CertificateList, - 'certificate:describe' => DNSimple::Commands::CertificateDescribe, - 'certificate:purchase' => DNSimple::Commands::CertificatePurchase, - 'certificate:submit' => DNSimple::Commands::CertificateSubmit, - } - end - end -end - -require 'dnsimple/commands/me' - -require 'dnsimple/commands/domain_list' -require 'dnsimple/commands/domain_describe' -require 'dnsimple/commands/domain_check' -require 'dnsimple/commands/domain_create' -require 'dnsimple/commands/domain_register' -require 'dnsimple/commands/domain_transfer' -require 'dnsimple/commands/domain_delete' -require 'dnsimple/commands/domain_clear' -require 'dnsimple/commands/domain_apply_template' - -require 'dnsimple/commands/record_list' -require 'dnsimple/commands/record_describe' -require 'dnsimple/commands/record_create' -require 'dnsimple/commands/record_update' -require 'dnsimple/commands/record_delete' - -require 'dnsimple/commands/template_list' -require 'dnsimple/commands/template_create' -require 'dnsimple/commands/template_delete' -require 'dnsimple/commands/template_record_list' -require 'dnsimple/commands/template_record_create' -require 'dnsimple/commands/template_record_delete' - -require 'dnsimple/commands/contact_list' -require 'dnsimple/commands/contact_describe' -require 'dnsimple/commands/contact_create' -require 'dnsimple/commands/contact_update' -require 'dnsimple/commands/contact_delete' - -require 'dnsimple/commands/extended_attribute_list' - -require 'dnsimple/commands/service_list' -require 'dnsimple/commands/service_describe' - -require 'dnsimple/commands/service_list_available' -require 'dnsimple/commands/service_list_applied' -require 'dnsimple/commands/service_add' -require 'dnsimple/commands/service_remove' - -require 'dnsimple/commands/certificate_list' -require 'dnsimple/commands/certificate_describe' -require 'dnsimple/commands/certificate_purchase' -require 'dnsimple/commands/certificate_submit' diff --git a/lib/dnsimple/client.rb b/lib/dnsimple/client.rb index b41c1a71..21133224 100644 --- a/lib/dnsimple/client.rb +++ b/lib/dnsimple/client.rb @@ -37,37 +37,6 @@ def self.http_proxy @http_proxy end - def self.load_credentials_if_necessary - load_credentials unless credentials_loaded? - end - - def self.config_path - ENV['DNSIMPLE_CONFIG'] || '~/.dnsimple' - end - - def self.load_credentials(path = config_path) - begin - credentials = YAML.load_file(File.expand_path(path)) - self.username = credentials['username'] - self.password = credentials['password'] - self.exchange_token = credentials['exchange_token'] - self.api_token = credentials['api_token'] - self.domain_api_token = credentials['domain_api_token'] - self.base_uri = credentials['site'] if credentials['site'] - self.base_uri = credentials['base_uri'] if credentials['base_uri'] - @http_proxy = { :addr => credentials['proxy_addr'], :port => credentials['proxy_port'] } if credentials['proxy_addr'] || credentials['proxy_port'] - @credentials_loaded = true - puts "Credentials loaded from #{path}" - rescue => error - puts "Error loading your credentials: #{error.message}" - exit 1 - end - end - - def self.credentials_loaded? - (@credentials_loaded ||= false) or domain_api_token or (username and (password or api_token)) - end - def self.base_options options = { :format => :json, diff --git a/lib/dnsimple/commands/certificate_describe.rb b/lib/dnsimple/commands/certificate_describe.rb deleted file mode 100644 index 699d5cb0..00000000 --- a/lib/dnsimple/commands/certificate_describe.rb +++ /dev/null @@ -1,34 +0,0 @@ -module DNSimple - module Commands - class CertificateDescribe - def execute(args, options = {}) - domain_name = args.shift - certificate_id = args.shift - domain = Domain.find(domain_name) - certificate = Certificate.find(domain, certificate_id) - puts "Certificate: #{certificate.fqdn}" - puts "\tID: #{certificate.id}" - puts "\tStatus: #{certificate.certificate_status}" - puts "\tCreated: #{certificate.created_at}" - puts "\tOrder Date: #{certificate.order_date}" - puts "\tExpires: #{certificate.expiration_date}" - - if certificate.approver_email =~ /\S+/ - puts "\tApprover email: #{certificate.approver_email}" - else - puts "\tAvailable approver emails:" - certificate.available_approver_emails.split(",").each do |email| - puts "\t\t#{email}" - end - end - - puts - puts "#{certificate.csr}" - puts - puts "#{certificate.private_key}" - puts - puts "#{certificate.ssl_certificate}" - end - end - end -end diff --git a/lib/dnsimple/commands/certificate_list.rb b/lib/dnsimple/commands/certificate_list.rb deleted file mode 100644 index 3ef25ff3..00000000 --- a/lib/dnsimple/commands/certificate_list.rb +++ /dev/null @@ -1,15 +0,0 @@ -module DNSimple - module Commands - class CertificateList - def execute(args, options = {}) - domain_name = args.shift - domain = DNSimple::Domain.find(domain_name) - certificates = DNSimple::Certificate.all(domain) - puts "Found #{certificates.length} certificate for #{domain_name}" - certificates.each do |certificate| - puts "\t#{certificate.fqdn} (id: #{certificate.id}, status: #{certificate.certificate_status})" - end - end - end - end -end diff --git a/lib/dnsimple/commands/certificate_purchase.rb b/lib/dnsimple/commands/certificate_purchase.rb deleted file mode 100644 index bb44c3c2..00000000 --- a/lib/dnsimple/commands/certificate_purchase.rb +++ /dev/null @@ -1,17 +0,0 @@ -module DNSimple - module Commands - class CertificatePurchase - def execute(args, options = {}) - domain_name = args.shift - name = args.shift - contact_id = args.shift - - domain = Domain.find(domain_name) - contact = Contact.find(contact_id) - - certificate = Certificate.purchase(domain, name, contact) - puts "Purchased certificate for #{certificate.fqdn}" - end - end - end -end diff --git a/lib/dnsimple/commands/certificate_submit.rb b/lib/dnsimple/commands/certificate_submit.rb deleted file mode 100644 index 20efc700..00000000 --- a/lib/dnsimple/commands/certificate_submit.rb +++ /dev/null @@ -1,17 +0,0 @@ -module DNSimple - module Commands - class CertificateSubmit - def execute(args, options = {}) - domain_name = args.shift - certificate_id = args.shift - approver_email = args.shift - - domain = DNSimple::Domain.find(domain_name) - certificate = DNSimple::Certificate.find(domain, certificate_id) - certificate.submit(approver_email) - - puts "Certificate submitted, authorization by email required" - end - end - end -end diff --git a/lib/dnsimple/commands/contact_create.rb b/lib/dnsimple/commands/contact_create.rb deleted file mode 100644 index b05ae78f..00000000 --- a/lib/dnsimple/commands/contact_create.rb +++ /dev/null @@ -1,23 +0,0 @@ -module DNSimple - module Commands - - # Command to create a contact. - # - # contact:create [ name:value name:value ... ] - # - class ContactCreate - def execute(args, options = {}) - attributes = {} - attributes['state_province_choice'] = 'S' - args.each do |arg| - name, value = arg.split(":") - attributes[Contact.resolve(name)] = value - end - - contact = Contact.create(attributes, options) - puts "Created contact #{contact.name} (id: #{contact.id})" - end - end - - end -end diff --git a/lib/dnsimple/commands/contact_delete.rb b/lib/dnsimple/commands/contact_delete.rb deleted file mode 100644 index 390c0e91..00000000 --- a/lib/dnsimple/commands/contact_delete.rb +++ /dev/null @@ -1,14 +0,0 @@ -module DNSimple - module Commands - class ContactDelete - def execute(args, options = {}) - id = args.shift - - contact = Contact.find(id) - contact.delete - - puts "Deleted #{contact.name} (id: #{contact.id})" - end - end - end -end diff --git a/lib/dnsimple/commands/contact_describe.rb b/lib/dnsimple/commands/contact_describe.rb deleted file mode 100644 index 28871970..00000000 --- a/lib/dnsimple/commands/contact_describe.rb +++ /dev/null @@ -1,25 +0,0 @@ -module DNSimple - module Commands - class ContactDescribe - def execute(args, options = {}) - id = args.shift - contact = Contact.find(id) - puts "Contact: #{contact.name}:" - puts "\tID: #{contact.id}" - puts "\tFirst Name: #{contact.first_name}" - puts "\tLast Name: #{contact.last_name}" - puts "\tOrganization Name: #{contact.organization_name}" if contact.organization_name - puts "\tJob Title: #{contact.job_title}" if contact.job_title - puts "\tAddress 1: #{contact.address1}" - puts "\tAddress 2: #{contact.address2}" - puts "\tCity: #{contact.city}" - puts "\tState or Province: #{contact.state_province}" - puts "\tPostal Code: #{contact.postal_code}" - puts "\tCountry: #{contact.country}" - puts "\tEmail: #{contact.email_address}" - puts "\tPhone: #{contact.phone}" - puts "\tPhone Ext: #{contact.phone_ext}" if contact.phone_ext - end - end - end -end diff --git a/lib/dnsimple/commands/contact_list.rb b/lib/dnsimple/commands/contact_list.rb deleted file mode 100644 index d630fa5e..00000000 --- a/lib/dnsimple/commands/contact_list.rb +++ /dev/null @@ -1,13 +0,0 @@ -module DNSimple - module Commands - class ContactList - def execute(args, options = {}) - contacts = Contact.all - puts "Found #{contacts.length} contacts:" - contacts.each do |contact| - puts "\t#{contact.name} (id:#{contact.id})" - end - end - end - end -end diff --git a/lib/dnsimple/commands/contact_update.rb b/lib/dnsimple/commands/contact_update.rb deleted file mode 100644 index 2bc42b1d..00000000 --- a/lib/dnsimple/commands/contact_update.rb +++ /dev/null @@ -1,25 +0,0 @@ -module DNSimple - module Commands - class ContactUpdate - # Execute the contact:update command. - # - # Args expected: - # id [name:value name:value ...] - def execute(args, options = {}) - attributes = {} - id = args.shift - args.each do |arg| - name, value = arg.split(":") - attributes[Contact.resolve(name)] = value - end - - contact = Contact.find(id) - attributes.each do |name, value| - contact.send("#{name}=", value) - end - contact.save - puts "Updated contact #{contact.name} (id: #{contact.id})" - end - end - end -end diff --git a/lib/dnsimple/commands/domain_apply_template.rb b/lib/dnsimple/commands/domain_apply_template.rb deleted file mode 100644 index 476afdfb..00000000 --- a/lib/dnsimple/commands/domain_apply_template.rb +++ /dev/null @@ -1,15 +0,0 @@ -module DNSimple - module Commands - class DomainApplyTemplate - def execute(args, options = {}) - domain_name = args.shift - template_name = args.shift - - domain = Domain.find(domain_name) - domain.apply(template_name) - - puts "Applied template #{template_name} to #{domain.name}" - end - end - end -end diff --git a/lib/dnsimple/commands/domain_check.rb b/lib/dnsimple/commands/domain_check.rb deleted file mode 100644 index 8deb6493..00000000 --- a/lib/dnsimple/commands/domain_check.rb +++ /dev/null @@ -1,11 +0,0 @@ -module DNSimple - module Commands - class DomainCheck - def execute(args, options = {}) - name = args.shift - response = Domain.check(name) - puts "Check domain result for #{name}: #{response}" - end - end - end -end diff --git a/lib/dnsimple/commands/domain_clear.rb b/lib/dnsimple/commands/domain_clear.rb deleted file mode 100644 index 82d35702..00000000 --- a/lib/dnsimple/commands/domain_clear.rb +++ /dev/null @@ -1,16 +0,0 @@ -module DNSimple - module Commands - class DomainClear - def execute(args, options = {}) - name = args.shift - - records = Record.all(name) - records.each do |record| - record.delete - end - - puts "Deleted #{records.length} records from #{name}" - end - end - end -end diff --git a/lib/dnsimple/commands/domain_create.rb b/lib/dnsimple/commands/domain_create.rb deleted file mode 100644 index bdcaa05f..00000000 --- a/lib/dnsimple/commands/domain_create.rb +++ /dev/null @@ -1,16 +0,0 @@ -module DNSimple - module Commands - class DomainCreate - def execute(args, options = {}) - name = args.shift - domain = Domain.create(name) - puts "Created #{domain.name}" - - if template = options.delete(:template) - domain.apply(template) - puts "Applied template #{template} to #{domain.name}" - end - end - end - end -end diff --git a/lib/dnsimple/commands/domain_delete.rb b/lib/dnsimple/commands/domain_delete.rb deleted file mode 100644 index c716677a..00000000 --- a/lib/dnsimple/commands/domain_delete.rb +++ /dev/null @@ -1,14 +0,0 @@ -module DNSimple - module Commands - class DomainDelete - def execute(args, options = {}) - name_or_id = args.shift - - domain = Domain.find(name_or_id) - domain.delete - - puts "Deleted #{domain.name}" - end - end - end -end diff --git a/lib/dnsimple/commands/domain_describe.rb b/lib/dnsimple/commands/domain_describe.rb deleted file mode 100644 index b0010ebf..00000000 --- a/lib/dnsimple/commands/domain_describe.rb +++ /dev/null @@ -1,14 +0,0 @@ -module DNSimple - module Commands - class DomainDescribe - def execute(args, options = {}) - name = args.shift - domain = Domain.find(name) - puts "Domain #{domain.name}:" - puts "\tID: #{domain.id}" - puts "\tCreated: #{domain.created_at}" - puts "\tName Server Status: #{domain.name_server_status}" - end - end - end -end diff --git a/lib/dnsimple/commands/domain_list.rb b/lib/dnsimple/commands/domain_list.rb deleted file mode 100644 index 37685938..00000000 --- a/lib/dnsimple/commands/domain_list.rb +++ /dev/null @@ -1,13 +0,0 @@ -module DNSimple - module Commands - class DomainList - def execute(args, options = {}) - domains = Domain.all - puts "Found #{domains.length} domains:" - domains.each do |domain| - puts "\t#{domain.name}" - end - end - end - end -end diff --git a/lib/dnsimple/commands/domain_register.rb b/lib/dnsimple/commands/domain_register.rb deleted file mode 100644 index c806ad6c..00000000 --- a/lib/dnsimple/commands/domain_register.rb +++ /dev/null @@ -1,33 +0,0 @@ -module DNSimple - module Commands - class DomainRegister - def execute(args, options = {}) - name = args.shift - registrant = nil - - registrant_id_or_attribute = args.shift - if registrant_id_or_attribute - if registrant_id_or_attribute =~ /^\d+$/ - registrant = {:id => registrant_id_or_attribute} - else - args.unshift(registrant_id_or_attribute) - end - end - - extended_attributes = {} - args.each do |arg| - n, v = arg.split(":") - extended_attributes[n] = v - end - - domain = Domain.register(name, registrant, extended_attributes) - puts "Registered #{domain.name}" - - if template = options.delete(:template) - domain.apply(template) - puts "Applied template #{template} to #{domain.name}" - end - end - end - end -end diff --git a/lib/dnsimple/commands/domain_transfer.rb b/lib/dnsimple/commands/domain_transfer.rb deleted file mode 100644 index d206940e..00000000 --- a/lib/dnsimple/commands/domain_transfer.rb +++ /dev/null @@ -1,21 +0,0 @@ -module DNSimple - module Commands - class DomainTransfer - def execute(args, options = {}) - name = args.shift - registrant = {:id => args.shift} - authinfo = args.shift unless args.empty? - authinfo ||= '' - - extended_attributes = {} - args.each do |arg| - n, v = arg.split(":") - extended_attributes[n] = v - end - - transfer_order = TransferOrder.create(name, authinfo, registrant, extended_attributes) - puts "Transfer order issued for #{name}" - end - end - end -end diff --git a/lib/dnsimple/commands/extended_attribute_list.rb b/lib/dnsimple/commands/extended_attribute_list.rb deleted file mode 100644 index d3c5ebe6..00000000 --- a/lib/dnsimple/commands/extended_attribute_list.rb +++ /dev/null @@ -1,25 +0,0 @@ -module DNSimple - module Commands - class ExtendedAttributeList - def execute(args, options = {}) - tld = args.shift - extended_attributes = ExtendedAttribute.find(tld) - puts "Extended attributes: " - extended_attributes.each do |extended_attribute| - o = " #{extended_attribute.name}" - o << " (required)" if extended_attribute.required - o << " : #{extended_attribute.description}\n" - unless extended_attribute.options.empty? - o << " Options:\n" - extended_attribute.options.each do |option| - o << " #{option.title}: #{option.value}" - o << " (#{option.description})" if option.description - o << "\n" - end - end - puts o - end - end - end - end -end diff --git a/lib/dnsimple/commands/me.rb b/lib/dnsimple/commands/me.rb deleted file mode 100644 index 8b362371..00000000 --- a/lib/dnsimple/commands/me.rb +++ /dev/null @@ -1,18 +0,0 @@ -module DNSimple - module Commands - class Me - def execute(args, options = {}) - puts "Connecting to #{Client.base_uri}" - user = User.me - puts "User details:" - puts "\tID:#{user.id}" - puts "\tCreated: #{user.created_at}" - puts "\tEmail: #{user.email}" - puts "\tSuccessful logins: #{user.login_count}" - puts "\tFailed logins: #{user.failed_login_count}" - puts "\tDomains in account: #{user.domain_count}" - puts "\tDomains allowed: #{user.domain_limit}" - end - end - end -end diff --git a/lib/dnsimple/commands/record_create.rb b/lib/dnsimple/commands/record_create.rb deleted file mode 100644 index 3eb48adb..00000000 --- a/lib/dnsimple/commands/record_create.rb +++ /dev/null @@ -1,18 +0,0 @@ -module DNSimple - module Commands - class RecordCreate - def execute(args, options = {}) - name = args.shift - record_name = args.shift - record_type = args.shift - content = args.shift - ttl = args.shift - - domain = Domain.find(name) - record = Record.create(domain, record_name, record_type, content, :ttl => ttl, :prio => options[:prio]) - - puts "Created #{record.record_type} record for #{domain.name} (id:#{record.id})" - end - end - end -end diff --git a/lib/dnsimple/commands/record_delete.rb b/lib/dnsimple/commands/record_delete.rb deleted file mode 100644 index 047d543d..00000000 --- a/lib/dnsimple/commands/record_delete.rb +++ /dev/null @@ -1,16 +0,0 @@ -module DNSimple - module Commands - class RecordDelete - def execute(args, options = {}) - domain_name = args.shift - id = args.shift - - domain = Domain.find(domain_name) - record = Record.find(domain, id) - record.delete - - puts "Deleted #{record.id} from #{domain.name}" - end - end - end -end diff --git a/lib/dnsimple/commands/record_describe.rb b/lib/dnsimple/commands/record_describe.rb deleted file mode 100644 index 3669a5ec..00000000 --- a/lib/dnsimple/commands/record_describe.rb +++ /dev/null @@ -1,16 +0,0 @@ -module DNSimple - module Commands - class RecordDescribe - def execute(args, options = {}) - name = args.shift - id = args.shift - record = Record.find(name, id) - puts "Record #{record.fqdn}:" - puts "\tID: #{record.id}" - puts "\tTTL: #{record.ttl}" - puts "\tPrio: #{record.prio}" - puts "\tContent: #{record.content}" - end - end - end -end diff --git a/lib/dnsimple/commands/record_list.rb b/lib/dnsimple/commands/record_list.rb deleted file mode 100644 index 96d2c8e2..00000000 --- a/lib/dnsimple/commands/record_list.rb +++ /dev/null @@ -1,19 +0,0 @@ -module DNSimple - module Commands - class RecordList - def execute(args, options = {}) - domain_name = args.shift - - records = Record.all(DNSimple::Domain.new(:name => domain_name)) - - puts "Found #{records.length} records for #{domain_name}" - records.each do |record| - extra = ["ttl:#{record.ttl}", "id:#{record.id}"] - extra << "prio:#{record.prio}" if record.record_type == "MX" - extra = "(#{extra.join(', ')})" - puts "\t#{record.name}.#{record.domain.name} (#{record.record_type})-> #{record.content} #{extra}" - end - end - end - end -end diff --git a/lib/dnsimple/commands/record_update.rb b/lib/dnsimple/commands/record_update.rb deleted file mode 100644 index cd140e9c..00000000 --- a/lib/dnsimple/commands/record_update.rb +++ /dev/null @@ -1,23 +0,0 @@ -module DNSimple - module Commands - class RecordUpdate - def execute(args, options = {}) - attributes = {} - domain_name = args.shift - id = args.shift - args.each do |arg| - name, value = arg.split(":") - attributes[Record.resolve(name)] = value - end - - domain = Domain.find(domain_name) - record = Record.find(domain, id) - attributes.each do |name, value| - record.send("#{name}=", value) - end - record.save - puts "Updated record #{record.fqdn} (id: #{record.id})" - end - end - end -end diff --git a/lib/dnsimple/commands/service_add.rb b/lib/dnsimple/commands/service_add.rb deleted file mode 100644 index e76e19cc..00000000 --- a/lib/dnsimple/commands/service_add.rb +++ /dev/null @@ -1,14 +0,0 @@ -module DNSimple - module Commands - class ServiceAdd - def execute(args, options = {}) - domain_name = args.shift - domain = Domain.find(domain_name) - short_name = args.shift - service = Service.find(short_name) - domain.add_service(short_name) - puts "Added #{service.name} to #{domain_name}" - end - end - end -end diff --git a/lib/dnsimple/commands/service_describe.rb b/lib/dnsimple/commands/service_describe.rb deleted file mode 100644 index f3adae75..00000000 --- a/lib/dnsimple/commands/service_describe.rb +++ /dev/null @@ -1,12 +0,0 @@ -module DNSimple - module Commands - class ServiceDescribe - def execute(args, options = {}) - short_name = args.shift - service = Service.find(short_name) - puts "\t#{service.name} (short: #{service.short_name}, id: #{service.id})" - puts "\t\t#{service.description}" - end - end - end -end diff --git a/lib/dnsimple/commands/service_list.rb b/lib/dnsimple/commands/service_list.rb deleted file mode 100644 index 86fabb5e..00000000 --- a/lib/dnsimple/commands/service_list.rb +++ /dev/null @@ -1,14 +0,0 @@ -module DNSimple - module Commands - class ServiceList - def execute(args, options = {}) - services = Service.all - puts "Found #{services.length} services:" - services.each do |service| - puts "\t#{service.name} (short: #{service.short_name}, id: #{service.id})" - puts "\t\t#{service.description}" - end - end - end - end -end diff --git a/lib/dnsimple/commands/service_list_applied.rb b/lib/dnsimple/commands/service_list_applied.rb deleted file mode 100644 index bb06a821..00000000 --- a/lib/dnsimple/commands/service_list_applied.rb +++ /dev/null @@ -1,16 +0,0 @@ -module DNSimple - module Commands - class ServiceListApplied - def execute(args, options = {}) - domain_name = args.shift - domain = Domain.find(domain_name) - services = domain.applied_services - puts "Found #{services.length} applied services for #{domain_name}" - services.each do |service| - puts "\t#{service.name} (short: #{service.short_name}, id: #{service.id})" - puts "\t\t#{service.description}" - end - end - end - end -end diff --git a/lib/dnsimple/commands/service_list_available.rb b/lib/dnsimple/commands/service_list_available.rb deleted file mode 100644 index 7693d59c..00000000 --- a/lib/dnsimple/commands/service_list_available.rb +++ /dev/null @@ -1,16 +0,0 @@ -module DNSimple - module Commands - class ServiceListAvailable - def execute(args, options = {}) - domain_name = args.shift - domain = Domain.find(domain_name) - services = domain.available_services - puts "Found #{services.length} available services for #{domain_name}" - services.each do |service| - puts "\t#{service.name} (short: #{service.short_name}, id: #{service.id})" - puts "\t\t#{service.description}" - end - end - end - end -end diff --git a/lib/dnsimple/commands/service_remove.rb b/lib/dnsimple/commands/service_remove.rb deleted file mode 100644 index 47014407..00000000 --- a/lib/dnsimple/commands/service_remove.rb +++ /dev/null @@ -1,14 +0,0 @@ -module DNSimple - module Commands - class ServiceRemove - def execute(args, options = {}) - domain_name = args.shift - domain = Domain.find(domain_name) - short_name = args.shift - service = Service.find(short_name) - domain.remove_service(service.id) - puts "Removed #{service.name} from #{domain_name}" - end - end - end -end diff --git a/lib/dnsimple/commands/template_create.rb b/lib/dnsimple/commands/template_create.rb deleted file mode 100644 index c18b6bca..00000000 --- a/lib/dnsimple/commands/template_create.rb +++ /dev/null @@ -1,14 +0,0 @@ -module DNSimple - module Commands - class TemplateCreate - def execute(args, options = {}) - name = args.shift - short_name = args.shift - description = args.shift unless args.empty? - - template = Template.create(name, short_name, description) - puts "Created #{template.name} (short_name:#{template.short_name})" - end - end - end -end diff --git a/lib/dnsimple/commands/template_delete.rb b/lib/dnsimple/commands/template_delete.rb deleted file mode 100644 index 59632217..00000000 --- a/lib/dnsimple/commands/template_delete.rb +++ /dev/null @@ -1,13 +0,0 @@ -module DNSimple - module Commands - class TemplateDelete - def execute(args, options = {}) - short_name = args.shift - template = Template.find(short_name) - template.delete - - puts "Deleted template #{short_name}" - end - end - end -end diff --git a/lib/dnsimple/commands/template_list.rb b/lib/dnsimple/commands/template_list.rb deleted file mode 100644 index 6a2bf107..00000000 --- a/lib/dnsimple/commands/template_list.rb +++ /dev/null @@ -1,13 +0,0 @@ -module DNSimple - module Commands - class TemplateList - def execute(args, options = {}) - templates = Template.all - puts "Found #{templates.length} templates:" - templates.each do |template| - puts "\t#{template.name} (short_name:#{template.short_name})" - end - end - end - end -end diff --git a/lib/dnsimple/commands/template_record_create.rb b/lib/dnsimple/commands/template_record_create.rb deleted file mode 100644 index 48491311..00000000 --- a/lib/dnsimple/commands/template_record_create.rb +++ /dev/null @@ -1,18 +0,0 @@ -module DNSimple - module Commands - class TemplateRecordCreate - def execute(args, options = {}) - short_name = args.shift - record_name = args.shift - record_type = args.shift - content = args.shift - ttl = args.shift - - template = Template.find(short_name) - record = TemplateRecord.create(template.short_name, record_name, record_type, content, :ttl => ttl, :prio => options[:prio]) - - puts "Created #{record.record_type} with content '#{record.content}' record for template #{template.name}" - end - end - end -end diff --git a/lib/dnsimple/commands/template_record_delete.rb b/lib/dnsimple/commands/template_record_delete.rb deleted file mode 100644 index fda30511..00000000 --- a/lib/dnsimple/commands/template_record_delete.rb +++ /dev/null @@ -1,16 +0,0 @@ -module DNSimple - module Commands - class TemplateRecordDelete - def execute(args, options = {}) - short_name = args.shift - id = args.shift - - template = Template.find(short_name) - record = TemplateRecord.find(template.short_name, id) - record.delete - - puts "Deleted #{record.id} from template #{short_name}" - end - end - end -end diff --git a/lib/dnsimple/commands/template_record_list.rb b/lib/dnsimple/commands/template_record_list.rb deleted file mode 100644 index 722cc671..00000000 --- a/lib/dnsimple/commands/template_record_list.rb +++ /dev/null @@ -1,17 +0,0 @@ -module DNSimple - module Commands - class TemplateRecordList - def execute(args, options = {}) - short_name = args.shift - template_records = TemplateRecord.all(short_name) - puts "Found #{template_records.length} records for #{short_name}" - template_records.each do |record| - extra = ["ttl:#{record.ttl}", "id:#{record.id}"] - extra << "prio:#{record.prio}" if record.record_type == "MX" - extra = "(#{extra.join(', ')})" - puts "\t#{record.name} (#{record.record_type})-> #{record.content} #{extra}" - end - end - end - end -end diff --git a/spec/ci/.dnsimple.test b/spec/ci/.dnsimple.test deleted file mode 100644 index 7811b7da..00000000 --- a/spec/ci/.dnsimple.test +++ /dev/null @@ -1,3 +0,0 @@ -username: username -password: password -base_uri: https://api.ci.dnsimple.com diff --git a/spec/commands/certificate_purchase_spec.rb b/spec/commands/certificate_purchase_spec.rb deleted file mode 100644 index e195bd1f..00000000 --- a/spec/commands/certificate_purchase_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'spec_helper' -require 'dnsimple/certificate' -require 'dnsimple/commands/certificate_purchase' - -describe DNSimple::Commands::CertificatePurchase do - let(:domain_name) { 'example.com' } - let(:domain) { stub('domain') } - let(:contact) { stub('contact') } - - context "with one argument" do - before :each do - DNSimple::Domain.stubs(:find).returns(domain) - DNSimple::Contact.stubs(:find).returns(contact) - end - - it "purchases the certificate" do - DNSimple::Certificate.expects(:purchase). - with(domain, 'certname', contact). - returns(stub("certificate", :fqdn => domain_name)) - - DNSimple::Commands::CertificatePurchase.new. - execute([domain_name, 'certname', stub('contact id')]) - end - end -end diff --git a/spec/commands/certificate_submit_spec.rb b/spec/commands/certificate_submit_spec.rb deleted file mode 100644 index 42c1633b..00000000 --- a/spec/commands/certificate_submit_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'spec_helper' -require 'dnsimple/commands/certificate_submit' - -describe DNSimple::Commands::CertificateSubmit do - let(:domain) { DNSimple::Domain.new(:name => domain_name) } - let(:domain_name) { 'example.com' } - let(:name) { 'www' } - let(:certificate) { DNSimple::Certificate.new(:id => certificate_id, :domain => domain) } - let(:certificate_id) { 1 } - let(:approver_email) { 'admin@example.com' } - - it "submits the certificate" do - DNSimple::Domain.stubs(:find).with(domain_name).returns(domain) - DNSimple::Certificate.expects(:find).with(domain, certificate_id).returns(certificate) - certificate.expects(:submit).with(approver_email) - DNSimple::Commands::CertificateSubmit.new.execute([domain_name, certificate_id, approver_email]) - end -end diff --git a/spec/commands/record_create_spec.rb b/spec/commands/record_create_spec.rb deleted file mode 100644 index cf2f40e6..00000000 --- a/spec/commands/record_create_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'spec_helper' -require 'dnsimple/domain' -require 'dnsimple/record' -require 'dnsimple/commands/record_create' - -describe DNSimple::Commands::RecordCreate do - let(:domain_name) { 'example.com' } - let(:record_name) { 'www' } - let(:record_type) { 'CNAME' } - let(:ttl) { "3600" } - - context "with one argument" do - it "purchases the certificate" do - domain_stub = stub("domain", :name => domain_name) - record_stub = stub("record", :id => 1, :record_type => record_type) - DNSimple::Domain.expects(:find).with(domain_name).returns(domain_stub) - DNSimple::Record.expects(:create).with(domain_stub, record_name, record_type, domain_name, :ttl => ttl, :prio => nil).returns(record_stub) - - DNSimple::Commands::RecordCreate.new.execute([domain_name, record_name, record_type, domain_name, ttl]) - end - end -end - diff --git a/spec/commands/record_list_spec.rb b/spec/commands/record_list_spec.rb deleted file mode 100644 index 5c39c48a..00000000 --- a/spec/commands/record_list_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'spec_helper' -require 'dnsimple/commands/record_list' - -describe DNSimple::Commands::RecordList do - before do - DNSimple::Record.expects(:all).with(instance_of(DNSimple::Domain)).returns(records) - end - - let(:records) { [ record ] } - let(:record) { stub(:ttl => ttl, :id => id, :record_type => record_type, :name => name, :domain => domain, :content => content) } - - let(:ttl) { 'ttl' } - let(:id) { 'id' } - let(:record_type) { 'A' } - let(:name) { 'name' } - let(:content) { 'content' } - - let(:args) { [ domain_name ] } - let(:domain_name) { 'example.com' } - let(:domain) { DNSimple::Domain.new(:name => domain_name) } - -end - diff --git a/spec/commands/service_add_spec.rb b/spec/commands/service_add_spec.rb deleted file mode 100644 index bb9fa497..00000000 --- a/spec/commands/service_add_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'spec_helper' -require 'dnsimple/commands/service_add' - -describe DNSimple::Commands::ServiceAdd do - let(:domain_name) { 'example.com' } - let(:short_name) { 'service-name' } - - let(:domain) { DNSimple::Domain.new(:name => domain_name) } - let(:service) { stub("service", :name => "Service") } - - before do - DNSimple::Domain.expects(:find).with(domain_name).returns(domain) - DNSimple::Service.expects(:find).with(short_name).returns(service) - end - - it "adds a service to a domain" do - domain.expects(:add_service).with(short_name) - DNSimple::Commands::ServiceAdd.new.execute([domain_name, short_name]) - end -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ffeeeeb4..cf3ec3ff 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -12,15 +12,10 @@ SPEC_ROOT = File.expand_path("../", __FILE__) end -if ENV['DNSIMPLE_TEST_CONFIG'] - DNSimple::Client.load_credentials(ENV['DNSIMPLE_TEST_CONFIG']) - CONFIG = { 'username' => DNSimple::Client.username, 'password' => DNSimple::Client.password, 'base_uri' => DNSimple::Client.base_uri, 'host' => URI.parse(DNSimple::Client.base_uri).host } -else - CONFIG = { 'username' => 'username', 'password' => 'password', 'base_uri' => 'https://api.sandbox.dnsimple.com/', 'host' => 'api.sandbox.dnsimple.com' } - DNSimple::Client.base_uri = CONFIG['base_uri'] - DNSimple::Client.username = CONFIG['username'] - DNSimple::Client.password = CONFIG['password'] -end +CONFIG = { 'username' => 'username', 'password' => 'password', 'base_uri' => 'https://api.sandbox.dnsimple.com/', 'host' => 'api.sandbox.dnsimple.com' } +DNSimple::Client.base_uri = CONFIG['base_uri'] +DNSimple::Client.username = CONFIG['username'] +DNSimple::Client.password = CONFIG['password'] RSpec.configure do |c|