namecheap 0.2.0 → 0.3.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.
data/lib/monkey_patch.rb DELETED
@@ -1,84 +0,0 @@
1
- # Monkey-patches, mostly taken from Rails :)
2
-
3
- class Hash
4
- def symbolize_keys!
5
- keys.each do |key|
6
- self[(key.to_sym rescue key) || key] = delete(key)
7
- end
8
- self
9
- end
10
-
11
- def to_param(namespace = nil)
12
- collect do |key, value|
13
- value.to_query(namespace ? "#{namespace}[#{key}]" : key)
14
- end.sort * '&'
15
- end
16
-
17
- def camelize_keys!
18
- keys.each do |key|
19
- self[key.to_s.camelize] = delete(key)
20
- end
21
- self
22
- end
23
-
24
-
25
- protected
26
-
27
- def to_query(key)
28
- require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
29
- "#{CGI.escape(key.to_param)}=#{CGI.escape(to_param.to_s)}"
30
- end
31
- end
32
-
33
- class Module
34
- # Delegate method
35
- # It expects an array of arguments that contains
36
- # the methods to be delegated and a hash of options
37
- def delegate(*methods)
38
- # Pop up the options hash from arguments array
39
- options = methods.pop
40
- # Check the availability of the options hash
41
- # and more specifically the :to option
42
- # Raises an error if one of them is not there
43
- unless options.is_a?(Hash) && to = options[:to]
44
- raise ArgumentError, "Delegation needs a target. Supply an options hash with a :to key as the last argument (e.g. delegate :hello, :to => :greeter)."
45
- end
46
-
47
- # Make sure the :to option follows syntax rules
48
- # for method names
49
- if options[:prefix] == true && options[:to].to_s =~ /^[^a-z_]/
50
- raise ArgumentError, "Can only automatically set the delegation prefix when delegating to a method."
51
- end
52
-
53
- # Set the real prefix value
54
- prefix = options[:prefix] && "#{options[:prefix] == true ? to : options[:prefix]}_"
55
-
56
- # Here comes the magic of ruby :)
57
- # Reflection techniques are used here:
58
- # module_eval is used to add new methods on the fly which:
59
- # expose the contained methods' objects
60
- methods.each do |method|
61
- module_eval("def #{prefix}#{method}(*args, &block)\n#{to}.__send__(#{method.inspect}, *args, &block)\nend\n", "(__DELEGATION__)", 1)
62
- end
63
- end
64
- end
65
-
66
- class String
67
- def camelize(first_letter = :upper)
68
- case first_letter
69
- when :upper then _camelize(self, true)
70
- when :lower then _camelize(self, false)
71
- end
72
- end
73
-
74
- private
75
-
76
- def _camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true)
77
- if first_letter_in_uppercase
78
- lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
79
- else
80
- lower_case_and_underscored_word.to_s[0].chr.downcase + camelize(lower_case_and_underscored_word)[1..-1]
81
- end
82
- end
83
-
84
- end
data/namecheap.gemspec DELETED
@@ -1,25 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "namecheap/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "namecheap"
7
- s.version = Namecheap::VERSION
8
- s.authors = ["parasquid"]
9
- s.email = ["tristan.gomez@gmail.com"]
10
- s.homepage = "https://github.com/parasquid/namecheap"
11
- s.summary = %q{Ruby wrapper for the Namecheap API}
12
- s.description = %q{Ruby wrapper for the Namecheap API}
13
-
14
- s.rubyforge_project = "namecheap"
15
-
16
- s.files = `git ls-files`.split("\n")
17
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
- s.require_paths = ["lib"]
20
-
21
- # specify any dependencies here; for example:
22
- s.add_development_dependency "rspec"
23
- # s.add_runtime_dependency "rest-client"
24
- s.add_runtime_dependency "httparty"
25
- end
data/spec/domains_spec.rb DELETED
@@ -1,11 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- describe "Domains" do
4
- it 'should initialize' do
5
- Namecheap::Domains.new
6
- end
7
-
8
- it 'should be already initialized from the Namecheap namespace' do
9
- Namecheap.domains.should_not be_nil
10
- end
11
- end
@@ -1,48 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- describe "NamecheapAPI Wrapper" do
4
- describe "initializating settings" do
5
-
6
- before :each do
7
- Namecheap.reset
8
- end
9
-
10
- describe "with defaults" do
11
- it "should contain a username" do
12
- Namecheap.username.should == 'apiuser'
13
- end
14
- it "should contain a key" do
15
- Namecheap.key.should == 'apikey'
16
- end
17
- it "should contain a client_ip" do
18
- Namecheap.client_ip.should == '127.0.0.1'
19
- end
20
- end
21
-
22
- describe "with defaults overidden" do
23
- it "should contain an overidden key" do
24
- Namecheap.configure do |config|
25
- config.key = 'newkey'
26
- end
27
-
28
- Namecheap.key.should == 'newkey'
29
- end
30
-
31
- it "should contain an overridden username" do
32
- Namecheap.configure do |config|
33
- config.username = 'newuser'
34
- end
35
-
36
- Namecheap.username.should == 'newuser'
37
- end
38
-
39
- it "should contain an overridden client_ip" do
40
- Namecheap.configure do |config|
41
- config.client_ip = '192.168.0.1'
42
- end
43
-
44
- Namecheap.client_ip.should == '192.168.0.1'
45
- end
46
- end
47
- end
48
- end
data/spec/spec_helper.rb DELETED
@@ -1,10 +0,0 @@
1
- begin
2
- require 'rspec'
3
- rescue LoadError
4
- require 'rubygems'
5
- gem 'rspec'
6
- require 'spec'
7
- end
8
-
9
- require File.dirname(__FILE__) + '/../lib/namecheap'
10
- $LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib/namecheap")