ispmanager 0.1.0
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/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +40 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +34 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/ispmanager.gemspec +72 -0
- data/lib/ispmanager.rb +72 -0
- data/lib/ispmanager/base.rb +51 -0
- data/lib/ispmanager/domain.rb +8 -0
- data/spec/ispmanager/domain_spec.rb +35 -0
- data/spec/ispmanager_spec.rb +24 -0
- data/spec/spec_helper.rb +12 -0
- metadata +177 -0
    
        data/.document
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            --color
         | 
    
        data/Gemfile
    ADDED
    
    | @@ -0,0 +1,17 @@ | |
| 1 | 
            +
            source "http://rubygems.org"
         | 
| 2 | 
            +
            # Add dependencies required to use your gem here.
         | 
| 3 | 
            +
            # Example:
         | 
| 4 | 
            +
            #   gem "activesupport", ">= 2.3.5"
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            # Add dependencies to develop your gem here.
         | 
| 7 | 
            +
            # Include everything needed to run rake, tests, features, etc.
         | 
| 8 | 
            +
            gem "json"
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            group :development do
         | 
| 11 | 
            +
              gem "rspec", "~> 2.8.0"
         | 
| 12 | 
            +
              gem "rdoc", "~> 3.12"
         | 
| 13 | 
            +
              gem "bundler", "~> 1.0.0"
         | 
| 14 | 
            +
              gem "jeweler", "~> 1.8.3"
         | 
| 15 | 
            +
              gem "simplecov", ">= 0"
         | 
| 16 | 
            +
            	gem "fakeweb"
         | 
| 17 | 
            +
            end
         | 
    
        data/Gemfile.lock
    ADDED
    
    | @@ -0,0 +1,40 @@ | |
| 1 | 
            +
            GEM
         | 
| 2 | 
            +
              remote: http://rubygems.org/
         | 
| 3 | 
            +
              specs:
         | 
| 4 | 
            +
                diff-lcs (1.1.3)
         | 
| 5 | 
            +
                fakeweb (1.3.0)
         | 
| 6 | 
            +
                git (1.2.5)
         | 
| 7 | 
            +
                jeweler (1.8.3)
         | 
| 8 | 
            +
                  bundler (~> 1.0)
         | 
| 9 | 
            +
                  git (>= 1.2.5)
         | 
| 10 | 
            +
                  rake
         | 
| 11 | 
            +
                  rdoc
         | 
| 12 | 
            +
                json (1.7.3)
         | 
| 13 | 
            +
                multi_json (1.3.5)
         | 
| 14 | 
            +
                rake (0.9.2.2)
         | 
| 15 | 
            +
                rdoc (3.12)
         | 
| 16 | 
            +
                  json (~> 1.4)
         | 
| 17 | 
            +
                rspec (2.8.0)
         | 
| 18 | 
            +
                  rspec-core (~> 2.8.0)
         | 
| 19 | 
            +
                  rspec-expectations (~> 2.8.0)
         | 
| 20 | 
            +
                  rspec-mocks (~> 2.8.0)
         | 
| 21 | 
            +
                rspec-core (2.8.0)
         | 
| 22 | 
            +
                rspec-expectations (2.8.0)
         | 
| 23 | 
            +
                  diff-lcs (~> 1.1.2)
         | 
| 24 | 
            +
                rspec-mocks (2.8.0)
         | 
| 25 | 
            +
                simplecov (0.6.4)
         | 
| 26 | 
            +
                  multi_json (~> 1.0)
         | 
| 27 | 
            +
                  simplecov-html (~> 0.5.3)
         | 
| 28 | 
            +
                simplecov-html (0.5.3)
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            PLATFORMS
         | 
| 31 | 
            +
              ruby
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            DEPENDENCIES
         | 
| 34 | 
            +
              bundler (~> 1.0.0)
         | 
| 35 | 
            +
              fakeweb
         | 
| 36 | 
            +
              jeweler (~> 1.8.3)
         | 
| 37 | 
            +
              json
         | 
| 38 | 
            +
              rdoc (~> 3.12)
         | 
