Compare commits

..

No commits in common. "master" and "0.21" have entirely different histories.
master ... 0.21

13 changed files with 176 additions and 240 deletions

View File

@ -4,7 +4,7 @@
!v!Pluie.Berel.Meta meta : !v!Pluie.Berel.Meta meta :
keys : keys :
software : berel; <https://git.pluie.org/pluie/berel> software : berel; <https://git.pluie.org/pluie/berel>
version : 0.25 version : 0.21
type : program type : program
date : 2018 date : 2018
license : GPLv3.0; <http://www.gnu.org/licenses/> license : GPLv3.0; <http://www.gnu.org/licenses/>
@ -15,7 +15,7 @@
- sh : - sh :
file : file :
- build.sh - build.sh
startline : 2 # to embed shebang before header tpl startline : 2
sepline : sepline :
motif : "# " motif : "# "
repeat : 40 repeat : 40
@ -26,7 +26,7 @@
- meson : - meson :
file : file :
- meson.build - meson.build
- src/meson.build startline : 1
sepline : sepline :
motif : "# " motif : "# "
repeat : 40 repeat : 40
@ -39,6 +39,9 @@
- src - src
extension : extension :
- .vala - .vala
file :
- install.vala.in
startline : 1
sepline : sepline :
motif : " *" motif : " *"
repeat : 40 repeat : 40

View File

@ -2,7 +2,7 @@
#^# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #^# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# @software : berel <https://git.pluie.org/pluie/berel> # @software : berel <https://git.pluie.org/pluie/berel>
# @version : 0.25 # @version : 0.21
# @type : program # @type : program
# @date : 2018 # @date : 2018
# @license : GPLv3.0 <http://www.gnu.org/licenses/> # @license : GPLv3.0 <http://www.gnu.org/licenses/>

View File

@ -1,7 +1,7 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : berel <https://git.pluie.org/pluie/berel> * @software : berel <https://git.pluie.org/pluie/berel>
* @version : 0.25 * @version : 0.21
* @type : program * @type : program
* @date : 2018 * @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>

17
main.vala Normal file
View File

@ -0,0 +1,17 @@
using GLib;
using Gee;
using Pluie;
int main (string[] args)
{
Echo.init(false);
var done = false;
var app = new Berel.App();
done = app!=null && app.done;
of.rs (done);
of.echo ();
return (int) done;
}

View File

@ -1,7 +1,7 @@
#^# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #^# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# @software : berel <https://git.pluie.org/pluie/berel> # @software : berel <https://git.pluie.org/pluie/berel>
# @version : 0.25 # @version : 0.21
# @type : program # @type : program
# @date : 2018 # @date : 2018
# @license : GPLv3.0 <http://www.gnu.org/licenses/> # @license : GPLv3.0 <http://www.gnu.org/licenses/>
@ -27,35 +27,47 @@
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #^# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #^#
project('berel', ['vala', 'c'], version:'0.22') project('berel', 'vala', 'c', version:'0.21')
cc = meson.get_compiler('c')
dep_glib = dependency('glib-2.0')
dep_gobject = dependency('gobject-2.0')
dep_gmodule = dependency('gmodule-2.0')
dep_gio = dependency('gio-2.0')
dep_gee = dependency('gee-0.8')
dep_echo = dependency('pluie-echo-0.2')
dep_yaml = dependency('pluie-yaml-0.5')
dep_m = cc.find_library('m', required : false)
# dep_yaml = cc.find_library('yaml', required : true)
version = meson.project_version()
bindir = join_paths(get_option('prefix'), get_option('bindir'))
datadir = join_paths(get_option('prefix'), get_option('datadir'), 'pluie/berel')
libdir = join_paths(get_option('prefix'), get_option('libdir'), 'pkgconfig')
incdir = join_paths(get_option('prefix'), get_option('includedir'), 'pluie')
conf = configuration_data() conf = configuration_data()
conf.set('VERSION' , meson.project_version()) conf.set('VERSION' , version)
conf.set('INSTALL_PATH', join_paths(get_option('prefix'), get_option('bindir'))) conf.set('INSTALL_PATH', bindir)
conf.set('DATA_PATH' , join_paths(get_option('prefix'), get_option('datadir'), 'pluie/berel')) conf.set('DATA_PATH' , datadir)
configure_file( configure_file(
input : 'src/install.vala', input: 'install.vala.in',
output: 'install.vala', output: 'install.vala',
configuration: conf configuration: conf
) )
subdir('src') sources = [
'build/install.vala',
executable( 'src/Pluie/Berel.App.vala',
meson.project_name(), 'src/Pluie/Berel.Comment.vala',
src_files + [ 'build/install.vala' ], 'src/Pluie/Berel.HeaderDef.vala',
install : true, 'src/Pluie/Berel.Key.vala',
dependencies : [ 'src/Pluie/Berel.Meta.vala',
dependency('glib-2.0'), 'src/Pluie/Berel.Sepline.vala',
dependency('gobject-2.0'), 'main.vala',
dependency('gmodule-2.0'),
dependency('gio-2.0'),
dependency('gee-0.8'),
dependency('pluie-echo-0.2'),
dependency('pluie-yaml-0.5'),
meson.get_compiler('c').find_library('m', required : false)
] ]
)
executable('berel', sources, install : true, dependencies : [dep_glib, dep_gobject, dep_gmodule, dep_gio, dep_gee, dep_echo, dep_yaml, dep_m])

