summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2024-02-09 21:56:33 +0100
committerAki <please@ignore.pl>2024-02-09 21:56:33 +0100
commit9b1f5d2b5554c0ff9f355866d4669b3ffcaa3686 (patch)
tree3e04f1f09244e712e61220baae8857ec21906111
parentd41c7d0e1d864bec20cd917354fe82330d0781d5 (diff)
downloadactivity-9b1f5d2b5554c0ff9f355866d4669b3ffcaa3686.zip
activity-9b1f5d2b5554c0ff9f355866d4669b3ffcaa3686.tar.gz
activity-9b1f5d2b5554c0ff9f355866d4669b3ffcaa3686.tar.bz2
Moved the standalone activity.lua into activity.generators
-rw-r--r--Makefile11
-rw-r--r--activity/generators.lua (renamed from activity.lua)6
-rwxr-xr-x[-rw-r--r--]generate.lua7
-rw-r--r--spec/generators_spec.lua (renamed from spec/activity_spec.lua)16
4 files changed, 19 insertions, 21 deletions
diff --git a/Makefile b/Makefile
index 4ea4d71..236b04d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,6 @@
-LUA_VERSION?=5.4
-PREFIX?=/usr/local
+LUA_VERSION=5.4
+PREFIX=/usr/local
BINDIR=$(PREFIX)/bin
-LIBDIR=$(PREFIX)/lib
DATADIR=$(PREFIX)/share
LUA_LMOD=$(DATADIR)/lua/$(LUA_VERSION)
@@ -9,15 +8,13 @@ all:
@echo Nothing to be built
install:
- install -m644 -Dt $(DESTDIR)$(LUA_LMOD) activity.lua
install -m644 -Dt $(DESTDIR)$(LUA_LMOD)/activity activity/*.lua
install -m644 -Dt $(DESTDIR)$(LUA_LMOD)/activity/formats activity/formats/*.lua
- install -m755 -Dt $(DESTDIR)$(BINDIR) generate.lua
+ install -m755 -DT generate.lua $(DESTDIR)$(BINDIR)/activity
uninstall:
- rm -f $(DESTDIR)$(LUA_LMOD)/activity.lua
rm -rf $(DESTDIR)$(LUA_LMOD)/activity
- rm -f $(DESTIR)$(BINDIR)/generate.lua
+ rm -f $(DESTIR)$(BINDIR)/activity
test:
busted
diff --git a/activity.lua b/activity/generators.lua
index 55cb061..ff7f0a9 100644
--- a/activity.lua
+++ b/activity/generators.lua
@@ -1,6 +1,6 @@
local dates = require "activity.dates"
local git = require "activity.git"
-local activity = {}
+local generators = {}
local
@@ -50,7 +50,7 @@ function generate_rolling (lookup, format, date)
end
-function activity.generate_table (year, lookup, format, ...)
+function generators.generate_table (year, lookup, format, ...)
if year == "rolling" then
return generate_rolling(lookup, format, ...)
end
@@ -94,4 +94,4 @@ function activity.generate_table (year, lookup, format, ...)
end
-return activity
+return generators
diff --git a/generate.lua b/generate.lua
index cea6a87..478bc9d 100644..100755
--- a/generate.lua
+++ b/generate.lua
@@ -6,15 +6,16 @@ Generates activity chart
-R Generate rolling chart
<repos...> (optional string) Paths to repositories with activity
]]
-local activity = require "activity"
+local generators = require "activity.generators"
local git = require "activity.git"
local ok, maybe_format = pcall(require, "activity.formats." .. args.f)
if not ok then
- io.stderr:write(("couldn't find specified format: %q\n"):format(args.f))
+ io.stderr:write(("could not find specified format: %q\n\n"):format(args.f))
+ io.stderr:write(maybe_format, "\n")
os.exit(1)
end
local maybe_year = args.y
if args.R then
maybe_year = "rolling"
end
-io.write(activity.generate_table(maybe_year, git.lookup(args.repos), maybe_format))
+io.write(generators.generate_table(maybe_year, git.lookup(args.repos), maybe_format))
diff --git a/spec/activity_spec.lua b/spec/generators_spec.lua
index 38338e8..a6c1e9a 100644
--- a/spec/activity_spec.lua
+++ b/spec/generators_spec.lua
@@ -1,5 +1,5 @@
-local activity = require "activity"
local dates = require "activity.dates"
+local generators = require "activity.generators"
local plain = require "activity.formats.plain"
local Y2024 = [[
@@ -52,15 +52,15 @@ end
describe("Yearly chart generator", function()
describe("shall generate empty table for year", function()
it("2024", function()
- assert.are.equal(Y2024, activity.generate_table(2024, always_zero, plain))
+ assert.are.equal(Y2024, generators.generate_table(2024, always_zero, plain))
end)
it("2023", function()
- assert.are.equal(Y2023, activity.generate_table(2023, always_zero, plain))
+ assert.are.equal(Y2023, generators.generate_table(2023, always_zero, plain))
end)
it("2020", function()
- assert.are.equal(Y2020, activity.generate_table(2020, always_zero, plain))
+ assert.are.equal(Y2020, generators.generate_table(2020, always_zero, plain))
end)
end)
@@ -74,11 +74,11 @@ describe("Yearly chart generator", function()
end
it("regular years", function()
- assert.are.equal(Y2023:gsub("0", "1"), activity.generate_table(2023, lookup, plain))
+ assert.are.equal(Y2023:gsub("0", "1"), generators.generate_table(2023, lookup, plain))
end)
it("leap years", function()
- assert.are.equal(Y2024:gsub("0", "1"), activity.generate_table(2024, lookup, plain))
+ assert.are.equal(Y2024:gsub("0", "1"), generators.generate_table(2024, lookup, plain))
end)
end)
end)
@@ -87,7 +87,7 @@ end)
describe("Rolling chart generator", function()
it("shall generate empty table", function()
local date = os.date("*t", os.time{year=2024, month=2, day=8})
- assert.are.equal(ROLL, activity.generate_table("rolling", always_zero, plain, date))
+ assert.are.equal(ROLL, generators.generate_table("rolling", always_zero, plain, date))
end)
it("shall put activity into cells", function()
@@ -103,6 +103,6 @@ describe("Rolling chart generator", function()
return 0
end
- assert.are.equal(ROLL:gsub("0", "1"), activity.generate_table("rolling", lookup, plain, date))
+ assert.are.equal(ROLL:gsub("0", "1"), generators.generate_table("rolling", lookup, plain, date))
end)
end)