forked from schacon/git-scribe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-scribe.rb
63 lines (47 loc) · 1.09 KB
/
git-scribe.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
require 'rubygems'
require 'nokogiri'
require 'liquid'
require 'yaml'
require 'git-scribe/generate'
require 'git-scribe/check'
require 'git-scribe/init'
require 'fileutils'
require 'pp'
class GitScribe
include Init
include Check
include Generate
attr_accessor :subcommand, :args, :options
attr_reader :info
BOOK_FILE = 'book.asc'
OUTPUT_TYPES = ['docbook', 'html', 'pdf', 'epub', 'mobi', 'site']
SCRIBE_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
def initialize
@subcommand = nil
@args = []
@options = {}
@config = YAML::parse(File.open(local('.gitscribe'))).transform rescue {}
end
## COMMANDS ##
def die(message)
raise message
end
def local(file)
File.expand_path(File.join(Dir.pwd, file))
end
def base(file)
File.join(SCRIBE_ROOT, file)
end
# API/DATA HELPER FUNCTIONS #
def git(subcommand)
`git #{subcommand}`.chomp
end
def first_arg(args)
Array(args).shift
end
# eventually we'll want to log this or have it retrievable elsehow
def info(message)
@info ||= []
@info << message
end
end