View File

@ -1,7 +1,7 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : berel <https://git.pluie.org/pluie/berel> * @software : berel <https://git.pluie.org/pluie/berel>
* @version : 0.25 * @version : 0.21
* @type : program * @type : program
* @date : 2018 * @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
@ -77,7 +77,6 @@ public class Pluie.Berel.App
{ {
bool done = false; bool done = false;
this.pwd = GLib.Environment.get_current_dir (); this.pwd = GLib.Environment.get_current_dir ();
Yaml.Loader.PACK_NESTED_ENTRIES = true;
var config = new Yaml.Config (Path.build_filename (path != null ? path : pwd, ".berel.yml"), false); var config = new Yaml.Config (Path.build_filename (path != null ? path : pwd, ".berel.yml"), false);
var root = config.root_node (); var root = config.root_node ();
root.name = Path.get_basename (pwd)+"/.berel.yml"; root.name = Path.get_basename (pwd)+"/.berel.yml";
@ -94,16 +93,13 @@ public class Pluie.Berel.App
private void write_header (Berel.HeaderDef header) private void write_header (Berel.HeaderDef header)
{ {
of.action ("write headers from header def", header.yaml_name); of.action ("write headers from header def", header.yaml_name);
var hasHeader = false;
string? data = null; string? data = null;
string? path = null; string? path = null;
foreach (var name in header.file) { foreach (var name in header.file) {
path = Path.build_filename(this.pwd, name); path = Path.build_filename(this.pwd, name);
data = this.get_write_content(path, header); data = this.get_write_content(path, header);
if (data.length > 0 && this.write_file (path, data)) { this.write_file (path, data);
if (header.yaml_name == "sh") {
FileUtils.chmod (path, 0775);
}
}
} }
foreach (var name in header.dir) { foreach (var name in header.dir) {
path = Path.build_filename(this.pwd, name); path = Path.build_filename(this.pwd, name);
@ -116,9 +112,9 @@ public class Pluie.Berel.App
*/ */
private void write_dir (string path, HeaderDef header) private void write_dir (string path, HeaderDef header)
{ {
of.echo (" > reading directory %s".printf (path));
string? dname = null; string? dname = null;
string? data = null; string? data = null;
try {
Dir dir = Dir.open (path, 0); Dir dir = Dir.open (path, 0);
while ((dname = dir.read_name ()) != null) { while ((dname = dir.read_name ()) != null) {
string? p = Path.build_filename (path, dname); string? p = Path.build_filename (path, dname);
@ -126,13 +122,10 @@ public class Pluie.Berel.App
this.write_dir (p, header); this.write_dir (p, header);
else { else {
data = this.get_write_content(p, header, true); data = this.get_write_content(p, header, true);
if (data.length > 00) this.write_file (p, data); this.write_file (p, data);
} }
} }
} of.echo (" < directory %s".printf (path));
catch(GLib.FileError e) {
of.error (e.message);
}
} }
/** /**

View File

@ -1,7 +1,7 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : berel <https://git.pluie.org/pluie/berel> * @software : berel <https://git.pluie.org/pluie/berel>
* @version : 0.25 * @version : 0.21
* @type : program * @type : program
* @date : 2018 * @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
@ -68,6 +68,6 @@ public class Pluie.Berel.Comment : Yaml.Object
*/ */
public string get_line (string data, bool disabled = false) public string get_line (string data, bool disabled = false)
{ {
return "%s%s".printf (disabled ? "" : this.begin, data).chomp (); return "%s%s".printf (disabled ? "" : this.begin, data);
} }
} }

View File

@ -1,7 +1,7 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : berel <https://git.pluie.org/pluie/berel> * @software : berel <https://git.pluie.org/pluie/berel>
* @version : 0.25 * @version : 0.21
* @type : program * @type : program
* @date : 2018 * @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
@ -34,7 +34,7 @@ public class Pluie.Berel.HeaderDef : Yaml.Object
{ {
public Gee.ArrayList<string> file { get; set; } public Gee.ArrayList<string> file { get; set; }
public Gee.ArrayList<string> dir { get; set; } public Gee.ArrayList<string> dir { get; set; }
public int startline { get; set; default = 1; } public int startline { get; set; }
public Berel.Sepline sepline { get; set; } public Berel.Sepline sepline { get; set; }
public Gee.ArrayList<string> extension { get; set; } public Gee.ArrayList<string> extension { get; set; }
public Berel.Comment comment { get; set; } public Berel.Comment comment { get; set; }

View File

@ -1,7 +1,7 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : berel <https://git.pluie.org/pluie/berel> * @software : berel <https://git.pluie.org/pluie/berel>
* @version : 0.25 * @version : 0.21
* @type : program * @type : program
* @date : 2018 * @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>

View File

@ -1,7 +1,7 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : berel <https://git.pluie.org/pluie/berel> * @software : berel <https://git.pluie.org/pluie/berel>
* @version : 0.25 * @version : 0.21
* @type : program * @type : program
* @date : 2018 * @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
@ -111,7 +111,7 @@ public class Pluie.Berel.Meta : Yaml.Object
sb.append("%s\n".printf (hd.comment.get_line(str, str==hd.sepline.to_string ()))); sb.append("%s\n".printf (hd.comment.get_line(str, str==hd.sepline.to_string ())));
} }
} }
return "%s%s\n".printf (sb.str.substring (0, sb.str.length - 3 - hd.comment.end.length), hd.comment.end); return "%s\n".printf (sb.str.substring (0, sb.str.length - 5 -(hd.sepline.motif[0] == ' ' ? 0 : 1) - hd.comment.end.length)+hd.comment.end);
} }
/** /**
@ -119,11 +119,10 @@ public class Pluie.Berel.Meta : Yaml.Object
*/ */
public string tpl_replace_var (HeaderDef hd) public string tpl_replace_var (HeaderDef hd)
{ {
string str = this.tpl;
this.varlist = new Gee.HashMap<string, string> ();
try {
MatchInfo? mi = null; MatchInfo? mi = null;
Regex reg = new Regex ("\\^([^\\^]+)\\^"); Regex reg = new Regex ("\\^([^\\^]+)\\^");
string str = this.tpl;
this.varlist = new Gee.HashMap<string, string> ();
if (reg.match (str, 0, out mi)) { if (reg.match (str, 0, out mi)) {
this.define_var (mi.fetch (1), hd); this.define_var (mi.fetch (1), hd);
while (mi.next ()) {; while (mi.next ()) {;
@ -135,10 +134,6 @@ public class Pluie.Berel.Meta : Yaml.Object
str = str.replace("^%s^".printf (entry.key), (entry.key == "sepline" ? "" : "")+entry.value); str = str.replace("^%s^".printf (entry.key), (entry.key == "sepline" ? "" : "")+entry.value);
} }
} }
}
catch (GLib.RegexError e) {
of.error (e.message);
}
return str; return str;
} }
@ -191,14 +186,14 @@ public class Pluie.Berel.Meta : Yaml.Object
} }
int count = 0; int count = 0;
foreach (var bk in this.keys) { foreach (var bk in this.keys) {
sb.append (hd.comment.get_line("@%s%s : %s%s%s".printf ( sb.append (hd.comment.get_line("@%s%s : %s%s%s%s".printf (
bk.yaml_name, bk.yaml_name,
string.nfill(lenk+2-bk.yaml_name.length, ' '), string.nfill(lenk+2-bk.yaml_name.length, ' '),
bk.name, bk.name,
string.nfill(len+2-bk.name.length, ' '), string.nfill(len+2-bk.name.length, ' '),
bk.address != null ? " %s".printf (bk.address) : "" bk.address != null ? " %s".printf (bk.address) : "",
count == this.keys.size -1 ? "" : "\n"
),count++ == 0)); ),count++ == 0));
sb.append ("\n");
} }
return sb.str; return sb.str;
} }