| 39 | 
            +
              rspec (~> 2.8.0)
         | 
| 40 | 
            +
              simplecov
         | 
    
        data/LICENSE.txt
    ADDED
    
    | @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            Copyright (c) 2012 Aleksei Kvitinskii
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining
         | 
| 4 | 
            +
            a copy of this software and associated documentation files (the
         | 
| 5 | 
            +
            "Software"), to deal in the Software without restriction, including
         | 
| 6 | 
            +
            without limitation the rights to use, copy, modify, merge, publish,
         | 
| 7 | 
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 8 | 
            +
            permit persons to whom the Software is furnished to do so, subject to
         | 
| 9 | 
            +
            the following conditions:
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            The above copyright notice and this permission notice shall be
         | 
| 12 | 
            +
            included in all copies or substantial portions of the Software.
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 15 | 
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 16 | 
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 17 | 
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 18 | 
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 19 | 
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 20 | 
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
    
        data/README.rdoc
    ADDED
    
    | @@ -0,0 +1,34 @@ | |
| 1 | 
            +
            = ISPManager Gem
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            This ruby gem provides connection wrapper for ISPManager API
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            == Install
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            Run in terminal:
         | 
| 8 | 
            +
            	gem install ispmanager
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            == Examples
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            	panel = ISPManager.new(
         | 
| 13 | 
            +
            		:host => 'example.com',
         | 
| 14 | 
            +
            		:user => 'user',
         | 
| 15 | 
            +
            		:password => 'password'
         | 
| 16 | 
            +
            	)
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            	p panel.domains.list
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            == Contributing to ispmanager
         | 
| 21 | 
            +
             
         | 
| 22 | 
            +
            * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
         | 
| 23 | 
            +
            * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
         | 
| 24 | 
            +
            * Fork the project.
         | 
| 25 | 
            +
            * Start a feature/bugfix branch.
         | 
| 26 | 
            +
            * Commit and push until you are happy with your contribution.
         | 
| 27 | 
            +
            * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
         | 
| 28 | 
            +
            * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            == Copyright
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            Copyright (c) 2012 Aleksei Kvitinskii. See LICENSE.txt for
         | 
| 33 | 
            +
            further details.
         | 
| 34 | 
            +
             | 
    
        data/Rakefile
    ADDED
    
    | @@ -0,0 +1,49 @@ | |
| 1 | 
            +
            # encoding: utf-8
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'rubygems'
         | 
| 4 | 
            +
            require 'bundler'
         | 
| 5 | 
            +
            begin
         | 
| 6 | 
            +
              Bundler.setup(:default, :development)
         | 
| 7 | 
            +
            rescue Bundler::BundlerError => e
         | 
| 8 | 
            +
              $stderr.puts e.message
         | 
| 9 | 
            +
              $stderr.puts "Run `bundle install` to install missing gems"
         | 
| 10 | 
            +
              exit e.status_code
         | 
| 11 | 
            +
            end
         | 
| 12 | 
            +
            require 'rake'
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            require 'jeweler'
         | 
| 15 | 
            +
            Jeweler::Tasks.new do |gem|
         | 
| 16 | 
            +
              # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
         | 
| 17 | 
            +
              gem.name = "ispmanager"
         | 
| 18 | 
            +
              gem.homepage = "http://github.com/axy/ispmanager"
         | 
| 19 | 
            +
              gem.license = "MIT"
         | 
| 20 | 
            +
              gem.summary = %Q{API client for ISPManager panel}
         | 
| 21 | 
            +
              gem.description = %Q{API client for ISPManager panel}
         | 
| 22 | 
            +
              gem.email = "aleksei.wm@gmail.com"
         | 
| 23 | 
            +
              gem.authors = ["Aleksei Kvitinskii"]
         | 
| 24 | 
            +
              # dependencies defined in Gemfile
         | 
| 25 | 
            +
            end
         | 
| 26 | 
            +
            Jeweler::RubygemsDotOrgTasks.new
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            require 'rspec/core'
         | 
| 29 | 
            +
            require 'rspec/core/rake_task'
         | 
| 30 | 
            +
            RSpec::Core::RakeTask.new(:spec) do |spec|
         | 
| 31 | 
            +
              spec.pattern = FileList['spec/**/*_spec.rb']
         | 
| 32 | 
            +
            end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            RSpec::Core::RakeTask.new(:rcov) do |spec|
         | 
| 35 | 
            +
              spec.pattern = 'spec/**/*_spec.rb'
         | 
| 36 | 
            +
              spec.rcov = true
         | 
| 37 | 
            +
            end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            task :default => :spec
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            require 'rdoc/task'
         | 
| 42 | 
            +
            Rake::RDocTask.new do |rdoc|
         | 
| 43 | 
            +
              version = File.exist?('VERSION') ? File.read('VERSION') : ""
         | 
| 44 | 
            +
             | 
| 45 | 
            +
              rdoc.rdoc_dir = 'rdoc'
         | 
| 46 | 
            +
              rdoc.title = "ispmanager #{version}"
         | 
| 47 | 
            +
              rdoc.rdoc_files.include('README*')
         | 
| 48 | 
            +
              rdoc.rdoc_files.include('lib/**/*.rb')
         | 
| 49 | 
            +
            end
         | 
    
        data/VERSION
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            0.1.0
         | 
    
        data/ispmanager.gemspec
    ADDED
    
    | @@ -0,0 +1,72 @@ | |
| 1 | 
            +
            # Generated by jeweler
         | 
| 2 | 
            +
            # DO NOT EDIT THIS FILE DIRECTLY
         | 
| 3 | 
            +
            # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
         | 
| 4 | 
            +
            # -*- encoding: utf-8 -*-
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |s|
         | 
| 7 | 
            +
              s.name = "ispmanager"
         | 
| 8 | 
            +
              s.version = "0.1.0"
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 11 | 
            +
              s.authors = ["Aleksei Kvitinskii"]
         | 
| 12 | 
            +
              s.date = "2012-05-25"
         | 
| 13 | 
            +
              s.description = "API client for ISPManager panel"
         | 
| 14 | 
            +
              s.email = "aleksei.wm@gmail.com"
         | 
| 15 | 
            +
              s.extra_rdoc_files = [
         | 
| 16 | 
            +
                "LICENSE.txt",
         | 
| 17 | 
            +
                "README.rdoc"
         | 
| 18 | 
            +
              ]
         | 
| 19 | 
            +
              s.files = [
         | 
| 20 | 
            +
                ".document",
         | 
| 21 | 
            +
                ".rspec",
         | 
| 22 | 
            +
                "Gemfile",
         | 
| 23 | 
            +
                "Gemfile.lock",
         | 
| 24 | 
            +
                "LICENSE.txt",
         | 
| 25 | 
            +
                "README.rdoc",
         | 
| 26 | 
            +
                "Rakefile",
         | 
| 27 | 
            +
                "VERSION",
         | 
| 28 | 
            +
                "ispmanager.gemspec",
         | 
| 29 | 
            +
                "lib/ispmanager.rb",
         | 
| 30 | 
            +
                "lib/ispmanager/base.rb",
         | 
| 31 | 
            +
                "lib/ispmanager/domain.rb",
         | 
| 32 | 
            +
                "spec/ispmanager/domain_spec.rb",
         | 
| 33 | 
            +
                "spec/ispmanager_spec.rb",
         | 
| 34 | 
            +
                "spec/spec_helper.rb"
         | 
| 35 | 
            +
              ]
         | 
| 36 | 
            +
              s.homepage = "http://github.com/axy/ispmanager"
         | 
| 37 | 
            +
              s.licenses = ["MIT"]
         | 
| 38 | 
            +
              s.require_paths = ["lib"]
         | 
| 39 | 
            +
              s.rubygems_version = "1.8.24"
         | 
| 40 | 
            +
              s.summary = "API client for ISPManager panel"
         | 
| 41 | 
            +
             | 
| 42 | 
            +
              if s.respond_to? :specification_version then
         | 
