Skip to content

A little elixir program to update time registers in a google drive spreadsheet (proof of concept)

License

Notifications You must be signed in to change notification settings

ialiendeg/TimeRegister

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TimeRegister

A little elixir program to update time registers in a google drive spreadsheet

Installation

If you're a developer and clone the repo, you can use mix to install dependencies and then build and install the executable.

$ mix deps.get
$ MIX_ENV=prod mix escript.build
$ MIX_ENV=prod mix escript.install

By default, escript executables are installed in ~/.mix/escripts, so you have to add this folder to your path. Otherwise, you can copy the executable in a folder already added to the path, like /usr/local/bin

NOTE: An escript is an executable that can be invoked from the command line. An escript can run on any machine that has Erlang/OTP installed and by default does not require Elixir to be installed, as Elixir is embedded as part of the escript.

Configuration

Follow this steps to create and configure a project in Google Developers Console (extracted from https://github.com/Voronchuk/elixir_google_spreadsheets, the best explanation I've found so far, thx Voronchuk)

  1. Use this wizard to create or select a project in the Google Developers Console and automatically turn on the API. Click Continue, then Go to credentials.
  2. On the Add credentials to your project page, create Service account key.
  3. Select your project name as service account and JSON as key format, download the created key and rename it to service_account.json.
  4. Press Manage service accounts on a credential page, copy your Service Account Identifier: [projectname]@[domain].iam.gserviceaccount.com

Create or open existing Google Spreadsheet document on your Google Drive and add Service Account Identifier as user invited in spreadsheet's Collaboration Settings.

Put your service_account.json in ~/.time_register folder

Finally, in the same folder, create a settings json file with general configuration and secrets.

{
  "spreadsheet_url": "XXXXXXXXXXXXXXXXXXXXXXXXXXX-XXXXXXXXXXXXXXXX",
  "first_row": 0,
  "columns_to_update": 0
}

spreadsheet_url: spreadsheet id from url

header_rows: number of header rows to skip (1 in sheet example below)

columns_to_update: columns to be updated in every month day row (5 in sheet example below)

Time registers sheet example

1 | month day | morning start | afternoon start | morning end | afternoon end
2 |     1     |               |                 |             |
3 |     2     |               |                 |             |

Usage

time_register -i|--item <item>   # Updates item in current day row
time_register -s                 # Show current day row values

item: It's one of: sm (start at morning); em (end at morning); sa (start at afternoon); ea (end at afternoon)

Notes

Use of tzdata version ~>0.1.8 is needed for escript building (see bitwalker/timex#86)

About

A little elixir program to update time registers in a google drive spreadsheet (proof of concept)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages