Class: Diglossa::CLI
- Inherits:
-
Thor
- Object
- Thor
- Diglossa::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/diglossa/cli.rb
Instance Attribute Summary collapse
-
#appdir ⇒ Object
Returns the value of attribute appdir.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#config_file ⇒ Object
Returns the value of attribute config_file.
-
#debug ⇒ Object
Returns the value of attribute debug.
Instance Method Summary collapse
- #author(nic, push = false, env = 'default') ⇒ Object
- #build(path = 'default', push = "book") ⇒ Object
- #generate(to = nil) ⇒ Object
- #get(path, env = 'default') ⇒ Object
-
#gettexts(url, delete = false, env = 'default') ⇒ Object
125037 rows.
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #push(path, env = 'default') ⇒ Object
- #pushtexts(path = 'default') ⇒ Object
- #warns(path, env = 'default') ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/diglossa/cli.rb', line 85 def initialize(*) super self.appdir = [:appdir] || File.(Dir.pwd) # self.config_file = options[:config] # self.debug = options[:debug] # if debug # Soca.debug = true # logger.level = Logger::DEBUG # end self.source_paths << File.(File.join(File.dirname(__FILE__), 'templates')) end |
Instance Attribute Details
#appdir ⇒ Object
Returns the value of attribute appdir.
15 16 17 |
# File 'lib/diglossa/cli.rb', line 15 def appdir @appdir end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
16 17 18 |
# File 'lib/diglossa/cli.rb', line 16 def config @config end |
#config_file ⇒ Object
Returns the value of attribute config_file.
15 16 17 |
# File 'lib/diglossa/cli.rb', line 15 def config_file @config_file end |
#debug ⇒ Object
Returns the value of attribute debug.
15 16 17 |
# File 'lib/diglossa/cli.rb', line 15 def debug @debug end |
Instance Method Details
#author(nic, push = false, env = 'default') ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/diglossa/cli.rb', line 71 def (nic, push=false, env = 'default') response = remote(env). nic response.empty? ? say("WARN: no author #{nic}", :red) : pp(response) return unless push doc = parse.(nic) dbdoc = response.find{|d|d["nic"] == nic} if dbdoc doc["_id"] = dbdoc["_id"] doc["_rev"] = dbdoc["_rev"] end response = remote(env).push_docs doc pp response end |
#build(path = 'default', push = "book") ⇒ Object
35 36 37 38 |
# File 'lib/diglossa/cli.rb', line 35 def build(path = 'default', push = "book") book = parse.build path, "book" book ? pp(book) : say("can not build book by path #{path}", :red) end |
#generate(to = nil) ⇒ Object
116 117 118 119 120 121 122 |
# File 'lib/diglossa/cli.rb', line 116 def generate(to = nil) self.appdir = to if to self.destination_root = appdir directory('hooks') template('couchapprc.erb', '.couchapprc') end |
#get(path, env = 'default') ⇒ Object
27 28 29 30 31 32 |
# File 'lib/diglossa/cli.rb', line 27 def get(path, env = 'default') size = path.split("/").size url = size < 3 ? path : path.to_url resp = remote(env).get_book url resp ? pp(resp) : say("no book by url #{url}", :red) end |
#gettexts(url, delete = false, env = 'default') ⇒ Object
125037 rows
60 61 62 63 64 65 66 67 |
# File 'lib/diglossa/cli.rb', line 60 def gettexts(url, delete=false, env = 'default') # 125037 rows docs = remote(env).texts_get url docs.empty? ? say("WARN: no docs by url: #{url}", :red) : pp(docs) return unless delete == "delete!" docs.each{|doc|doc["_deleted"] = true} response = remote(env).push_docs docs pp response end |
#push(path, env = 'default') ⇒ Object
41 42 43 44 45 |
# File 'lib/diglossa/cli.rb', line 41 def push(path, env = 'default') books = parse.build path, "book" resp = remote(env).push_book books resp ? pp(resp) : say("WARN: no book to push by #{path}", :red) end |
#pushtexts(path = 'default') ⇒ Object
54 55 56 57 |
# File 'lib/diglossa/cli.rb', line 54 def pushtexts(path = 'default') fpaths = parse.build path, "docs" fpaths ? pp(fpaths) : say("can not build texts by path #{path}", :red) end |
#warns(path, env = 'default') ⇒ Object
48 49 50 51 |
# File 'lib/diglossa/cli.rb', line 48 def warns(path, env = 'default') resp = parse.build path, "warns" resp ? pp(resp) : say("WARN: no book to push by #{path}", :red) end |