| 43 | 
            +
                s.specification_version = 3
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
         | 
| 46 | 
            +
                  s.add_runtime_dependency(%q<json>, [">= 0"])
         | 
| 47 | 
            +
                  s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
         | 
| 48 | 
            +
                  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
         | 
| 49 | 
            +
                  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
         | 
| 50 | 
            +
                  s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
         | 
| 51 | 
            +
                  s.add_development_dependency(%q<simplecov>, [">= 0"])
         | 
| 52 | 
            +
                  s.add_development_dependency(%q<fakeweb>, [">= 0"])
         | 
| 53 | 
            +
                else
         | 
| 54 | 
            +
                  s.add_dependency(%q<json>, [">= 0"])
         | 
| 55 | 
            +
                  s.add_dependency(%q<rspec>, ["~> 2.8.0"])
         | 
| 56 | 
            +
                  s.add_dependency(%q<rdoc>, ["~> 3.12"])
         | 
| 57 | 
            +
                  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
         | 
| 58 | 
            +
                  s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
         | 
| 59 | 
            +
                  s.add_dependency(%q<simplecov>, [">= 0"])
         | 
| 60 | 
            +
                  s.add_dependency(%q<fakeweb>, [">= 0"])
         | 
| 61 | 
            +
                end
         | 
| 62 | 
            +
              else
         | 
| 63 | 
            +
                s.add_dependency(%q<json>, [">= 0"])
         | 
| 64 | 
            +
                s.add_dependency(%q<rspec>, ["~> 2.8.0"])
         | 
| 65 | 
            +
                s.add_dependency(%q<rdoc>, ["~> 3.12"])
         | 
| 66 | 
            +
                s.add_dependency(%q<bundler>, ["~> 1.0.0"])
         | 
| 67 | 
            +
                s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
         | 
| 68 | 
            +
                s.add_dependency(%q<simplecov>, [">= 0"])
         | 
| 69 | 
            +
                s.add_dependency(%q<fakeweb>, [">= 0"])
         | 
| 70 | 
            +
              end
         | 
| 71 | 
            +
            end
         | 
| 72 | 
            +
             | 
    
        data/lib/ispmanager.rb
    ADDED
    
    | @@ -0,0 +1,72 @@ | |
| 1 | 
            +
            class ISPManager
         | 
| 2 | 
            +
            	require 'ispmanager/base'
         | 
| 3 | 
            +
            	require 'ispmanager/domain'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            	def initialize params
         | 
| 6 | 
            +
            		unless params[:host] && params[:user] && params[:password]
         | 
| 7 | 
            +
            			raise RequireConnectionParams
         | 
| 8 | 
            +
            		end
         | 
| 9 | 
            +
            		params[:port] ||= 443
         | 
| 10 | 
            +
            		@params = params
         | 
| 11 | 
            +
            	end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            	def domains
         | 
| 14 | 
            +
            		@domains ||= ISPManager::Domain.new @params
         | 
| 15 | 
            +
            	end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            	class RequireConnectionParams < StandardError
         | 
| 18 | 
            +
            	end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            	class Request
         | 
| 21 | 
            +
            		def self.create function, params, connection
         | 
| 22 | 
            +
            			p connection
         | 
| 23 | 
            +
            			http = Net::HTTP.new connection[:host], connection[:port]
         | 
| 24 | 
            +
            			http.use_ssl = true
         | 
| 25 | 
            +
            			http.verify_mode = OpenSSL::SSL::VERIFY_NONE
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            			params ||= {}
         | 
| 28 | 
            +
            			params[:authinfo] = "#{connection[:user]}:#{connection[:password]}"
         | 
| 29 | 
            +
            			params[:out] = :json
         | 
| 30 | 
            +
            			params[:func] = function
         | 
| 31 | 
            +
            			query = URI.encode_www_form(params)
         | 
| 32 | 
            +
            			path = "/manager/ispmgr?#{query}"
         | 
| 33 | 
            +
            			request = Net::HTTP::Get.new(path)
         | 
