akamai_api 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -17,3 +17,4 @@ test/version_tmp
17
17
  tmp
18
18
  spec/auth.rb
19
19
  Gemfile.lock
20
+ bin/stubs/
data/README.md CHANGED
@@ -177,13 +177,17 @@ Use the ::publish method to publish an ECCU Request:
177
177
 
178
178
  You can specify the following optional arguments in args: file_name, notes, version, emails, property_type, property_exact_match
179
179
 
180
- # Specs
180
+ # Contributing
181
181
 
182
- Before running the specs create a file auth.rb in ./spec with the following
182
+ - Clone this repository
183
+ - Run 'bundle install --binstubs=bin/stubs'
184
+ - To run the specs, create the file spec/auth.rb with the following content:
183
185
 
184
- ```ruby
186
+ ```ruby
185
187
  # Fill the following with your akamai login before running your spec
186
188
  AkamaiApi.config.merge!({
187
189
  :auth => ['user', 'pass']
188
190
  })
189
- ```
191
+ ```
192
+
193
+ - Run specs with `thor spec`
@@ -4,19 +4,4 @@ require 'active_support/core_ext'
4
4
  require 'akamai_api'
5
5
  require 'akamai_api/cli'
6
6
 
7
- class AkamaiApiCommand < Thor
8
- desc 'ccu', 'CCU Interface'
9
- subcommand 'ccu', AkamaiApi::Cli::Ccu
10
-
11
- desc 'eccu', 'ECCU Interface'
12
- subcommand 'eccu', AkamaiApi::Cli::Eccu
13
-
14
- def help *args
15
- puts
16
- puts "AkamaiApi is a command line utility to interact with Akamai CCU (Content Control Utility) and ECCU (Enhanced Content Control Utility) services."
17
- puts
18
- super
19
- end
20
- end
21
-
22
- AkamaiApiCommand.start
7
+ AkamaiApi::Cli::App.start
@@ -1,3 +1,3 @@
1
- %w(template command ccu_cp_code ccu_arl ccu eccu).each do |file|
1
+ %w(template command ccu_cp_code ccu_arl ccu eccu app).each do |file|
2
2
  require File.expand_path "../cli/#{file}", __FILE__
3
3
  end
@@ -0,0 +1,18 @@
1
+ module AkamaiApi
2
+ module Cli
3
+ class App < Thor
4
+ desc 'ccu', 'CCU Interface'
5
+ subcommand 'ccu', AkamaiApi::Cli::Ccu
6
+
7
+ desc 'eccu', 'ECCU Interface'
8
+ subcommand 'eccu', AkamaiApi::Cli::Eccu
9
+
10
+ def help *args
11
+ puts
12
+ puts "AkamaiApi is a command line utility to interact with Akamai CCU (Content Control Utility) and ECCU (Enhanced Content Control Utility) services."
13
+ puts
14
+ super
15
+ end
16
+ end
17
+ end
18
+ end
@@ -14,7 +14,9 @@ module AkamaiApi
14
14
 
15
15
  def self.all
16
16
  basic_auth *AkamaiApi.config[:auth]
