Installation

Add this line to your application's Gemfile:

gem 'freenom-dns'

And then execute:

$ bundle

Or install it yourself as:

$ gem install freenom-dns

Usage

Initialize your Freenom::Dns object

dns = Freenom::Dns.new(
  username: <freenom-username>,
  password: <freenom-password>,
  domain: <your-domain>
)

List all DNS records

dns.records

This will return an array of Freenom::Record objects.

Check if DNS record exist

dns.exist_record?([
  name: <name>,
  type: <type>,
  time_to_live: <time-to-live>,
  target: <target>
])

This will return either true or false. The parameters are all optional.

Delete a DNS record

dns.delete_record!(dns.records.sample)

This will return either true or raise Freenom::RecordDeleteError.

Create a new record

dns.create_record!(
  name: <name>,
  type: <type>,
  time_to_live: <time-to-live>,
  target: <target>
)

This will return either true or raise Freenom::RecordCreateError.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/thongncvn/freenom-dns.