Module: Twit
- Defined in:
- lib/twit.rb,
lib/twit/cli.rb,
lib/twit/repo.rb,
lib/twit/error.rb,
lib/twit/version.rb
Overview
This module exposes twit commands as methods.
Defined Under Namespace
Modules: GUI Classes: CLI, Error, InvalidParameter, NotARepositoryError, NothingToCommitError, Repo, UnsavedChanges
Constant Summary collapse
- VERSION =
Gem version
"0.0.3"
Class Method Summary collapse
-
.current_branch ⇒ Object
See Repo#current_branch.
-
.discard ⇒ Object
See Repo#discard.
-
.init(dir = nil) ⇒ Object
Initialize a git repository in a directory.
-
.is_repo?(dir = nil) ⇒ Boolean
Check if a given directory is a git repository.
-
.list ⇒ Object
See Repo#list.
- .nothing_to_commit? ⇒ Boolean
-
.open(branch) ⇒ Object
See Repo#open.
-
.repo ⇒ Object
Get a Repo representing the repository for the current working directory.
-
.rewind(amount) ⇒ Object
See Repo#rewind.
-
.save(message) ⇒ Object
See Repo#save.
-
.saveas(branch, message = nil) ⇒ Object
See Repo#saveas.
Class Method Details
.current_branch ⇒ Object
79 80 81 |
# File 'lib/twit.rb', line 79 def self.current_branch self.repo.current_branch end |
.discard ⇒ Object
See Twit::Repo#discard. (WARNING: PERMANENTLY DESTROYS DATA!)
59 60 61 |
# File 'lib/twit.rb', line 59 def self.discard self.repo.discard end |
.init(dir = nil) ⇒ Object
Initialize a git repository in a directory. Return a Twit::Repo object representing the new repository.
If no argument is supplied, use the working directory.
If init is called on a directory that is already part of a repository, simply do nothing.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/twit.rb', line 23 def self.init dir = nil dir ||= Dir.getwd if is_repo? dir return end Rugged::Repository.init_at(dir) Repo.new dir end |
.is_repo?(dir = nil) ⇒ Boolean
Check if a given directory is a git repository.
If no argument is supplied, use the working directory.
38 39 40 41 42 43 44 45 46 |
# File 'lib/twit.rb', line 38 def self.is_repo? dir = nil dir ||= Dir.getwd begin root = Rugged::Repository.discover(dir) rescue Rugged::RepositoryError return false end return true end |
.list ⇒ Object
See Twit::Repo#list.
74 75 76 |
# File 'lib/twit.rb', line 74 def self.list self.repo.list end |
.nothing_to_commit? ⇒ Boolean
84 85 86 |
# File 'lib/twit.rb', line 84 def self.nothing_to_commit? self.repo.nothing_to_commit? end |
.open(branch) ⇒ Object
See Twit::Repo#open.
64 65 66 |
# File 'lib/twit.rb', line 64 def self.open branch self.repo.open branch end |
.repo ⇒ Object
Get a Repo representing the repository for the current working directory.
12 13 14 |
# File 'lib/twit.rb', line 12 def self.repo Twit::Repo.new end |
.rewind(amount) ⇒ Object
See Twit::Repo#rewind.
69 70 71 |
# File 'lib/twit.rb', line 69 def self.rewind amount self.repo.rewind amount end |
.save(message) ⇒ Object
See Twit::Repo#save.
49 50 51 |
# File 'lib/twit.rb', line 49 def self.save self.repo.save end |
.saveas(branch, message = nil) ⇒ Object
See Twit::Repo#saveas.
54 55 56 |
# File 'lib/twit.rb', line 54 def self.saveas branch, = nil self.repo.saveas branch, end |