<commit_before># Fastly [![Build Status](https://travis-ci.org/fastly/fastly-ruby.svg?branch=master)](https://travis-ci.org/fastly/fastly-ruby)

Client library for interacting with the Fastly web acceleration service [API](http://docs.fastly.com/api)

## Example

```ruby
# Gemfile
gem 'fastly'

# some_file.rb
fastly = Fastly.new(login_opts)

current_user     = fastly.current_user
current_customer = fastly.current_customer

user     = fastly.get_user(current_user.id)
customer = fastly.get_customer(current_customer.id)

puts "Name: #{user.name}"
puts "Works for #{user.customer.name}"
puts "Which is the same as #{customer.name}"
puts "Which has the owner #{customer.owner.name}"

# Let's see which services we have defined
fastly.list_services.each do |service|
  puts "Service ID: #{service.id}"
  puts "Service Name: #{service.name}"
  puts "Service Versions:"
  service.versions.each do |version|
    puts "\t#{version.number}"
  end
end

service        = fastly.create_service(:name => "MyFirstService")
latest_version = service.version

# Create a domain and a backend for the service ...
domain         = fastly.create_domain(:service_id => service.id, :version => latest_version.number, :name => "www.example.com")<commit_msg>having login_opts examples in the readme<commit_after># Fastly [![Build Status](https://travis-ci.org/fastly/fastly-ruby.svg?branch=master)](https://travis-ci.org/fastly/fastly-ruby)

Client library for interacting with the Fastly web acceleration service [API](http://docs.fastly.com/api)

## Example

```ruby
# Gemfile
gem 'fastly'

# some_file.rb
# use {api_key: 'your-key'} or {user: 'username', password: 'password'} as login options
fastly = Fastly.new(login_opts)

current_user     = fastly.current_user
current_customer = fastly.current_customer

user     = fastly.get_user(current_user.id)
customer = fastly.get_customer(current_customer.id)

puts "Name: #{user.name}"
puts "Works for #{user.customer.name}"
puts "Which is the same as #{customer.name}"
puts "Which has the owner #{customer.owner.name}"

# Let's see which services we have defined
fastly.list_services.each do |service|
  puts "Service ID: #{service.id}"
  puts "Service Name: #{service.name}"
  puts "Service Versions:"
  service.versions.each do |version|
    puts "\t#{version.number}"
  end
end

service        = fastly.create_service(:name => "MyFirstService")
latest_version = service.version

# Create a domain and a backend for the service ...
domain         = fastly.create_domain(:service_id => service.id, :version => latest_version.number, :name => "www.example.com")
{'fraction_non_alphanumeric': 0.13503086419753085, 'fraction_numerical': 0.0, 'mean_word_length': 4.749445676274944, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4341031', 'n_tokens_mistral': 844, 'n_tokens_neox': 838, 'n_words': 215}