Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed deprecated functions to new ones and so updated minimal version of elixir to 1.10 #86

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/calliope/compile.ex
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ defmodule Calliope.Compiler do
defp leader(line, si) do
case line[:indent] do
nil -> ""
value -> String.rjust("", (value - si) * @indent_size)
value -> String.pad_leading("", (value - si) * @indent_size)
end
end

Expand All @@ -82,7 +82,7 @@ defmodule Calliope.Compiler do
end

def evaluate_script(nil), do: ""
def evaluate_script(script) when is_binary(script), do: "<%= #{String.lstrip(script)} %>"
def evaluate_script(script) when is_binary(script), do: "<%= #{String.trim_leading(script)} %>"

defp smart_script_to_string("if" <> script, children, "else", si) do
%{cmd: cmd, end_tag: end_tag} = handle_script("if" <> script)
Expand Down Expand Up @@ -150,7 +150,7 @@ defmodule Calliope.Compiler do
def compile_attributes(list) do
Enum.map_join(@attributes, &reject_or_compile_key(&1, list[&1])) |>
precompile_content |>
String.rstrip
String.trim_trailing
end

def reject_or_compile_key( _, nil), do: nil
Expand Down
12 changes: 6 additions & 6 deletions lib/calliope/parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ defmodule Calliope.Parser do
[sym, val] = [head(h), tail(h)]
acc = case sym do
@doctype -> [ doctype: h ] ++ acc
@tag -> [ tag: String.strip(val) ] ++ acc
@tag -> [ tag: String.trim(val) ] ++ acc
@id -> handle_id(acc, val)
@class -> merge_into(:classes, acc, [val])
@tab -> [ indent: String.length(h) ] ++ acc
@attrs -> merge_attributes( acc, val)
@parens -> merge_attributes( acc, val)
@comment -> handle_comment(val) ++ acc
@script -> [ script: val ] ++ acc
@smart -> [ smart_script: String.strip(val) ] ++ acc
@smart -> [ smart_script: String.trim(val) ] ++ acc
@filter -> handle_filter(acc, val)
_ -> [ content: String.strip(h) ] ++ acc
_ -> [ content: String.trim(h) ] ++ acc
end
parse_line(t, acc)
end

def handle_comment(val), do: [ comment: String.rstrip "!--#{val}" ]
def handle_comment(val), do: [ comment: String.trim_trailing "!--#{val}" ]
def handle_id(line, id) do
cond do
line[:id] -> raise_error :multiple_ids_assigned, line[:line_number]
Expand Down Expand Up @@ -73,7 +73,7 @@ defmodule Calliope.Parser do
String.replace(~r/"(.+?)"\s=>\s(@?\w+)\s?/, "\\1='#\{\\2}'") |>
String.replace(~r/:(.+?)\s=>\s['"](.*)['"]\s?/, "\\1='\\2'") |>
filter_commas |>
String.strip
String.trim
end

@empty_param ~S/^\s*?[-\w]+?\s*?$/
Expand All @@ -93,7 +93,7 @@ defmodule Calliope.Parser do
@wraps [?', ?"]

def filter_commas(string) do
state = String.to_char_list(string)
state = String.to_charlist(string)
|> Enum.reduce(%{buffer: [], closing: false}, fn(ch, state) ->
{char, closing} = case {ch, state[:closing]} do
{ch, false} when ch in @wraps -> {ch, ch}
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ defmodule Calliope.Mixfile do
def project do
[ app: :calliope,
version: "0.4.2",
elixir: "~> 1.4",
elixir: ">= 1.10",
deps: [{:ex_doc, ">= 0.0.0", only: :dev}],
package: [
files: ["lib", "mix.exs", "README*", "LICENSE*"],
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Code.load_file("equivalent_html.exs", "./test/support")
Code.require_file("equivalent_html.exs", "./test/support")

ExUnit.start