Class: Oxidized::Git
Defined Under Namespace
Classes: GitError
Instance Method Summary collapse
- #fetch(node, group) ⇒ Object
-
#initialize ⇒ Git
constructor
A new instance of Git.
- #setup ⇒ Object
- #store(file, outputs, opt = {}) ⇒ Object
Methods inherited from Output
Constructor Details
#initialize ⇒ Git
Returns a new instance of Git.
11 12 13 |
# File 'lib/oxidized/output/git.rb', line 11 def initialize @cfg = CFG.output.git end |
Instance Method Details
#fetch(node, group) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/oxidized/output/git.rb', line 51 def fetch node, group begin repo = @cfg.repo if group repo = File.join File.dirname(repo), group + '.git' end repo = Rugged::Repository.new repo index = repo.index index.read_tree repo.head.target.tree unless repo.empty? repo.read(index.get(node)[:oid]).data rescue 'node not found' end end |
#setup ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/oxidized/output/git.rb', line 15 def setup if @cfg.empty? CFGS.user.output.git.user = 'Oxidized' CFGS.user.output.git.email = '[email protected]' CFGS.user.output.git.repo = File.join(Config::Root, 'oxidized.git') CFGS.save :user raise NoConfig, 'no output git config, edit ~/.config/oxidized/config' end end |
#store(file, outputs, opt = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/oxidized/output/git.rb', line 25 def store file, outputs, opt={} @msg = opt[:msg] @user = (opt[:user] or @cfg.user) @email = (opt[:email] or @cfg.email) @opt = opt repo = @cfg.repo outputs.types.each do |type| type_cfg = '' type_repo = File.join File.dirname(repo), type + '.git' outputs.type(type).each do |output| (type_cfg << output; next) if not output.name type_file = file + '--' + output.name if @cfg.type_as_directory? type_file = type + '/' + type_file type_repo = repo end update type_repo, type_file, output end update type_repo, file, type_cfg end update repo, file, outputs.to_cfg end |