Permalink
Browse files

Now a gem and has specs

  • Loading branch information...
1 parent b267b2c commit 6a0072f7d62d082d9191ece62186704e99c332e8 @myobie committed Nov 21, 2008
Showing with 154 additions and 13 deletions.
  1. +20 −0 LICENSE
  2. +13 −13 README
  3. +57 −0 Rakefile
  4. 0 TODO
  5. +30 −0 htmldiff.gemspec
  6. 0 lib/{diff.rb → htmldiff.rb}
  7. +32 −0 spec/htmldiff_spec.rb
  8. +2 −0 spec/spec_helper.rb
View
20 LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2008 Nathan Herald
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
26 README
@@ -1,15 +1,15 @@
- class Stuff
-
- class << self
- include HTMLDiff
- end
-
- # or extend HTMLDiff ?
-
+class Stuff
+
+ class << self
+ include HTMLDiff
end
- Stuff.diff('a word is here', 'a nother word is there')
-
- # => 'a<ins> nother</ins>word is <del>here</del><ins>there</ins>'
- #
- # or something like that
+ # or extend HTMLDiff ?
+
+end
+
+Stuff.diff('a word is here', 'a nother word is there')
+
+# => 'a<ins class=\"diffins\"> nother</ins> word is <del class=\"diffmod\">here</del><ins class=\"diffmod\">there</ins>'
+
+Checkout the crappy specs for good examples.
View
@@ -0,0 +1,57 @@
+require 'rubygems'
+require 'rake/gempackagetask'
+require 'rubygems/specification'
+require 'date'
+require 'spec/rake/spectask'
+
+GEM = "htmldiff"
+GEM_VERSION = "0.0.1"
+AUTHOR = "Nathan Herald"
+EMAIL = "nathan@myobie.com"
+HOMEPAGE = "http://github.com/myobie/htmldiff"
+SUMMARY = "HTML diffs of text (borrowed from a wiki software I no longer remember)"
+
+spec = Gem::Specification.new do |s|
+ s.name = GEM
+ s.version = GEM_VERSION
+ s.platform = Gem::Platform::RUBY
+ s.has_rdoc = true
+ s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
+ s.summary = SUMMARY
+ s.description = s.summary
+ s.author = AUTHOR
+ s.email = EMAIL
+ s.homepage = HOMEPAGE
+
+ # Uncomment this to add a dependency
+ # s.add_dependency "foo"
+
+ s.require_path = 'lib'
+ s.autorequire = GEM
+ s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,spec}/**/*")
+end
+
+task :default => :spec
+
+desc "Run specs"
+Spec::Rake::SpecTask.new do |t|
+ t.spec_files = FileList['spec/**/*_spec.rb']
+ t.spec_opts = %w(-fs --color)
+end
+
+
+Rake::GemPackageTask.new(spec) do |pkg|
+ pkg.gem_spec = spec
+end
+
+desc "install the gem locally"
+task :install => [:package] do
+ sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
+end
+
+desc "create a gemspec file"
+task :make_spec do
+ File.open("#{GEM}.gemspec", "w") do |file|
+ file.puts spec.to_ruby
+ end
+end
View
0 TODO
No changes.
View
@@ -0,0 +1,30 @@
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{htmldiff}
+ s.version = "0.0.1"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Nathan Herald"]
+ s.autorequire = %q{htmldiff}
+ s.date = %q{2008-11-21}
+ s.description = %q{HTML diffs of text (borrowed from a wiki software I no longer remember)}
+ s.email = %q{nathan@myobie.com}
+ s.extra_rdoc_files = ["README", "LICENSE", "TODO"]
+ s.files = ["LICENSE", "README", "Rakefile", "TODO", "lib/htmldiff.rb", "spec/htmldiff_spec.rb", "spec/spec_helper.rb"]
+ s.has_rdoc = true
+ s.homepage = %q{http://github.com/myobie/htmldiff}
+ s.require_paths = ["lib"]
+ s.rubygems_version = %q{1.3.1}
+ s.summary = %q{HTML diffs of text (borrowed from a wiki software I no longer remember)}
+
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 2
+
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
+ else
+ end
+ else
+ end
+end
File renamed without changes.
View
@@ -0,0 +1,32 @@
+require File.dirname(__FILE__) + '/spec_helper'
+require 'htmldiff'
+
+class TestDiff
+ extend HTMLDiff
+end
+
+describe "htmldiff" do
+
+ it "should diff text" do
+
+ diff = TestDiff.diff('a word is here', 'a nother word is there')
+ diff.should == "a<ins class=\"diffins\"> nother</ins> word is <del class=\"diffmod\">here</del><ins class=\"diffmod\">there</ins>"
+
+ end
+
+ it "should insert a letter and a space" do
+ diff = TestDiff.diff('a c', 'a b c')
+ diff.should == "a <ins class=\"diffins\">b </ins>c"
+ end
+
+ it "should remove a letter and a space" do
+ diff = TestDiff.diff('a b c', 'a c')
+ diff.should == "a <del class=\"diffdel\">b </del>c"
+ end
+
+ it "should change a letter" do
+ diff = TestDiff.diff('a b c', 'a d c')
+ diff.should == "a <del class=\"diffmod\">b</del><ins class=\"diffmod\">d</ins> c"
+ end
+
+end
View
@@ -0,0 +1,2 @@
+$TESTING=true
+$:.push File.join(File.dirname(__FILE__), '..', 'lib')

0 comments on commit 6a0072f

Please sign in to comment.