kloxo 0.1.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 351531770824c1362fa576907f4b3677b3e79597
4
+ data.tar.gz: 320575e9651514f20f2ca6aa48f8dadfff3c7b33
5
+ SHA512:
6
+ metadata.gz: 944a48d66caadb3288f8aaf76e13f8b23eff0490fa239fe74a67f90bac5be27946cf93202c1d02ed71425d030df2c9d57c52b24248c477dcd3a5f5bb7ed25483
7
+ data.tar.gz: 600e6320e1b3e43e6e1217a4a14cb21a1ead8b56a46034268d90dd6a869fbb2cb463a9e2747c641f3ffebf25bd7f8553c9b1b91492661c2f8edf9ac6b670efba
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.3
5
+ before_install: gem install bundler -v 1.13.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in kloxo.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Kloxo
2
+
3
+ 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/kloxo`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'kloxo'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install kloxo
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/kloxo.
36
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "kloxo"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/kloxo.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'kloxo/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "kloxo"
8
+ spec.version = Kloxo::VERSION
9
+ spec.authors = ["Neil Abendan"]
10
+ spec.email = ["na.abendan@dot.ph"]
11
+
12
+ spec.summary = %q{Gem to wrap Kloxo API}
13
+ spec.description = %q{Gem to wrap Kloxo API}
14
+
15
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
16
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
17
+ if spec.respond_to?(:metadata)
18
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
19
+ else
20
+ raise "RubyGems 2.0 or newer is required to protect against " \
21
+ "public gem pushes."
22
+ end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
25
+ f.match(%r{^(test|spec|features)/})
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_development_dependency "bundler", "~> 1.13"
32
+ spec.add_development_dependency "rake", "~> 10.0"
33
+ spec.add_development_dependency "rspec", "~> 3.0"
34
+
35
+ spec.add_dependency "httparty"
36
+ spec.add_dependency "activesupport"
37
+ end
data/lib/kloxo.rb ADDED
@@ -0,0 +1,21 @@
1
+ module Kloxo
2
+ require "kloxo/version"
3
+
4
+ require "kloxo/api/service"
5
+
6
+ require "kloxo/api/request"
7
+ require "kloxo/api/response"
8
+ require "kloxo/api/resource"
9
+ require "kloxo/api/resource_response"
10
+
11
+ require "kloxo/api/client/create"
12
+ require "kloxo/api/client/create_response"
13
+ require "kloxo/api/client/delete"
14
+ require "kloxo/api/client/delete_response"
15
+ require "kloxo/api/client/disable"
16
+ require "kloxo/api/client/disable_response"
17
+ require "kloxo/api/client/enable"
18
+ require "kloxo/api/client/enable_response"
19
+ require "kloxo/api/client/info"
20
+ require "kloxo/api/client/info_response"
21
+ end
@@ -0,0 +1,34 @@
1
+ module Kloxo
2
+ module API
3
+ module Client
4
+ class Create < Kloxo::API::Request
5
+ attr_accessor :name, :password, :plan, :email, :domain, :dns_template
6
+
7
+ def initialize params = {}
8
+ self.name = params[:name]
9
+ self.password = params[:password]
10
+ self.plan = params[:plan]
11
+ self.email = params[:email]
12
+ self.domain = params[:domain]
13
+ self.dns_template = params[:dns_template]
14
+ end
15
+
16
+ def param
17
+ {
18
+ "action" => "add",
19
+ "class" => "client",
20
+ "name" => self.name,
21
+ "v-plan_name" => self.plan,
22
+ "v-type" => "customer",
23
+ "v-contactemail" => self.email,
24
+ "v-password" => self.password,
25
+ "v-send_welcome_f" => "on",
26
+ "v-domain_name" => self.domain,
27
+ "v-dnstemplate_name" => self.dns_template
28
+ }.to_param
29
+ end
30
+
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,9 @@
1
+ module Kloxo
2
+ module API
3
+ module Client
4
+ class CreateResponse < Kloxo::API::Response
5
+
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,22 @@
1
+ module Kloxo
2
+ module API
3
+ module Client
4
+ class Delete < Kloxo::API::Request
5
+ attr_accessor :name
6
+
7
+ def initialize params = {}
8
+ self.name = params[:name]
9
+ end
10
+
11
+ def param
12
+ {
13
+ "action" => "delete",
14
+ "class" => "client",
15
+ "name" => self.name
16
+ }.to_param
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,9 @@
1
+ module Kloxo
2
+ module API
3
+ module Client
4
+ class DeleteResponse < Kloxo::API::Response
5
+
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,23 @@
1
+ module Kloxo
2
+ module API
3
+ module Client
4
+ class Disable < Kloxo::API::Request
5
+ attr_accessor :name
6
+
7
+ def initialize params = {}
8
+ self.name = params[:name]
9
+ end
10
+
11
+ def param
12
+ {
13
+ "action" => "update",
14
+ "class" => "client",
15
+ "name" => self.name,
16
+ "subaction" => "disable",
17
+ }.to_param
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,9 @@
1
+ module Kloxo
2
+ module API
3
+ module Client
4
+ class DisableResponse < Kloxo::API::Response
5
+
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,23 @@
1
+ module Kloxo
2
+ module API
3
+ module Client
4
+ class Enable < Kloxo::API::Request
5
+ attr_accessor :name
6
+
7
+ def initialize params = {}
8
+ self.name = params[:name]
9
+ end
10
+
11
+ def param
12
+ {
13
+ "action" => "update",
14
+ "class" => "client",
15
+ "name" => self.name,
16
+ "subaction" => "enable",
17
+ }.to_param
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,9 @@
1
+ module Kloxo
2
+ module API
3
+ module Client
4
+ class EnableResponse < Kloxo::API::Response
5
+
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,27 @@
1
+ module Kloxo
2
+ module API
3
+ module Client
4
+ class Info < Kloxo::API::Request
5
+ attr_accessor :name
6
+
7
+ def initialize params = {}
8
+ self.name = params[:name]
9
+ end
10
+
11
+ def param
12
+ {
13
+ "action" => "getproperty",
14
+ "class" => "client",
15
+ "name" => self.name,
16
+ "v-status" => "",
17
+ "v-contactemail" => "",
18
+ "v-used" => "",
19
+ "v-priv" => "",
20
+ "v-resourceplan_used" => ""
21
+ }.to_param
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,9 @@
1
+ module Kloxo
2
+ module API
3
+ module Client
4
+ class InfoResponse < Kloxo::API::Response
5
+
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ require 'active_support'
2
+ require 'active_support/core_ext/hash'
3
+
4
+ module Kloxo
5
+ module API
6
+ class Request
7
+
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,19 @@
1
+ module Kloxo
2
+ module API
3
+ class Resource < Kloxo::API::Request
4
+ attr_accessor :type
5
+
6
+ def initialize params = {}
7
+ self.type = params[:type]
8
+ end
9
+
10
+ def param
11
+ {
12
+ "action" => "simplelist",
13
+ "resource" => self.type
14
+ }.to_param
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,7 @@
1
+ module Kloxo
2
+ module API
3
+ class ResourceResponse < Kloxo::API::Response
4
+
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,16 @@
1
+ module Kloxo
2
+ module API
3
+ class Response
4
+
5
+ def initialize response
6
+ @response = response
7
+
8
+ end
9
+
10
+ def body
11
+ @response.body
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,57 @@
1
+ require 'httparty'
2
+
3
+ module Kloxo
4
+ module API
5
+ class Service
6
+ attr_accessor :address, :port, :username, :password, :query
7
+
8
+ def initialize params = {}
9
+ self.address = params[:address]
10
+ self.port = params[:port]
11
+ self.username = params[:username]
12
+ self.password = params[:password]
13
+ end
14
+
15
+ def query
16
+ "#{self.address}:#{self.port}/webcommand.php?login-class=client&login-name=#{self.username}&login-password=#{self.password}&output-type=json&"
17
+ end
18
+
19
+ def info request
20
+ response = HTTParty.get (self.query + request.param)
21
+
22
+ Kloxo::API::Client::InfoResponse.new(response)
23
+ end
24
+
25
+ def create request
26
+ response = HTTParty.post (self.query + request.param)
27
+
28
+ Kloxo::API::Client::CreateResponse.new(response)
29
+ end
30
+
31
+ def resource request
32
+ response = HTTParty.post (self.query + request.param)
33
+
34
+ Kloxo::API::ResourceResponse.new(response)
35
+ end
36
+
37
+ def delete request
38
+ response = HTTParty.post (self.query + request.param)
39
+
40
+ Kloxo::API::Client::DeleteResponse.new(response)
41
+ end
42
+
43
+ def enable request
44
+ response = HTTParty.post (self.query + request.param)
45
+
46
+ Kloxo::API::Client::EnableResponse.new(response)
47
+ end
48
+
49
+ def disable request
50
+ response = HTTParty.post (self.query + request.param)
51
+
52
+ Kloxo::API::Client::DisableResponse.new(response)
53
+ end
54
+
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,3 @@
1
+ module Kloxo
2
+ VERSION = "0.1.1"
3
+ end
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kloxo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Neil Abendan
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-03-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: httparty
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: activesupport
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Gem to wrap Kloxo API
84
+ email:
85
+ - na.abendan@dot.ph
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - README.md
95
+ - Rakefile
96
+ - bin/console
97
+ - bin/setup
98
+ - kloxo.gemspec
99
+ - lib/kloxo.rb
100
+ - lib/kloxo/api/client/create.rb
101
+ - lib/kloxo/api/client/create_response.rb
102
+ - lib/kloxo/api/client/delete.rb
103
+ - lib/kloxo/api/client/delete_response.rb
104
+ - lib/kloxo/api/client/disable.rb
105
+ - lib/kloxo/api/client/disable_response.rb
106
+ - lib/kloxo/api/client/enable.rb
107
+ - lib/kloxo/api/client/enable_response.rb
108
+ - lib/kloxo/api/client/info.rb
109
+ - lib/kloxo/api/client/info_response.rb
110
+ - lib/kloxo/api/request.rb
111
+ - lib/kloxo/api/resource.rb
112
+ - lib/kloxo/api/resource_response.rb
113
+ - lib/kloxo/api/response.rb
114
+ - lib/kloxo/api/service.rb
115
+ - lib/kloxo/version.rb
116
+ homepage:
117
+ licenses: []
118
+ metadata:
119
+ allowed_push_host: https://rubygems.org
120
+ post_install_message:
121
+ rdoc_options: []
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ requirements: []
135
+ rubyforge_project:
136
+ rubygems_version: 2.4.8
137
+ signing_key:
138
+ specification_version: 4
139
+ summary: Gem to wrap Kloxo API
140
+ test_files: []