cps-client 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -2,3 +2,5 @@ pkg/*
2
2
  *.gem
3
3
  .bundle
4
4
  doc
5
+ .rvmrc
6
+ test-*
@@ -1,13 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cps-client (0.1.0)
4
+ cps-client (0.0.5)
5
5
  always_verify_ssl_certificates (>= 0.2.0)
6
+ punycode4r (>= 0.2.0)
6
7
 
7
8
  GEM
8
9
  remote: http://rubygems.org/
9
10
  specs:
10
11
  always_verify_ssl_certificates (0.2.0)
12
+ punycode4r (0.2.0)
11
13
 
12
14
  PLATFORMS
13
15
  ruby
@@ -15,3 +17,4 @@ PLATFORMS
15
17
  DEPENDENCIES
16
18
  always_verify_ssl_certificates (>= 0.2.0)
17
19
  cps-client!
20
+ punycode4r (>= 0.2.0)
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ == MIT License
2
+
3
+ Copyright (c) 2008, Swank Innovations, LLC.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -2,6 +2,10 @@
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
3
  require "cps-client/version"
4
4
 
5
+ # to publish the gem to rubygems.org run:
6
+ # rake install
7
+ # rake release
8
+
5
9
  Gem::Specification.new do |s|
6
10
  s.name = "cps-client"
7
11
  s.version = CPS::VERSION
@@ -13,6 +17,8 @@ Gem::Specification.new do |s|
13
17
  s.description = %q{ruby api for the arp-client of cps-datensysteme.de}
14
18
 
15
19
  s.add_dependency('always_verify_ssl_certificates', '>= 0.2.0')
20
+ s.add_dependency('punycode4r', '>= 0.2.0')
21
+ s.add_dependency('domainatrix', '>= 0.0.7')
16
22
 
17
23
  s.rubyforge_project = "cps-client"
18
24
 
@@ -1,19 +1,34 @@
1
1
  require 'iconv'
2
+ require 'punycode'
3
+ require 'domainatrix'
2
4
 
3
5
  class String
4
6
 
5
7
  CONVERTION_TABLE = {
6
8
  'Ç' => 'C',
7
9
  'ç' => 'c',
8
- '[ûúù]' => 'u',
9
- '[éêëè]' => 'e',
10
- '[âàåá]' => 'a',
11
- '[ïîìí]' => 'i',
12
- '[Å]' => 'A',
10
+ 'û' => 'u',
11
+ 'ú' => 'u',
12
+ 'ù' => 'u',
13
+ 'é' => 'e',
14
+ 'ê' => 'e',
15
+ 'ë' => 'e',
16
+ 'è' => 'e',
17
+ 'â' => 'a',
18
+ 'à' => 'a',
19
+ 'å' => 'a',
20
+ 'á' => 'a',
21
+ 'ï' => 'i',
22
+ 'î' => 'i',
23
+ 'ì' => 'i',
24
+ 'í' => 'i',
25
+ 'Å' => 'A',
13
26
  'É' => 'E',
14
27
  'æ' => 'ae',
15
28
  'Æ' => 'Ae',
16
- '[ôòó]' => 'o',
29
+ 'ô' => 'o',
30
+ 'ò' => 'o',
31
+ 'ó' => 'o',
17
32
  'Ä' => 'Ae',
18
33
  'Ö' => 'Oe',
19
34
  'Ü' => 'Ue',
@@ -36,20 +51,41 @@ class String
36
51
  return s
37
52
  end
38
53
 
39
- def convert_to_iso_8859_1
54
+ def to_punycode
55
+ result = self
56
+ if self.match(/@/)
57
+ name = self.split('@')[0]
58
+ url = Domainatrix.parse("http://"+self.split('@')[1]) # Domainatrix needs a protocol...
59
+ result = "#{name}@#{url.domain.domain_to_punycode}.#{url.public_suffix}"
60
+ elsif self.match(/./)
61
+ url = Domainatrix.parse("http://"+self)
62
+ result = "#{url.domain.domain_to_punycode}.#{url.public_suffix}"
63
+ end
64
+ return result
65
+ end
66
+
67
+ def to_iso_8859_1
40
68
  begin
41
69
  i = Iconv.new('ISO-8859-1', 'UTF-8') # Iconv.new(to, from)
42
- f = i.iconv(self.i18n_safe)
43
- i.close
44
- return f
70
+ i.iconv(self.i18n_safe)
45
71
  rescue
46
- i.close
47
72
  self
73
+ ensure
74
+ i.close
48
75
  end
49
76
  end
50
-
77
+
51
78
  def blank?
52
79
  self.nil? || self == ""
53
80
  end
54
-
81
+
82
+ def domain_to_punycode
83
+ p = Punycode.encode(self)
84
+ unless p.match(/-$/)
85
+ "xn--#{p}"
86
+ else
87
+ p.sub(/-$/, "")
88
+ end
89
+ end
90
+
55
91
  end
@@ -7,17 +7,17 @@ module CPS
7
7
 
8
8
  def initialize(options = {})
9
9
  @object = options[:object].upcase
10
- @firstname = options[:firstname]
11
- @lastname = options[:lastname]
12
- @orgname = options[:orgname].nil? || options[:orgname] == "" ? "-" : options[:orgname]
13
- @street = options[:street]
14
- @postal = options[:postal]
15
- @city = options[:city]
16
- @state = options[:state]
17
- @iso_country = options[:iso_country]
18
- @phone = options[:phone]
19
- @fax = options[:fax]
20
- @email = options[:email]
10
+ @firstname = options[:firstname].to_iso_8859_1
11
+ @lastname = options[:lastname].to_iso_8859_1
12
+ @orgname = options[:orgname].nil? || options[:orgname] == "" ? "-" : options[:orgname].to_iso_8859_1
13
+ @street = options[:street].to_iso_8859_1
14
+ @postal = options[:postal].to_iso_8859_1
15
+ @city = options[:city].to_iso_8859_1
16
+ @state = options[:state].to_iso_8859_1
17
+ @iso_country = options[:iso_country].to_iso_8859_1
18
+ @phone = options[:phone].to_iso_8859_1
19
+ @fax = options[:fax].to_iso_8859_1
20
+ @email = options[:email].to_punycode
21
21
  @privacy_rule = options[:privacy_rule] || ""
22
22
  @contact_type = @orgname == '-' ? "person" : "organisation"
23
23
  end
@@ -4,7 +4,7 @@ module CPS
4
4
  attr_reader :domain
5
5
 
6
6
  def initialize(options = {})
7
- @domain = options[:domain]
7
+ @domain = options[:domain].downcase.to_punycode
8
8
  @adminc = options[:adminc]
9
9
  @techc = options[:techc]
10
10
  @billc = options[:billc]
@@ -7,7 +7,7 @@ module CPS
7
7
  module Version
8
8
  MAJOR = 0
9
9
  MINOR = 0
10
- PATCH = 3
10
+ PATCH = 4
11
11
  BUILD = nil
12
12
 
13
13
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join(".")
@@ -1,9 +1,9 @@
1
1
  <?xml version="1.0" encoding="iso-8859-1"?>
2
2
  <request>
3
3
  <auth>
4
- <cid><%= @cid.convert_to_iso_8859_1 %></cid>
5
- <user><%= @uid.convert_to_iso_8859_1 %></user>
6
- <pwd><%= @pwd.convert_to_iso_8859_1 %></pwd>
4
+ <cid><%= @cid.to_iso_8859_1 %></cid>
5
+ <user><%= @uid.to_iso_8859_1 %></user>
6
+ <pwd><%= @pwd.to_iso_8859_1 %></pwd>
7
7
  </auth>
8
8
  <transaction>
9
9
  <%= @xml %>
@@ -1,19 +1,19 @@
1
1
  <group>contact</group>
2
2
  <action>create</action>
3
3
  <attribute>contact</attribute>
4
- <object><%= @object.convert_to_iso_8859_1 %></object>
4
+ <object><%= @object %></object>
5
5
  <values>
6
- <firstname><%= @firstname.convert_to_iso_8859_1 %></firstname>
7
- <lastname><%= @lastname.convert_to_iso_8859_1 %></lastname>
8
- <orgname><%= @orgname.convert_to_iso_8859_1 %></orgname>
9
- <street><%= @street.convert_to_iso_8859_1 %></street>
10
- <postal><%= @postal.convert_to_iso_8859_1 %></postal>
11
- <city><%= @city.convert_to_iso_8859_1 %></city>
12
- <state><%= @state.convert_to_iso_8859_1 %></state>
13
- <iso_country><%= @iso_country.convert_to_iso_8859_1 %></iso_country>
14
- <phone><%= @phone.convert_to_iso_8859_1 %></phone>
15
- <fax><%= @fax.convert_to_iso_8859_1 %></fax>
16
- <email><%= @email.convert_to_iso_8859_1 %></email>
17
- <privacy_rule><%= @privacy_rule.convert_to_iso_8859_1 %></privacy_rule>
18
- <contact_type><%= @contact_type.convert_to_iso_8859_1 %></contact_type>
6
+ <firstname><%= @firstname %></firstname>
7
+ <lastname><%= @lastname %></lastname>
8
+ <orgname><%= @orgname %></orgname>
9
+ <street><%= @street %></street>
10
+ <postal><%= @postal %></postal>
11
+ <city><%= @city %></city>
12
+ <state><%= @state %></state>
13
+ <iso_country><%= @iso_country %></iso_country>
14
+ <phone><%= @phone %></phone>
15
+ <fax><%= @fax %></fax>
16
+ <email><%= @email %></email>
17
+ <privacy_rule><%= @privacy_rule %></privacy_rule>
18
+ <contact_type><%= @contact_type %></contact_type>
19
19
  </values>
@@ -1,4 +1,4 @@
1
1
  <group>contact</group>
2
2
  <action>delete</action>
3
3
  <attribute>contact</attribute>
4
- <object><%= @object.convert_to_iso_8859_1 %></object>
4
+ <object><%= @object %></object>
@@ -1,13 +1,13 @@
1
- <firstname><%= @firstname.convert_to_iso_8859_1 %></firstname>
2
- <lastname><%= @lastname.convert_to_iso_8859_1 %></lastname>
3
- <orgname><%= @orgname.convert_to_iso_8859_1 %></orgname>
4
- <street><%= @street.convert_to_iso_8859_1 %></street>
5
- <postal><%= @postal.convert_to_iso_8859_1 %></postal>
6
- <city><%= @city.convert_to_iso_8859_1 %></city>
7
- <state><%= @state.convert_to_iso_8859_1 %></state>
8
- <iso_country><%= @iso_country.convert_to_iso_8859_1 %></iso_country>
9
- <phone><%= @phone.convert_to_iso_8859_1 %></phone>
10
- <fax><%= @fax.convert_to_iso_8859_1 %></fax>
11
- <email><%= @email.convert_to_iso_8859_1 %></email>
12
- <privacy_rule><%= @privacy_rule.convert_to_iso_8859_1 %></privacy_rule>
13
- <contact_type><%= @contact_type.convert_to_iso_8859_1 %></contact_type>
1
+ <firstname><%= @firstname %></firstname>
2
+ <lastname><%= @lastname %></lastname>
3
+ <orgname><%= @orgname %></orgname>
4
+ <street><%= @street %></street>
5
+ <postal><%= @postal %></postal>
6
+ <city><%= @city %></city>
7
+ <state><%= @state %></state>
8
+ <iso_country><%= @iso_country %></iso_country>
9
+ <phone><%= @phone %></phone>
10
+ <fax><%= @fax %></fax>
11
+ <email><%= @email %></email>
12
+ <privacy_rule><%= @privacy_rule %></privacy_rule>
13
+ <contact_type><%= @contact_type %></contact_type>
@@ -1,4 +1,4 @@
1
1
  <group>contact</group>
2
2
  <action>info</action>
3
3
  <attribute>contact</attribute>
4
- <object><%= @object.convert_to_iso_8859_1 %></object>
4
+ <object><%= @object %></object>
@@ -1,16 +1,16 @@
1
1
  <group>domain</group>
2
2
  <action>create</action>
3
3
  <attribute>domain</attribute>
4
- <object><%= @domain.convert_to_iso_8859_1 %></object>
4
+ <object><%= @domain %></object>
5
5
  <values>
6
- <adminc><%= @adminc.convert_to_iso_8859_1 %></adminc>
7
- <techc><%= @techc.convert_to_iso_8859_1 %></techc>
8
- <billc><%= @billc.convert_to_iso_8859_1 %></billc>
9
- <ownerc><%= @ownerc.convert_to_iso_8859_1 %></ownerc>
6
+ <adminc><%= @adminc %></adminc>
7
+ <techc><%= @techc %></techc>
8
+ <billc><%= @billc %></billc>
9
+ <ownerc><%= @ownerc %></ownerc>
10
10
  <dns>
11
- <hostname><%= @ns1.convert_to_iso_8859_1 %></hostname>
11
+ <hostname><%= @ns1 %></hostname>
12
12
  </dns>
13
13
  <dns>
14
- <hostname><%= @ns2.convert_to_iso_8859_1 %></hostname>
14
+ <hostname><%= @ns2 %></hostname>
15
15
  </dns>
16
16
  </values>
@@ -1,4 +1,4 @@
1
1
  <group>domain</group>
2
2
  <action>delete</action>
3
3
  <attribute>domain</attribute>
4
- <object><%= @domain.convert_to_iso_8859_1 %></object>
4
+ <object><%= @domain %></object>
@@ -1,4 +1,4 @@
1
1
  <group>domain</group>
2
2
  <action>info</action>
3
3
  <attribute>domain</attribute>
4
- <object><%= @domain.convert_to_iso_8859_1 %></object>
4
+ <object><%= @domain %></object>
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cps-client
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
5
- prerelease: false
4
+ hash: 23
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - jfqd
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-05 00:00:00 +01:00
18
+ date: 2011-04-01 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -34,6 +34,38 @@ dependencies:
34
34
  version: 0.2.0
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: punycode4r
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 23
46
+ segments:
47
+ - 0
48
+ - 2
49
+ - 0
50
+ version: 0.2.0
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: domainatrix
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 17
62
+ segments:
63
+ - 0
64
+ - 0
65
+ - 7
66
+ version: 0.0.7
67
+ type: :runtime
68
+ version_requirements: *id003
37
69
  description: ruby api for the arp-client of cps-datensysteme.de
38
70
  email:
39
71
  - jfqd@blun.org
@@ -47,6 +79,7 @@ files:
47
79
  - .gitignore
48
80
  - Gemfile
49
81
  - Gemfile.lock
82
+ - LICENSE
50
83
  - Rakefile
51
84
  - Readme.textile
52
85
  - cps-client.gemspec
@@ -98,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
131
  requirements: []
99
132
 
100
133
  rubyforge_project: cps-client
101
- rubygems_version: 1.3.7
134
+ rubygems_version: 1.4.1
102
135
  signing_key:
103
136
  specification_version: 3
104
137
  summary: ruby api for the arp-client of cps-datensysteme.de