~sbaildon/calibex

0ae18797aff9b6cde43a4cc28924c4e7763f6f7d — Sean Baildon 8 months ago 508fadf master
remove timex dependency
M README.md => README.md +1 -1
@@ 41,7 41,7 @@ some helpers functions are provided :
## Example usage : email event request generation 

```elixir
Calibex.request(dtstart: Timex.now, dtend: Timex.shift(Timex.now,hours: 1), summary: "Mon évènement",
Calibex.request(dtstart: DateTime.utc_now(), dtend: DateTime.add(DateTime.utc_now(), 3_600, :second), summary: "Mon évènement",
          organizer: "arnaud.wetzel@example.com", attendee: "jeanpierre@yahoo.fr", attendee: "jean@ya.fr")
 |> Calibex.encode
```

M config/config.exs => config/config.exs +1 -0
@@ 28,3 28,4 @@ import Config
# here (which is why it is important to import them last).
#
#     import_config "#{Mix.env}.exs"
import_config "#{config_env()}.exs"

A config/dev.exs => config/dev.exs +1 -0
@@ 0,0 1,1 @@
import Config

A config/test.exs => config/test.exs +3 -0
@@ 0,0 1,3 @@
import Config

config :elixir, :time_zone_database, Tz.TimeZoneDatabase

M lib/calibex.ex => lib/calibex.ex +1 -1
@@ 38,7 38,7 @@ defmodule Calibex do
  ## Example usage : email event request generation 

  ```
  Calibex.request(dtstart: Timex.now, dtend: Timex.shift(Timex.now,hours: 1), summary: "Mon évènement",
  Calibex.request(dtstart: DateTime.utc_now(), dtend: DateTime.add(DateTime.utc_now(), 3_600, :second), summary: "Mon évènement",
            organizer: "arnaud.wetzel@example.com", attendee: "jeanpierre@yahoo.fr", attendee: "jean@ya.fr")
   |> Calibex.encode
  ```

M lib/codec.ex => lib/codec.ex +5 -2
@@ 22,8 22,11 @@ defmodule Calibex.Codec do
  # encode standard key value
  def encode_value({k, v}), do: "#{encode_key(k)}:#{encode_value(v)}"

  def encode_value(%DateTime{} = dt),
    do: %{dt | microsecond: {0, 0}} |> Timex.to_datetime("UTC") |> Timex.format!("{ISO:Basic:Z}")
  def encode_value(%DateTime{} = dt) do
    dt
    |> DateTime.shift_zone!("Etc/UTC")
    |> Calendar.strftime("%Y%m%dT%H%M%SZ")
  end

  def encode_value(atom) when is_atom(atom), do: atom |> to_string() |> String.upcase()
  def encode_value(other), do: other

M lib/helpers.ex => lib/helpers.ex +3 -3
@@ 55,10 55,10 @@ defmodule Calibex.Helper do
  def default(:uid, vals),
    do: :crypto.hash(:sha, :erlang.term_to_binary(vals)) |> Base.encode16(case: :lower)

  def default(:last_modified, _vals), do: Timex.now()
  def default(:last_modified, _vals), do: DateTime.utc_now()
  def default(:sequence, _vals), do: 0
  def default(:dtstamp, _vals), do: Timex.now()
  def default(:created, _vals), do: Timex.now()
  def default(:dtstamp, _vals), do: DateTime.utc_now()
  def default(:created, _vals), do: DateTime.utc_now()
  def default(:status, _vals), do: :confirmed
  def default(:cutype, _vals), do: "INDIVIDUAL"
  def default(:role, _vals), do: "REQ-PARTICIPANT"

M mix.exs => mix.exs +5 -1
@@ 17,8 17,12 @@ defmodule Calibex.Mixfile do
  def application do
    [extra_applications: [:crypto]]
  end

  defp deps do
    [{:timex, "~> 3.1"}, {:ex_doc, ">= 0.0.0", only: :dev}]
    [
      {:ex_doc, ">= 0.0.0", only: :dev},
      {:tz, "~> 0.25.1", only: :test}
    ]
  end

  defp package do

