Permalink
Browse files

convert things to work with rspec >= 2.0

Bump version to 0.2.1.
Remove active_support dependency, add the underscore manaulaly as a String method in helperr.rb
Some formatting.
  • Loading branch information...
1 parent 73e5c59 commit 7c9d61946ce2ee49fabd48cf3a139fd1f319ed09 @fairchild fairchild committed Jun 5, 2011
Showing with 31 additions and 31 deletions.
  1. 0 spec/spec.opts → .rspec
  2. +3 −15 Rakefile
  3. +1 −1 VERSION
  4. +2 −1 lib/dynect_rest.rb
  5. +12 −0 lib/dynect_rest/helpers.rb
  6. +10 −11 lib/dynect_rest/resource.rb
  7. +3 −3 spec/spec_helper.rb
File renamed without changes.
View
@@ -10,31 +10,19 @@ begin
gem.email = "adam@opscode.com"
gem.homepage = "http://github.com/adamhjk/dynect-rest"
gem.authors = ["Adam Jacob"]
- gem.add_development_dependency "rspec", ">= 1.2.9"
+ gem.add_development_dependency "rspec", ">= 2.0"
gem.add_development_dependency "yard", ">= 0"
gem.add_dependency('json')
gem.add_dependency('rest-client')
- gem.add_dependency('activesupport')
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
end
Jeweler::GemcutterTasks.new
rescue LoadError
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
end
-require 'spec/rake/spectask'
-Spec::Rake::SpecTask.new(:spec) do |spec|
- spec.libs << 'lib' << 'spec'
- spec.spec_files = FileList['spec/**/*_spec.rb']
-end
-
-Spec::Rake::SpecTask.new(:rcov) do |spec|
- spec.libs << 'lib' << 'spec'
- spec.pattern = 'spec/**/*_spec.rb'
- spec.rcov = true
-end
-
-task :spec => :check_dependencies
+require 'rspec/core/rake_task'
+RSpec::Core::RakeTask.new(:spec)
task :default => :spec
View
@@ -1 +1 @@
-0.2.0
+0.2.1
View
@@ -18,11 +18,11 @@
class DynectRest
+ require 'dynect_rest/helpers'
require 'dynect_rest/exceptions'
require 'dynect_rest/resource'
require 'rest_client'
require 'json'
- require 'active_support/inflector'
attr_accessor :customer_name, :user_name, :password, :rest, :zone
@@ -113,6 +113,7 @@ def thaw(zone=nil)
put("Zone/#{zone}", { "freeze" => true })
end
+
##
# Resource Records
##
@@ -0,0 +1,12 @@
+class String
+ # Convert a CamelCasedString to an under_scored_string.
+ def underscore
+ word = self.to_s.dup
+ word.gsub!(/::/, '/')
+ word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
+ word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
+ word.tr!("-", "_")
+ word.downcase!
+ word
+ end
+end
@@ -72,18 +72,17 @@ def get(fqdn = nil, record_id=nil)
elsif fqdn
results = @dynect.get("#{resource_path}/#{fqdn}")
raw_rr_list = results.map do |record|
- if record =~ /^#{resource_path(:full)}\/#{fqdn}\/(\d+)$/
- self.get(fqdn, $1)
- else
- record
- end
- end
-
+ if (record =~ /^#{resource_path(:full)}\/#{Regexp.escape(fqdn)}\/(\d+)$/)
+ self.get(fqdn, $1)
+ else
+ record
+ end
+ end
case raw_rr_list.length
- when 0
- raise DynectRest::Exceptions::RequestFailed, "Cannot find #{record_type} record for #{fqdn}"
- when 1
- raw_rr_list[0]
+ when 0
+ raise DynectRest::Exceptions::RequestFailed, "Cannot find #{record_type} record for #{fqdn}"
+ when 1
+ raw_rr_list[0]
else
raw_rr_list
end
View
@@ -1,9 +1,9 @@
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'dynect_rest'
-require 'spec'
-require 'spec/autorun'
+require 'rspec'
+require 'rspec/autorun'
-Spec::Runner.configure do |config|
+RSpec.configure do |config|
end

0 comments on commit 7c9d619

Please sign in to comment.