weight-recorder 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -0
  5. data/CODE_OF_CONDUCT.md +49 -0
  6. data/Gemfile +8 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +49 -0
  9. data/Rakefile +6 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/config.ru +3 -0
  13. data/exe/recorder +5 -0
  14. data/exe/weight-recorder +5 -0
  15. data/lib/application.rb +98 -0
  16. data/lib/public/chartkick.js +1396 -0
  17. data/lib/public/css/bootstrap-theme.css +587 -0
  18. data/lib/public/css/bootstrap-theme.css.map +1 -0
  19. data/lib/public/css/bootstrap-theme.min.css +6 -0
  20. data/lib/public/css/bootstrap-theme.min.css.map +1 -0
  21. data/lib/public/css/bootstrap.css +6757 -0
  22. data/lib/public/css/bootstrap.css.map +1 -0
  23. data/lib/public/css/bootstrap.min.css +6 -0
  24. data/lib/public/css/bootstrap.min.css.map +1 -0
  25. data/lib/public/fonts/glyphicons-halflings-regular.eot +0 -0
  26. data/lib/public/fonts/glyphicons-halflings-regular.svg +288 -0
  27. data/lib/public/fonts/glyphicons-halflings-regular.ttf +0 -0
  28. data/lib/public/fonts/glyphicons-halflings-regular.woff +0 -0
  29. data/lib/public/fonts/glyphicons-halflings-regular.woff2 +0 -0
  30. data/lib/public/js/bootstrap.js +2377 -0
  31. data/lib/public/js/bootstrap.min.js +7 -0
  32. data/lib/public/js/npm.js +13 -0
  33. data/lib/recorder/command/options.rb +95 -0
  34. data/lib/recorder/command.rb +80 -0
  35. data/lib/recorder/data.rb +8 -0
  36. data/lib/recorder/db.rb +51 -0
  37. data/lib/recorder/version.rb +3 -0
  38. data/lib/recorder.rb +7 -0
  39. data/lib/views/_errors.haml +6 -0
  40. data/lib/views/_form.haml +13 -0
  41. data/lib/views/chart.haml +8 -0
  42. data/lib/views/edit.haml +8 -0
  43. data/lib/views/index.haml +36 -0
  44. data/lib/views/layout.haml +16 -0
  45. data/lib/views/new.haml +18 -0
  46. data/weight-recorder.gemspec +40 -0
  47. metadata +231 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f2f31def9f7bf46c1c20bc80bec7b0fca4691e02
4
+ data.tar.gz: 6bc2ec1be02e852a8d3efb1bb68f9328ff7ab792
5
+ SHA512:
6
+ metadata.gz: 307041f4f5d69f89a3ac42c9f70938777e4e0289afa05fed6a93f76de8d26e66e84df496c0ff3b68c5bab1dda97d032d824e2aabd85a8daed7a0046a54ceca6f
7
+ data.tar.gz: 1c52a6bcb57d3712e302e58f3482a0afcfa69c62d9463163513140e34c72105dca06bd7a7d832713ba439177f9f08b04459f4a6b4b03785899d037ec1d8da99c
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.11.2
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at shigeto_nishitani@me.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :development do
4
+ gem 'sinatra-reloader'
5
+ end
6
+
7
+ # Specify your gem's dependencies in recorder.gemspec
8
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Shigeto R. Nishitani
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # Recorder
2
+
3
+ Recording values, spcifically weight and fat, and display chart
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'recorder'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install recorder
20
+
21
+ ## Usage
22
+
23
+ ```
24
+ bundle exec exe/recorder --help
25
+ Usage: recorder [-h|--help] [-v|--version] <command> [<args>]
26
+ -v, --version show program version
27
+ -h, --help Show this message
28
+
29
+ recorder Available Commands:
30
+ create -w weight -b bodyfat Create Data
31
+ update id -w weiht -b bodyfat -d date Update Data
32
+ delete id Delete Data
33
+ ```
34
+
35
+ ## Development
36
+
37
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec recorder` to use the gem in this directory, ignoring other installed copies of this gem.
38
+
39
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
40
+
41
+ ## Contributing
42
+
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/daddygongon/recorder. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
44
+
45
+
46
+ ## License
47
+
48
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
49
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "weight/recorder"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/config.ru ADDED
@@ -0,0 +1,3 @@
1
+ require 'application'
2
+
3
+ run Recorder::Application
data/exe/recorder ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "recorder"
4
+
5
+ Recorder::Command.run(ARGV)
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "weight-recorder"
4
+
5
+ WeightRecorder::Command.run(ARGV)
@@ -0,0 +1,98 @@
1
+ # coding: utf-8
2
+
3
+ require 'sinatra/base'
4
+ require 'haml'
5
+ require 'chartkick'
6
+
7
+ require 'recorder/db'
8
+ require 'recorder/data'
9
+
10
+ module Recorder
11
+ class Application < Sinatra::Base
12
+ use Rack::MethodOverride
13
+ set :haml, escape_html: true
14
+ enable :prefixed_redirects
15
+
16
+ configure do
17
+ DB.prepare
18
+ end
19
+
20
+ configure :development do
21
+ require 'sinatra/reloader'
22
+ register Sinatra::Reloader
23
+ end
24
+
25
+ get '/' do
26
+ redirect 'data'
27
+ end
28
+
29
+ get '/data' do
30
+ @data = Data.order('created_at DESC')
31
+
32
+ haml :index
33
+ end
34
+
35
+ get '/data/new' do
36
+ @data = Data.new
37
+
38
+ haml :new
39
+ end
40
+
41
+ get '/data/:id/edit' do
42
+ @data = Data.find(params[:id])
43
+
44
+ haml :edit
45
+ end
46
+
47
+ put '/data/:id' do
48
+ begin
49
+ data = Data.find(params[:id])
50
+ data.update_attributes!(
51
+ weight: params[:weight],
52
+ bodyfat: params[:bodyfat],
53
+ date: params[:date]
54
+ )
55
+ redirect '/'
56
+ rescue ActiveRecord::RecordInvalid => e
57
+ @data = e.record
58
+ haml :edit
59
+ end
60
+ end
61
+
62
+ post '/data' do
63
+ begin
64
+ Data.create!(weight: params[:weight],
65
+ bodyfat: params[:bodyfat],
66
+ date: params[:date])
67
+
68
+ redirect '/'
69
+ rescue ActiveRecord::RecordInvalid => e
70
+ @data = e.record
71
+
72
+ haml :new
73
+ end
74
+ end
75
+
76
+ delete '/data/:id' do
77
+ data = Data.find(params[:id])
78
+ data.destroy
79
+ redirect '/'
80
+ end
81
+
82
+ get '/chart' do
83
+ @weight_options = {min: 84, max: 90}
84
+ @weight_data,@bodyfat_data = get_data
85
+ haml :chart
86
+ end
87
+
88
+ def get_data
89
+ @data = Data.order('created_at DESC')
90
+ weight_data,bodyfat_data=[],[]
91
+ @data.each{|d|
92
+ weight_data << [d.date,d.weight]
93
+ bodyfat_data << [d.date,d.bodyfat]
94
+ }
95
+ return weight_data,bodyfat_data
96
+ end
97
+ end
98
+ end