summaryrefslogtreecommitdiffstats
path: root/lib/git
diff options
context:
space:
mode:
Diffstat (limited to 'lib/git')
-rw-r--r--lib/git/base.rb59
-rw-r--r--lib/git/index.rb4
-rw-r--r--lib/git/path.rb23
-rw-r--r--lib/git/repository.rb5
-rw-r--r--lib/git/working_directory.rb4
5 files changed, 95 insertions, 0 deletions
diff --git a/lib/git/base.rb b/lib/git/base.rb
new file mode 100644
index 0000000..6eb3455
--- /dev/null
+++ b/lib/git/base.rb
@@ -0,0 +1,59 @@
+module Git
+
+ class Base
+
+ @working_directory = nil
+ @repository = nil
+ @index = nil
+
+ # opens a Git Repository - no working directory options
+ def self.repo(git_dir)
+ self.new :repository => git_dir
+ end
+
+ # opens a new Git Project from a working directory
+ # you can specify non-standard git_dir and index file in the options
+ def self.open(working_dir, opts={})
+ default = {:working_directory => working_dir,
+ :repository => File.join(working_dir, '.git'),
+ :index => File.join(working_dir, '.git', 'index')}
+ git_options = default.merge(opts)
+
+ self.new(git_options)
+ end
+
+ def initialize(options = {})
+ @working_directory = Git::Repository.new(options[:working_directory]) if options[:working_directory]
+ @repository = Git::Repository.new(options[:repository]) if options[:repository]
+ @index = Git::Index.new(options[:index]) if options[:index]
+ end
+
+ def self.clone
+ raise NotImplementedError
+ end
+
+ def self.init
+ raise NotImplementedError
+ end
+
+
+ def dir
+ @working_directory
+ end
+
+ def repo
+ @repository
+ end
+
+ def index
+ @index
+ end
+
+ private
+
+ def is_git_dir(dir)
+ end
+
+ end
+
+end \ No newline at end of file
diff --git a/lib/git/index.rb b/lib/git/index.rb
new file mode 100644
index 0000000..b96eedb
--- /dev/null
+++ b/lib/git/index.rb
@@ -0,0 +1,4 @@
+module Git
+ class Index < Git::Path
+ end
+end
diff --git a/lib/git/path.rb b/lib/git/path.rb
new file mode 100644
index 0000000..9d6ba49
--- /dev/null
+++ b/lib/git/path.rb
@@ -0,0 +1,23 @@
+module Git
+ class Path
+
+ attr_accessor :path
+
+ def initialize(path)
+ if File.exists?(path)
+ @path = path
+ else
+ raise ArgumentError, "path does not exist", path
+ end
+ end
+
+ def readable?
+ File.readable?(@path)
+ end
+
+ def writable?
+ File.writable?(@path)
+ end
+
+ end
+end \ No newline at end of file
diff --git a/lib/git/repository.rb b/lib/git/repository.rb
new file mode 100644
index 0000000..d76dc8b
--- /dev/null
+++ b/lib/git/repository.rb
@@ -0,0 +1,5 @@
+module Git
+ class Repository < Path
+
+ end
+end
diff --git a/lib/git/working_directory.rb b/lib/git/working_directory.rb
new file mode 100644
index 0000000..3f37f1a
--- /dev/null
+++ b/lib/git/working_directory.rb
@@ -0,0 +1,4 @@
+module Git
+ class WorkingDirectory < Git::Path
+ end
+end