Class: Diglossa::Parse
- Inherits:
-
Object
- Object
- Diglossa::Parse
- Defined in:
- lib/diglossa/parse.rb
Instance Attribute Summary collapse
-
#app_dir ⇒ Object
, :config_path, :revision.
-
#author_nic ⇒ Object
, :config_path, :revision.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#counter ⇒ Object
, :config_path, :revision.
-
#dbauthors ⇒ Object
, :config_path, :revision.
-
#document ⇒ Object
, :config_path, :revision.
-
#filepaths ⇒ Object
, :config_path, :revision.
-
#locale ⇒ Object
, :config_path, :revision.
-
#nics ⇒ Object
, :config_path, :revision.
-
#root ⇒ Object
, :config_path, :revision.
-
#rpp ⇒ Object
, :config_path, :revision.
-
#warns ⇒ Object
, :config_path, :revision.
Instance Method Summary collapse
- #build(root, push = false) ⇒ Object
-
#initialize(app_dir) ⇒ Parse
constructor
, config_path = nil).
- #parse_author(nic) ⇒ Object
Constructor Details
#initialize(app_dir) ⇒ Parse
, config_path = nil)
11 12 13 14 15 16 |
# File 'lib/diglossa/parse.rb', line 11 def initialize(app_dir) #, config_path = nil) self.app_dir = File.(app_dir) + '/' @warns = {file:[], size:[]} @counter = [] #load_couchapprc end |
Instance Attribute Details
#app_dir ⇒ Object
, :config_path, :revision
8 9 10 |
# File 'lib/diglossa/parse.rb', line 8 def app_dir @app_dir end |
#author_nic ⇒ Object
, :config_path, :revision
8 9 10 |
# File 'lib/diglossa/parse.rb', line 8 def @author_nic end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
9 10 11 |
# File 'lib/diglossa/parse.rb', line 9 def config @config end |
#counter ⇒ Object
, :config_path, :revision
8 9 10 |
# File 'lib/diglossa/parse.rb', line 8 def counter @counter end |
#dbauthors ⇒ Object
, :config_path, :revision
8 9 10 |
# File 'lib/diglossa/parse.rb', line 8 def @dbauthors end |
#document ⇒ Object
, :config_path, :revision
8 9 10 |
# File 'lib/diglossa/parse.rb', line 8 def document @document end |
#filepaths ⇒ Object
, :config_path, :revision
8 9 10 |
# File 'lib/diglossa/parse.rb', line 8 def filepaths @filepaths end |
#locale ⇒ Object
, :config_path, :revision
8 9 10 |
# File 'lib/diglossa/parse.rb', line 8 def locale @locale end |
#nics ⇒ Object
, :config_path, :revision
8 9 10 |
# File 'lib/diglossa/parse.rb', line 8 def nics @nics end |
#root ⇒ Object
, :config_path, :revision
8 9 10 |
# File 'lib/diglossa/parse.rb', line 8 def root @root end |
#rpp ⇒ Object
, :config_path, :revision
8 9 10 |
# File 'lib/diglossa/parse.rb', line 8 def rpp @rpp end |
#warns ⇒ Object
, :config_path, :revision
8 9 10 |
# File 'lib/diglossa/parse.rb', line 8 def warns @warns end |
Instance Method Details
#build(root, push = false) ⇒ Object
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 64 65 |
# File 'lib/diglossa/parse.rb', line 28 def build root, push=false # FIXME: Lib to .diglossarc fn = File.(File.join(Diglossa::Lib, root)) fullname = File.exist?("#{fn}.json") ? "#{fn}.json" : File.exist?("#{fn}.yml") ? "#{fn}.yml" : false return nil unless fullname doc = fullname ? YAML.load_file(fullname) : "no .json or .yml file at #{root}" @nics = doc["authors"] remote = Diglossa::Remote.new(app_dir) #puts "locales #{remote.config["locales"]}" @rpp = {} @dbauthors = remote.(doc["authors"]) @author_nic = root.split("/")[1].downcase #lang = root.split('/').first.downcase @locale = "ru" title = root.split("/").last # .gsub("_", " ") if push == "book" jsru = {isFolder:true, expand: true, children:[]} jsen = {isFolder:true, expand: true, children:[]} traverse jsru, doc["tree"], root, title do |path| parallels path # cause of rpp, alas end @locale = "en" traverse jsen, doc["tree"], root, title [{type:"book", url:root.to_url, jstree:jsru, rpp:rpp, locale:"ru"}, {type:"book", url:root.to_url, jstree:jsen, rpp:rpp, locale:"en"}] elsif push == "docs" jsru = {url:root.to_url, isFolder:true, expand: true, children:[]} traverse jsru, doc["tree"], root, title do |path| parallels path, true end elsif push == "warns" jsru = {url:root.to_url, isFolder:true, expand: true, children:[]} traverse jsru, doc["tree"], root, title do |path| parallels path end warns end end |
#parse_author(nic) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/diglossa/parse.rb', line 18 def (nic) # FIXME: поправить название, это чтение файла fn = File.(File.join(app_dir, nic)) fullname = "#{fn}.json" return nil unless File.exist?(fullname) doc = YAML.load_file fullname doc end |