weight-recorder 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 04fc913ff738d9c2de6b940171ef6eccf8f13e35
4
- data.tar.gz: 432108a4c9d9081b56f7bba2fd28cfb0a7c224df
3
+ metadata.gz: c249d4e0df8064c1dfa8d8adf4859a531d11021e
4
+ data.tar.gz: 01aca001cb8bfaf54e4ad1eb27dbf2ce18fd374b
5
5
  SHA512:
6
- metadata.gz: 2f852b2c0b419cff4092f187caaf618b85d75e73b250509a1b71dbb436867ef027cc2eed0acd100f7c1456da380f4ceb7a1b62f627dd32b61bb9b339fe11168e
7
- data.tar.gz: bfbfc80b825add0f68d7754e3d1718b85380b4fc8db52c37658bb546c20208feb152fc40ba54d840f40f7cfa48811dfdae068b365c26ff990ebd619aafa2df0e
6
+ metadata.gz: 4d5b69014cab33cbc08c0e052ed122a89bc5e79a2062629a82f2e319d5bbba76b6c26c8ca5548b07c7a527a384de57bca45a21facbd482720c4d9ea015825ef6
7
+ data.tar.gz: d79383cac20fc7ecb163393a4a8f3e51ae4d5df6c30ba72fc450d87547934d0137167ca9c2eada0b78e26e25178a4ac697c19f1d82cb36f675c1581548a338e6
data/lib/application.rb CHANGED
@@ -108,6 +108,7 @@ module Recorder
108
108
 
109
109
  require 'date'
110
110
  require 'time'
111
+
111
112
  def get_data(period=:all)
112
113
  @data = Data.order('created_at DESC')
113
114
  weight_data,bodyfat_data=[],[]
@@ -0,0 +1,48 @@
1
+ #encoding: utf-8
2
+
3
+ require 'fileutils'
4
+ require 'active_record'
5
+
6
+ module Recorder
7
+
8
+ module DB
9
+
10
+ def self.prepare
11
+ database_path = File.join(ENV['HOME'], '.recorder','recorder.sqlite3')
12
+
13
+ connect_database database_path
14
+ create_table_if_not_exists database_path
15
+ end
16
+
17
+ def self.connect_database(path)
18
+ spec = {adapter: 'sqlite3', database: path}
19
+ ActiveRecord::Base.establish_connection spec
20
+ end
21
+
22
+ def self.create_table_if_not_exists(path)
23
+ create_database_path path
24
+
25
+ connection = ActiveRecord::Base.connection
26
+
27
+ return if connection.table_exists?(:data)
28
+
29
+ connection.create_table :data do |d|
30
+ d.column :weight, :real, null: false
31
+ d.column :bodyfat, :real, null: true
32
+ d.column :date, :text, null: true
33
+ d.column :memo, :text, null: true
34
+ d.timestamps
35
+ end
36
+ connection.add_index :data, :created_at
37
+ connection.add_index :data, :date
38
+
39
+ end
40
+
41
+ def self.create_database_path(path)
42
+ FileUtils.mkdir_p File.dirname(path)
43
+ end
44
+
45
+ private_class_method :connect_database, :create_table_if_not_exists, :create_database_path
46
+
47
+ end
48
+ end
@@ -1,3 +1,3 @@
1
1
  module Recorder
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
data/lib/views/chart.haml CHANGED
@@ -3,3 +3,4 @@
3
3
  %p
4
4
  != line_chart @weight_data, @weight_options
5
5
  != line_chart @bodyfat_data, @bodyfat_options
6
+
@@ -13,8 +13,9 @@
13
13
  %nav.navbar.navbar-default
14
14
  .container-fluid
15
15
  .navbar-header
16
- /%a.navbar-brand{href: uri('/data')} Weight Recorder
17
- %a.navbar-brand Bob's weight
16
+ %a.navbar-brand{href: uri('/data')} Weight Recorder
17
+ /%a.navbar-brand Bob's weight
18
+ /%a.navbar-brand #{@title}
18
19
  %button{class: ('btn btn-default navbar-btn')}
19
20
  %a(class="glyphicon glyphicon-pencil"){href: uri('data/new')} new
20
21
  %button{class: ('btn btn-default navbar-btn')}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weight-recorder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shigeto R. Nishitani
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-31 00:00:00.000000000 Z
11
+ date: 2016-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -218,7 +218,6 @@ files:
218
218
  - exe/weight-recorder
219
219
  - hikis/README_en.hiki
220
220
  - hikis/modify_db.hiki
221
- - latexes/handout_pre.tex
222
221
  - lib/application.rb
223
222
  - lib/public/chartkick.js
224
223
  - lib/public/css/bootstrap-theme.css
@@ -238,6 +237,7 @@ files:
238
237
  - lib/public/js/bootstrap.min.js
239
238
  - lib/public/js/npm.js
240
239
  - lib/recorder.rb
240
+ - lib/recorder/#db.rb#
241
241
  - lib/recorder/command.rb
242
242
  - lib/recorder/command/options.rb
243
243
  - lib/recorder/data.rb
@@ -1,11 +0,0 @@
1
- \documentclass[10pt,a4j,twocolumn]{jsarticle}
2
-
3
- \usepackage[dvipdfmx]{graphicx}
4
-
5
- \setlength{\textheight}{275mm}
6
- \headheight 5mm
7
- \topmargin -30mm
8
- \textwidth 185mm
9
- \oddsidemargin -15mm
10
- \evensidemargin -15mm
11
- \pagestyle{empty}