Skip to content

Commit

Permalink
Update liquid for elixir 1.4 compatibility and update depencies also …
Browse files Browse the repository at this point in the history
…for reducing warnings
  • Loading branch information
Peter Arentsen committed Feb 1, 2017
1 parent 3c4ab5f commit 26101fa
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 48 deletions.
20 changes: 10 additions & 10 deletions lib/liquid.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Liquid do
use Application

def start(_type, _args), do: start
def start(_type, _args), do: start()

def start do
Liquid.Filters.add_filter_modules
Expand All @@ -10,10 +10,10 @@ defmodule Liquid do

def stop, do: {:ok, "stopped"}

def filter_arguments, do: ~r/(?::|,)\s*(#{quoted_fragment})/
def filter_arguments, do: ~r/(?::|,)\s*(#{quoted_fragment()})/
def single_quote, do: "'"
def double_quote, do: "\""
def quote_matcher, do: ~r/#{single_quote}|#{double_quote}/
def quote_matcher, do: ~r/#{single_quote()}|#{double_quote()}/

def variable_start, do: "{{"
def variable_end, do: "}}"
Expand All @@ -24,17 +24,17 @@ defmodule Liquid do

def any_starting_tag, do: "(){{()|(){%()"

def tokenizer, do: ~r/()#{tag_start}.*?#{tag_end}()|()#{variable_start}.*?#{variable_end}()/
def parser, do: ~r/#{tag_start}\s*(?<tag>.*?)\s*#{tag_end}|#{variable_start}\s*(?<variable>.*?)\s*#{variable_end}/m
def template_parser, do: ~r/#{partial_template_parser}|#{any_starting_tag}/ms
def partial_template_parser, do: "()#{tag_start}.*?#{tag_end}()|()#{variable_start}.*?#{variable_incomplete_end}()"
def tokenizer, do: ~r/()#{tag_start()}.*?#{tag_end()}()|()#{variable_start()}.*?#{variable_end()}()/
def parser, do: ~r/#{tag_start()}\s*(?<tag>.*?)\s*#{tag_end()}|#{variable_start()}\s*(?<variable>.*?)\s*#{variable_end()}/m
def template_parser, do: ~r/#{partial_template_parser()}|#{any_starting_tag()}/ms
def partial_template_parser, do: "()#{tag_start()}.*?#{tag_end()}()|()#{variable_start()}.*?#{variable_incomplete_end()}()"

def quoted_string, do: "\"[^\"]*\"|'[^']*'"
def quoted_fragment, do: "#{quoted_string}|(?:[^\s,\|'\"]|#{quoted_string})+"
def quoted_fragment, do: "#{quoted_string()}|(?:[^\s,\|'\"]|#{quoted_string()})+"

def tag_attributes, do: ~r/(\w+)\s*\:\s*(#{quoted_fragment})/
def tag_attributes, do: ~r/(\w+)\s*\:\s*(#{quoted_fragment()})/
def variable_parser, do: ~r/\[[^\]]+\]|[\w\-]+/
def filter_parser, do: ~r/(?:\||(?:\s*(?!(?:\|))(?:#{quoted_fragment}|\S+)\s*)+)/
def filter_parser, do: ~r/(?:\||(?:\s*(?!(?:\|))(?:#{quoted_fragment()}|\S+)\s*)+)/

defmodule List do
def even_elements([_,h|t]) do
Expand Down
10 changes: 5 additions & 5 deletions lib/liquid/appointer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ defmodule Liquid.Appointer do
@spec parse_name(String.t) :: String.t
def parse_name(name) do
value = cond do
literals |> Map.has_key?(name) ->
literals |> Map.get(name)
integer |> Regex.match?(name) ->
literals() |> Map.has_key?(name) ->
literals() |> Map.get(name)
integer() |> Regex.match?(name) ->
name |> String.to_integer
float |> Regex.match?(name) ->
float() |> Regex.match?(name) ->
name |> String.to_float
start_quoted_string |> Regex.match?(name) ->
start_quoted_string() |> Regex.match?(name) ->
Liquid.quote_matcher |> Regex.replace(name, "")
true ->
Liquid.variable_parser |> Regex.scan(name) |> List.flatten
Expand Down
4 changes: 2 additions & 2 deletions lib/liquid/file_system.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ defmodule Liquid.FileSystem do
Get full file system path
"""
def full_path(path) do
case lookup do
case lookup() do
nil -> { :error, "No file system defined" }
{ mod, root } -> mod.full_path(root, path)
end
end

def read_template_file(path, options \\ []) do
case lookup do
case lookup() do
nil -> { :error, "No file system defined" }
{ mod, root } -> mod.read_template_file(root, path, options)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/liquid/include.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule Liquid.Include do
def syntax, do: ~r/(#{Liquid.quoted_fragment}+)(\s+(?:with|for)\s+(#{Liquid.quoted_fragment}+))?/

def parse(%Tag{markup: markup}=tag, %Template{}=template) do
[parts|_] = syntax |> Regex.scan(markup)
[parts|_] = syntax() |> Regex.scan(markup)
tag = parse_tag(tag, parts)
attributes = parse_attributes(markup)
{ %{tag | attributes: attributes }, template }
Expand Down
6 changes: 3 additions & 3 deletions lib/liquid/registers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ defmodule Liquid.Registers do
end

def clear do
Application.put_env(:liquid, :extra_tags, default_tags)
Application.put_env(:liquid, :extra_tags, default_tags())
end

def lookup(name) when is_binary(name) do
Expand All @@ -35,15 +35,15 @@ defmodule Liquid.Registers do

def lookup(name) when is_atom(name) do
custom_tags = Application.get_env(:liquid, :extra_tags)
case {name, default_tags[name], custom_tags[name]} do
case {name, default_tags()[name], custom_tags[name]} do
{nil, _, _} -> nil
{_, nil, nil} -> nil
{_, nil, custom_tag} -> custom_tag
{_, tag, _} -> tag
end
end

def lookup(_), do: nil
def lookup(_), do: nil

def register(name, module, type) do
custom_tags = Application.get_env(:liquid, :extra_tags) || %{}
Expand Down
2 changes: 1 addition & 1 deletion lib/liquid/tags/assign.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule Liquid.Assign do
def parse(%Tag{}=tag, %Liquid.Template{}=template), do: { %{tag | blank: true }, template }

def render(output, %Tag{markup: markup}, %Context{}=context) do
[[_, to, from]] = syntax |> Regex.scan(markup)
[[_, to, from]] = syntax() |> Regex.scan(markup)
from_value = from |> Variable.create
|> Variable.lookup(context)
result_assign = context.assigns |> Map.put(to, from_value)
Expand Down
4 changes: 2 additions & 2 deletions lib/liquid/tags/case.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defmodule Liquid.Case do


def parse(%Block{markup: markup}=b, %Template{}=t) do
[[_, name]] = syntax |> Regex.scan(markup)
[[_, name]] = syntax() |> Regex.scan(markup)
{ split(name |> Variable.create, b.nodelist), t }
end

Expand Down Expand Up @@ -39,7 +39,7 @@ defmodule Liquid.Case do


defp parse_when(markup) do
[[_,h|t]|m] = when_syntax |> Regex.scan(markup)
[[_,h|t]|m] = when_syntax() |> Regex.scan(markup)
m = m |> List.flatten |> Liquid.List.even_elements
t = [t|m] |> Enum.join(" ")
t = if t == "", do: [], else: [t]
Expand Down
2 changes: 1 addition & 1 deletion lib/liquid/tags/for_else.ex
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ defmodule Liquid.ForElse do
end

defp parse_iterator(%Block{markup: markup}) do
[[_,item|[orig_collection|reversed]]] = Regex.scan(syntax, markup)
[[_,item|[orig_collection|reversed]]] = Regex.scan(syntax(), markup)
collection = Expression.parse(orig_collection)
reversed = !(reversed |> List.first |> is_nil)
attributes = Liquid.tag_attributes |> Regex.scan(markup)
Expand Down
4 changes: 2 additions & 2 deletions lib/liquid/tags/if_else.ex
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ defmodule Liquid.IfElse do

defp split_conditions(expressions) do
expressions |> List.flatten |> Enum.map(&String.strip/1) |> Enum.map(fn(x) ->
case syntax |> Regex.scan(x) do
case syntax() |> Regex.scan(x) do
[[_, left, operator, right]] -> { left, operator, right }
[[_, x]] -> x
end
end)
end

defp parse_conditions(%Block{markup: markup}=block) do
expressions = Regex.scan(expressions_and_operators, markup)
expressions = Regex.scan(expressions_and_operators(), markup)
expressions = expressions |> split_conditions |> Enum.reverse
condition = Condition.create(expressions)
%{block | condition: condition }
Expand Down
4 changes: 2 additions & 2 deletions lib/liquid/tags/table_row.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ defmodule Liquid.TableRow do


defp parse_iterator(%Block{markup: markup}) do
[[_,item|[orig_collection]]] = Regex.scan(syntax, markup)
[[_,item|[orig_collection]]] = Regex.scan(syntax(), markup)
collection = Expression.parse(orig_collection)
attributes = Liquid.tag_attributes |> Regex.scan(markup)
limit = attributes |> parse_attribute("limit") |> Variable.create
Expand Down Expand Up @@ -195,4 +195,4 @@ defmodule Liquid.TableRow do
defp get_loop_indexes(loop, _cols, _offset),
do: {loop["col"], false, loop["row"]}

end
end
8 changes: 4 additions & 4 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ defmodule Liquid.Mixfile do

def project do
[ app: :liquid,
version: "0.5.0",
version: "0.6.0",
elixir: "~> 1.3",
deps: deps,
deps: deps(),
name: "Liquid",
description: description,
package: package,
description: description(),
package: package(),
source_url: "https://github.com/bettyblocks/liquid-elixir"]
end

Expand Down
30 changes: 15 additions & 15 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
%{"benchfella": {:hex, :benchfella, "0.3.2", "b9648e77fa8d8b8b9fe8f54293bee63f7de03909b3af6ab22a0e546716a396fb", [:mix], []},
"bunt": {:hex, :bunt, "0.1.6", "5d95a6882f73f3b9969fdfd1953798046664e6f77ec4e486e6fafc7caad97c6f", [:mix], []},
"certifi": {:hex, :certifi, "0.4.0", "a7966efb868b179023618d29a407548f70c52466bf1849b9e8ebd0e34b7ea11f", [:rebar3], []},
"combine": {:hex, :combine, "0.9.2", "cd3c8721f378ebe032487d8a4fa2ced3181a456a3c21b16464da8c46904bb552", [:mix], []},
"credo": {:hex, :credo, "0.4.11", "03a64e9d53309b7132556284dda0be57ba1013885725124cfea7748d740c6170", [:mix], [{:bunt, "~> 0.1.6", [hex: :bunt, optional: false]}]},
"earmark": {:hex, :earmark, "1.0.1", "2c2cd903bfdc3de3f189bd9a8d4569a075b88a8981ded9a0d95672f6e2b63141", [:mix], []},
"ex_doc": {:hex, :ex_doc, "0.13.0", "aa2f8fe4c6136a2f7cfc0a7e06805f82530e91df00e2bff4b4362002b43ada65", [:mix], [{:earmark, "~> 1.0", [hex: :earmark, optional: false]}]},
%{"benchfella": {:hex, :benchfella, "0.3.3", "bbde48b5fe1ef556baa7ad933008e214e050e81ddb0916350715f5759fb35c0c", [:mix], []},
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], []},
"certifi": {:hex, :certifi, "0.7.0", "861a57f3808f7eb0c2d1802afeaae0fa5de813b0df0979153cbafcd853ababaf", [:rebar3], []},
"combine": {:hex, :combine, "0.9.6", "8d1034a127d4cbf6924c8a5010d3534d958085575fa4d9b878f200d79ac78335", [:mix], []},
"credo": {:hex, :credo, "0.6.0", "44a82f82b94eeb4ba6092c89b8a6730ca1a3291c7940739d5acc8806d25ac991", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, optional: false]}]},
"earmark": {:hex, :earmark, "1.1.0", "8c2bf85d725050a92042bc1edf362621004d43ca6241c756f39612084e95487f", [:mix], []},
"ex_doc": {:hex, :ex_doc, "0.14.5", "c0433c8117e948404d93ca69411dd575ec6be39b47802e81ca8d91017a0cf83c", [:mix], [{:earmark, "~> 1.0", [hex: :earmark, optional: false]}]},
"exprintf": {:hex, :exprintf, "0.1.6", "b5b0a38bf78a357dbc61cdf7364fea004af6fdf5214be44021eb2ea7edf61f6e", [:mix], []},
"exprof": {:hex, :exprof, "0.2.0", "b03f50d0d33e2f18c8e047d9188ba765dc32daba0b553ed717a98a78561d5eaf", [:mix], [{:exprintf, "~> 0.1", [hex: :exprintf, optional: false]}]},
"gettext": {:hex, :gettext, "0.11.0", "80c1dd42d270482418fa158ec5ba073d2980e3718bacad86f3d4ad71d5667679", [:mix], []},
"hackney": {:hex, :hackney, "1.6.1", "ddd22d42db2b50e6a155439c8811b8f6df61a4395de10509714ad2751c6da817", [:rebar3], [{:certifi, "0.4.0", [hex: :certifi, optional: false]}, {:idna, "1.2.0", [hex: :idna, optional: false]}, {:metrics, "1.0.1", [hex: :metrics, optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, optional: false]}, {:ssl_verify_fun, "1.1.0", [hex: :ssl_verify_fun, optional: false]}]},
"idna": {:hex, :idna, "1.2.0", "ac62ee99da068f43c50dc69acf700e03a62a348360126260e87f2b54eced86b2", [:rebar3], []},
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], []},
"mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], []},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.0", "edee20847c42e379bf91261db474ffbe373f8acb56e9079acb6038d4e0bf414f", [:rebar, :make], []},
"timex": {:hex, :timex, "3.0.8", "71d5ebafcdc557c6c866cdc196c5054f587e7cd1118ad8937e2293d51fc85608", [:mix], [{:combine, "~> 0.7", [hex: :combine, optional: false]}, {:gettext, "~> 0.10", [hex: :gettext, optional: false]}, {:tzdata, "~> 0.1.8 or ~> 0.5", [hex: :tzdata, optional: false]}]},
"tzdata": {:hex, :tzdata, "0.5.9", "575be217b039057a47e133b72838cbe104fb5329b19906ea4e66857001c37edb", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, optional: false]}]}}
"gettext": {:hex, :gettext, "0.13.1", "5e0daf4e7636d771c4c71ad5f3f53ba09a9ae5c250e1ab9c42ba9edccc476263", [:mix], []},
"hackney": {:hex, :hackney, "1.6.5", "8c025ee397ac94a184b0743c73b33b96465e85f90a02e210e86df6cbafaa5065", [:rebar3], [{:certifi, "0.7.0", [hex: :certifi, optional: false]}, {:idna, "1.2.0", [hex: :idna, optional: false]}, {:metrics, "1.0.1", [hex: :metrics, optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, optional: false]}]},
"idna": {:hex, :idna, "1.2.0", "ac62ee99da068f43c50dc69acf700e03a62a348360126260e87f2b54eced86b2", [], []},
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [], []},
"mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [], []},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], []},
"timex": {:hex, :timex, "3.1.8", "a32f636c4260dd7515a3767be3d3a163dc09d15f0e9e689254b7bab152b29209", [:mix], [{:combine, "~> 0.7", [hex: :combine, optional: false]}, {:gettext, "~> 0.10", [hex: :gettext, optional: false]}, {:tzdata, "~> 0.1.8 or ~> 0.5", [hex: :tzdata, optional: false]}]},
"tzdata": {:hex, :tzdata, "0.5.10", "087e8dfe8c0283473115ad8ca6974b898ecb55ca5c725427a142a79593391e90", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, optional: false]}]}}

0 comments on commit 26101fa

Please sign in to comment.