M mix.lock => mix.lock +1 -10
@@ 1,14 1,5 @@
%{
  "certifi": {:hex, :certifi, "1.1.0", "c9b71a547016c2528a590ccfc28de786c7edb74aafa17446b84f54e04efc00ee", [:rebar3], [], "hexpm", "766db7fae3104ac598216658a8e851fc61df89761ca841952a24a5a70613257c"},
  "combine": {:hex, :combine, "0.9.6", "8d1034a127d4cbf6924c8a5010d3534d958085575fa4d9b878f200d79ac78335", [:mix], [], "hexpm", "0b450698443dc9ab84cee85976752b4af1009cdf0f01da9ee8ef2550dc67c47f"},
  "earmark": {:hex, :earmark, "1.2.2", "f718159d6b65068e8daeef709ccddae5f7fdc770707d82e7d126f584cd925b74", [:mix], [], "hexpm", "59514c4a207f9f25c5252e09974367718554b6a0f41fe39f7dc232168f9cb309"},
  "ex_doc": {:hex, :ex_doc, "0.15.1", "d5f9d588fd802152516fccfdb96d6073753f77314fcfee892b15b6724ca0d596", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm", "00d41bec3590533279b90870d68ebc4fdfcc3a1c7b6629796167b49bfa199d54"},
  "gettext": {:hex, :gettext, "0.13.1", "5e0daf4e7636d771c4c71ad5f3f53ba09a9ae5c250e1ab9c42ba9edccc476263", [:mix], [], "hexpm", "b233b4ab0d349a359b52592d2d591fc6e4b20fdbe0b15a624cc15a3ca509a1cc"},
  "hackney": {:hex, :hackney, "1.8.0", "8388a22f4e7eb04d171f2cf0285b217410f266d6c13a4c397a6c22ab823a486c", [:rebar3], [{:certifi, "1.1.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "4.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "0cb8724402a04397003ad5daaef663698c9448ce312a1f3ba911b89109bfe168"},
  "idna": {:hex, :idna, "4.0.0", "10aaa9f79d0b12cf0def53038547855b91144f1bfcc0ec73494f38bb7b9c4961", [:rebar3], [], "hexpm", "f1b699f7275728538da7b5e35679f9e0f41ad8e0a49896e6a27b61867ed344eb"},
  "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"},
  "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm", "7a4c8e1115a2732a67d7624e28cf6c9f30c66711a9e92928e745c255887ba465"},
  "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], [], "hexpm", "4f8805eb5c8a939cf2359367cb651a3180b27dfb48444846be2613d79355d65e"},
  "timex": {:hex, :timex, "3.1.13", "48b33162e3ec33e9a08fb5f98e3f3c19c3e328dded3156096c1969b77d33eef0", [:mix], [{:combine, "~> 0.7", [hex: :combine, repo: "hexpm", optional: false]}, {:gettext, "~> 0.10", [hex: :gettext, repo: "hexpm", optional: false]}, {:tzdata, "~> 0.1.8 or ~> 0.5", [hex: :tzdata, repo: "hexpm", optional: false]}], "hexpm", "760120055428edad7fd9b67aeed280b89ac7fab4b1e330a274cd09703f31f314"},
  "tzdata": {:hex, :tzdata, "0.5.12", "1c17b68692c6ba5b6ab15db3d64cc8baa0f182043d5ae9d4b6d35d70af76f67b", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "2b1f46940a61331fc01e4b33384bfa4d43195a2122816dcd8817345d294e7a27"},
  "tz": {:hex, :tz, "0.25.1", "918eef2965c952919d9108d97b7e0c332bc707943170d9060352e945a0bd2c64", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:mint, "~> 1.4", [hex: :mint, repo: "hexpm", optional: true]}], "hexpm", "6f34779ae6d05de78fdfc99244b83455c140a0ac0ac18b44d8129a48cc587294"},
}

M test/calibex_test.exs => test/calibex_test.exs +9 -7
@@ 12,9 12,9 @@ defmodule CalibexTest do
            method: "REQUEST",
            vevent: [
              [
                dtstart: Timex.to_datetime({{2017, 5, 14}, {9, 0, 0}}, "Europe/Paris"),
                dtend: Timex.to_datetime({{2017, 5, 14}, {10, 0, 0}}, "Europe/Paris"),
                dtstamp: Timex.to_datetime({{2017, 5, 13}, {10, 52, 50}}, "UTC"),
                dtstart: DateTime.new!(~D[2017-05-14], ~T[09:00:00], "Europe/Paris"),
                dtend: DateTime.new!(~D[2017-05-14], ~T[10:00:00], "Europe/Paris"),
                dtstamp: DateTime.new!(~D[2017-05-13], ~T[10:52:50], "UTC"),
                organizer: [cn: "Arnaud Wetzel", value: "mailto:arnaud.wetzel@example.com"],
                uid: "r30al68kn0b2epd9af6kqjg8rg@google.com",
                attendee: [


@@ 35,7 35,7 @@ defmodule CalibexTest do
                  x_num_guests: 0,
                  value: "mailto:arnaud.wetzel@example.com"
                ],
                created: Timex.to_datetime({{2017, 5, 13}, {10, 50, 32}}, "UTC"),
                created: DateTime.new!(~D[2017-05-13], ~T[10:50:32], "Etc/UTC"),
                description:
                  String.trim_trailing("""
                  Cet événement est associé à un appel vidéo Google Hangouts.


@@ 43,7 43,7 @@ defmodule CalibexTest do

                  Affichez votre événement sur la page https://www.google.com/calendar/event?action=VIEW&eid=cjMwYWw2OGtuMGIyZXBkOWFmNmtxamc4cmcgYXJuYXVkd2V0emVsQHlhaG9vLmNvbQ&tok=MzEjYXJuYXVkLndldHplbEBrYnJ3YWR2ZW50dXJlLmNvbTdjMzQ0ZGFjN2FlYTM2OGI2NzEzNjAzZjVmNzk2NDVkMjA5ZDc0YjQ&ctz=Europe/Paris&hl=fr.
                  """),
                last_modified: Timex.to_datetime({{2017, 5, 13}, {10, 52, 49}}, "UTC"),
                last_modified: DateTime.new!(~D[2017-05-13], ~T[10:52:49], "Etc/UTC"),
                location: "",
                sequence: 0,
                status: "CONFIRMED",


@@ 69,10 69,12 @@ defmodule CalibexTest do
  # end

  test "ical helpers" do
    now = DateTime.utc_now()

    req =
      Calibex.request(
        dtstart: Timex.now(),
        dtend: Timex.shift(Timex.now(), hours: 1),
        dtstart: now,
        dtend: DateTime.add(now, 3_600, :second),
        summary: "Mon évènement",
        organizer: "arnaud.wetzel@example.com",
        attendee: "jeanpierre@yahoo.fr",