Skip to content

Commit f3c7145

Browse files
committed
Update repository to match other projects
1 parent 09edb9c commit f3c7145

File tree

10 files changed

+211
-34
lines changed

10 files changed

+211
-34
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
root = true
22

3-
[*]
3+
[*.lua]
44
indent_style = tab
55
end_of_line = lf
66
charset = utf-8

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
/modules
22
/luacov.*
3-
/rodux-installer.lua
3+
/installer.lua

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ before_install:
1515
- export PATH=$PATH:$PWD/lua_install/bin
1616

1717
install:
18+
- luarocks install luafilesystem
1819
- luarocks install busted
1920
- luarocks install luacov
2021
- luarocks install luacov-coveralls
2122
- luarocks install luacheck
22-
- ./install-dependencies
23+
- lua bin/install-dependencies.lua
2324

2425
script:
2526
- luacheck lib

CONTRIBUTING.md

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,72 @@
11
# Contributing to Rodux
2-
TODO
2+
Thanks for considering contributing to Rodux! This guide has a few tips and guidelines to make contributing to the project as easy as possible.
3+
4+
## Bug Reports
5+
Any bugs (or things that look like bugs) can be reported on the [GitHub issue tracker](https://github.com/Roblox/Rodux/issues).
6+
7+
Make sure you check to see if someone has already reported your bug first! Don't fret about it; if we notice a duplicate we'll send you a link to the right issue!
8+
9+
## Feature Requests
10+
If there are any features you think are missing from Rodux, you can post a request in the [GitHub issue tracker](https://github.com/Roblox/Rodux/issues).
11+
12+
Just like bug reports, take a peak at the issue tracker for duplicates before opening a new feature request.
13+
14+
## Working on Rodux
15+
To get started working on Rodux, you'll need:
16+
* Git
17+
* Lua 5.1
18+
* [LuaFileSystem](https://keplerproject.github.io/luafilesystem/) (`luarocks install luafilesystem`)
19+
* [Luacheck](https://github.com/mpeterv/luacheck) (`luarocks install luacheck`)
20+
* [LuaCov](https://keplerproject.github.io/luacov) (`luarocks install luacov`)
21+
22+
Once you have all of these installed, you can run the `install-dependencies` script to grab a couple additional local dependencies automatically.
23+
24+
Finally, you can run all of Rodux's tests with:
25+
26+
```sh
27+
lua spec.lua
28+
```
29+
30+
Or, to generate a LuaCov coverage report:
31+
32+
```sh
33+
lua -lluacov spec.lua
34+
luacov
35+
```
36+
37+
## Pull Requests
38+
Before starting a pull request, open an issue about the feature or bug. This helps us prevent duplicated and wasted effort. These issues are a great place to ask for help if you run into problems!
39+
40+
Before you submit a new pull request, check:
41+
* Code Style: Match the existing code!
42+
* Changelog: Add an entry to [CHANGELOG.md](CHANGELOG.md)
43+
* Luacheck: Run [Luacheck](https://github.com/mpeterv/luacheck) on your code, no warnings allowed!
44+
* Tests: They all need to pass!
45+
46+
### Code Style
47+
Try to match the existing code style! In short:
48+
49+
* Tabs for indentation
50+
* Double quotes
51+
* One statement per line
52+
53+
Eventually we'll have a tool to check these things automatically.
54+
55+
### Changelog
56+
Adding an entry to [CHANGELOG.md](CHANGELOG.md) alongside your commit makes it easier for everyone to keep track of what's been changed.
57+
58+
Add a line under the "Current master" heading. When we make a new release, all of those bullet points will be attached to a new version and the "Current master" section will become empty again.
59+
60+
### Luacheck
61+
We use [Luacheck](https://github.com/mpeterv/luacheck) for static analysis of Lua on all of our projects.
62+
63+
From the command line, just run `luacheck lib` to check the Rodux source.
64+
65+
You should get it working on your system, and then get a plugin for the editor you use. There are plugins available for most popular editors!
66+
67+
### Tests
68+
When submitting a bug fix, create a test that verifies the broken behavior and that the bug fix works. This helps us avoid regressions!
69+
70+
When submitting a new feature, add tests for all functionality.
71+
72+
We use [LuaCov](https://keplerproject.github.io/luacov) for keeping track of code coverage. We'd like it to be as close to 100% as possible, but it's not always easy.

README.md

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<img src="https://coveralls.io/repos/github/Roblox/Rodux/badge.svg?branch=master" alt="Coveralls Coverage" />
88
</a>
99
<a href="#">
10-
<img src="https://img.shields.io/badge/docs-website-brightgreen.svg" alt="Documentation" />
10+
<img src="https://img.shields.io/badge/docs-soon-red.svg" alt="Documentation" />
1111
</a>
1212
</div>
1313

@@ -32,9 +32,40 @@ This installation script is generated by a tool called [rbxpacker](https://githu
3232
* Use a plugin like [rbxfs](https://github.com/LPGhatguy/rbxfs) to sync the files into a place
3333

3434
## Usage
35-
TODO
35+
Rodux works just like [Redux](https://redux.js.org)'s base API with the addition of [Redux Thunk](https://github.com/gaearon/redux-thunk) for simple side effects.
3636

37-
## License
38-
Rodux is available under the Apache 2.0 license. See [LICENSE](LICENSE) for details.
37+
Documentation is currently in progress!
38+
39+
```lua
40+
local Rodux = require(script.Parent.Rodux)
41+
42+
local function reducer(state, action)
43+
state = state or {
44+
frobulations = 0,
45+
}
46+
47+
if action.type == "frobulate" then
48+
return {
49+
frobulations = state.frobulations + 1,
50+
}
51+
end
52+
53+
return state
54+
end
55+
56+
local store = Rodux.store.new(reducer)
3957

40-
For easy distribution, the license is duplicated in [lib/LICENSE.lua](lib/LICENSE.lua).
58+
store:getState() -- { frobulations = 0 }
59+
60+
store:dispatch({
61+
type = "frobulate",
62+
})
63+
64+
store:getState() -- { frobulations = 1 }
65+
```
66+
67+
## Contributing
68+
Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for information.
69+
70+
## License
71+
Rodux is available under the Apache 2.0 license. See [LICENSE](LICENSE) for details.

bin/build-installer.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--[[
2+
Generates an install script using rbxpacker.
3+
4+
It should be run from the project directory, like:
5+
6+
lua bin/build-installer.lua
7+
]]
8+
9+
os.exit(os.execute("rbxpacker --exclude **/*.spec.lua --folder Rodux --name Rodux lib LICENSE > installer.lua"))

bin/install-dependencies.lua

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--[[
2+
Dependencies added here will be installed into the `modules` folder.
3+
4+
It should be run from the project directory, like:
5+
6+
lua bin/install-dependencies.lua
7+
]]
8+
9+
local dependencies = {
10+
lemur = {
11+
git = "https://github.com/LPGhatguy/lemur.git",
12+
version = "v0.1.0",
13+
},
14+
testez = {
15+
git = "https://github.com/Roblox/TestEZ.git",
16+
version = "master",
17+
},
18+
}
19+
20+
local lfs = require("lfs")
21+
22+
lfs.mkdir("modules")
23+
assert(lfs.chdir("modules"))
24+
25+
for name, dependency in pairs(dependencies) do
26+
os.execute(("git clone --depth=1 %s %s"):format(
27+
dependency.git,
28+
name
29+
))
30+
31+
assert(lfs.chdir(name))
32+
os.execute(("git checkout %s"):format(
33+
dependency.version
34+
))
35+
36+
assert(lfs.chdir(".."))
37+
end

build-installer

Lines changed: 0 additions & 3 deletions
This file was deleted.

install-dependencies

Lines changed: 0 additions & 4 deletions
This file was deleted.

spec.lua

Lines changed: 54 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,69 @@
1+
--[[
2+
Loads our library and all of its dependencies, then runs tests using TestEZ.
3+
]]
4+
5+
-- If you add any dependencies, add them to this table so they'll be loaded!
6+
local LOAD_MODULES = {
7+
{"lib", "Library"},
8+
{"modules/testez/lib", "TestEZ"},
9+
}
10+
11+
-- This makes sure we can load Lemur and other libraries that depend on init.lua
12+
package.path = package.path .. ";?/init.lua"
13+
14+
-- If this fails, make sure you've run `lua bin/install-dependencies.lua` first!
115
local lemur = require("modules.lemur")
216

3-
local habitat = lemur.Habitat.new()
17+
--[[
18+
Collapses ModuleScripts named 'init' into their parent folders.
19+
20+
This is the same behavior as the collapsing mechanism from rbxpacker.
21+
]]
22+
local function collapse(root)
23+
local init = root:FindFirstChild("init")
24+
if init then
25+
init.Name = root.Name
26+
init.Parent = root.Parent
427

5-
local Rodux = lemur.Instance.new("Folder")
6-
Rodux.Name = "Rodux"
7-
habitat:loadFromFs("lib", Rodux)
28+
for _, child in ipairs(root:GetChildren()) do
29+
child.Parent = init
30+
end
831

9-
-- Simulate rbxpacker's 'collapse' mechanism
10-
do
11-
local newRoot = Rodux:FindFirstChild("init")
12-
newRoot.Name = Rodux.Name
13-
newRoot.Parent = nil
32+
root:Destroy()
33+
root = init
34+
end
1435

15-
for _, child in ipairs(Rodux:GetChildren()) do
16-
child.Parent = newRoot
36+
for _, child in ipairs(root:GetChildren()) do
37+
if child:IsA("Folder") then
38+
collapse(child)
39+
end
1740
end
1841

19-
Rodux = newRoot
42+
return root
43+
end
44+
45+
-- Create a virtual Roblox tree
46+
local habitat = lemur.Habitat.new()
47+
48+
-- We'll put all of our library code and dependencies here
49+
local Root = lemur.Instance.new("Folder")
50+
Root.Name = "Root"
51+
52+
-- Load all of the modules specified above
53+
for _, module in ipairs(LOAD_MODULES) do
54+
local container = lemur.Instance.new("Folder", Root)
55+
container.Name = module[2]
56+
habitat:loadFromFs(module[1], container)
2057
end
2158

22-
local TestEZ = lemur.Instance.new("Folder")
23-
TestEZ.Name = "TestEZ"
24-
habitat:loadFromFs("modules/testez/lib", TestEZ)
59+
collapse(Root)
2560

26-
local TestBootstrap = habitat:require(TestEZ.TestBootstrap)
27-
local TextReporter = habitat:require(TestEZ.Reporters.TextReporter)
61+
-- Load TestEZ and run our tests
62+
local TestEZ = habitat:require(Root.TestEZ)
2863

29-
local results = TestBootstrap:run(Rodux, TextReporter)
64+
local results = TestEZ.TestBootstrap:run(Root.Library, TestEZ.Reporters.TextReporter)
3065

66+
-- Did something go wrong?
3167
if results.failureCount > 0 then
3268
os.exit(1)
3369
end

0 commit comments

Comments
 (0)