| 34 | 
            +
            			result = http.start {|http| http.request(request) }.body
         | 
| 35 | 
            +
            		end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
             | 
| 38 | 
            +
            		class ::Hash
         | 
| 39 | 
            +
            			def recursive_symbolize_keys!
         | 
| 40 | 
            +
            				recursive_modify_keys! { |key| key.to_sym }
         | 
| 41 | 
            +
            			end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            			def recursive_stringify_keys!
         | 
| 44 | 
            +
            				recursive_modify_keys! { |key| key.to_s }
         | 
| 45 | 
            +
            			end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
            			#def symbolize_keys!
         | 
| 48 | 
            +
            				#modify_keys! { |key| key.to_sym }
         | 
| 49 | 
            +
            			#end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
            			#def stringify_keys!
         | 
| 52 | 
            +
            				#modify_keys! {|key| key.to_s }
         | 
| 53 | 
            +
            			#end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
            			protected
         | 
| 56 | 
            +
            			def modify_keys!
         | 
| 57 | 
            +
            				keys.each do |key|
         | 
| 58 | 
            +
            					self[(yield(key) rescue key) || key] = delete(key)
         | 
| 59 | 
            +
            				end
         | 
| 60 | 
            +
            				self
         | 
| 61 | 
            +
            			end
         | 
| 62 | 
            +
             | 
| 63 | 
            +
            			def recursive_modify_keys! &block
         | 
| 64 | 
            +
            				modify_keys!(&block)
         | 
| 65 | 
            +
            				values.each { |h| h.recursive_modify_keys!(&block) if h.is_a?(Hash) }
         | 
| 66 | 
            +
            				values.select { |v| v.is_a?(Array) }.flatten.each { |h| h.recursive_modify_keys!(&block) if h.is_a?(Hash) }
         | 
| 67 | 
            +
            				self
         | 
| 68 | 
            +
            			end
         | 
| 69 | 
            +
            		end
         | 
| 70 | 
            +
             | 
| 71 | 
            +
            	end
         | 
| 72 | 
            +
            end
         | 
| @@ -0,0 +1,51 @@ | |
| 1 | 
            +
            require 'net/http'
         | 
| 2 | 
            +
            require 'net/https'
         | 
| 3 | 
            +
            require 'json'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            class ISPManager::Base
         | 
| 6 | 
            +
            	def initialize params
         | 
| 7 | 
            +
            		@params = params
         | 
| 8 | 
            +
            	end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            	def request method, params = {}
         | 
| 11 | 
            +
            		result = ISPManager::Request.create method, params, @params
         | 
| 12 | 
            +
            		result = JSON.parse(result)
         | 
| 13 | 
            +
            		if result.is_a? Hash
         | 
| 14 | 
            +
            			result.recursive_symbolize_keys!
         | 
| 15 | 
            +
            			return result[:elem] ? result[:elem] : result
         | 
| 16 | 
            +
            		end
         | 
| 17 | 
            +
            	end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            	class ::Hash
         | 
| 20 | 
            +
            		def recursive_symbolize_keys!
         | 
| 21 | 
            +
            			recursive_modify_keys! { |key| key.to_sym }
         | 
| 22 | 
            +
            		end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            		def recursive_stringify_keys!
         | 
| 25 | 
            +
            			recursive_modify_keys! { |key| key.to_s }
         | 
| 26 | 
            +
            		end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            		#def symbolize_keys!
         | 
| 29 | 
            +
            		#modify_keys! { |key| key.to_sym }
         | 
| 30 | 
            +
            		#end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            		#def stringify_keys!
         | 
| 33 | 
            +
            		#modify_keys! {|key| key.to_s }
         | 
| 34 | 
            +
            		#end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            		protected
         | 
| 37 | 
            +
            		def modify_keys!
         | 
| 38 | 
            +
            			keys.each do |key|
         | 
| 39 | 
            +
            				self[(yield(key) rescue key) || key] = delete(key)
         | 
| 40 | 
            +
            			end
         | 
| 41 | 
            +
            			self
         | 
