Browse Source

Merge pull request #8 from bjornbytes/luvit

Luvit
Bjorn Swenson 9 years ago
parent
commit
b76c2d5f53
4 changed files with 77 additions and 26 deletions
  1. 42 17
      README.md
  2. 3 2
      doc/CONTRIBUTING.md
  3. 1 1
      rx.lua
  4. 31 6
      tools/build.lua

+ 42 - 17
README.md

@@ -3,32 +3,63 @@ RxLua [![Build Status](https://travis-ci.org/bjornbytes/RxLua.svg)](https://trav
 
 [Reactive Extensions](http://reactivex.io) for Lua.
 
-Examples
+RxLua gives Lua the power of Observables, which are data structures that represent a stream of values that arrive over time.  They're very handy when dealing with events, streams of data, asynchronous requests, and concurrency.
+
+Getting Started
 ---
 
-Cheer someone on using functional reactive programming:
+#### Lua
+
+Copy the `rx.lua` file into your project and require it:
+
+```lua
+local rx = require 'rx'
+```
+
+#### Luvit
+
+Install using `lit`:
+
+```sh
+lit install bjornbytes/rx
+```
+
+Then require it:
+
+```lua
+local rx = require 'rx'
+```
+
+#### Love2D
+
+See [RxLove](https://github.com/bjornbytes/RxLove).
+
+Example Usage
+---
+
+Use RxLua to construct a simple cheer:
 
 ```lua
 local Rx = require 'rx'
 
-Rx.Observable.fromRange(1, 4)
-  :map(function(x) return x * 2 end)
+Rx.Observable.fromRange(1, 8)
+  :filter(function(x) return x % 2 == 0 end)
   :concat(Rx.Observable.fromValue('who do we appreciate'))
   :map(function(value) return value .. '!' end)
   :subscribe(print)
+
+-- => 2! 4! 6! 8! who do we appreciate!
 ```
 
 See [examples](examples) for more.
 
-Documentation
+Resources
 ---
 
-See [here](doc).
-
-Contributing
----
-
-See [here](doc/CONTRIBUTING.md).
+- [Documentation](doc)
+- [Contributor Guide](doc/CONTRIBUTING.md)
+- [Trello board](https://trello.com/b/Q9dJicKK)
+- [Rx Introduction](http://reactivex.io/intro.html)
 
 Tests
 ---
@@ -45,12 +76,6 @@ or, to run a specific test:
 lua tests/runner.lua skipUntil
 ```
 
-Related
----
-
-- [Trello](https://trello.com/b/Q9dJicKK)
-- [RxLove](https://github.com/bjornbytes/RxLove)
-
 License
 ---
 

+ 3 - 2
doc/CONTRIBUTING.md

@@ -11,9 +11,10 @@ Tooling
 
 There are a number of scripts in the `tools` folder that automate certain tasks.  In general, they are run using `lua tools/<file>.lua` from the project root and take no arguments.
 
-- Everything in the `src` directory is concatenated into a single `rx.lua` file in the project root.  The file `tools/concat.lua` does this concatenation.  It strips out both the requires at the top of files and the return values at the bottom.
+- Everything in the `src` directory is concatenated into a single `rx.lua` file in the project root.  The file `tools/build.lua` does this concatenation.  It strips out both the requires at the top of files and the return values at the bottom.
+  - If you want to create a luvit build with additional features, you can run `lua tools/build.lua luvit`.
 - The documentation in `doc/README.md` is automatically generated based on comments in the source.  The file `tools/update_documentation.lua` performs this generation.  Internally it uses `docroc`, which is a library that parses Lua comments and returns them in a table.  From here, `update_documentation` converts the table to markdown and writes it to the `doc` directory.
-- Currently, you should run both of these scripts and include an updated `rx.lua` and `doc/README.md` as part of a pull request.  If you've added a new file you'll have to add it (alphabetized) to the file list in `tools/concat.lua`.
+- Currently, you should run both of these scripts and include an updated `rx.lua` and `doc/README.md` as part of a pull request.  If you've added a new file you'll have to add it (alphabetized) to the file list in `tools/build.lua`.
 
 Tests
 ---

+ 1 - 1
rx.lua

@@ -1,4 +1,4 @@
--- RxLua v0.0.1
+-- RxLua v0.0.2
 -- https://github.com/bjornbytes/rxlua
 -- MIT License
 

+ 31 - 6
tools/concat.lua → tools/build.lua

@@ -1,5 +1,6 @@
--- Horrible script to concatenate everything in /src into a single rx.lua file.
--- Usage: lua tools/concat.lua [dest=rx.lua]
+--- Horrible script to concatenate everything in /src into a single rx.lua file.
+-- @usage lua tools/build.lua [distribution=base]
+-- @arg {string='base'} distribution - Type of distribution to build, either 'base' or 'luvit'.
 
 local files = {
   'src/util.lua',
@@ -66,12 +67,22 @@ local files = {
 }
 
 local header = [[
--- RxLua v0.0.1
+-- RxLua v0.0.2
 -- https://github.com/bjornbytes/rxlua
 -- MIT License
 
 ]]
 
+local exports = [[
+exports.name = 'bjornbytes/rx'
+exports.version = '0.0.2'
+exports.description = 'Reactive Extensions for Lua'
+exports.license = 'MIT'
+exports.author = { url = 'https://github.com/bjornbytes' }
+exports.homepage = 'https://github.com/bjornbytes/rxlua'
+
+]]
+
 local footer = [[return {
   util = util,
   Subscription = Subscription,
@@ -104,8 +115,22 @@ for _, filename in ipairs(files) do
   output = output .. str .. '\n\n'
 end
 
-local outputFile = arg[1] or 'rx.lua'
-local file = io.open(outputFile, 'w')
+local distribution = arg[1] or 'base'
+local destination, components
+
+if distribution == 'base' then
+  destination = 'rx.lua'
+  components = { header, output, footer }
+elseif distribution == 'luvit' then
+  destination = 'rx-luvit.lua'
+  components = { header, exports, output, footer }
+else
+  error('Invalid distribution specified.')
+end
+
+local file = io.open(destination, 'w')
+
 if file then
-  file:write(header .. output .. footer)
+  file:write(table.concat(components, ''))
+  file:close()
 end