aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/guff/database.cr30
-rw-r--r--src/guff/models/post.cr52
-rw-r--r--src/guff/models/tag.cr10
-rw-r--r--src/guff/results.cr8
-rw-r--r--src/guff/template.cr2
-rw-r--r--src/guff/views/html/page.cr2
6 files changed, 52 insertions, 52 deletions
diff --git a/src/guff/database.cr b/src/guff/database.cr
index 1bec00a..8559f36 100644
--- a/src/guff/database.cr
+++ b/src/guff/database.cr
@@ -40,8 +40,8 @@ module Guff
end
def one(
- sql : String,
- args = nil : Array(String) | Hash(String, String) | Nil
+ sql : String,
+ args : Array(String) | Hash(String, String) | Nil = nil
)
r = nil
@@ -56,8 +56,8 @@ module Guff
end
def row(
- sql : String,
- args = nil : Array(String) | Hash(String, String) | Nil
+ sql : String,
+ args : Array(String) | Hash(String, String) | Nil = nil
)
r = nil
@@ -71,9 +71,9 @@ module Guff
end
def all(
- sql : String,
- args = nil : Array(String) | Hash(String, String) | Nil,
- &block : Hash(String, ::SQLite3::Value) -> \
+ sql : String,
+ args : Array(String) | Hash(String, String) | Nil = nil,
+ &block : Hash(String, ::SQLite3::Value) -> \
)
# build statement
run(sql, args) do |rs|
@@ -98,8 +98,8 @@ module Guff
end
def query(
- sql : String,
- args = nil : Array(String) | Hash(String, String) | Nil,
+ sql : String,
+ args : Array(String) | Hash(String, String) | Nil = nil,
)
run(sql, args) do |rs|
# make sure query executes
@@ -113,9 +113,9 @@ module Guff
# or the query will _not_ execute!!!
#
def query(
- sql : String,
- args = nil : Array(String) | Hash(String, String) | Nil,
- &block : ::SQLite3::ResultSet -> \
+ sql : String,
+ args : Array(String) | Hash(String, String) | Nil = nil,
+ &block : ::SQLite3::ResultSet -> \
)
run(sql, args, &block)
end
@@ -152,9 +152,9 @@ module Guff
end
private def run(
- sql : String,
- args = nil : Array(String | Hash(String, String))?,
- &block : ::SQLite3::ResultSet -> \
+ sql : String,
+ args : Array(String | Hash(String, String))? = nil,
+ &block : ::SQLite3::ResultSet -> \
)
# build statement
puts "sql = %s" % [sql]
diff --git a/src/guff/models/post.cr b/src/guff/models/post.cr
index 826bb7c..fa34c2d 100644
--- a/src/guff/models/post.cr
+++ b/src/guff/models/post.cr
@@ -156,13 +156,13 @@ module Guff
#####################
def get_posts(
- cols = nil : Array(String)?,
- site_id = nil : Int?,
- filters = {} of Symbol => String : Hash(Symbol, String),
- tags = [] of Array(String) : Array(Array(String)),
- page = 1 : Int,
- limit = 20 : Int,
- sort = nil : Array(Hash(String, String))?,
+ cols : Array(String)? = nil,
+ site_id : Int? = nil,
+ filters : Hash(Symbol, String) = {} of Symbol => String,
+ tags : Array(Array(String)) = [] of Array(String),
+ page : Int = 1,
+ limit : Int = 20,
+ sort : Array(Hash(String, String))? = nil,
)
# build sql args
sql_args = {
@@ -298,7 +298,7 @@ module Guff
}]
private def get_sort_clause(
- sort = nil : Array(Hash(String, String))?
+ sort : Array(Hash(String, String))? = nil
) : String
(sort || GET_POSTS_DEFAULT_SORT).map { |row|
# verify sort column
@@ -350,12 +350,12 @@ module Guff
####################
def add_post(
- site_id = nil : Int?,
- slug = "" : String,
- name = "" : String,
- body = "" : String,
- tags = [] of String : Array(String),
- state = "draft" : String?,
+ site_id : Int? = nil,
+ slug : String = "",
+ name : String = "",
+ body : String = "",
+ tags : Array(String) = [] of String,
+ state : String? = "draft",
) : Int64
post_id = -1_i64
@@ -394,13 +394,13 @@ module Guff
#######################
def update_post(
- site_id = nil : Int?,
- post_id = nil : Int?,
- slug = nil : String?,
- name = nil : String?,
- body = nil : String?,
- tags = nil : Array(String)?,
- state = nil : String?
+ site_id : Int? = nil,
+ post_id : Int? = nil,
+ slug : String? = nil,
+ name : String? = nil,
+ body : String? = nil,
+ tags : Array(String)? = nil,
+ state : String? = nil
)
raise "null post_id" if post_id.nil?
@@ -470,8 +470,8 @@ module Guff
################
def remove_posts(
- site_id = nil : Int?,
- post_ids = [] of Int : Array(Int)
+ site_id : Int? = nil,
+ post_ids : Array(Int) = [] of Int,
)
query(:remove_posts, {
"site_id": (site_id || @models.site.get_default).to_s,
@@ -490,9 +490,9 @@ module Guff
####################
def set_tags(
- site_id = nil : Int?,
- post_id = nil : Int?,
- tags = [] of String : Array(String),
+ site_id : Int? = nil,
+ post_id : Int? = nil,
+ tags : Array(String) = [] of String,
)
return unless post_id
diff --git a/src/guff/models/tag.cr b/src/guff/models/tag.cr
index 46a69eb..f4232ce 100644
--- a/src/guff/models/tag.cr
+++ b/src/guff/models/tag.cr
@@ -47,8 +47,8 @@ module Guff
end
def get_tags(
- tags = [] of String : Array(String),
- show_all = false : Bool,
+ tags : Array(String) = [] of String,
+ show_all : Bool = false,
) : Array(Hash(String, String | Int32))
r = [] of Hash(String, String | Int32)
@@ -81,7 +81,7 @@ module Guff
end
def add_tags(
- tags = [] of String : Array(String)
+ tags : Array(String) = [] of String,
)
missing_tags = get_missing_tags(tags)
@@ -95,7 +95,7 @@ module Guff
end
private def get_missing_tags(
- tags = [] of String : Array(String)
+ tags : Array(String) = [] of String,
) : Array(String)
# get ids of existing tags
ids = get_ids(tags)
@@ -105,7 +105,7 @@ module Guff
end
private def get_ids(
- tags = [] of String : Array(String)
+ tags : Array(String) = [] of String,
) : Hash(String, Int32)
r = {} of String => Int32
diff --git a/src/guff/results.cr b/src/guff/results.cr
index 61d5ce5..3133d21 100644
--- a/src/guff/results.cr
+++ b/src/guff/results.cr
@@ -6,10 +6,10 @@ module Guff
getter :rows
def initialize(
- @page = 1 : Int32,
- @limit = 1 : Int32,
- @num_rows = 0 : Int32,
- @rows = [] of R : Array(R),
+ @page : Int32 = 1,
+ @limit : Int32 = 1,
+ @num_rows : Int32 = 0,
+ @rows : Array(R) = [] of R,
)
end
diff --git a/src/guff/template.cr b/src/guff/template.cr
index f5a1693..b203337 100644
--- a/src/guff/template.cr
+++ b/src/guff/template.cr
@@ -15,7 +15,7 @@ module Guff
end
def run(
- args = {} of String => String : Hash(String, String)
+ args : Hash(String, String) = {} of String => String,
) : String
if @has_keys
# check template args
diff --git a/src/guff/views/html/page.cr b/src/guff/views/html/page.cr
index 6ea9502..8c0e9bc 100644
--- a/src/guff/views/html/page.cr
+++ b/src/guff/views/html/page.cr
@@ -21,7 +21,7 @@ module Guff
script: "<script type='text/javascript' src='%s'></script>",
}
- def initialize(@title = "" : String, @body = "" : String)
+ def initialize(@title : String = "", @body : String = "")
@charset = "utf-8"
@lang = "en-US"
@scripts = [] of String