| 42 | 
            +
            		end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
            		def recursive_modify_keys! &block
         | 
| 45 | 
            +
            			modify_keys!(&block)
         | 
| 46 | 
            +
            			values.each { |h| h.recursive_modify_keys!(&block) if h.is_a?(Hash) }
         | 
| 47 | 
            +
            			values.select { |v| v.is_a?(Array) }.flatten.each { |h| h.recursive_modify_keys!(&block) if h.is_a?(Hash) }
         | 
| 48 | 
            +
            			self
         | 
| 49 | 
            +
            		end
         | 
| 50 | 
            +
            	end
         | 
| 51 | 
            +
            end
         | 
| @@ -0,0 +1,35 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
            require 'fakeweb'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            describe ISPManager::Domain do
         | 
| 5 | 
            +
            	before( :each ) do
         | 
| 6 | 
            +
            		ISPManager::Request.should_receive(:create).and_return <<REQUREST
         | 
| 7 | 
            +
            {
         | 
| 8 | 
            +
            "elem": [
         | 
| 9 | 
            +
            	{
         | 
| 10 | 
            +
            		"name": "site1.com",
         | 
| 11 | 
            +
            		"ip": "8.8.8.8",
         | 
| 12 | 
            +
            		"docroot": "\/www\/site1.com",
         | 
| 13 | 
            +
            		"php": "on",
         | 
| 14 | 
            +
            		"ssi": "on"
         | 
| 15 | 
            +
            	},
         | 
| 16 | 
            +
            	{
         | 
| 17 | 
            +
            		"name": "site2.com",
         | 
| 18 | 
            +
            		"ip": "8.8.8.8",
         | 
| 19 | 
            +
            		"docroot": "\/www\/site2.com",
         | 
| 20 | 
            +
            		"php": "on",
         | 
| 21 | 
            +
            		"ssi": "on"
         | 
| 22 | 
            +
            	}
         | 
| 23 | 
            +
            ]
         | 
| 24 | 
            +
            }
         | 
| 25 | 
            +
            REQUREST
         | 
| 26 | 
            +
            		
         | 
| 27 | 
            +
            	end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            	subject { ISPManager::Domain.new :host => 'example.com', :user => 'user', :password => 'password'}
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            	describe "list" do
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            		it {should have(2).list}
         | 
| 34 | 
            +
            	end
         | 
| 35 | 
            +
            end
         | 
| @@ -0,0 +1,24 @@ | |
| 1 | 
            +
            require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe ISPManager do
         | 
| 4 | 
            +
            	let(:params){{host: 'example.com', user: 'user', password: 'password'}}
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            	it "should not raise exceptions" do
         | 
| 7 | 
            +
            		ISPManager.new params
         | 
| 8 | 
            +
            	end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            	it "should require host" do
         | 
| 11 | 
            +
            		params.delete(:host)
         | 
| 12 | 
            +
            		expect {ISPManager.new params}.should raise_exception( ISPManager::RequireConnectionParams)
         | 
| 13 | 
            +
            	end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            	it "should require user" do
         | 
| 16 | 
            +
            		params.delete(:user)
         | 
| 17 | 
            +
            		expect {ISPManager.new params}.should raise_exception( ISPManager::RequireConnectionParams)
         | 
| 18 | 
            +
            	end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            	it "should require password" do
         | 
| 21 | 
            +
            		params.delete(:password)
         | 
| 22 | 
            +
            		expect {ISPManager.new params}.should raise_exception( ISPManager::RequireConnectionParams)
         | 
| 23 | 
            +
            	end
         | 
| 24 | 
            +
            end
         | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | @@ -0,0 +1,12 @@ | |
| 1 | 
            +
            $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
         | 
| 2 | 
            +
            $LOAD_PATH.unshift(File.dirname(__FILE__))
         | 
| 3 | 
            +
            require 'rspec'
         | 
| 4 | 
            +
            require 'ispmanager'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            # Requires supporting files with custom matchers and macros, etc,
         | 
| 7 | 
            +
            # in ./support/ and its subdirectories.
         | 
