epp 1.1.3 → 1.2.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.
Files changed (5) hide show
  1. data/README.rdoc +8 -12
  2. data/Rakefile +1 -1
  3. data/VERSION +1 -1
  4. data/lib/epp/server.rb +17 -32
  5. metadata +18 -42
data/README.rdoc CHANGED
@@ -7,25 +7,21 @@ The EPP gem provides basic functionality for connecting and making requests on E
7
7
 
8
8
  == Installation
9
9
 
10
- If you already have {Gemcutter}[http://gemcutter.org] installed, you can install this gem with:
10
+ You can install this gem with:
11
11
 
12
12
  $ gem install epp
13
13
 
14
- Otherwise, a few more steps are involved:
15
-
16
- $ gem install gemcutter
17
- $ gem tumble
18
- $ gem install epp
19
-
20
- Then, you can require it in your Ruby app:
14
+ Then, you can require it in your Ruby/Rails app:
21
15
 
22
16
  require "epp"
23
17
 
24
- If you're using Rails, add the following line to your Rails <tt>config/environment.rb</tt>:
18
+ If you're using Rails, configure your gem in the following file:
25
19
 
26
- config.gem "epp", :source => "http://gemcutter.org"
20
+ # Rails 2.x - config/environment.rb
21
+ config.gem "epp"
27
22
 
28
- Once you do that, you can install the gem by typing <tt>sudo rake gems:install</tt>.
23
+ # Rails 3 - Gemfile
24
+ gem "epp"
29
25
 
30
26
  == Example Usage
31
27
 
@@ -64,7 +60,7 @@ http://github.com/ultraspeed/epp/issues
64
60
 
65
61
  == Credit
66
62
 
67
- Author: Josh Delsman at Ultraspeed (http://twitter.com/voxxit)
63
+ Author: Josh Delsman (http://twitter.com/voxxit)
68
64
  Inspired from: http://labs.centralnic.com/Net_EPP_Client.php
69
65
 
70
66
  == License
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ begin
14
14
 
15
15
  # Dependencies
16
16
  gem.add_development_dependency "shoulda"
17
- gem.add_dependency "activesupport"
17
+ gem.add_dependency "active_support"
18
18
  gem.add_dependency "hpricot"
19
19
  end
20
20
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.3
1
+ 1.2.0
data/lib/epp/server.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  module Epp #:nodoc:
2
2
  class Server
3
+ include REXML
3
4
  include RequiresParameters
4
5
 
5
- attr_accessor :tag, :password, :server, :port, :old_server, :lang, :extensions, :version
6
+ attr_accessor :tag, :password, :server, :port, :old_server, :services, :lang, :extensions, :version
6
7
 
7
8
  # ==== Required Attrbiutes
8
9
  #
@@ -27,11 +28,10 @@ module Epp #:nodoc:
27
28
  @server = attributes[:server]
28
29
  @port = attributes[:port] || 700
29
30
  @old_server = attributes[:old_server] || false
30
- @lang = attributes[:lang] || 'en'
31
+ @lang = attributes[:lang] || "en"
31
32
  @services = attributes[:services] || ["urn:ietf:params:xml:ns:domain-1.0", "urn:ietf:params:xml:ns:contact-1.0", "urn:ietf:params:xml:ns:host-1.0"]
32
33
  @extensions = attributes[:extensions] || []
33
34
  @version = attributes[:verison] || "1.0"
34
- @debug_log = attributes[:debug_log] || false
35
35
 
36
36
  @logged_in = false
37
37
  end
@@ -46,10 +46,9 @@ module Epp #:nodoc:
46
46
  @logged_in = true if login
47
47
 
48
48
  begin
49
- puts "** EPP - Sending frame..." if @debug_log
50
49
  @response = send_request(xml)
51
50
  ensure
52
- if @logged_in && !@old_server
51
+ if @logged_in && !old_server
53
52
  @logged_in = false if logout
54
53
  end
55
54
 
@@ -63,19 +62,17 @@ module Epp #:nodoc:
63
62
 
64
63
  # Sends a standard login request to the EPP server.
65
64
  def login
66
- puts "** EPP - Attempting login..." if @debug_log
67
-
68
65
  xml = new_epp_request
69
66
 
70
67
  command = xml.root.add_element("command")
71
68
  login = command.add_element("login")
72
69
 
73
- login.add_element("clID").text = @tag
74
- login.add_element("pw").text = @password
70
+ login.add_element("clID").text = tag
71
+ login.add_element("pw").text = password
75
72
 
76
73
  options = login.add_element("options")
77
- options.add_element("version").text = @version
78
- options.add_element("lang").text = @lang
74
+ options.add_element("version").text = version
75
+ options.add_element("lang").text = lang
79
76
 
80
77
  services = login.add_element("svcs")
81
78
  services.add_element("objURI").text = "urn:ietf:params:xml:ns:domain-1.0"
@@ -83,9 +80,9 @@ module Epp #:nodoc:
83
80
  services.add_element("objURI").text = "urn:ietf:params:xml:ns:host-1.0"
84
81
 
85
82
  # Include schema extensions for registrars which require it
86
- extensions_container = services.add_element("svcExtension") unless @extensions.empty?
83
+ extensions_container = services.add_element("svcExtension") unless extensions.empty?
87
84
 
88
- for uri in @extensions
85
+ for uri in extensions
89
86
  extensions_container.add_element("extURI").text = uri
90
87
  end
91
88
 
@@ -98,7 +95,6 @@ module Epp #:nodoc:
98
95
  result_code = (response/"epp"/"response"/"result").attr("code").to_i
99
96
 
100
97
  if result_code == 1000
101
- puts "** EPP - Successfully logged in." if @debug_log
102
98
  return true
103
99
  else
104
100
  raise EppErrorResponse.new(:xml => response, :code => result_code, :message => result_message)
@@ -107,8 +103,6 @@ module Epp #:nodoc:
107
103
 
108
104
  # Sends a standard logout request to the EPP server.
109
105
  def logout
110
- puts "** EPP - Attempting logout..." if @debug_log
111
-
112
106
  xml = new_epp_request
113
107
 
114
108
  command = xml.root.add_element("command")
@@ -121,7 +115,6 @@ module Epp #:nodoc:
121
115
  result_code = (response/"epp"/"response"/"result").attr("code").to_i
122
116
 
123
117
  if result_code == 1500
124
- puts "** EPP - Successfully logged out." if @debug_log
125
118
  return true
126
119
  else
127
120
  raise EppErrorResponse.new(:xml => response, :code => result_code, :message => result_message)
@@ -129,8 +122,8 @@ module Epp #:nodoc:
129
122
  end
130
123
 
131
124
  def new_epp_request
132
- xml = REXML::Document.new
133
- xml << REXML::XMLDecl.new("1.0", "UTF-8", "no")
125
+ xml = Document.new
126
+ xml << XMLDecl.new("1.0", "UTF-8", "no")
134
127
 
135
128
  xml.add_element("epp", {
136
129
  "xmlns" => "urn:ietf:params:xml:ns:epp-1.0",
@@ -153,7 +146,7 @@ module Epp #:nodoc:
153
146
  # the EPP <tt><greeting></tt> frame which is sent by the
154
147
  # server upon connection.
155
148
  def open_connection
156
- @connection = TCPSocket.new(@server, @port)
149
+ @connection = TCPSocket.new(server, port)
157
150
  @socket = OpenSSL::SSL::SSLSocket.new(@connection)
158
151
 
159
152
  # Synchronously close the connection & socket
@@ -163,12 +156,7 @@ module Epp #:nodoc:
163
156
  @socket.connect
164
157
 
165
158
  # Get the initial frame
166
- frame = get_frame
167
-
168
- if frame
169
- puts "EPP - Connection opened." if @debug_log
170
- return frame
171
- end
159
+ get_frame
172
160
  end
173
161
 
174
162
  # Closes the connection to the EPP server.
@@ -183,10 +171,7 @@ module Epp #:nodoc:
183
171
  @connection = nil
184
172
  end
185
173
 
186
- if @connection.nil? and @socket.nil?
187
- puts "EPP - Connection closed." if @debug_log
188
- return true
189
- end
174
+ return true if @connection.nil? and @socket.nil?
190
175
  end
191
176
 
192
177
  # Receive an EPP frame from the server. Since the connection is blocking,
@@ -194,7 +179,7 @@ module Epp #:nodoc:
194
179
  # the connection is broken, a SocketError will be raised. Otherwise,
195
180
  # it will return a string containing the XML from the server.
196
181
  def get_frame
197
- if @old_server
182
+ if old_server
198
183
  data = ""
199
184
  first_char = @socket.read(1)
200
185
 
@@ -235,7 +220,7 @@ module Epp #:nodoc:
235
220
  # size of the frame sent to the server. If the socket returns EOF,
236
221
  # the connection has closed and a SocketError is raised.
237
222
  def send_frame(xml)
238
- @socket.write(@old_server ? (xml + "\r\n") : ([xml.size + 4].pack("N") + xml))
223
+ @socket.write(old_server ? (xml + "\r\n") : ([xml.size + 4].pack("N") + xml))
239
224
  end
240
225
  end
241
226
  end
metadata CHANGED
@@ -1,13 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epp
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
5
- prerelease: false
6
- segments:
7
- - 1
8
- - 1
9
- - 3
10
- version: 1.1.3
4
+ version: 1.2.0
11
5
  platform: ruby
12
6
  authors:
13
7
  - Josh Delsman
@@ -15,51 +9,39 @@ autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
11
 
18
- date: 2010-07-01 00:00:00 -04:00
12
+ date: 2010-02-04 00:00:00 +00:00
19
13
  default_executable:
20
14
  dependencies:
21
15
  - !ruby/object:Gem::Dependency
22
16
  name: shoulda
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
26
20
  requirements:
27
21
  - - ">="
28
22
  - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
23
  version: "0"
33
- type: :development
34
- version_requirements: *id001
24
+ version:
35
25
  - !ruby/object:Gem::Dependency
36
- name: activesupport
37
- prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
- none: false
26
+ name: active_support
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
40
30
  requirements:
41
31
  - - ">="
42
32
  - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
33
  version: "0"
47
- type: :runtime
48
- version_requirements: *id002
34
+ version:
49
35
  - !ruby/object:Gem::Dependency
50
36
  name: hpricot
51
- prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
53
- none: false
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
54
40
  requirements:
55
41
  - - ">="
56
42
  - !ruby/object:Gem::Version
57
- hash: 3
58
- segments:
59
- - 0
60
43
  version: "0"
61
- type: :runtime
62
- version_requirements: *id003
44
+ version:
63
45
  description: Basic functionality for connecting and making requests on EPP (Extensible Provisioning Protocol) servers
64
46
  email: jdelsman@ultraspeed.com
65
47
  executables: []
@@ -90,27 +72,21 @@ rdoc_options:
90
72
  require_paths:
91
73
  - lib
92
74
  required_ruby_version: !ruby/object:Gem::Requirement
93
- none: false
94
75
  requirements:
95
76
  - - ">="
96
77
  - !ruby/object:Gem::Version
97
- hash: 3
98
- segments:
99
- - 0
100
78
  version: "0"
79
+ version:
101
80
  required_rubygems_version: !ruby/object:Gem::Requirement
102
- none: false
103
81
  requirements:
104
82
  - - ">="
105
83
  - !ruby/object:Gem::Version
106
- hash: 3
107
- segments:
108
- - 0
109
84
  version: "0"
85
+ version:
110
86
  requirements: []
111
87
 
112
88
  rubyforge_project:
113
- rubygems_version: 1.3.7
89
+ rubygems_version: 1.3.5
114
90
  signing_key:
115
91
  specification_version: 3
116
92
  summary: EPP (Extensible Provisioning Protocol) for Ruby