Class: Devist

Inherits:
Object
  • Object
show all
Defined in:
lib/devist.rb

Overview

devist.rb This file is a part of the devist package. Halis Duraki <duraki.halis@nsoft.ba>

This is the place where the ep action is being taken. Devist check if setup is ok and proceed with parsing and creating the static export.

Defined Under Namespace

Classes: Compiler, Extractor, Parser, Project, Tag, Version

Constant Summary

@@default_search =

Default files to look for

%w[CHANGELOG RELEASES NEWS]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, theme = 'default') ⇒ Devist

Init



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
# File 'lib/devist.rb', line 22

def initialize(filename, theme = 'default')

  @parser = Parser.new
  @filename = filename + ".md"
  @themename = "_" + theme + ".html.erb"

  # Theme directory is absolute dirpath + subs
  theme_dir = __dir__ + "/devist/export/html/"

  # Check if both theme and filename exists
  if File.file?(@filename) 
    print "  * File '#{@filename}' exists; continuing ...\n"
  else
    print "  * File '#{@filename}' does NOT exists; exit ...\n"
    print "  > Do you want to allow devist to search the file for you? (y\/N) "
    devist_as = STDIN.gets.chomp
    
    # Search for changelogs automatically
    if devist_as.downcase.eql?("y")
        print "  * Searching for changelog data ...\n"
        available

        if @@available.count > 0
          print "  * Try to run with filename #{@@available_list}\n"
        end
    end
        
    exit
  end

  if File.file?(theme_dir + @themename)
    print "  * Theme '#{@themename}' exists; continuing ...\n"
  else
    print "  * Theme '#{@themename}' does NOT exists; exit ...\n"
    exit
  end

end

Instance Attribute Details

#compilerObject (readonly)

@project: stacklog/devist @author: Halis Duraki <duraki.halis@nsoft.ba> @homepage: github.com/stacklog/devist



16
17
18
# File 'lib/devist.rb', line 16

def compiler
  @compiler
end

#parserObject (readonly)

@project: stacklog/devist @author: Halis Duraki <duraki.halis@nsoft.ba> @homepage: github.com/stacklog/devist



16
17
18
# File 'lib/devist.rb', line 16

def parser
  @parser
end

Instance Method Details

#availableObject

Auto-search for available changelog



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/devist.rb', line 62

def available
  @@available = []
  @@available_list = String.new 

  @@default_search.each do |filename|
    filename.concat(".md")
    if File.file?(filename)
      @@available_list.concat(filename + " ")
      @@available.push(filename)   
    end
  end

  print "  * Found #{@@available.count} results.\n"

  @@available.count
end

#decompileObject

Decompile .md file.



80
81
82
83
# File 'lib/devist.rb', line 80

def decompile
  @parser.parse_data(@filename)
  @parser.project
end

#recompileObject

Recompile .md file.



86
87
88
89
# File 'lib/devist.rb', line 86

def recompile
  @compiler = Compiler.new(@parser.project, @parser.changelog, @themename)
  @compiler.compile_data
end