Repository creation
This commit is contained in:
commit
9ec88ea823
3
META
Normal file
3
META
Normal file
@ -0,0 +1,3 @@
|
||||
description="OCaml binding to Google Apps"
|
||||
archive(byte)="googleApps.cma"
|
||||
|
16
Makefile
Normal file
16
Makefile
Normal file
@ -0,0 +1,16 @@
|
||||
.PHONY: install uninstall
|
||||
|
||||
install: META googleApps.mli _build/googleApps.cmo _build/googleApps.cmi _build/googleApps.cma
|
||||
ocamlfind install ocaml-google-apps $^
|
||||
|
||||
uninstall:
|
||||
ocamlfind remove ocaml-google-apps
|
||||
|
||||
_build/googleApps.cmi: googleApps.mli
|
||||
ocamlbuild googleApps.cmi
|
||||
|
||||
_build/googleApps.cmo: googleApps.mli googleApps.ml
|
||||
ocamlbuild googleApps.cmo
|
||||
|
||||
_build/googleApps.cma: googleApps.mli googleApps.ml
|
||||
ocamlbuild googleApps.cma
|
4
_tags
Normal file
4
_tags
Normal file
@ -0,0 +1,4 @@
|
||||
<googleApps.*>: package(gen_js_api.ppx)
|
||||
<test.cmo>: package(js_of_ocaml)
|
||||
<test.byte>: package(gen_js_api), package(js_of_ocaml), linkpkg, no_check_prims,prettyjs
|
||||
|
138
googleApps.ml
Normal file
138
googleApps.ml
Normal file
@ -0,0 +1,138 @@
|
||||
module Dict : sig
|
||||
type 'a t = (string * 'a) list
|
||||
val t_to_js: ('a -> Ojs.t) -> 'a t -> Ojs.t
|
||||
val t_of_js: (Ojs.t -> 'a) -> Ojs.t -> 'a t
|
||||
end = struct
|
||||
type 'a t = (string * 'a) list
|
||||
|
||||
let t_to_js ml2js l =
|
||||
let o = Ojs.empty_obj () in
|
||||
List.iter (fun (k, v) -> Ojs.set o k (ml2js v)) l;
|
||||
o
|
||||
|
||||
let t_of_js js2ml o =
|
||||
let l = ref [] in
|
||||
Ojs.iter_properties o
|
||||
(fun k -> l := (k, js2ml (Ojs.get o k)) :: !l);
|
||||
!l
|
||||
end
|
||||
|
||||
|
||||
include ([%js] : sig
|
||||
module Date : sig
|
||||
type t
|
||||
val t_of_js: Ojs.t -> t
|
||||
val t_to_js: t -> Ojs.t
|
||||
val now: unit -> t [@@js.new "Date"]
|
||||
val get_day: t -> int [@@js.call] (* day of the week (0-6) *)
|
||||
val get_full_year: t -> int [@@js.call] (* year (4 digits for 4-digit years) *)
|
||||
val get_month: t -> int [@@js.call] (* month (0-11) *)
|
||||
val get_date: t -> int [@@js.call] (* day of the month (1-31) *)
|
||||
val get_hours: t -> int [@@js.call] (* hour (0-23) *)
|
||||
val get_minutes: t -> int [@@js.call] (* minutes (0-59) *)
|
||||
val get_seconds: t -> int [@@js.call] (* seconds (0-59) *)
|
||||
val to_date_string: t -> string [@@js.call]
|
||||
val to_ISO_string: t -> string [@@js.call]
|
||||
val to_locale_date_string: t -> string [@@js.call]
|
||||
val to_string: t -> string [@@js.call]
|
||||
end
|
||||
|
||||
module File : sig
|
||||
type t
|
||||
val t_of_js: Ojs.t -> t
|
||||
val get_id: t -> string [@@js.call]
|
||||
val get_name: t -> string [@@js.call]
|
||||
val get_size: t -> int [@@js.call]
|
||||
end
|
||||
|
||||
module FileIterator : sig
|
||||
type t
|
||||
val get_files: unit -> t [@@js.global "DriveApp.getFiles"]
|
||||
val t_of_js: Ojs.t -> t
|
||||
val has_next: t -> bool [@@js.call]
|
||||
val next: t -> File.t [@@js.call]
|
||||
end
|
||||
|
||||
|
||||
val log: string -> unit [@@js.global "Logger.log"]
|
||||
|
||||
module Range : sig
|
||||
type t
|
||||
val get_a1_notation: t -> string [@@js.call]
|
||||
val get_background: t -> string [@@js.call]
|
||||
val get_row: t -> int [@@js.call]
|
||||
val get_last_row: t -> int [@@js.call]
|
||||
val get_column: t -> int [@@js.call]
|
||||
val get_last_column: t -> int [@@js.call]
|
||||
val get_num_columns: t -> int [@@js.call]
|
||||
val get_num_rows: t -> int [@@js.call]
|
||||
val get_values: t -> Ojs.t array array [@@js.call]
|
||||
val get_formulas: t -> string array array [@@js.call]
|
||||
val get_display_values: t -> string array array [@@js.call]
|
||||
val set_value: t -> Ojs.t -> t [@@js.call]
|
||||
end
|
||||
|
||||
module NamedRange: sig
|
||||
type t
|
||||
val get_name: t -> string [@@js.call]
|
||||
val get_range: t -> Range.t [@@js.call]
|
||||
end
|
||||
|
||||
module Sheet : sig
|
||||
type t
|
||||
val get_active_sheet: unit -> t [@@js.global "SpreadsheetApp.getActiveSheet"]
|
||||
val get_last_row: t -> int [@@js.call]
|
||||
val get_last_column: t -> int [@@js.call]
|
||||
val get_sheet_values: t -> start_row:int -> start_column:int -> num_rows:int -> num_columns:int -> Ojs.t array array [@@js.call]
|
||||
val get_range: t -> start_row:int -> start_column:int -> num_rows:int -> num_columns:int -> Range.t [@@js.call]
|
||||
val get_data_range: t -> Range.t [@@js.call]
|
||||
val get_name: t -> string [@@js.call]
|
||||
val get_named_ranges: t -> NamedRange.t list [@@js.call]
|
||||
end
|
||||
|
||||
module EmailField : sig
|
||||
type t
|
||||
val get_address: t -> string [@@js.call]
|
||||
end
|
||||
|
||||
module PhoneField : sig
|
||||
type t
|
||||
module Field : sig
|
||||
type t =
|
||||
| Work [@js "ContactsApp.Field.WORK_PHONE"]
|
||||
| Mobile [@js "ContactsApp.Field.MOBILE_PHONE"]
|
||||
| Home [@js "ContactsApp.Field.HOME_PHONE"]
|
||||
[@@js.enum]
|
||||
end
|
||||
val get_phone_number: t -> string [@@js.call]
|
||||
end
|
||||
|
||||
module Contacts : sig
|
||||
type t
|
||||
val get_contacts: unit -> t list [@@js.global "ContactsApp.getContacts"]
|
||||
|
||||
val get_family_name: t -> string [@@js.call]
|
||||
val get_given_name: t -> string [@@js.call]
|
||||
val get_full_name: t -> string [@@js.call]
|
||||
|
||||
val get_emails: t -> EmailField.t list [@@js.call]
|
||||
val get_phones: t -> PhoneField.t list [@@js.call]
|
||||
val add_phone: t -> PhoneField.Field.t -> string -> PhoneField.t [@@js.call]
|
||||
|
||||
module Group : sig
|
||||
type g
|
||||
val get_contact_group: string -> g [@@js.global "ContactsApp.getContactGroup"]
|
||||
val get_contacts: g -> t list [@@js.call]
|
||||
end
|
||||
|
||||
val get_contact_groups: t -> Group.g list
|
||||
end
|
||||
|
||||
|
||||
module GmailApp : sig
|
||||
type t
|
||||
val i : t [@@js.global "GmailApp"]
|
||||
val send_email: t -> address:string -> subject:string -> content:string -> unit [@@js.call]
|
||||
end
|
||||
|
||||
end)
|
110
googleApps.mli
Normal file
110
googleApps.mli
Normal file
@ -0,0 +1,110 @@
|
||||
module Dict :
|
||||
sig
|
||||
type 'a t = (string * 'a) list
|
||||
val t_to_js : ('a -> Ojs.t) -> 'a t -> Ojs.t
|
||||
val t_of_js : (Ojs.t -> 'a) -> Ojs.t -> 'a t
|
||||
end
|
||||
module Date :
|
||||
sig
|
||||
type t
|
||||
val t_of_js : Ojs.t -> t
|
||||
val t_to_js : t -> Ojs.t
|
||||
val now : unit -> t
|
||||
val get_day : t -> int
|
||||
val get_full_year : t -> int
|
||||
val get_month : t -> int
|
||||
val get_date : t -> int
|
||||
val get_hours : t -> int
|
||||
val get_minutes : t -> int
|
||||
val get_seconds : t -> int
|
||||
val to_date_string : t -> string
|
||||
val to_ISO_string : t -> string
|
||||
val to_locale_date_string : t -> string
|
||||
val to_string : t -> string
|
||||
end
|
||||
module File :
|
||||
sig
|
||||
type t
|
||||
val t_of_js : Ojs.t -> t
|
||||
val get_id : t -> string
|
||||
val get_name : t -> string
|
||||
val get_size : t -> int
|
||||
end
|
||||
module FileIterator :
|
||||
sig
|
||||
type t
|
||||
val get_files : unit -> t
|
||||
val t_of_js : Ojs.t -> t
|
||||
val has_next : t -> bool
|
||||
val next : t -> File.t
|
||||
end
|
||||
val log : string -> unit
|
||||
module Range :
|
||||
sig
|
||||
type t
|
||||
val get_a1_notation : t -> string
|
||||
val get_background : t -> string
|
||||
val get_row : t -> int
|
||||
val get_last_row : t -> int
|
||||
val get_column : t -> int
|
||||
val get_last_column : t -> int
|
||||
val get_num_columns : t -> int
|
||||
val get_num_rows : t -> int
|
||||
val get_values : t -> Ojs.t array array
|
||||
val get_formulas : t -> string array array
|
||||
val get_display_values : t -> string array array
|
||||
val set_value : t -> Ojs.t -> t
|
||||
end
|
||||
module NamedRange :
|
||||
sig type t val get_name : t -> string val get_range : t -> Range.t end
|
||||
module Sheet :
|
||||
sig
|
||||
type t
|
||||
val get_active_sheet : unit -> t
|
||||
val get_last_row : t -> int
|
||||
val get_last_column : t -> int
|
||||
val get_sheet_values :
|
||||
t ->
|
||||
start_row:int ->
|
||||
start_column:int ->
|
||||
num_rows:int -> num_columns:int -> Ojs.t array array
|
||||
val get_range :
|
||||
t ->
|
||||
start_row:int ->
|
||||
start_column:int -> num_rows:int -> num_columns:int -> Range.t
|
||||
val get_data_range : t -> Range.t
|
||||
val get_name : t -> string
|
||||
val get_named_ranges : t -> NamedRange.t list
|
||||
end
|
||||
module EmailField : sig type t val get_address : t -> string end
|
||||
module PhoneField :
|
||||
sig
|
||||
type t
|
||||
module Field : sig type t = Work | Mobile | Home end
|
||||
val get_phone_number : t -> string
|
||||
end
|
||||
module Contacts :
|
||||
sig
|
||||
type t
|
||||
val get_contacts : unit -> t list
|
||||
module Group :
|
||||
sig
|
||||
type g
|
||||
val get_contact_group : string -> g
|
||||
val get_contacts : g -> t list
|
||||
end
|
||||
val get_emails : t -> EmailField.t list
|
||||
val get_family_name : t -> string
|
||||
val get_given_name : t -> string
|
||||
val get_full_name : t -> string
|
||||
val get_phones : t -> PhoneField.t list
|
||||
val get_contact_groups : t -> Group.g list
|
||||
val add_phone : t -> PhoneField.Field.t -> string -> PhoneField.t
|
||||
end
|
||||
module GmailApp :
|
||||
sig
|
||||
type t
|
||||
val i : t
|
||||
val send_email :
|
||||
t -> address:string -> subject:string -> content:string -> unit
|
||||
end
|
24
myocamlbuild.ml
Normal file
24
myocamlbuild.ml
Normal file
@ -0,0 +1,24 @@
|
||||
open Ocamlbuild_plugin
|
||||
|
||||
module MyProject = struct
|
||||
flag ["js_of_ocaml";"prettyjs"](A"--pretty");
|
||||
flag ["link";"byte";"ocaml";"program";"no_check_prims"](A"-no-check-prims");
|
||||
rule "%.js -> %.byte"
|
||||
~dep:"%.byte"
|
||||
~prod:"%.js"
|
||||
(
|
||||
fun env build ->
|
||||
let input = env "%.byte" in
|
||||
let tags = tags_of_pathname input ++ "js_of_ocaml" in
|
||||
Cmd(S[A"js_of_ocaml"; T tags; A"+gen_js_api/ojs_runtime.js"; A input])
|
||||
)
|
||||
end
|
||||
|
||||
let () = dispatch (
|
||||
function
|
||||
| Before_options ->
|
||||
Options.use_ocamlfind := true;
|
||||
| After_rules ->
|
||||
()
|
||||
| _ -> ()
|
||||
)
|
Loading…
Reference in New Issue
Block a user