• Stars
    star
    1,883
  • Rank 24,628 (Top 0.5 %)
  • Language
    Lua
  • License
    MIT License
  • Created over 14 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A set of pure Lua libraries focusing on input data handling (such as reading configuration files), functional programming (such as map, reduce, placeholder expressions,etc), and OS path management. Much of the functionality is inspired by the Python standard libraries.

Penlight Lua Libraries

Unix build AppVeyor build status Coveralls code coverage Luacheck SemVer

Why a new set of libraries?

Penlight brings together a set of generally useful pure Lua modules, focusing on input data handling (such as reading configuration files), functional programming (such as map, reduce, placeholder expressions, etc), and OS path management. Much of the functionality is inspired by the Python standard libraries.

Module Overview

Paths, Files and Directories

  • path: queries like isdir,isfile,exists, splitting paths like dirname and basename
  • dir: listing files in directories (getfiles,getallfiles) and creating/removing directory paths
  • file: copy,move; read/write contents with read and write

Application Support

  • app: require_here to rebase require to work with main script path; simple argument parsing parse_args
  • lapp: sophisticated usage-text-driven argument parsing for applications
  • config: flexibly read Unix config files and Windows INI files
  • strict: check for undefined global variables - can use strict.module for modules
  • utils,compat: Penlight support for unified Lua 5.1/5.2 codebases
  • types: predicates like is_callable and is_integer; extended type function.

Extra String Operations

  • utils: can split a string with a delimiter using utils.split
  • stringx: extended string functions covering the Python string type
  • stringio: open strings for reading, and creating strings using standard Lua IO methods
  • lexer: lexical scanner for splitting text into tokens; special cases for Lua and C
  • text: indenting and dedenting text, wrapping paragraphs; optionally make % work as in Python
  • template: small but powerful template expansion engine
  • sip: Simple Input Patterns - higher-level string patterns for parsing text

Extra Table Operations

  • tablex: copying, comparing and mapping over
  • pretty: pretty-printing Lua tables, and various safe ways to load Lua as data
  • List: implementation of Python 'list' type - slices, concatenation and partitioning
  • Map, Set, OrderedMap: classes for specialized kinds of tables
  • data: reading tabular data into 2D arrays and efficient queries
  • array2d: operations on 2D arrays
  • permute: generate permutations

Iterators, OOP and Functional

  • seq: working with iterator pipelines; collecting iterators as tables
  • class: a simple reusable class framework
  • func: symbolic manipulation of expressions and lambda expressions
  • utils: utils.string_lambda converts short strings like '|x| x^2' into functions
  • comprehension: list comprehensions: C'x for x=1,4'()=={1,2,3,4}

Versioning

Penlight is strictly versioned according to Semantic Versioning.

In scope of the version:

  • functionality provided by Penlight modules/classes
  • based on stock Lua PuC-Rio or LuaJIT

Not in scope of the version:

  • Documentation
  • Error messages (textual changes)
  • Deprecation warnings (by default to stderr)

Deprecating functionality

Any version may deprecate functionality. So new deprecation notices may appear in major, minor, and patch releases. Final removal of functionality (assuming it is a breaking change) will only be done in a major version.

It is strongly suggested to use the deprecation warning mechanism to test usage of deprecated functionalities when upgrading. This is done by enabling the warning system (in Lua 5.4, or the Penlight compatibility function for earlier versions):

require "pl.compat"
warn "@on"

See pl.utils.raise_deprecation for more info.

License

Penlight is distributed under the MIT license.

Installation

Using LuaRocks: simply run luarocks install penlight.

Manually: copy lua/pl directory into your Lua module path. It's typically /usr/local/share/lua/5.x on a Linux system and C:\Program Files\Lua\5.x\lua for Lua for Windows.

Dependencies

The file and directory functions depend on LuaFileSystem, which is installed automatically if you are using LuaRocks. Additionally, if you want dir.copyfile to work elegantly on Windows, then you need Alien. Both libraries are present in Lua for Windows.

Building the Documentation

Requires ldoc, which is available through LuaRocks. Then it's a simple matter of running ldoc . from the repo.

Contributing

Contributions are most welcome, please check the contribution guidelines.

Running tests

Execute lua run.lua tests to run the tests. Execute lua run.lua examples to run examples.

History

For a complete history of the development of Penlight, please check the changelog.

More Repositories

1

luasocket

Network support for the Lua language
HTML
1,814
star
2

busted

Elegant Lua unit testing.
Lua
1,387
star
3

luafilesystem

LuaFileSystem is a Lua library developed to complement the set of functions related to file systems offered by the standard Lua distribution.
C
891
star
4

ldoc

LDoc is a LuaDoc-compatible documentation generator which can also process C extension source. Markdown may be optionally used to render comments, as well as integrated readme documentation and pretty-printed example files.
Lua
774
star
5

luasql

LuaSQL is a simple interface from Lua to a DBMS.
Lua
536
star
6

luasec

LuaSec
C
364
star
7

luacov

LuaCov is a simple coverage analyzer for Lua code.
Lua
295
star
8

lua-compat-5.3

Compatibility module providing Lua-5.3-style APIs for Lua 5.2 and 5.1
C
225
star
9

luassert

Assertion library for Lua
Lua
202
star
10

copas

Copas is a dispatcher based on coroutines that can be used by TCP/IP servers.
Lua
202
star
11

lua_cliargs

A command-line argument parsing module for Lua.
Lua
120
star
12

md5

MD5 offers basic cryptographic facilities for Lua 5.1.
C
109
star
13

cgilua

CGILua is a tool for creating dynamic HTML pages and manipulating input data from Web forms.
Lua
93
star
14

lua-iconv

Lua bindings for POSIX iconv
Lua
90
star
15

lualogging

A simple API to use logging features in Lua
Lua
51
star
16

say

Lua string hashing library, useful for internationalization
Lua
45
star
17

luaexpat

LuaExpat is a SAX XML parser based on the Expat library
Lua
23
star
18

luasystem

Platform independent system calls for Lua
C
19
star
19

lua-mimetypes

fixed repo of https://luarocks.org/modules/luarocks/mimetypes
Lua
6
star
20

luasyslog

Addon for lualogging to log to the system log on unix systems
Lua
6
star
21

moon-sand

Sandbox to mess with CI‌ deployments using LunarModules CI key(s)
Lua
2
star
22

expadom

An XML DOM Level 2 Core implementation in Lua, based on the (Lua)Expat parser.
Lua
2
star
23

lunarmodules

providing the profile page (README.md) for the Lunar Modules organization
2
star
24

.github

Lunarmodules profile page and reusable workflows
2
star
25

lua-lace

Lua Access Control Engine
Lua
2
star