| 8 | 
            +
            Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            RSpec.configure do |config|
         | 
| 11 | 
            +
              
         | 
| 12 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,177 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: ispmanager
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.1.0
         | 
| 5 | 
            +
              prerelease: 
         | 
| 6 | 
            +
            platform: ruby
         | 
| 7 | 
            +
            authors:
         | 
| 8 | 
            +
            - Aleksei Kvitinskii
         | 
| 9 | 
            +
            autorequire: 
         | 
| 10 | 
            +
            bindir: bin
         | 
| 11 | 
            +
            cert_chain: []
         | 
| 12 | 
            +
            date: 2012-05-25 00:00:00.000000000 Z
         | 
| 13 | 
            +
            dependencies:
         | 
| 14 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 15 | 
            +
              name: json
         | 
| 16 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 17 | 
            +
                none: false
         | 
| 18 | 
            +
                requirements:
         | 
| 19 | 
            +
                - - ! '>='
         | 
| 20 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 21 | 
            +
                    version: '0'
         | 
| 22 | 
            +
              type: :runtime
         | 
| 23 | 
            +
              prerelease: false
         | 
| 24 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 25 | 
            +
                none: false
         | 
| 26 | 
            +
                requirements:
         | 
| 27 | 
            +
                - - ! '>='
         | 
| 28 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            +
                    version: '0'
         | 
| 30 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 31 | 
            +
              name: rspec
         | 
| 32 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 33 | 
            +
                none: false
         | 
| 34 | 
            +
                requirements:
         | 
| 35 | 
            +
                - - ~>
         | 
| 36 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 37 | 
            +
                    version: 2.8.0
         | 
| 38 | 
            +
              type: :development
         | 
| 39 | 
            +
              prerelease: false
         | 
| 40 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 41 | 
            +
                none: false
         | 
| 42 | 
            +
                requirements:
         | 
| 43 | 
            +
                - - ~>
         | 
| 44 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 45 | 
            +
                    version: 2.8.0
         | 
| 46 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 47 | 
            +
              name: rdoc
         | 
| 48 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 49 | 
            +
                none: false
         | 
| 50 | 
            +
                requirements:
         | 
| 51 | 
            +
                - - ~>
         | 
| 52 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 53 | 
            +
                    version: '3.12'
         | 
| 54 | 
            +
              type: :development
         | 
| 55 | 
            +
              prerelease: false
         | 
| 56 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 57 | 
            +
                none: false
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - ~>
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '3.12'
         | 
| 62 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 63 | 
            +
              name: bundler
         | 
| 64 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                none: false
         | 
| 66 | 
            +
                requirements:
         | 
| 67 | 
            +
                - - ~>
         | 
| 68 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 69 | 
            +
                    version: 1.0.0
         | 
| 70 | 
            +
              type: :development
         | 
| 71 | 
            +
              prerelease: false
         | 
| 72 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 73 | 
            +
                none: false
         | 
| 74 | 
            +
                requirements:
         | 
| 75 | 
            +
                - - ~>
         | 
| 76 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 77 | 
            +
                    version: 1.0.0
         | 
| 78 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 79 | 
            +
              name: jeweler
         | 
| 80 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 81 | 
            +
                none: false
         | 
| 82 | 
            +
                requirements:
         | 
| 83 | 
            +
                - - ~>
         | 
| 84 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 85 | 
            +
                    version: 1.8.3
         | 
| 86 | 
            +
              type: :development
         | 
| 87 | 
            +
              prerelease: false
         | 
| 88 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 89 | 
            +
                none: false
         | 
| 90 | 
            +
                requirements:
         | 
| 91 | 
            +
                - - ~>
         | 
| 92 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 93 | 
            +
                    version: 1.8.3
         | 
| 94 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 95 | 
            +
              name: simplecov
         | 
| 96 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 97 | 
            +
                none: false
         | 
| 98 | 
            +
                requirements:
         | 
| 99 | 
            +
                - - ! '>='
         | 
| 100 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 101 | 
            +
                    version: '0'
         | 
