Skip to content

Commit

Permalink
first commit (#1)
Browse files Browse the repository at this point in the history
* first commit

* rename google_protobuf to google_protos

* remove unused files

* remove protos we may not need

* regenrate protos
  • Loading branch information
falood authored and tony612 committed Mar 1, 2018
1 parent 3c8beaf commit aa7febc
Show file tree
Hide file tree
Showing 17 changed files with 364 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[
inputs: ["mix.exs", "{config,lib,test}/**/*.{ex,exs}"],
import_deps: [:protobuf]
]
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# The directory Mix will write compiled artifacts to.
/_build/

# If you run "mix test --cover", coverage assets end up here.
/cover/

# The directory Mix downloads your dependencies sources to.
/deps/

# Where 3rd-party dependencies like ExDoc output generated docs.
/doc/

# Ignore .fetch files in case you like to edit your project deps locally.
/.fetch

# If the VM crashes, it generates a dump, let's ignore it too.
erl_crash.dump

# Also ignore archive artifacts (built via "mix archive.build").
*.ez

# Ignore package tarball (built via "mix hex.build").
google_protobuf-*.tar

3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "protobuf"]
path = protobuf
url = https://github.com/google/protobuf
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Bing Han

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
30 changes: 30 additions & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
use Mix.Config

# This configuration is loaded before any dependency and is restricted
# to this project. If another project depends on this project, this
# file won't be loaded nor affect the parent project. For this reason,
# if you want to provide default values for your application for
# 3rd-party users, it should be done in your "mix.exs" file.

# You can configure your application as:
#
# config :google_protobuf, key: :value
#
# and access this configuration in your application as:
#
# Application.get_env(:google_protobuf, :key)
#
# You can also configure a 3rd-party app:
#
# config :logger, level: :info
#

# It is also possible to import configuration files, relative to this
# directory. For example, you can emulate configuration per environment
# by uncommenting the line below and defining dev.exs, test.exs and such.
# Configuration from the imported file will override the ones defined
# here (which is why it is important to import them last).
#
# import_config "#{Mix.env}.exs"
16 changes: 16 additions & 0 deletions generate_google_protos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