17
- client.request('getCPCodes').body[:multi_ref].map do |hash|
17
+ response = client.request('getCPCodes').body[:multi_ref]
18
+
19
+ Array.wrap(response).map do |hash|
18
20
  new({
19
21
  :code => hash[:cpcode],
20
22
  :description => hash[:description],
@@ -53,7 +53,7 @@ module AkamaiApi
53
53
  end
54
54
 
55
55
  def all args = {}
56
- all_ids.map { |v| EccuRequest.find v, args }
56
+ Array.wrap(all_ids).map { |v| EccuRequest.find v, args }
57
57
  end
58
58
 
59
59
  def last args = {}
@@ -1,3 +1,3 @@
1
1
  module AkamaiApi
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,16 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3
+ <soapenv:Body>
4
+ <getCPCodesResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
5
+ <getCPCodesReturn soapenc:arrayType="ns1:CPCodeInfo[34]" xsi:type="soapenc:Array" xmlns:ns1="https://control.akamai.com/Data.xsd" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
6
+ <getCPCodesReturn href="#id0"/>
7
+ <getCPCodesReturn href="#id1"/>
8
+ </getCPCodesReturn>
9
+ </getCPCodesResponse>
10
+ <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:CPCodeInfo" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="https://control.akamai.com/Data.xsd">
11
+ <cpcode xsi:type="xsd:int">12345</cpcode>
12
+ <description xsi:type="xsd:string">Foo Site</description>
13
+ <service xsi:type="xsd:string">Site_Accel::Site_Accel</service>
14
+ </multiRef>
15
+ </soapenv:Body>
16
+ </soapenv:Envelope>
@@ -15,11 +15,29 @@ module AkamaiApi
15
15
  end
16
16
 
17
17
  it 'should correctly fill each object' do
18
+ CpCode.all.count.should == 2
19
+
18
20
  model = CpCode.all.first
19
21
  model.code.should == '12345'
20
22
  model.description.should == 'Foo Site'
21
23
  model.service.should == 'Site_Accel::Site_Accel'
22
24
  end
25
+
26
+ describe '::only one item' do
27
+ before do
28
+ savon.expects('getCPCodes').returns(:sample_one_item)
29
+ stub_savon_model CpCode
30
+ end
31
+
32
+ it 'should correctly fill when we have only one cp on return' do
33
+ CpCode.all.count.should == 1
34
+
35
+ model = CpCode.all.first
36
+ model.code.should == '12345'
37
+ model.description.should == 'Foo Site'
38
+ model.service.should == 'Site_Accel::Site_Accel'
39
+ end
40
+ end
23
41
  end
24
42
  end
25
43
  end
@@ -63,6 +63,11 @@ module AkamaiApi
63
63
  EccuRequest.should_receive(:find).with('b', anything()).and_return(:b)
64
64
  EccuRequest.all.should =~ [:a, :b]
65
65
  end
66
+ it 'returns the detail for each enlisted id even if only one id is returned' do
67
+ EccuRequest.stub! :all_ids => "a"
68
+ EccuRequest.should_receive(:find).with('a', anything()).and_return(:a)
69
+ EccuRequest.all.should =~ [:a]
70
+ end
66
71
  end
67
72
 
68
73
  describe 'publishing' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: akamai_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-30 00:00:00.000000000 Z
12
+ date: 2013-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -139,6 +139,7 @@ files:
139
139
  - lib/akamai_api/ccu.rb
140
140
  - lib/akamai_api/ccu_response.rb
141
141
  - lib/akamai_api/cli.rb
142
+ - lib/akamai_api/cli/app.rb
142
143
  - lib/akamai_api/cli/ccu.rb
143
144
  - lib/akamai_api/cli/ccu_arl.rb
144
145
  - lib/akamai_api/cli/ccu_cp_code.rb
@@ -152,6 +153,7 @@ files:
152
153
  - spec/fixtures/delete/success.xml
153
154
  - spec/fixtures/eccu_request.xml
154
155
  - spec/fixtures/get_cp_codes/sample.xml
156
+ - spec/fixtures/get_cp_codes/sample_one_item.xml
155
157
  - spec/fixtures/get_ids/success.xml
156
158
  - spec/fixtures/get_info/success.xml
157
159
  - spec/fixtures/set_notes/success.xml
@@ -180,7 +182,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
180
182
  version: '0'
181
183
  segments:
182
184
  - 0
183
- hash: -2678283261335380600
185
+ hash: -381323867441421978
184
186
  required_rubygems_version: !ruby/object:Gem::Requirement
185
187
  none: false
186
188
  requirements:
@@ -189,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
191
  version: '0'
190
192
  segments:
191
193
  - 0
192
- hash: -2678283261335380600
194
+ hash: -381323867441421978
193
195
  requirements: []
194
196
  rubyforge_project:
195
197
  rubygems_version: 1.8.24
@@ -200,6 +202,7 @@ test_files:
200
202
  - spec/fixtures/delete/success.xml
201
203
  - spec/fixtures/eccu_request.xml
202
204
  - spec/fixtures/get_cp_codes/sample.xml
205
+ - spec/fixtures/get_cp_codes/sample_one_item.xml
203
206
  - spec/fixtures/get_ids/success.xml
204
207
  - spec/fixtures/get_info/success.xml
205
208
  - spec/fixtures/set_notes/success.xml