-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactored crack for upcoming improvements
* renamed Crack to Nori * split classes into separate files * introduced a parser class * changed tests to specs
- Loading branch information
Showing
29 changed files
with
407 additions
and
522 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
*.sw? | ||
.DS_Store | ||
doc | ||
coverage | ||
rdoc | ||
pkg | ||
*~ | ||
*.gem | ||
.bundle | ||
Gemfile.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--colour |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,4 @@ | ||
source :rubygems | ||
gemspec | ||
|
||
group :development do | ||
gem "jeweler" | ||
gem "rcov", "~> 0.9.8" | ||
end | ||
|
||
group :test do | ||
gem "test-unit", "~> 2.1.2" | ||
gem "shoulda", "~> 2.11.0" | ||
gem "jnunemaker-matchy", ">= 0.4.0", :require => "matchy" | ||
end | ||
# Specify your gem's dependencies in nori.gemspec | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,2 @@ | ||
require 'bundler' | ||
Bundler.require :development | ||
|
||
$:.unshift File.expand_path('../lib', __FILE__) | ||
require 'crack' | ||
|
||
Jeweler::Tasks.new do |gem| | ||
gem.name = "crack" | ||
gem.summary = %Q{Really simple JSON and XML parsing, ripped from Merb and Rails.} | ||
gem.email = "[email protected]" | ||
gem.homepage = "http://github.com/jnunemaker/crack" | ||
gem.authors = ["John Nunemaker", "Wynn Netherland"] | ||
gem.rubyforge_project = 'crack' | ||
gem.version = Crack::VERSION | ||
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings | ||
end | ||
Jeweler::GemcutterTasks.new | ||
|
||
require 'rake/rdoctask' | ||
Rake::RDocTask.new do |rdoc| | ||
rdoc.rdoc_dir = 'rdoc' | ||
rdoc.title = 'crack' | ||
rdoc.options << '--line-numbers' << '--inline-source' | ||
rdoc.rdoc_files.include('README*') | ||
rdoc.rdoc_files.include('lib/**/*.rb') | ||
end | ||
|
||
require 'rake/testtask' | ||
Rake::TestTask.new(:test) do |test| | ||
test.libs << 'lib' << 'test' | ||
test.pattern = 'test/**/*_test.rb' | ||
test.verbose = false | ||
end | ||
|
||
begin | ||
require 'rcov/rcovtask' | ||
Rcov::RcovTask.new do |test| | ||
test.libs << 'test' | ||
test.pattern = 'test/**/*_test.rb' | ||
test.verbose = true | ||
end | ||
rescue LoadError | ||
task :rcov do | ||
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov" | ||
end | ||
end | ||
|
||
task :default => :test | ||
require "bundler" | ||
Bundler::GemHelper.install_tasks |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require "nori/version" | ||
require "nori/core_ext" | ||
require "nori/parser" | ||
|
||
module Nori | ||
|
||
def self.parse(xml) | ||
adapter = Parser.find Parser.use | ||
adapter.new.parse xml | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require "nori/core_ext/object" | ||
require "nori/core_ext/string" | ||
require "nori/core_ext/hash" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module Nori | ||
module CoreExt | ||
module Object | ||
|
||
def blank? | ||
respond_to?(:empty?) ? empty? : !self | ||
end unless method_defined?(:blank?) | ||
|
||
end | ||
end | ||
end | ||
|
||
Object.send :include, Nori::CoreExt::Object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Nori | ||
module CoreExt | ||
module String | ||
|
||
def snake_case | ||
return self.downcase if self =~ /^[A-Z]+$/ | ||
self.gsub(/([A-Z]+)(?=[A-Z][a-z]?)|\B[A-Z]/, '_\&') =~ /_*(.*)/ | ||
$+.downcase | ||
end unless method_defined?(:snake_case) | ||
|
||
end | ||
end | ||
end | ||
|
||
String.send :include, Nori::CoreExt::String |
Oops, something went wrong.