Permalink
Browse files

Documenting some more of the internals.

  • Loading branch information...
adamsanderson committed Jun 9, 2008
1 parent 387e781 commit d8c3c0846278c68d1f310412035ccf8a00ffe414
View
@@ -1,2 +1,9 @@
-=== 0.0.1 / 2008-06-03
- Initial verison of RubyDiff
+=== 0.1.5 / --
+Making everything a little better:
+- Merged changes from kballard to fix the git feeder
+- Added support for git working directory (use --git-wd)
+- Added support for multiple inputs
+- Metamethods such as 'attr_reader' are now processed
+
+=== 0.1 / 2008-06-03
+Initial verison of RubyDiff
View
@@ -11,7 +11,7 @@
require 'pp'
module RubyDiff
- VERSION = "0.1.1"
+ VERSION = "0.1.5"
end
# RubyDiff
@@ -1,3 +1,5 @@
+# A CodeChange represents a difference between two sets of ruby
+# code. It may contain child changes.
class CodeChange
attr_reader :signature
attr_reader :operation
@@ -23,12 +25,15 @@ def to_s(depth=1)
end
end
+# Compares two sets of parsed CodeObjects. A CodeComparison
+# Expects sets of CodeObjects hashed by their signature.
class CodeComparison
def initialize(old_signatures, new_signatures)
@old = old_signatures
@new = new_signatures
end
+ # Returns the set of changes.
def changes
changes = []
seen = Set.new
@@ -1,3 +1,9 @@
+# A Feeder reads in files for RubyDiff's processor to
+# run over. FileFeeder reads them from the file system.
+#
+# Example Usage:
+# ruby_diff --file old_version.rb --file new_version.rb
+# ruby_diff --file old_dir/ --file new_dir
class FileFeeder
attr_accessor :files
attr_accessor :path
@@ -1,5 +1,12 @@
-GitFile = Struct.new :access, :type, :hash, :name
+# A Feeder reads in files for RubyDiff's processor to
+# run over. GitFeeder reads them from a git repository.
+#
+# Example Usage:
+# ruby_diff --git v0.1:lib --git v0.1:lib
+# ruby_diff --git HEAD^2 --git HEAD^1 --git HEAD
class GitFeeder
+ GitFile = Struct.new :access, :type, :hash, :name
+
attr_accessor :files
attr_accessor :path
@@ -1,4 +1,8 @@
+# Common feeder support for working with git repositories.
module GitSupport
+
+ # Finds root of a git repository. If the repository is the parent of the
+ # supplied path, then the remainder is made into the search path.
def init_git(path, search_path='')
path = File.expand_path(path)
if File.exist?(File.join(path, ".git"))
@@ -18,6 +22,7 @@ def init_git(path, search_path='')
end
end
+ # issues a command to git
def git command
output = `git #{command} 2>&1`.chomp
unless $?.success?
@@ -1,3 +1,9 @@
+# A Feeder reads in files for RubyDiff's processor to
+# run over. GitWorkingDirFeeder reads them from a git repository. Usually
+# used in conjunction with the GitFeeder.
+#
+# Example Usage:
+# ruby_diff --git v0.1:lib --git-wd lib
class GitWorkingDirFeeder
attr_accessor :files
attr_accessor :path
@@ -94,6 +94,9 @@ def name_for_arg(name_sexp)
end
end
+# StructureProcessor is a SexpProcessor which will generate a logical
+# model of the ruby code. It can be fooled by metaprogramming and method
+# redefinition, but in most cases should be fairly accurate.
class StructureProcessor < SexpProcessor
attr_reader :name
attr_accessor :code_objects

0 comments on commit d8c3c08

Please sign in to comment.