| 102 | 
            +
              type: :development
         | 
| 103 | 
            +
              prerelease: false
         | 
| 104 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 105 | 
            +
                none: false
         | 
| 106 | 
            +
                requirements:
         | 
| 107 | 
            +
                - - ! '>='
         | 
| 108 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 109 | 
            +
                    version: '0'
         | 
| 110 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 111 | 
            +
              name: fakeweb
         | 
| 112 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 113 | 
            +
                none: false
         | 
| 114 | 
            +
                requirements:
         | 
| 115 | 
            +
                - - ! '>='
         | 
| 116 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 117 | 
            +
                    version: '0'
         | 
| 118 | 
            +
              type: :development
         | 
| 119 | 
            +
              prerelease: false
         | 
| 120 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 121 | 
            +
                none: false
         | 
| 122 | 
            +
                requirements:
         | 
| 123 | 
            +
                - - ! '>='
         | 
| 124 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 125 | 
            +
                    version: '0'
         | 
| 126 | 
            +
            description: API client for ISPManager panel
         | 
| 127 | 
            +
            email: aleksei.wm@gmail.com
         | 
| 128 | 
            +
            executables: []
         | 
| 129 | 
            +
            extensions: []
         | 
| 130 | 
            +
            extra_rdoc_files:
         | 
| 131 | 
            +
            - LICENSE.txt
         | 
| 132 | 
            +
            - README.rdoc
         | 
| 133 | 
            +
            files:
         | 
| 134 | 
            +
            - .document
         | 
| 135 | 
            +
            - .rspec
         | 
| 136 | 
            +
            - Gemfile
         | 
| 137 | 
            +
            - Gemfile.lock
         | 
| 138 | 
            +
            - LICENSE.txt
         | 
| 139 | 
            +
            - README.rdoc
         | 
| 140 | 
            +
            - Rakefile
         | 
| 141 | 
            +
            - VERSION
         | 
| 142 | 
            +
            - ispmanager.gemspec
         | 
| 143 | 
            +
            - lib/ispmanager.rb
         | 
| 144 | 
            +
            - lib/ispmanager/base.rb
         | 
| 145 | 
            +
            - lib/ispmanager/domain.rb
         | 
| 146 | 
            +
            - spec/ispmanager/domain_spec.rb
         | 
| 147 | 
            +
            - spec/ispmanager_spec.rb
         | 
| 148 | 
            +
            - spec/spec_helper.rb
         | 
| 149 | 
            +
            homepage: http://github.com/axy/ispmanager
         | 
| 150 | 
            +
            licenses:
         | 
| 151 | 
            +
            - MIT
         | 
| 152 | 
            +
            post_install_message: 
         | 
| 153 | 
            +
            rdoc_options: []
         | 
| 154 | 
            +
            require_paths:
         | 
| 155 | 
            +
            - lib
         | 
| 156 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 157 | 
            +
              none: false
         | 
| 158 | 
            +
              requirements:
         | 
| 159 | 
            +
              - - ! '>='
         | 
| 160 | 
            +
                - !ruby/object:Gem::Version
         | 
| 161 | 
            +
                  version: '0'
         | 
| 162 | 
            +
                  segments:
         | 
| 163 | 
            +
                  - 0
         | 
| 164 | 
            +
                  hash: 3890904994089321579
         | 
| 165 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 166 | 
            +
              none: false
         | 
| 167 | 
            +
              requirements:
         | 
| 168 | 
            +
              - - ! '>='
         | 
| 169 | 
            +
                - !ruby/object:Gem::Version
         | 
| 170 | 
            +
                  version: '0'
         | 
| 171 | 
            +
            requirements: []
         | 
| 172 | 
            +
            rubyforge_project: 
         | 
| 173 | 
            +
            rubygems_version: 1.8.24
         | 
| 174 | 
            +
            signing_key: 
         | 
| 175 | 
            +
            specification_version: 3
         | 
| 176 | 
            +
            summary: API client for ISPManager panel
         | 
| 177 | 
            +
            test_files: []
         |