diff options
author | David Walter Seikel | 2014-03-27 03:01:41 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-03-27 03:01:41 +1000 |
commit | 9106ee5d97278ce8bbd85b002a8ca213a342b718 (patch) | |
tree | 786b841d391459c58dd2ed6447284f65d995ced6 | |
parent | TODO++ (diff) | |
download | SledjHamr-9106ee5d97278ce8bbd85b002a8ca213a342b718.zip SledjHamr-9106ee5d97278ce8bbd85b002a8ca213a342b718.tar.gz SledjHamr-9106ee5d97278ce8bbd85b002a8ca213a342b718.tar.bz2 SledjHamr-9106ee5d97278ce8bbd85b002a8ca213a342b718.tar.xz |
Proper copyright parsing.
-rw-r--r-- | ClientHamr/GuiLua/skang.lua | 35 | ||||
-rw-r--r-- | ClientHamr/GuiLua/test.lua | 5 |
2 files changed, 32 insertions, 8 deletions
diff --git a/ClientHamr/GuiLua/skang.lua b/ClientHamr/GuiLua/skang.lua index 1ed7b90..b11f617 100644 --- a/ClientHamr/GuiLua/skang.lua +++ b/ClientHamr/GuiLua/skang.lua | |||
@@ -62,6 +62,19 @@ things = {} | |||
62 | Thing = {} | 62 | Thing = {} |
63 | 63 | ||
64 | 64 | ||
65 | -- TODO - This needs to be expanded a bit to cover things like 1.42 | ||
66 | local versions = { | ||
67 | '0%.0', 'unwritten', 'Just a stub, no code at all, or completely non-existant.', | ||
68 | '0%.1', 'prototype', 'Stuff that has only been prototyped, or partly written. There is some code, and it may even work, but it is not even close to the finished product.', | ||
69 | '%d%.3', 'written', 'Stuff that has already been written. It may not be perfect, but it is considered an aproximation of the finished product.', | ||
70 | '%d%.5', 'alpha', 'Version being tested by official alpha testers.', | ||
71 | '%d%.9', 'beta', 'Version passed alpha testing, but not ready for final release.', | ||
72 | '1%.0', 'final', 'Version ready for final release, fully tested.', | ||
73 | '3%.0', 'poetry', 'Near perfection has been acheived.', | ||
74 | '5%.0', 'nirvana', 'Perfection has been acheived.', | ||
75 | '9%.0', 'bible', 'This is the Whord of Ghod.', | ||
76 | } | ||
77 | |||
65 | -- Trying to capture best practices here for creating modules, especially since module() is broken and deprecated. | 78 | -- Trying to capture best practices here for creating modules, especially since module() is broken and deprecated. |
66 | moduleBegin = function (name, author, copyright, version, timestamp, skin) | 79 | moduleBegin = function (name, author, copyright, version, timestamp, skin) |
67 | local _M = {} -- This is what we return to require(). | 80 | local _M = {} -- This is what we return to require(). |
@@ -89,11 +102,21 @@ moduleBegin = function (name, author, copyright, version, timestamp, skin) | |||
89 | _M._NAME = name | 102 | _M._NAME = name |
90 | _M._PACKAGE = string.gsub(_M._NAME, "[^.]*$", "") -- Strip the name down to the package name. | 103 | _M._PACKAGE = string.gsub(_M._NAME, "[^.]*$", "") -- Strip the name down to the package name. |
91 | 104 | ||
92 | -- TODO - Should parse in an entire copyright message, and strip that down into bits, to put back together. | 105 | -- Parse in an entire copyright message, and strip that down into bits, to put back together. |
93 | _M.AUTHOR = author | 106 | local date, owner = string.match(copyright, '[Cc]opyright (%d%d%d%d) (.*)') |
94 | _M.COPYRIGHT = copyright .. ' ' .. author | 107 | _M.AUTHOR = author or owner |
95 | -- TODO - Translate the version number into a version string. | 108 | _M.COPYRIGHT = 'Copyright ' .. date .. ' ' .. _M.AUTHOR |
96 | _M.VERSION = version .. ' lookup version here ' .. timestamp | 109 | -- Translate the version number into a version string. |
110 | local versionName, versionDesc = ' ', '' | ||
111 | for i = 1, #versions / 3 do | ||
112 | if 1 == string.find(version, versions[i]) then | ||
113 | versionName = ' ' .. versions[i + 1] .. ' ' | ||
114 | versionDesc = versions[i + 2] | ||
115 | break | ||
116 | end | ||
117 | end | ||
118 | _M.VERSION = version .. versionName .. timestamp | ||
119 | _M.VERSION_DESC = versionDesc | ||
97 | -- TODO - If there's no skin passed in, try to find the file skin .. '.skang' and load that instead. | 120 | -- TODO - If there's no skin passed in, try to find the file skin .. '.skang' and load that instead. |
98 | _M.DEFAULT_SKANG = skin | 121 | _M.DEFAULT_SKANG = skin |
99 | 122 | ||
@@ -123,7 +146,7 @@ moduleEnd = function (module) | |||
123 | end | 146 | end |
124 | 147 | ||
125 | -- Call this now so that from now on, this is like any other module. | 148 | -- Call this now so that from now on, this is like any other module. |
126 | local _M = moduleBegin('skang', 'David Seikel', '2014', '0.0', '2014-03-19 19:01:00') | 149 | local _M = moduleBegin('skang', 'David Seikel', 'Copyright 2014 David Seikel', '0.1', '2014-03-27 02:57:00') |
127 | 150 | ||
128 | 151 | ||
129 | -- My clever boolean check, this is the third language I've written this in. B-) | 152 | -- My clever boolean check, this is the third language I've written this in. B-) |
diff --git a/ClientHamr/GuiLua/test.lua b/ClientHamr/GuiLua/test.lua index 96d46e6..f3dcb62 100644 --- a/ClientHamr/GuiLua/test.lua +++ b/ClientHamr/GuiLua/test.lua | |||
@@ -3,8 +3,7 @@ | |||
3 | do -- Only I'm not gonna indent this. | 3 | do -- Only I'm not gonna indent this. |
4 | 4 | ||
5 | local skang = require 'skang' | 5 | local skang = require 'skang' |
6 | --On the other hand, having 'Copyright 2014 David Seikel' here makes the copyright self documenting. B-) | 6 | local _M = skang.moduleBegin('test', nil, 'Copyright 2014 David Seikel', '0.1', '2014-03-27 03:57:00', [[ |
7 | local _M = skang.moduleBegin('test', 'David Seikel', '2014', '0.0', '2014-03-19 14:01:00', [[ | ||
8 | #!skang test.skang -- This is Lua, so this might not work. | 7 | #!skang test.skang -- This is Lua, so this might not work. |
9 | 8 | ||
10 | -- There's an implied local this = require 'test' | 9 | -- There's an implied local this = require 'test' |
@@ -49,6 +48,8 @@ end | |||
49 | local skang = require 'skang' | 48 | local skang = require 'skang' |
50 | local test = require 'test' | 49 | local test = require 'test' |
51 | 50 | ||
51 | print('MODULE ' .. test._NAME .. ', ' .. test.COPYRIGHT .. ' Version: ' .. test.VERSION .. '\n' .. test.VERSION_DESC .. '\n') | ||
52 | |||
52 | print('foo = ' .. test.foo .. ' ->> ' .. skang.things.foo.help) | 53 | print('foo = ' .. test.foo .. ' ->> ' .. skang.things.foo.help) |
53 | print('End ' .. test.bar .. ' ' .. test.VERSION .. ' ' .. skang.things.ffunc.help .. ' ->> ' .. skang.things.f.action) | 54 | print('End ' .. test.bar .. ' ' .. test.VERSION .. ' ' .. skang.things.ffunc.help .. ' ->> ' .. skang.things.f.action) |
54 | test.ffunc('one', 2) | 55 | test.ffunc('one', 2) |