156b4406c7c7352244dc09aa1a2376493280e282
[software/sisu] / lib / sisu / current / se_version.rb
1 # encoding: utf-8
2 =begin
3
4 * Name: SiSU
5
6 ** Description: documents, structuring, processing, publishing, search
7 *** system environment, resource control and configuration details
8
9 ** Author: Ralph Amissah
10 <ralph@amissah.com>
11 <ralph.amissah@gmail.com>
12
13 ** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
14 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
15 All Rights Reserved.
16
17 ** License: GPL 3 or later:
18
19 SiSU, a framework for document structuring, publishing and search
20
21 Copyright (C) Ralph Amissah
22
23 This program is free software: you can redistribute it and/or modify it
24 under the terms of the GNU General Public License as published by the Free
25 Software Foundation, either version 3 of the License, or (at your option)
26 any later version.
27
28 This program is distributed in the hope that it will be useful, but WITHOUT
29 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
30 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
31 more details.
32
33 You should have received a copy of the GNU General Public License along with
34 this program. If not, see <http://www.gnu.org/licenses/>.
35
36 If you have Internet connection, the latest version of the GPL should be
37 available at these locations:
38 <http://www.fsf.org/licensing/licenses/gpl.html>
39 <http://www.gnu.org/licenses/gpl.html>
40
41 <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
42
43 ** SiSU uses:
44 * Standard SiSU markup syntax,
45 * Standard SiSU meta-markup syntax, and the
46 * Standard SiSU object citation numbering and system
47
48 ** Hompages:
49 <http://www.jus.uio.no/sisu>
50 <http://www.sisudoc.org>
51
52 ** Git
53 <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
54 <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/se_version.rb;hb=HEAD>
55
56 =end
57 module SiSU_Info_Version
58 require_relative 'constants' # constants.rb
59 require_relative 'utils' # utils.rb
60 require_relative 'se_info_env' # se_info_env.rb
61 begin
62 require 'singleton'
63 rescue LoadError
64 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
65 error('singleton NOT FOUND (LoadError)')
66 end
67 class InfoVersion < SiSU_Info_Env::InfoEnv # se_info_env.rb
68 include Singleton
69 begin
70 require 'rbconfig'
71 require 'yaml'
72 rescue LoadError
73 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
74 error('rbconfig or yaml NOT FOUND (LoadError)')
75 end
76 @@lib_path=nil
77 def get_version
78 @version={}
79 @pwd=ENV['PWD']
80 lib_path=
81 @@lib_path \
82 ? @@lib_path
83 : `echo $RUBYLIB`.split(':')
84 @@lib_path ||=lib_path
85 if File.exist?(SiSU_is.version_info_path?)
86 @version=YAML::load(File::open(SiSU_is.version_info_path?))
87 end
88 @version[:install_method]=if SiSU_is.run_from? ==:gem_install
89 spec = Gem::Specification.find_by_name("sisu")
90 gem_root = spec.gem_dir
91 (File.dirname(__FILE__.gsub(/\/lib\/sisu\/#{SiSU_is.branch_name?}/,'')) == gem_root) \
92 ? ' (ruby gem install)' : ''
93 else ''
94 end
95 @version[:branch_name]=SiSU_is.branch_name?
96 @version[:branch_version]=SiSU_is.branch_version?
97 @version[:branch_number]=/^v([0-9]+)$/.match(@version[:branch_version])[1]
98 @version
99 end
100 def rbversion
101 %x{ruby -v}.strip
102 end
103 end
104 end
105 module SiSU_Info_About
106 require_relative 'constants' # constants.rb
107 require_relative 'utils' # utils.rb
108 begin
109 require 'singleton'
110 rescue LoadError
111 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
112 error('singleton NOT FOUND (LoadError)')
113 end
114 class InfoAbout
115 def initialize(color='')
116 @color=color
117 end
118 def sisu_version
119 version=SiSU_Env::InfoVersion.instance.get_version
120 rb_ver=SiSU_Env::InfoVersion.instance.rbversion
121 if version[:version]
122 opt_cmd=if defined? @color.cmd \
123 and @color.cmd =~/[ck]/
124 @color.cmd
125 else '-v'
126 end
127 SiSU_Screen::Ansi.new(
128 opt_cmd,
129 version[:project],
130 version[:version],
131 version[:date_stamp],
132 version[:date],
133 version[:install_method],
134 rb_ver
135 ).version
136 else puts 'SiSU (version information not available)'
137 end
138 end
139 def sisu_about
140 puts <<-WOK
141 sisu: documents; markup, structuring, publishing in multiple standard formats, & search
142 most (not all) useful commands (are made in a directory containing a sisu markup file &) take the form:
143 sisu [action(s)] [filename(s)]
144 where filename refers to a valid sisu marked up file, e.g.:
145 cd /usr/share/doc/sisu/markup-samples/sisu_manual
146 sisu --html --verbose sisu_commands.sst
147 sisu --txt --html --epub --odt --pdf --sqlite --manpage --texinfo --concordance --qrcode --verbose sisu.ssm
148 cd -
149 See output produced, or see man pages: man sisu
150 <http://www.sisudoc.org/> <http://www.jus.uio.no/sisu/>
151 WOK
152 end
153 end
154 end
155 __END__