fanny_pack 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown ADDED
@@ -0,0 +1,75 @@
1
+ # FannyPack
2
+
3
+ [![Build Status](http://travis-ci.org/site5/fanny_pack.png)](http://travis-ci.org/site5/fanny_pack)
4
+
5
+ FannyPack is a Ruby library for working with the
6
+ [Fantastico API](https://netenberg.com/api/).
7
+
8
+ ## Installation
9
+
10
+ gem install fanny_pack
11
+
12
+ ## Usage
13
+
14
+ Set your Fantastico `accountHASH`
15
+
16
+ FannyPack.account_hash = '0mgpwn13s'
17
+
18
+ Add an IP
19
+
20
+ FannyPack::IP.add '127.0.0.1'
21
+
22
+ Add a VPS IP
23
+
24
+ FannyPack::IP.add '127.0.0.1', :vps
25
+
26
+ Edit an IP (`127.0.0.1` is the current IP, `127.0.0.2` is the new IP)
27
+
28
+ FannyPack::IP.edit '127.0.0.1', '127.0.0.2'
29
+
30
+ Deactivate an IP
31
+
32
+ FannyPack::IP.deactivate '127.0.0.1'
33
+
34
+ Reactivate an IP
35
+
36
+ FannyPack::IP.reactivate '127.0.0.1'
37
+
38
+ Delete an IP
39
+
40
+ FannyPack::IP.delete '127.0.0.1'
41
+
42
+ List all IPs
43
+
44
+ FannyPack::IP.list :all
45
+
46
+ List only 'normal' IPs
47
+
48
+ FannyPack::IP.list :normal
49
+
50
+ List only VPS IPs
51
+
52
+ FannyPack::IP.list :vps
53
+
54
+ Include details when listing IPs:
55
+
56
+ FannyPack::IP.list :all, true
57
+
58
+ Get an IP's details
59
+
60
+ FannyPack::IP.details '127.0.0.1'
61
+
62
+ ## Note on Patches/Pull Requests
63
+
64
+ * Fork the project.
65
+ * Make your feature addition or bug fix.
66
+ * Add tests for it. This is important so I don't break it in a future version
67
+ unintentionally.
68
+ * Commit, do not mess with rakefile, version, or history. (If you want to have
69
+ your own version, that is fine but bump version in a commit by itself I can
70
+ ignore when I pull)
71
+ * Send me a pull request. Bonus points for topic branches.
72
+
73
+ ## Copyright
74
+
75
+ Copyright (c) 2011 Site5 LLC. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,45 @@
1
+ $:.unshift 'lib'
2
+
3
+ begin
4
+ require 'rspec/core/rake_task'
5
+ rescue LoadError
6
+ puts "Please install rspec (bundle install)"
7
+ exit
8
+ end
9
+
10
+ begin
11
+ require 'metric_fu'
12
+ MetricFu::Configuration.run do |config|
13
+ config.rcov[:rcov_opts] << "-Ispec"
14
+ end
15
+ rescue LoadError
16
+ puts "Can't find metric_fu"
17
+ end
18
+
19
+ RSpec::Core::RakeTask.new :spec
20
+
21
+ desc "Open an irb session preloaded with this library"
22
+ task :console do
23
+ sh "irb -rubygems -r ./lib/fanny_pack.rb -I ./lib"
24
+ end
25
+
26
+ desc "Push a new version to RubyGems"
27
+ task :publish do
28
+ require 'fanny_pack/version'
29
+
30
+ ver = FannyPack::Version
31
+
32
+ sh "gem build fanny_pack.gemspec"
33
+ sh "gem push fanny_pack-#{ver}.gem"
34
+ sh "git tag -a -m 'FannyPack v#{ver}' v#{ver}"
35
+ sh "git push origin v#{ver}"
36
+ sh "git push origin master"
37
+ end
38
+
39
+ desc "Run all specs with rcov"
40
+ RSpec::Core::RakeTask.new(:rcov) do |t|
41
+ t.rcov = true
42
+ t.rcov_opts = %w{--exclude osx\/objc,gems\/,spec\/,features\/}
43
+ end
44
+
45
+ task :default => :spec
@@ -0,0 +1,21 @@
1
+ module FannyPack
2
+ module Errors #:nodoc: all
3
+ # Fault codes and error messages that are returned by the Fantastico API
4
+ FAULT_CODES = {
5
+ 1302 => "You have specified an invalid hash.",
6
+ 1401 => "You are trying to access the API from a server whose IP Address is not authorized.",
7
+ 1603 => "You are not allowed to add any more IP Addresses because you have reached your IP Address quota.",
8
+ 1703 => "The IP Address that you have specified is not a valid VPS IP Address.",
9
+ 1704 => "The new IP Address that you have specified is not a valid cPanel IP Address.",
10
+ 1705 => "The new IP Address that you have specified is not a valid cPanel IP Address.",
11
+ 1801 => "The IP Address that you have specified does not exist.",
12
+ 1804 => "The IP Address that you have specified already exists."
13
+ }.freeze
14
+
15
+ class AuthRequired < StandardError
16
+ def initialize(msg = nil)
17
+ super "Must set FannyPack.account_hash"
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,162 @@
1
+ module FannyPack
2
+ # FannyPack::IP is the main class for managing IPs via the Fantastico API.
3
+ class IP
4
+
5
+ # The Fantastico API tags your IPs as "normal" or "vps".
6
+ IP_TYPES = {
7
+ :all => 0,
8
+ :normal => 1,
9
+ :vps => 2
10
+ }.freeze
11
+
12
+ # Add an IP address to your Fantastico account.
13
+ #
14
+ # Returns a Hash containing the new IP info on success
15
+ # Returns a Hash containing an error code and message on error
16
+ #
17
+ # ==== Options
18
+ #
19
+ # * +ip+ - The cPanel IP address to add
20
+ # * +ip_type* - The type of IP address (:vps or :normal)
21
+ #
22
+ # ==== Examples
23
+ #
24
+ # # Add normal IP
25
+ # FannyPack::IP.add '127.0.0.1'
26
+ #
27
+ # # Add vps IP
28
+ # FannyPack::IP.add '127.0.0.1', :vps
29
+ def self.add(ip, ip_type = :normal)
30
+ Request.new.commit :addIp, :ip => ip, :type => IP_TYPES[ip_type]
31
+ end
32
+
33
+ # Edit an IP address, replacing +ip+ with +new_ip+
34
+ #
35
+ # Returns a Hash containing the new IP info on success
36
+ # Returns a Hash containing an error code and message on error
37
+ #
38
+ # ==== Options
39
+ #
40
+ # * +ip+ - The current IP address
41
+ # * +new_ip+ - The new IP address
42
+ #
43
+ # ==== Example
44
+ #
45
+ # FannyPack::IP.edit '127.0.0.1', '127.0.0.2'
46
+ def self.edit(ip, new_ip)
47
+ Request.new.commit :editIp, :ip => ip, :new_ip => new_ip
48
+ end
49
+
50
+ # Get a list of IP addresses on your Fantastico account
51
+ #
52
+ # The Fantastico API allows you to filter for only normal IPs, or only
53
+ # vps IPs. Use +list_type+ :all to get all IPs, :normal to get only normal
54
+ # IPs, or :vps to get only vps IPs.
55
+ #
56
+ # Raises ArgumentError if list_type is invalid
57
+ #
58
+ # If +details+ is false:
59
+ # Returns an Array containing IP addresses
60
+ #
61
+ # If +details+ is true:
62
+ # Returns an Array of Hashes containing info for each IP
63
+ #
64
+ # Returns a Hash containing an error code and message on error
65
+ #
66
+ # ==== Options
67
+ #
68
+ # * +list_type+ - The list type, one of :normal, :vps, :all
69
+ # * +details+ - Set to true to return details for each IP
70
+ #
71
+ # ==== Examples
72
+ #
73
+ # # Show all IPs (simple list)
74
+ # FannyPack::IP.list :all
75
+ #
76
+ # # Show all IPs (detailed list)
77
+ # FannyPack::IP.list :all, true
78
+ #
79
+ # # Show normal IPs (simple list)
80
+ # FannyPack::IP.list :normal
81
+ #
82
+ # # Show normal IPs (detailed list)
83
+ # FannyPack::IP.list :normal, true
84
+ #
85
+ # # Show vps IPs (simple list)
86
+ # FannyPack::IP.list :vps
87
+ #
88
+ # # Show normal IPs (detailed list)
89
+ # FannyPack::IP.list :vps, true
90
+ def self.list(list_type, details = false)
91
+ cmd = details ? :getIpListDetailed : :getIpList
92
+ unless IP_TYPES.keys.include? list_type
93
+ raise ArgumentError, "Invalid list type"
94
+ end
95
+ Request.new.commit cmd, :listType => IP_TYPES[list_type]
96
+ end
97
+
98
+ # Delete an IP address from your Fantastico Account
99
+ #
100
+ # Returns a Hash containing the IP info
101
+ # Returns a Hash containing an error code and message on error
102
+ #
103
+ # ==== Options
104
+ #
105
+ # * +ip+ - The IP address to delete
106
+ #
107
+ # ==== Example
108
+ #
109
+ # FannyPack::IP.delete '127.0.0.1'
110
+ def self.delete(ip)
111
+ Request.new.commit :deleteIp, :ip => ip
112
+ end
113
+
114
+ # Reactivate a deactivated IP address
115
+ #
116
+ # Returns a Hash containing the IP info
117
+ # Returns a Hash containing an error code and message on error
118
+ #
119
+ # ==== Options
120
+ #
121
+ # * +ip+ - The IP address to reactivate
122
+ #
123
+ # ==== Example
124
+ #
125
+ # FannyPack::IP.reactivate '127.0.0.1'
126
+ def self.reactivate(ip)
127
+ Request.new.commit :reactivateIp, :ip => ip
128
+ end
129
+
130
+ # Deactivate an IP address
131
+ #
132
+ # Returns a Hash containing the IP info
133
+ # Returns a Hash containing an error code and message on error
134
+ #
135
+ # ==== Options
136
+ #
137
+ # * +ip+ - The IP address to deactivate
138
+ #
139
+ # ==== Example
140
+ #
141
+ # FannyPack::IP.deactivate '127.0.0.1'
142
+ def self.deactivate(ip)
143
+ Request.new.commit :deactivateIp, :ip => ip
144
+ end
145
+
146
+ # Get details for an IP address
147
+ #
148
+ # Returns a Hash containing the IP info
149
+ # Returns a Hash containing an error code and message on error
150
+ #
151
+ # ==== Options
152
+ #
153
+ # * +ip+ - The IP address to lookup
154
+ #
155
+ # ==== Example
156
+ #
157
+ # FannyPack::IP.details '127.0.0.1'
158
+ def self.details(ip)
159
+ Request.new.commit :getIpDetails, :ip => ip
160
+ end
161
+ end
162
+ end
@@ -0,0 +1,118 @@
1
+ require 'builder'
2
+ require 'crack'
3
+ require 'open-uri'
4
+ require 'net/https'
5
+
6
+ module FannyPack
7
+ # FannyPack::Request handles forming the XML request to be sent to the
8
+ # Fantastico API, and parsing the response.
9
+ class Request
10
+ attr_reader :params, :response
11
+
12
+ # The Fantastico API supports these methods
13
+ VALID_ACTIONS = [
14
+ :getIpList, :getIpListDetailed, :getIpDetails, :addIp,
15
+ :editIp, :deactivateIp, :reactivateIp, :deleteIp
16
+ ].freeze
17
+
18
+ # The URL for the Fantastico API
19
+ API_URL = "https://netenberg.com/api/server.php"
20
+
21
+ def initialize
22
+ @action = :invalid
23
+ @response = {}
24
+ @params = {}
25
+ end
26
+
27
+ # Send this request to the Fantastico API
28
+ #
29
+ # Returns a Hash or Array, depending on the response from Fantastico
30
+ #
31
+ # ==== Options
32
+ #
33
+ # * +action+ - The action to perform, one of VALID_ACTIONS
34
+ # * +params+ - A hash containing parameters for the API method
35
+ def commit(action, params = {})
36
+ unless VALID_ACTIONS.include? action.to_sym
37
+ raise "Invalid action"
38
+ end
39
+ @action = action
40
+ @params = params
41
+
42
+ uri = URI.parse(API_URL)
43
+ http = Net::HTTP.new(uri.host, uri.port)
44
+ http.use_ssl = true
45
+ res = http.post(uri.path, to_xml, 'Content-Type' => 'text/xml; charset=utf-8')
46
+ parse(res.body)
47
+ end
48
+
49
+ # Parse the XML response from Fantastico
50
+ #
51
+ # Returns an Array or Hash depending on the API method called
52
+ #
53
+ # ==== Options
54
+ #
55
+ # * +data+ - The XML response from Fantastico
56
+ def parse(data)
57
+ res = find_key_in_hash(Crack::XML.parse(data), 'item')
58
+ if @action.to_sym == :getIpListDetailed
59
+ res.map! do |r|
60
+ Hash[r['item'].map { |i| [i['key'], i['value']] }]
61
+ end
62
+ elsif @action.to_sym == :getIpList
63
+ res
64
+ else
65
+ res = Hash[res.map { |r| [r['key'], r['value']] }] if res.is_a? Array
66
+ end
67
+
68
+ @success = ! res.has_key?("faultcode") if res.respond_to?(:has_key?)
69
+ res
70
+ end
71
+
72
+ # Returns true or false
73
+ def success?
74
+ @success
75
+ end
76
+
77
+ # Builds the SOAP Envelope to be sent to Fantastico for this request
78
+ def to_xml
79
+ xml = Builder::XmlMarkup.new :indent => 2
80
+ xml.instruct!
81
+ xml.tag! 'env:Envelope', 'xmlns:env' => 'http://schemas.xmlsoap.org/soap/envelope/' do
82
+ xml.tag! 'env:Body' do
83
+ xml.tag! @action do
84
+ xml.tag! 'accountHASH', FannyPack.account_hash
85
+ @params.each do |key, val|
86
+ xml.tag! key, val
87
+ end
88
+ end
89
+ end
90
+ end
91
+ xml.target!
92
+ end
93
+
94
+ private
95
+
96
+ # Finds +index+ in +hash+ by searching recursively
97
+ #
98
+ # ==== Options
99
+ #
100
+ # * +hash+ - The hash to search
101
+ # * +index+ - The hash key to look for
102
+ def find_key_in_hash(hash, index)
103
+ hash.each do |key, val|
104
+ if val.respond_to? :has_key?
105
+ if val.has_key? index
106
+ return val[index]
107
+ else
108
+ return find_key_in_hash val, index
109
+ end
110
+ else
111
+ val
112
+ end
113
+ end
114
+ end
115
+
116
+ end
117
+ end
118
+
@@ -0,0 +1,3 @@
1
+ module FannyPack
2
+ Version = VERSION = '0.1.0'
3
+ end
data/lib/fanny_pack.rb ADDED
@@ -0,0 +1,18 @@
1
+ module FannyPack
2
+ autoload :Version, 'fanny_pack/version'
3
+ autoload :Errors, 'fanny_pack/errors'
4
+ autoload :Request, 'fanny_pack/request'
5
+ autoload :IP, 'fanny_pack/ip'
6
+
7
+ class << self
8
+ # FannyPack.account_hash stores your Fantastico account hash. This is used
9
+ # to authenticate your account with the Fantastico API.
10
+ attr_accessor :account_hash
11
+ end
12
+
13
+ # Returns true if FannyPack.account_hash is not nil or blank
14
+ def self.account_hash?
15
+ ! (account_hash.nil? || account_hash.to_s == "")
16
+ end
17
+
18
+ end
@@ -0,0 +1,125 @@
1
+ require 'spec_helper'
2
+
3
+ describe FannyPack::IP do
4
+ describe "::IP_TYPES" do
5
+ it { FannyPack::IP::IP_TYPES.should be_a Hash }
6
+
7
+ it "has a value of 0 for :all" do
8
+ FannyPack::IP::IP_TYPES[:all].should == 0
9
+ end
10
+
11
+ it "has a value of 1 for :normal" do
12
+ FannyPack::IP::IP_TYPES[:normal].should == 1
13
+ end
14
+
15
+ it "has a value of 2 for :vps" do
16
+ FannyPack::IP::IP_TYPES[:vps].should == 2
17
+ end
18
+
19
+ it { FannyPack::IP::IP_TYPES.should be_frozen }
20
+ end
21
+
22
+ describe "::add" do
23
+ it "raises ArgumentError without IP" do
24
+ expect {
25
+ FannyPack::IP.add
26
+ }.to raise_error(ArgumentError)
27
+ end
28
+
29
+ it "returns a Hash" do
30
+ load_fixture :add
31
+ ip = FannyPack::IP.add '127.0.0.1'
32
+ ip.should be_a Hash
33
+ end
34
+ end
35
+
36
+ describe "::edit" do
37
+ it "raises ArgumentError without IP" do
38
+ expect { FannyPack::IP.edit }.to raise_error(ArgumentError)
39
+ end
40
+
41
+ it "edits the IP" do
42
+ load_fixture :edit
43
+ ip = FannyPack::IP.edit '127.0.0.1', '127.0.0.2'
44
+ ip.should be_a Hash
45
+ end
46
+ end
47
+
48
+ describe "::list" do
49
+ it "raises ArgumentError without type" do
50
+ expect { FannyPack::IP.list }.to raise_error(ArgumentError)
51
+ end
52
+
53
+ it "raises error with invalid type" do
54
+ expect { FannyPack::IP.list :Hollywood }.to raise_error(ArgumentError)
55
+ end
56
+
57
+ it "returns an array of IPs" do
58
+ load_fixture :list
59
+ ip = FannyPack::IP.list :all
60
+ ip.should be_a Array
61
+ ip.should have(2).items
62
+ ip[0].should == '127.0.0.1'
63
+ ip[1].should == '127.0.0.2'
64
+ end
65
+
66
+ it "returns an array of Hashes if details is true" do
67
+ load_fixture :list_details
68
+ ip = FannyPack::IP.list :all, true
69
+ ip.should be_a Array
70
+ ip.should have(2).items
71
+ ip.each do |hash|
72
+ hash.should be_a Hash
73
+ %w[ipAddress addedOn isVPS status].each do |key|
74
+ hash.should have_key key
75
+ end
76
+ end
77
+ end
78
+ end
79
+
80
+ describe "::delete" do
81
+ it "raises ArgumentError without IP" do
82
+ expect { FannyPack::IP.delete }.to raise_error(ArgumentError)
83
+ end
84
+
85
+ it "deletes the IP" do
86
+ load_fixture :delete
87
+ ip = FannyPack::IP.delete '127.0.0.1'
88
+ ip.should be_a Hash
89
+ ip.should have_key 'deleted'
90
+ ip.should have_key 'ip'
91
+ end
92
+ end
93
+
94
+ %w[reactivate deactivate].each do |method|
95
+ describe "::#{method}" do
96
+ it "raises ArgumentError without IP" do
97
+ expect { FannyPack::IP.send method }.to raise_error(ArgumentError)
98
+ end
99
+
100
+ it "#{method}s the IP" do
101
+ load_fixture method
102
+ ip = FannyPack::IP.send method, '127.0.0.1'
103
+ ip.should be_a Hash
104
+ %w[ipAddress addedOn isVPS status].each do |key|
105
+ ip.should have_key key
106
+ end
107
+ end
108
+ end
109
+ end
110
+
111
+ describe "::details" do
112
+ it "raises ArgumentError without IP" do
113
+ expect { FannyPack::IP.details }.to raise_error(ArgumentError)
114
+ end
115
+
116
+ it "returns a hash of IP details" do
117
+ load_fixture :details
118
+ ip = FannyPack::IP.details '127.0.0.1'
119
+ ip.should be_a Hash
120
+ %w[ipAddress addedOn isVPS status].each do |key|
121
+ ip.should have_key key
122
+ end
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,92 @@
1
+ require 'spec_helper'
2
+
3
+ describe FannyPack::Request do
4
+
5
+ describe "::VALID_ACTIONS" do
6
+ it { FannyPack::Request::VALID_ACTIONS.should be_frozen }
7
+ end
8
+
9
+ before :each do
10
+ @req = FannyPack::Request.new
11
+ end
12
+
13
+ describe "#initialize" do
14
+ %w[response params].each do |test|
15
+ it "sets @#{test} to a hash" do
16
+ @req.instance_variable_get("@#{test}").should be_a Hash
17
+ end
18
+ end
19
+ end
20
+
21
+ %w[response params].each do |test|
22
+ describe "##{test}" do
23
+ it "returns @#{test}" do
24
+ @req.instance_variable_get("@#{test}").should == @req.send(test)
25
+ end
26
+ end
27
+ end
28
+
29
+ describe "#to_xml" do
30
+ it "builds a SOAP envelope" do
31
+ xml = @req.to_xml
32
+ xml.should include
33
+ %{<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">\n <env:Body>}
34
+ xml.should include
35
+ %{</env:Body>\n</env:Envelope>}
36
+ xml.should match %r{<accountHASH>.*</accountHASH>}
37
+ end
38
+ end
39
+
40
+ describe "#commit" do
41
+ it "raises exception unless action is valid" do
42
+ expect { @req.commit :HammerTime }.to raise_error
43
+ end
44
+ end
45
+
46
+ describe "#parse" do
47
+ before :each do
48
+ @req.instance_variable_set("@action", :addIp)
49
+ end
50
+
51
+ it "returns an Array of Hashes if @action == :getIpListDetailed" do
52
+ @req.instance_variable_set("@action", :getIpListDetailed)
53
+ res = @req.parse load_fixture :list_details
54
+ res.should be_a Array
55
+ res.should have(2).items
56
+ %w[ipAddress addedOn isVPS status].each do |key|
57
+ res.first.should have_key key
58
+ end
59
+ end
60
+
61
+ it "returns a flat Array if @action is :getIpList" do
62
+ @req.instance_variable_set("@action", :getIpList)
63
+ res = @req.parse load_fixture :list
64
+ res.should be_a Array
65
+ res.should have(2).items
66
+ res[0].should == '127.0.0.1'
67
+ res[1].should == '127.0.0.2'
68
+ end
69
+
70
+ it "returns a Hash if @action is not :getIpList or :getIpListDetailed" do
71
+ @req.instance_variable_set("@action", :addIp)
72
+ res = @req.parse load_fixture :add
73
+ res.should be_a Hash
74
+ end
75
+
76
+ it "sets @success" do
77
+ @req.instance_variable_set("@action", :addIp)
78
+ res = @req.parse load_fixture :add
79
+ @req.instance_variable_get("@success").should_not be_nil
80
+ end
81
+ end
82
+
83
+ describe "#success?" do
84
+ it "returns true or false based on @success" do
85
+ @req.instance_variable_set("@action", :addIp)
86
+ @req.parse load_fixture :add
87
+ @req.instance_variable_get("@success").should_not be_nil
88
+ @req.success?.should be_true
89
+ end
90
+ end
91
+
92
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe FannyPack do
4
+ describe "::Version" do
5
+ it "has a valid version" do
6
+ FannyPack::Version.should match /\d+\.\d+\.\d+/
7
+ end
8
+ end
9
+
10
+ describe "::account_hash" do
11
+ it "gets the account_hash" do
12
+ FannyPack.should respond_to :account_hash
13
+ end
14
+
15
+ it "sets the account_hash" do
16
+ FannyPack.should respond_to :account_hash=
17
+ end
18
+ end
19
+
20
+ describe "::account_hash?" do
21
+ it "returns false if ::account_hash is nil or blank" do
22
+ [nil, ""].each do |hash|
23
+ FannyPack.account_hash = hash
24
+ FannyPack.account_hash?.should be_false
25
+ end
26
+ end
27
+
28
+ it "returns true if ::account_hash is set" do
29
+ FannyPack.account_hash = "hash"
30
+ FannyPack.account_hash?.should be_true
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:xmethods-delayed-quotes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
3
+ <SOAP-ENV:Body><ns1:addIpResponse>
4
+ <Result xsi:type="ns2:Map">
5
+ <item><key xsi:type="xsd:string">ip</key><value xsi:type="xsd:string">127.0.0.1</value></item>
6
+ <item><key xsi:type="xsd:string">id</key><value xsi:type="xsd:string">123456</value></item>
7
+ </Result>
8
+ </ns1:addIpResponse>
9
+ </SOAP-ENV:Body>
10
+ </SOAP-ENV:Envelope>
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:xmethods-delayed-quotes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
3
+ <SOAP-ENV:Body>
4
+ <ns1:deactivateIpResponse>
5
+ <Result xsi:type="ns2:Map">
6
+ <item><key xsi:type="xsd:string">ipAddress</key><value xsi:type="xsd:string">127.0.0.1</value></item>
7
+ <item><key xsi:type="xsd:string">addedOn</key><value xsi:type="xsd:string">2010-06-10 17:05:31</value></item>
8
+ <item><key xsi:type="xsd:string">isVPS</key><value xsi:type="xsd:string">No</value></item>
9
+ <item><key xsi:type="xsd:string">status</key><value xsi:type="xsd:string">Inactive</value></item>
10
+ </Result>
11
+ </ns1:deactivateIpResponse>
12
+ </SOAP-ENV:Body>
13
+ </SOAP-ENV:Envelope>
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:xmethods-delayed-quotes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
3
+ <SOAP-ENV:Body>
4
+ <ns1:deleteIpResponse>
5
+ <Result xsi:type="ns2:Map">
6
+ <item><key xsi:type="xsd:string">ip</key><value xsi:type="xsd:string">127.0.0.1</value></item>
7
+ <item><key xsi:type="xsd:string">deleted</key><value xsi:type="xsd:string">Yes</value></item>
8
+ </Result>
9
+ </ns1:deleteIpResponse>
10
+ </SOAP-ENV:Body>
11
+ </SOAP-ENV:Envelope>
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:xmethods-delayed-quotes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
3
+ <SOAP-ENV:Body>
4
+ <ns1:getIpDetailsResponse>
5
+ <Result xsi:type="ns2:Map">
6
+ <item><key xsi:type="xsd:string">ipAddress</key><value xsi:type="xsd:string">127.0.0.1</value></item>
7
+ <item><key xsi:type="xsd:string">addedOn</key><value xsi:type="xsd:string">2010-06-10 17:05:31</value></item>
8
+ <item><key xsi:type="xsd:string">isVPS</key><value xsi:type="xsd:string">No</value></item>
9
+ <item><key xsi:type="xsd:string">status</key><value xsi:type="xsd:string">Active</value></item>
10
+ </Result>
11
+ </ns1:getIpDetailsResponse>
12
+ </SOAP-ENV:Body>
13
+ </SOAP-ENV:Envelope>
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:xmethods-delayed-quotes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
3
+ <SOAP-ENV:Body>
4
+ <ns1:editIpResponse>
5
+ <Result xsi:type="ns2:Map">
6
+ <item><key xsi:type="xsd:string">ip</key><value xsi:type="xsd:string">127.0.0.1</value></item>
7
+ <item><key xsi:type="xsd:string">new_ip</key><value xsi:type="xsd:string">127.0.0.2</value></item>
8
+ </Result>
9
+ </ns1:editIpResponse>
10
+ </SOAP-ENV:Body>
11
+ </SOAP-ENV:Envelope>
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:xmethods-delayed-quotes" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
3
+ <SOAP-ENV:Body>
4
+ <ns1:getIpListResponse>
5
+ <Result SOAP-ENC:arrayType="xsd:string[1]" xsi:type="SOAP-ENC:Array">
6
+ <item xsi:type="xsd:string">127.0.0.1</item>
7
+ <item xsi:type="xsd:string">127.0.0.2</item>
8
+ </Result>
9
+ </ns1:getIpListResponse>
10
+ </SOAP-ENV:Body>
11
+ </SOAP-ENV:Envelope>
@@ -0,0 +1,20 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:xmethods-delayed-quotes" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
3
+ <SOAP-ENV:Body>
4
+ <ns1:getIpListDetailedResponse>
5
+ <Result SOAP-ENC:arrayType="ns2:Map[1]" xsi:type="SOAP-ENC:Array">
6
+ <item xsi:type="ns2:Map">
7
+ <item><key xsi:type="xsd:string">ipAddress</key><value xsi:type="xsd:string">127.0.0.1</value></item>
8
+ <item><key xsi:type="xsd:string">addedOn</key><value xsi:type="xsd:string">2011-05-19 14:23:57</value></item>
9
+ <item><key xsi:type="xsd:string">isVPS</key><value xsi:type="xsd:string">Yes</value></item>
10
+ <item><key xsi:type="xsd:string">status</key><value xsi:type="xsd:string">Active</value></item>
11
+ </item>
12
+ <item xsi:type="ns2:Map">
13
+ <item><key xsi:type="xsd:string">ipAddress</key><value xsi:type="xsd:string">127.0.0.2</value></item>
14
+ <item><key xsi:type="xsd:string">addedOn</key><value xsi:type="xsd:string">2011-05-19 14:23:57</value></item>
15
+ <item><key xsi:type="xsd:string">isVPS</key><value xsi:type="xsd:string">No</value></item>
16
+ <item><key xsi:type="xsd:string">status</key><value xsi:type="xsd:string">Active</value></item>
17
+ </item>
18
+ </Result>
19
+ </ns1:getIpListDetailedResponse>
20
+ </SOAP-ENV:Body></SOAP-ENV:Envelope>
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:xmethods-delayed-quotes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
3
+ <SOAP-ENV:Body>
4
+ <ns1:reactivateIpResponse>
5
+ <Result xsi:type="ns2:Map">
6
+ <item><key xsi:type="xsd:string">ipAddress</key><value xsi:type="xsd:string">127.0.0.1</value></item>
7
+ <item><key xsi:type="xsd:string">addedOn</key><value xsi:type="xsd:string">2010-06-10 17:05:31</value></item>
8
+ <item><key xsi:type="xsd:string">isVPS</key><value xsi:type="xsd:string">No</value></item>
9
+ <item><key xsi:type="xsd:string">status</key><value xsi:type="xsd:string">Active</value></item>
10
+ </Result>
11
+ </ns1:reactivateIpResponse>
12
+ </SOAP-ENV:Body>
13
+ </SOAP-ENV:Envelope>
@@ -0,0 +1,17 @@
1
+ require 'rspec'
2
+ require 'fakeweb'
3
+ require 'fanny_pack'
4
+
5
+ FakeWeb.allow_net_connect = false
6
+
7
+ def load_fixture(name, register = true)
8
+ body = File.read File.expand_path("../fixtures/#{name}.txt", __FILE__)
9
+ register_url(body) if register
10
+ body
11
+ end
12
+
13
+ def register_url(body)
14
+ FakeWeb.clean_registry
15
+ FakeWeb.allow_net_connect = false
16
+ FakeWeb.register_uri :any, FannyPack::Request::API_URL, :body => body
17
+ end
metadata ADDED
@@ -0,0 +1,150 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fanny_pack
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - Joshua Priddle
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-05-20 00:00:00 -04:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: builder
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0"
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: crack
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: "0"
36
+ type: :runtime
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: rspec
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: 2.5.0
47
+ type: :development
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: fakeweb
51
+ prerelease: false
52
+ requirement: &id004 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ version: 1.3.0
58
+ type: :development
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: awesome_print
62
+ prerelease: false
63
+ requirement: &id005 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: "0"
69
+ type: :development
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: rcov
73
+ prerelease: false
74
+ requirement: &id006 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ version: "0.9"
80
+ type: :development
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: metric_fu
84
+ prerelease: false
85
+ requirement: &id007 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: "2.1"
91
+ type: :development
92
+ version_requirements: *id007
93
+ description: " Ruby bindings for the Fantastico API\n"
94
+ email: jpriddle@site5.com
95
+ executables: []
96
+
97
+ extensions: []
98
+
99
+ extra_rdoc_files:
100
+ - README.markdown
101
+ files:
102
+ - Rakefile
103
+ - README.markdown
104
+ - lib/fanny_pack/errors.rb
105
+ - lib/fanny_pack/ip.rb
106
+ - lib/fanny_pack/request.rb
107
+ - lib/fanny_pack/version.rb
108
+ - lib/fanny_pack.rb
109
+ - spec/fanny_pack/ip_spec.rb
110
+ - spec/fanny_pack/request_spec.rb
111
+ - spec/fanny_pack_spec.rb
112
+ - spec/fixtures/add.txt
113
+ - spec/fixtures/deactivate.txt
114
+ - spec/fixtures/delete.txt
115
+ - spec/fixtures/details.txt
116
+ - spec/fixtures/edit.txt
117
+ - spec/fixtures/list.txt
118
+ - spec/fixtures/list_details.txt
119
+ - spec/fixtures/reactivate.txt
120
+ - spec/spec_helper.rb
121
+ has_rdoc: true
122
+ homepage: https://github.com/site5/fanny_pack
123
+ licenses: []
124
+
125
+ post_install_message:
126
+ rdoc_options:
127
+ - --charset=UTF-8
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ none: false
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: "0"
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: "0"
142
+ requirements: []
143
+
144
+ rubyforge_project:
145
+ rubygems_version: 1.6.2
146
+ signing_key:
147
+ specification_version: 3
148
+ summary: Ruby bindings for the Fantastico API
149
+ test_files: []
150
+