View File

@ -1,7 +1,7 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : berel <https://git.pluie.org/pluie/berel> * @software : berel <https://git.pluie.org/pluie/berel>
* @version : 0.25 * @version : 0.21
* @type : program * @type : program
* @date : 2018 * @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>

View File

@ -1,46 +0,0 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @software : berel <https://git.pluie.org/pluie/berel>
* @version : 0.25
* @type : program
* @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org>
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* This file is part of berel.
*
* berel is free software (free as in speech) : you can redistribute it
* and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* berel is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with berel. If not, see <http://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
using GLib;
using Gee;
using Pluie;
int main (string[] args)
{
Echo.init(false);
var done = false;
var app = new Berel.App();
done = app!=null && app.done;
of.rs (done);
of.echo ();
return (int) done;
}

View File

@ -1,38 +0,0 @@
#^# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# @software : berel <https://git.pluie.org/pluie/berel>
# @version : 0.25
# @type : program
# @date : 2018
# @license : GPLv3.0 <http://www.gnu.org/licenses/>
# @author : a-Sansara <[dev]at[pluie]dot[org]>
# @copyright : pluie.org <http://www.pluie.org>
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# This file is part of berel.
#
# berel is free software (free as in speech) : you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# berel is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License
# along with berel. If not, see <http://www.gnu.org/licenses/>.
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #^#
src_files = [
'src/Pluie/Berel.App.vala',
'src/Pluie/Berel.Comment.vala',
'src/Pluie/Berel.HeaderDef.vala',
'src/Pluie/Berel.Key.vala',
'src/Pluie/Berel.Meta.vala',
'src/Pluie/Berel.Sepline.vala',
'src/main.vala'
]