Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .codeclimate.yml

This file was deleted.

10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: bundler
directory: /
schedule:
interval: weekly
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: CI

on:
push:
branches: [master]
pull_request:

permissions:
contents: read

jobs:
test:
name: Test (Ruby ${{ matrix.ruby }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby: ['3.3', '3.4', '4.0']
steps:
- uses: actions/checkout@v7
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec rake test

lint:
name: RuboCop
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: ruby/setup-ruby@v1
with:
ruby-version: '4.0'
bundler-cache: true
- run: bundle exec rubocop

edge:
name: Test against fog-core and fog-xml master
runs-on: ubuntu-latest
continue-on-error: true
env:
BUNDLE_GEMFILE: gemfiles/Gemfile-edge
steps:
- uses: actions/checkout@v7
- uses: ruby/setup-ruby@v1
with:
ruby-version: '4.0'
bundler-cache: true
- run: bundle exec rake test
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ mkmf.log
tests/.fog
# RubyMine IDE
/.idea
.fog
.fog
*.gem
/gemfiles/*.lock
7 changes: 6 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
Metrics/LineLength:
AllCops:
TargetRubyVersion: 3.3
NewCops: enable
SuggestExtensions: false

Layout/LineLength:
Max: 160

Style/Documentation:
Expand Down
1 change: 0 additions & 1 deletion .ruby-gemset

This file was deleted.

2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-2.6.5
4.0.7
45 changes: 0 additions & 45 deletions .travis.yml

This file was deleted.

30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Changelog

## 0.6.0 - Unreleased

### Breaking

- Requires Ruby >= 3.3. Older Rubies are no longer supported.
- Requires fog-core ~> 2.1 (was ~> 1.27). The unused fog-json dependency is gone.

### Changed

- The service class is now `Fog::Akamai::Storage`, the layout fog-core 2 expects. `Fog::Storage::Akamai` still works as a deprecated alias and will be removed in a future major release. `Fog::Storage.new(provider: 'akamai')` is unchanged.
- The response parsers moved to `Fog::Parsers::Akamai::Storage` (internal API).
- The published gem only contains `lib/`, the README, the license and this changelog.

### Fixed

- Request signing no longer depends on `OpenSSL::Digest::Digest` or the `Base64` library, which are gone on current Rubies.
- `CGI.escape` is required explicitly, so `rename` and `symlink` work without a full `cgi`.
- `fog-core` no longer logs two deprecation lines on every `Fog::Storage.new`.
- Uploading a `nil` body raised `NoMethodError` instead of `ArgumentError`.
- `rake test` globbed a non-existent `tests/` directory and ran nothing.

### Development

- CI moved from Travis to GitHub Actions (Ruby 3.3, 3.4, 4.0, RuboCop, and fog-core/fog-xml master).
- Code Climate is gone; SimpleCov writes a local coverage report.
- Tests run on minitest 6 and webmock 3; RuboCop is on 1.x.

Earlier releases are listed on the [GitHub tags](https://github.com/fog/fog-akamai/tags).
51 changes: 51 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project

`fog-akamai` is a fog provider gem for Akamai NetStorage (the ObjectStore HTTP API; the spec is in `docs/NS_http_api_FS.pdf`). It implements every NetStorage action except quick-delete, which is left out on purpose. The gem requires Ruby >= 3.3 (`.ruby-version` pins 4.0.7 for development) and depends on fog-core 2.x and fog-xml. Development dependencies (minitest 6, minitest-mock, minitest-reporters, webmock 3, timecop, SimpleCov, RuboCop, rake) live in the `Gemfile`, not the gemspec.

## Commands

- Install deps: `bin/setup` (runs `bundle install`)
- Console: `bin/console`
- Tests and lint (the default task, also what CI runs): `bundle exec rake`
- Tests only: `bundle exec rake test`
- Lint: `bundle exec rubocop` (config in `.rubocop.yml`: TargetRubyVersion 3.3, line length 160, Style/Documentation off)
- Run one file: `bundle exec ruby -Itest -Ilib test/fog/akamai/requests/storage/upload_test.rb`
- Run one test: append `-n test_upload` (or `-n /pattern/`)
- Another Ruby: `mise exec ruby@3.3.5 -- bundle exec rake test`. CI runs 3.3, 3.4 and 4.0.
- Against fog-core/fog-xml master: `BUNDLE_GEMFILE=gemfiles/Gemfile-edge bundle exec rake test`

Tests need `test/` and `lib/` on the load path because they `require 'helpers/...'` and `require 'fog/akamai/storage_test_base'`. The Rakefile and the commands above already set that up.

Known quirks:

- On Ruby 4.0, fog-core 2.6.0 itself prints a `CGI library is removed` warning at load time, and a frozen-string-literal warning under `-w`. They come from fog-core, not from this gem.
- `Fog::Storage::Akamai` (the pre-0.6 constant) is a deprecated alias of `Fog::Akamai::Storage` and is meant to be removed in 1.0.
- `symlink` has no Mock implementation (issue #3); in mock mode fog-core raises `Fog::Errors::MockNotImplemented`.
- Model gaps: `File#get` and `File#destroy` are stubs that don't call the service yet, and `Files#all` returns `directory.files`.

## Architecture

The gem follows the standard fog provider layout, using the fog-core 2 `Fog::<Provider>::<Service>` namespace:

- `lib/fog/akamai.rb` registers the `Fog::Akamai` provider with a `:storage` service and autoloads `Fog::Akamai::Storage` (the autoload is what stops fog-core logging a deprecation on every `Fog::Storage.new`). `Fog::Akamai::Shared#full_path` joins a directory key and a path; models use it.
- `lib/fog/akamai/storage.rb` defines `Fog::Akamai::Storage < Fog::Service`, plus the deprecated `Fog::Storage::Akamai` alias at the bottom:
- Required credentials: `akamai_host`, `akamai_key_name`, `akamai_key`, `akamai_cp_code` (usually from `~/.fog`). Optional: `scheme`/`port` (defaults https/443).
- `Helpers#format_path` prefixes every path with `/<cp_code>`. Request methods take paths *without* the CP code; models strip it when building keys.
- `Real#request` signs every call with the ACS headers (`X-Akamai-ACS-Auth-Data`, `-Auth-Sign` = Base64 HMAC-SHA256 over auth data + path + action, `-Action`). Each action must be listed in `VALID_ACTIONS`, or `acs_action` raises.
- `Mock` keeps an in-memory class-level hash, `data`, keyed by the full `/<cp_code>/path`. Each value is `{ directory:, files: [], directories: [] }`, and file contents are stored at their own keys.
- `requests/storage/<action>.rb`: each file reopens `Real` and `Mock` and adds one method named after the NetStorage action (dir, mkdir, upload, download, stat, delete, du, mtime, rename, rmdir, symlink). **When adding an action**, add the file, register it with `request :name` in `storage.rb`, add it to `VALID_ACTIONS`, and implement both Real and Mock.
- `parsers/storage/` holds SAX parsers (`Fog::Parsers::Base`, namespaced `Fog::Parsers::Akamai::Storage`) for the XML responses. `Dir` handles both `dir` and `stat`, and splits `<file type="file|dir">` entries into `:files` and `:directories`.
- `models/storage/`: `Directories#get` calls `dir` and hydrates a `Directory` along with its `files` and `directories` sub-collections. `File#save` → `upload`, `touch` → `mtime`, `rename` → `rename`. `Files#get` → `download`, `stat` → `stat` (returns nil on 404).

## Tests

- Test framework: Minitest 6. `test/test_helper.rb` starts SimpleCov, requires `minitest/mock` (used for `Time.stub`/`SecureRandom.stub`) and auto-requires `test/support/*`, which set fake credentials (host `example-nsu.akamai.net`, cp_code `42`), enable webmock and use the minitest-reporters.
- `test/fog/akamai/storage_test_base.rb` defines two base classes:
- `StorageTestBase`: real mode. HTTP is stubbed with the webmock helpers in `test/helpers/<action>_request_stub.rb` (stubbed paths include `/42`).
- `MockStorageTestBase`: calls `Fog.mock!` and resets the mock data in teardown.
- Request tests usually define one class of each kind per action. Time-dependent mock assertions use `Timecop.freeze`.
- `test/fog/akamai_test.rb` covers provider loading: the namespace, no deprecation output (one test spawns a subprocess to check the load-time output), and the deprecated alias.
15 changes: 13 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# frozen_string_literal: true

source 'https://rubygems.org'

# Specify your gem's dependencies in fog-netstorage.gemspec
# Runtime dependencies live in fog-akamai.gemspec
gemspec

gem 'codeclimate-test-reporter', group: :test, require: nil
group :development, :test do
gem 'minitest', '~> 6.0'
gem 'minitest-mock', '~> 5.27'
gem 'minitest-reporters', '~> 1.8'
gem 'rake', '~> 13.0'
gem 'rubocop', '~> 1.92', require: false
gem 'simplecov', '~> 1.3', require: false
gem 'timecop', '~> 0.9'
gem 'webmock', '~> 3.29'
end
35 changes: 25 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[![Code Climate](https://codeclimate.com/github/alexandru-calinoiu/fog-akamai/badges/gpa.svg)](https://codeclimate.com/github/fog/fog-akamai)

[![Test Coverage](https://codeclimate.com/github/alexandru-calinoiu/fog-akamai/badges/coverage.svg)](https://codeclimate.com/github/fog/fog-akamai/coverage)
[![CI](https://github.com/fog/fog-akamai/actions/workflows/ci.yml/badge.svg)](https://github.com/fog/fog-akamai/actions/workflows/ci.yml)

# Fog Akamai

Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/fog/storage`. To experiment with that code, run `bin/console` for an interactive prompt.
A [fog](https://github.com/fog/fog) provider for Akamai NetStorage, built on the ObjectStore HTTP API (the spec is in `docs/NS_http_api_FS.pdf`).

All the functionality of the NetStorage API is implemented except the really dangerous bit, quick-delete.

All the functionality of the net storage api is implemented except the really dangerous bit, quick-delete.
Requires Ruby 3.3 or newer and fog-core 2.x.

## Installation

Expand Down Expand Up @@ -47,7 +47,19 @@ You can get more detail about how to obtain this credential form [this doc](http
### Connecting to NetStorage service

```ruby
net_storage = Fog::Compute.new :provider => 'akamai'
net_storage = Fog::Storage.new(provider: 'akamai')
```

You can also pass the credentials explicitly:

```ruby
net_storage = Fog::Storage.new(
provider: 'akamai',
akamai_host: '<YOUR_AKAMAIHOST>',
akamai_key_name: '<YOUR_KEY_NAME>',
akamai_key: '<YOU_KEY>',
akamai_cp_code: '<YOU_CP_CODE>'
)
```

### To get a directory:
Expand All @@ -68,17 +80,20 @@ directory.files.stat('file.ext')
directory.files.create(directory: directory, body: file_body, key: file_name)
```

### Upgrading from 0.5

The service class is now `Fog::Akamai::Storage`. `Fog::Storage::Akamai` still works but is deprecated and will be removed in a future major release. If you only use `Fog::Storage.new(provider: 'akamai')` nothing changes. See the [changelog](CHANGELOG.md) for the other changes.

## Roadmap

- implement ccu api

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake` to run the tests and RuboCop (`bundle exec rake test` runs only 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](https://rubygems.org).
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 the changelog, 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](https://rubygems.org).

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/alexandru-calinoiu/fog-akamai.

Bug reports and pull requests are welcome on GitHub at https://github.com/fog/fog-akamai.
11 changes: 8 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'rake/testtask'
require 'rubocop/rake_task'

Rake::TestTask.new do |t|
t.libs.push %w(tests)
t.test_files = FileList['tests/**/*_test.rb']
t.libs.push %w[test lib]
t.test_files = FileList['test/**/*_test.rb']
t.verbose = true
end

RuboCop::RakeTask.new

desc 'Default Task'
task default: [:test]
task default: %i[test rubocop]
1 change: 1 addition & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'bundler/setup'
require 'fog/akamai'
Expand Down
36 changes: 16 additions & 20 deletions fog-akamai.gemspec
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
# frozen_string_literal: true

lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'fog/akamai/version'

Expand All @@ -11,25 +12,20 @@ Gem::Specification.new do |spec|
spec.license = 'MIT'

spec.summary = "Module for 'fog' gem to support Akamai"
spec.description = 'This library can be used as a module for `fog` or as standalone provider
to use Akamai'
spec.homepage = 'https://github.com/alexandru-calinoiu/fog-akamai'
spec.description = 'This library can be used as a module for `fog` or as standalone provider to use Akamai NetStorage'
spec.homepage = 'https://github.com/fog/fog-akamai'

spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.bindir = 'exe'
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']
spec.metadata = {
'changelog_uri' => "#{spec.homepage}/blob/master/CHANGELOG.md",
'bug_tracker_uri' => "#{spec.homepage}/issues",
'rubygems_mfa_required' => 'true'
}

spec.add_development_dependency 'bundler', '~> 2.0'
spec.add_development_dependency 'rake', '>= 12.3.3'
spec.add_development_dependency 'minitest', '~> 5.8'
spec.add_development_dependency 'minitest-reporters', '~> 1.1'
spec.add_development_dependency 'test-unit', '~> 3.1'
spec.add_development_dependency 'webmock', '~> 1.22'
spec.add_development_dependency 'rubocop', '~> 0.49'
spec.add_development_dependency 'timecop', '~> 0.8.0'
spec.required_ruby_version = '>= 3.3'

spec.files = Dir['lib/**/*.rb', 'README.md', 'LICENSE.md', 'CHANGELOG.md']
spec.require_paths = ['lib']

spec.add_dependency 'fog-core', '~> 1.27'
spec.add_dependency 'fog-json', '~> 1.0'
spec.add_dependency 'fog-xml', '~> 0.1'
spec.add_dependency 'fog-core', '~> 2.1'
spec.add_dependency 'fog-xml', '~> 0.1'
end
Loading
Loading