Skip to content

Commit

Permalink
Format.
Browse files Browse the repository at this point in the history
  • Loading branch information
ostinelli committed Nov 16, 2013
1 parent 670c03e commit 41a9576
Show file tree
Hide file tree
Showing 38 changed files with 76 additions and 27 deletions.
4 changes: 2 additions & 2 deletions gin/cli/api_console.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-- init module dependencies
-- gin
local Application = require 'config/application'

local GinApiConsole = {}


GinApiConsole.html = [====[
<!DOCTYPE html>
Expand Down
2 changes: 2 additions & 0 deletions gin/cli/application.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
-- dep
local ansicolors = require 'ansicolors'

-- gin
local Gin = require 'gin.core.gin'
local helpers = require 'gin.helpers.common'

Expand Down
5 changes: 2 additions & 3 deletions gin/cli/base_launcher.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
-- dependencies
-- dep
local lfs = require 'lfs'

-- gin
local Gin = require 'gin.core.gin'

require 'gin.core.gin'


local function create_dirs(necessary_dirs)
for _, dir in pairs(necessary_dirs) do
Expand Down
2 changes: 2 additions & 0 deletions gin/cli/console.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
-- dep
local ansicolors = require 'ansicolors'
local prettyprint = require 'pl.pretty'

-- gin
local Gin = require 'gin.core.gin'


local GinConsole = {}

function GinConsole.start()
Expand Down
3 changes: 2 additions & 1 deletion gin/cli/launcher.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-- dependencies
-- dep
local ansicolors = require 'ansicolors'

-- gin
local Gin = require 'gin.core.gin'
local BaseLauncher = require 'gin.cli.base_launcher'
local helpers = require 'gin.helpers.common'
Expand Down
2 changes: 1 addition & 1 deletion gin/cli/migrations.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- dependencies
-- dep
local ansicolors = require 'ansicolors'

-- gin
Expand Down
2 changes: 1 addition & 1 deletion gin/core/detached.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-- detached modules
-- detached
local adapter_mysql = require 'gin.db.sql.mysql.adapter_detached'
package.loaded['gin.db.sql.mysql.adapter'] = adapter_mysql
6 changes: 6 additions & 0 deletions gin/core/error.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
-- gin
local helpers = require 'gin.helpers.common'

-- perf
local error = error
local pairs = pairs
local setmetatable = setmetatable


-- define error
Error = {}
Expand Down
7 changes: 5 additions & 2 deletions gin/core/gin.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
-- settings
-- gin
local settings = require 'gin.core.settings'

-- perf
local ogetenv = os.getenv


local Gin = {}

-- version
Gin.version = '0.1'

-- environment
Gin.env = os.getenv("GIN_ENV") or 'development'
Gin.env = ogetenv("GIN_ENV") or 'development'

-- directories
Gin.app_dirs = {
Expand Down
8 changes: 5 additions & 3 deletions gin/core/request.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
-- dependencies
-- dep
local json = require 'cjson'

-- perf
local error = error
local jdecode = json.decode
local pcall = pcall
local rawget = rawget
local setmetatable = setmetatable
local jdecode = json.decode


local Request = {}
Expand All @@ -23,7 +25,7 @@ function Request.new(ngx)
ok, json_or_error = pcall(function() return jdecode(body_raw) end)
if ok == false then error({ code = 103 }) end
if json_or_error[1] ~= nil then error({ code = 104 }) end
body= json_or_error
body = json_or_error
end

-- init instance
Expand Down
2 changes: 1 addition & 1 deletion gin/core/router.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package.path = './app/controllers/?.lua;' .. package.path

-- dependencies
-- dep
local json = require 'cjson'

-- gin
Expand Down
2 changes: 1 addition & 1 deletion gin/core/routes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ local setmetatable = setmetatable
local sgsub = string.gsub
local smatch = string.match
local tinsert = table.insert
local type = type
local tostring = tostring
local type = type


-- versions
Expand Down
3 changes: 1 addition & 2 deletions gin/core/settings.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
-- gin
local helpers = require 'gin.helpers.common'

-- perf
local pairs = pairs
local pcall = pcall
local require = require


local GinSettings = {}
Expand Down
2 changes: 1 addition & 1 deletion gin/db/migrations.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- run in detached mode
-- detached
require 'gin.core.detached'

-- gin
Expand Down
6 changes: 6 additions & 0 deletions gin/db/sql.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-- perf
local error = error
local pairs = pairs
local require = require
local setmetatable = setmetatable


local required_options = {
adapter = true,
Expand Down
3 changes: 2 additions & 1 deletion gin/db/sql/mysql/adapter.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
-- perf
local error = error
local ipairs = ipairs
local pairs = pairs
local require = require
local tinsert = table.insert
local error = error
local tonumber = tonumber

-- settings
local timeout_subsequent_ops = 1000 -- 1 sec
Expand Down
4 changes: 4 additions & 0 deletions gin/db/sql/mysql/adapter_detached.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ local Gin = require 'gin.core.gin'
-- perf
local assert = assert
local ipairs = ipairs
local pairs = pairs
local pcall = pcall
local setmetatable = setmetatable
local smatch = string.match
local tinsert = table.insert
local tonumber = tonumber

-- settings
local mysql_default_database = 'mysql'


-- deepcopy of a table
local function deepcopy(orig)
local orig_type = type(orig)
Expand Down
5 changes: 3 additions & 2 deletions gin/db/sql/mysql/orm.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
-- perf
local next = next
local pairs = pairs
local setmetatable = setmetatable
local tconcat = table.concat
local tinsert = table.insert
local type = type
local next = next


-- field and values helper
local function field_and_values(quote, attrs, concat)
local fav = {}
for field, value in pairs(attrs) do
Expand Down
1 change: 1 addition & 0 deletions gin/helpers/command.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-- dep
local prettyprint = require 'pl.pretty'


-- pretty print
function pp(o)
prettyprint.dump(o)
Expand Down
8 changes: 6 additions & 2 deletions gin/helpers/common.lua
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
-- dependencies
-- dep
local lfs = require 'lfs'
local prettyprint = require 'pl.pretty'

-- perf
local iopen = io.open
local ipairs = ipairs
local pairs = pairs
local pcall = pcall
local require = require
local sfind = string.find
local sgsub = string.gsub
local smatch = string.match
local ssub = string.sub
local tinsert = table.insert
local type = type


local CommonHelpers = {}
Expand Down Expand Up @@ -120,7 +124,7 @@ end

-- get the lua module name
function CommonHelpers.get_lua_module_name(file_path)
return string.match(file_path, "(.*)%.lua")
return smatch(file_path, "(.*)%.lua")
end

-- shallow copy of a table
Expand Down
1 change: 1 addition & 0 deletions gin/spec/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package.path = './?.lua;' .. package.path
-- gin
local helpers = require 'gin.helpers.common'


-- ensure test environment is specified
local posix = require "posix"
posix.setenv("GIN_ENV", 'test')
Expand Down
2 changes: 2 additions & 0 deletions gin/spec/runner.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
-- gin
require 'gin.spec.init'


-- add integration runner
local IntegrationRunner = require 'gin.spec.runners.integration'

Expand Down
2 changes: 1 addition & 1 deletion gin/spec/runners/integration.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- dependencies
-- dep
local http = require 'socket.http'
local url = require 'socket.url'
local json = require 'cjson'
Expand Down
3 changes: 1 addition & 2 deletions gin/spec/runners/response.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-- dep
local json = require 'cjson'


Expand All @@ -18,8 +19,6 @@ function ResponseSpec.new(options)
if options.body ~= nil and trim(options.body) ~= "" then
ok, json_body = pcall(function() return json.decode(options.body) end)
if ok == false then json_body = nil end
-- json_body = json.decode(options.body)
-- if type(json_body) ~= 'table' then json_body = nil end
end

-- init instance
Expand Down
1 change: 1 addition & 0 deletions spec/core/controller_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'spec.spec_helper'


describe("Controller", function()
before_each(function()
Controller = require 'gin.core.controller'
Expand Down
1 change: 0 additions & 1 deletion spec/core/error_spec.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'spec.spec_helper'



describe("Error", function()
before_each(function()
Error = require 'gin.core.error'
Expand Down
2 changes: 2 additions & 0 deletions spec/core/request_spec.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
require 'spec.spec_helper'

-- gin
local Request = require 'gin.core.request'


describe("Request", function()
before_each(function()
ngx = {
Expand Down
2 changes: 2 additions & 0 deletions spec/core/response_spec.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
require 'spec.spec_helper'

-- gin
local Response = require 'gin.core.response'


describe("Response", function()
describe(".new", function()
describe("when no options are passed in", function()
Expand Down
1 change: 1 addition & 0 deletions spec/core/router_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'spec.spec_helper'


describe("Router", function()
before_each(function()
-- stub application packages
Expand Down
1 change: 1 addition & 0 deletions spec/core/routes_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'spec.spec_helper'


describe("Routes", function()

before_each(function()
Expand Down
1 change: 1 addition & 0 deletions spec/core/settings_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'spec.spec_helper'


describe("Settings", function()

before_each(function()
Expand Down
1 change: 1 addition & 0 deletions spec/core/zebra_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'spec.spec_helper'


describe("Gin", function()
before_each(function()
package.loaded['gin.core.gin'] = nil
Expand Down
1 change: 1 addition & 0 deletions spec/db/migrations_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ CREATE TABLE schema_migrations (
);
]]


describe("Migrations", function()
before_each(function()
migrations = require 'gin.db.migrations'
Expand Down
1 change: 1 addition & 0 deletions spec/db/sql/mysql/orm_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'spec.spec_helper'


describe("MySqlOrm", function()

before_each(function()
Expand Down
3 changes: 3 additions & 0 deletions spec/db/sql/orm_spec.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
require 'spec.spec_helper'

-- gin
local helpers = require 'gin.helpers.common'


describe("SqlOrm", function()

before_each(function()
Expand Down
1 change: 1 addition & 0 deletions spec/db/sql_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'spec.spec_helper'


describe("Database SQL", function()
before_each(function()
SqlDatabase = require 'gin.db.sql'
Expand Down
1 change: 1 addition & 0 deletions spec/spec/runners/integration_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'spec.spec_helper'


describe("Integration", function()
before_each(function()
IntegrationRunner = require 'gin.spec.runners.integration'
Expand Down
1 change: 1 addition & 0 deletions spec/spec/runners/response_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'spec.spec_helper'


describe("ResponseSpec", function()
before_each(function()
ResponseSpec = require 'gin.spec.runners.response'
Expand Down

0 comments on commit 41a9576

Please sign in to comment.