PROTOS=("
protobuf/src/google/protobuf/any.proto
protobuf/src/google/protobuf/duration.proto
protobuf/src/google/protobuf/empty.proto
protobuf/src/google/protobuf/struct.proto
protobuf/src/google/protobuf/timestamp.proto
protobuf/src/google/protobuf/wrappers.proto
")

rm -rf ./lib/google_protos/*

for file in $PROTOS; do
protoc -I ./protobuf/src/google/protobuf/ --elixir_out=plugins=grpc:./lib/google_protos $file
done
9 changes: 9 additions & 0 deletions lib/google_protos.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
defmodule GoogleProtos do
@moduledoc false

use Application

def start(_type, _args) do
Supervisor.start_link([], strategy: :one_for_one, name: GoogleProtos.Supervisor)
end
end
13 changes: 13 additions & 0 deletions lib/google_protos/any.pb.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
defmodule Google.Protobuf.Any do
@moduledoc false
use Protobuf, syntax: :proto3

@type t :: %__MODULE__{
type_url: String.t(),
value: String.t()
}
defstruct [:type_url, :value]

field :type_url, 1, type: :string
field :value, 2, type: :bytes
end
13 changes: 13 additions & 0 deletions lib/google_protos/duration.pb.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
defmodule Google.Protobuf.Duration do
@moduledoc false
use Protobuf, syntax: :proto3

@type t :: %__MODULE__{
seconds: integer,
nanos: integer
}
defstruct [:seconds, :nanos]

field :seconds, 1, type: :int64
field :nanos, 2, type: :int32
end
6 changes: 6 additions & 0 deletions lib/google_protos/empty.pb.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
defmodule Google.Protobuf.Empty do
@moduledoc false
use Protobuf, syntax: :proto3

defstruct []
end
62 changes: 62 additions & 0 deletions lib/google_protos/struct.pb.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
defmodule Google.Protobuf.Struct do
@moduledoc false
use Protobuf, syntax: :proto3

@type t :: %__MODULE__{
fields: %{String.t() => Google.Protobuf.Value.t()}
}
defstruct [:fields]

field :fields, 1, repeated: true, type: Google.Protobuf.Struct.FieldsEntry, map: true
end

defmodule Google.Protobuf.Struct.FieldsEntry do
@moduledoc false
use Protobuf, map: true, syntax: :proto3

@type t :: %__MODULE__{
key: String.t(),
value: Google.Protobuf.Value.t()
}
defstruct [:key, :value]

field :key, 1, type: :string
field :value, 2, type: Google.Protobuf.Value
end

defmodule Google.Protobuf.Value do
@moduledoc false
use Protobuf, syntax: :proto3

@type t :: %__MODULE__{
kind: {atom, any}
}
defstruct [:kind]

oneof :kind, 0
field :null_value, 1, type: Google.Protobuf.NullValue, enum: true, oneof: 0
field :number_value, 2, type: :double, oneof: 0
field :string_value, 3, type: :string, oneof: 0
field :bool_value, 4, type: :bool, oneof: 0
field :struct_value, 5, type: Google.Protobuf.Struct, oneof: 0
field :list_value, 6, type: Google.Protobuf.ListValue, oneof: 0
end

defmodule Google.Protobuf.ListValue do
@moduledoc false
use Protobuf, syntax: :proto3

@type t :: %__MODULE__{
values: [Google.Protobuf.Value.t()]
}
defstruct [:values]

field :values, 1, repeated: true, type: Google.Protobuf.Value
end

defmodule Google.Protobuf.NullValue do
@moduledoc false
use Protobuf, enum: true, syntax: :proto3

field :NULL_VALUE, 0
end
13 changes: 13 additions & 0 deletions lib/google_protos/timestamp.pb.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
defmodule Google.Protobuf.Timestamp do
@moduledoc false
use Protobuf, syntax: :proto3

@type t :: %__MODULE__{
seconds: integer,
nanos: integer
}
defstruct [:seconds, :nanos]

field :seconds, 1, type: :int64
field :nanos, 2, type: :int32
end
107 changes: 107 additions & 0 deletions lib/google_protos/wrappers.pb.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
defmodule Google.Protobuf.DoubleValue do
@moduledoc false
use Protobuf, syntax: :proto3

@type t :: %__MODULE__{
value: float
}
defstruct [:value]

field :value, 1, type: :double
end

defmodule Google.Protobuf.FloatValue do
@moduledoc false
use Protobuf, syntax: :proto3

@type t :: %__MODULE__{
value: float
}
defstruct [:value]

field :value, 1, type: :float
end

defmodule Google.Protobuf.Int64Value do
@moduledoc false
use Protobuf, syntax: :proto3

@type t :: %__MODULE__{
value: integer
}
defstruct [:value]

field :value, 1, type: :int64
end

defmodule Google.Protobuf.UInt64Value do
@moduledoc false
use Protobuf, syntax: :proto3

@type t :: %__MODULE__{
value: non_neg_integer
}
defstruct [:value]

field :value, 1, type: :uint64
end

defmodule Google.Protobuf.Int32Value do
@moduledoc false
use Protobuf, syntax: :proto3

@type t :: %__MODULE__{
value: integer
}
defstruct [:value]

field :value, 1, type: :int32
end

defmodule Google.Protobuf.UInt32Value do
@moduledoc false
use Protobuf, syntax: :proto3

@type t :: %__MODULE__{
value: non_neg_integer
}
defstruct [:value]

field :value, 1, type: :uint32
end

defmodule Google.Protobuf.BoolValue do
@moduledoc false
use Protobuf, syntax: :proto3

@type t :: %__MODULE__{
value: boolean
}
defstruct [:value]

field :value, 1, type: :bool
end

defmodule Google.Protobuf.StringValue do
@moduledoc false
use Protobuf, syntax: :proto3

@type t :: %__MODULE__{
value: String.t()
}
defstruct [:value]

field :value, 1, type: :string
end

defmodule Google.Protobuf.BytesValue do
@moduledoc false
use Protobuf, syntax: :proto3

@type t :: %__MODULE__{
value: String.t()
}
defstruct [:value]

field :value, 1, type: :bytes
end
38 changes: 38 additions & 0 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
defmodule GoogleProtos.MixProject do
use Mix.Project

def project do
[
app: :google_protos,
name: "Google Protos",
version: "0.1.0",
elixir: "~> 1.6",
start_permanent: Mix.env() == :prod,
deps: deps(),
description: "Protos by Google",
package: package()
]
end

def application do
[
extra_applications: [:logger],
mod: {GoogleProtos, []}
]
end

defp deps do
[
{:protobuf, "~> 0.5"}
]
end

defp package do
[
maintainers: ["Tony Han"],
licenses: ["MIT"],
links: %{"GitHub" => "https://github.com/tony612/google-protos"},
files: ~w(mix.exs README.md lib config LICENSE)
]
end
end
3 changes: 3 additions & 0 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
%{
"protobuf": {:hex, :protobuf, "0.5.2", "c1338db827614cbe03a479ac9ef22bd8f3d0ff8a6bb44db5f63037688cd7806c", [:mix], [], "hexpm"},
}
1 change: 1 addition & 0 deletions protobuf
Submodule protobuf added at 9dc0a4
1 change: 1 addition & 0 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ExUnit.start()

0 comments on commit aa7febc

Please sign in to comment.