alu0100894646menu 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +11 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +111 -0
- data/Guardfile +82 -0
- data/README.md +37 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/tdd/dietetico_desl.rb +194 -0
- data/lib/tdd/dll_etiqueta.rb +77 -0
- data/lib/tdd/valor_energetico.rb +86 -0
- data/lib/tdd/valor_nutricional.rb +103 -0
- data/lib/tdd/version.rb +3 -0
- data/lib/tdd.rb +11 -0
- data/tdd.gemspec +44 -0
- data/travis.yml +0 -0
- metadata +159 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ffee2594d393bdf6979287964b4eb1d60f4af777
|
4
|
+
data.tar.gz: c29b6e87cf7048c2b25e75f991e83cc25bef23c2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d21e38c1dd11748bc2301f3e47cd06776db2b677ebe477da09dd6f826b3aed393f0871717b83081fd8fd153bbada6028e4195bc77dcefebac4c242ecb5a2d538
|
7
|
+
data.tar.gz: f374d01364f43c8bcd3c88cdc7df554e6c069a83f1eb88db09b48528d5a9fa3f2d313c7de5419a7368cd749da8a45aedbe8f90f90f50868bda03e57ad136477b
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
alu0100894646menu (0.1.5)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
coderay (1.1.2)
|
10
|
+
coveralls (0.7.1)
|
11
|
+
multi_json (~> 1.3)
|
12
|
+
rest-client
|
13
|
+
simplecov (>= 0.7)
|
14
|
+
term-ansicolor
|
15
|
+
thor
|
16
|
+
diff-lcs (1.3)
|
17
|
+
docile (1.3.1)
|
18
|
+
domain_name (0.5.20180417)
|
19
|
+
unf (>= 0.0.5, < 1.0.0)
|
20
|
+
ffi (1.9.25)
|
21
|
+
formatador (0.2.5)
|
22
|
+
guard (2.15.0)
|
23
|
+
formatador (>= 0.2.4)
|
24
|
+
listen (>= 2.7, < 4.0)
|
25
|
+
lumberjack (>= 1.0.12, < 2.0)
|
26
|
+
nenv (~> 0.1)
|
27
|
+
notiffany (~> 0.0)
|
28
|
+
pry (>= 0.9.12)
|
29
|
+
shellany (~> 0.0)
|
30
|
+
thor (>= 0.18.1)
|
31
|
+
guard-bundler (2.1.0)
|
32
|
+
bundler (~> 1.0)
|
33
|
+
guard (~> 2.2)
|
34
|
+
guard-compat (~> 1.1)
|
35
|
+
guard-compat (1.2.1)
|
36
|
+
guard-rspec (4.7.3)
|
37
|
+
guard (~> 2.1)
|
38
|
+
guard-compat (~> 1.1)
|
39
|
+
rspec (>= 2.99.0, < 4.0)
|
40
|
+
http-cookie (1.0.3)
|
41
|
+
domain_name (~> 0.5)
|
42
|
+
json (2.1.0)
|
43
|
+
listen (3.1.5)
|
44
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
45
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
46
|
+
ruby_dep (~> 1.2)
|
47
|
+
lumberjack (1.0.13)
|
48
|
+
method_source (0.9.2)
|
49
|
+
mime-types (3.2.2)
|
50
|
+
mime-types-data (~> 3.2015)
|
51
|
+
mime-types-data (3.2018.0812)
|
52
|
+
multi_json (1.13.1)
|
53
|
+
nenv (0.3.0)
|
54
|
+
netrc (0.11.0)
|
55
|
+
notiffany (0.1.1)
|
56
|
+
nenv (~> 0.1)
|
57
|
+
shellany (~> 0.0)
|
58
|
+
pry (0.12.2)
|
59
|
+
coderay (~> 1.1.0)
|
60
|
+
method_source (~> 0.9.0)
|
61
|
+
rake (10.5.0)
|
62
|
+
rb-fsevent (0.10.3)
|
63
|
+
rb-inotify (0.9.10)
|
64
|
+
ffi (>= 0.5.0, < 2)
|
65
|
+
rest-client (2.0.2)
|
66
|
+
http-cookie (>= 1.0.2, < 2.0)
|
67
|
+
mime-types (>= 1.16, < 4.0)
|
68
|
+
netrc (~> 0.8)
|
69
|
+
rspec (3.8.0)
|
70
|
+
rspec-core (~> 3.8.0)
|
71
|
+
rspec-expectations (~> 3.8.0)
|
72
|
+
rspec-mocks (~> 3.8.0)
|
73
|
+
rspec-core (3.8.0)
|
74
|
+
rspec-support (~> 3.8.0)
|
75
|
+
rspec-expectations (3.8.2)
|
76
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
77
|
+
rspec-support (~> 3.8.0)
|
78
|
+
rspec-mocks (3.8.0)
|
79
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
80
|
+
rspec-support (~> 3.8.0)
|
81
|
+
rspec-support (3.8.0)
|
82
|
+
ruby_dep (1.5.0)
|
83
|
+
shellany (0.0.1)
|
84
|
+
simplecov (0.16.1)
|
85
|
+
docile (~> 1.1)
|
86
|
+
json (>= 1.8, < 3)
|
87
|
+
simplecov-html (~> 0.10.0)
|
88
|
+
simplecov-html (0.10.2)
|
89
|
+
term-ansicolor (1.7.0)
|
90
|
+
tins (~> 1.0)
|
91
|
+
thor (0.20.3)
|
92
|
+
tins (1.20.2)
|
93
|
+
unf (0.1.4)
|
94
|
+
unf_ext
|
95
|
+
unf_ext (0.0.7.5)
|
96
|
+
|
97
|
+
PLATFORMS
|
98
|
+
ruby
|
99
|
+
|
100
|
+
DEPENDENCIES
|
101
|
+
alu0100894646menu!
|
102
|
+
bundler (~> 1.17)
|
103
|
+
coveralls
|
104
|
+
guard
|
105
|
+
guard-bundler
|
106
|
+
guard-rspec
|
107
|
+
rake (~> 10.0)
|
108
|
+
rspec (~> 3.0)
|
109
|
+
|
110
|
+
BUNDLED WITH
|
111
|
+
1.17.1
|
data/Guardfile
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features) \
|
6
|
+
# .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
guard :bundler do
|
19
|
+
require 'guard/bundler'
|
20
|
+
require 'guard/bundler/verify'
|
21
|
+
helper = Guard::Bundler::Verify.new
|
22
|
+
|
23
|
+
files = ['Gemfile']
|
24
|
+
files += Dir['*.gemspec'] if files.any? { |f| helper.uses_gemspec?(f) }
|
25
|
+
|
26
|
+
# Assume files are symlinked from somewhere
|
27
|
+
files.each { |file| watch(helper.real_path(file)) }
|
28
|
+
end
|
29
|
+
|
30
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
31
|
+
# rspec may be run, below are examples of the most common uses.
|
32
|
+
# * bundler: 'bundle exec rspec'
|
33
|
+
# * bundler binstubs: 'bin/rspec'
|
34
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
35
|
+
# installed the spring binstubs per the docs)
|
36
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
37
|
+
# * 'just' rspec: 'rspec'
|
38
|
+
|
39
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
40
|
+
require "guard/rspec/dsl"
|
41
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
42
|
+
|
43
|
+
# Feel free to open issues for suggestions and improvements
|
44
|
+
|
45
|
+
# RSpec files
|
46
|
+
rspec = dsl.rspec
|
47
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
48
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
49
|
+
watch(rspec.spec_files)
|
50
|
+
|
51
|
+
# Ruby files
|
52
|
+
ruby = dsl.ruby
|
53
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
54
|
+
|
55
|
+
# Rails files
|
56
|
+
rails = dsl.rails(view_extensions: %w(erb haml slim))
|
57
|
+
dsl.watch_spec_files_for(rails.app_files)
|
58
|
+
dsl.watch_spec_files_for(rails.views)
|
59
|
+
|
60
|
+
watch(rails.controllers) do |m|
|
61
|
+
[
|
62
|
+
rspec.spec.call("routing/#{m[1]}_routing"),
|
63
|
+
rspec.spec.call("controllers/#{m[1]}_controller"),
|
64
|
+
rspec.spec.call("acceptance/#{m[1]}")
|
65
|
+
]
|
66
|
+
end
|
67
|
+
|
68
|
+
# Rails config changes
|
69
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
70
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
71
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
72
|
+
|
73
|
+
# Capybara features specs
|
74
|
+
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
|
75
|
+
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
|
76
|
+
|
77
|
+
# Turnip features and steps
|
78
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
79
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
80
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
81
|
+
end
|
82
|
+
end
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Tdd
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/tdd`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'tdd'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install tdd
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
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.
|
30
|
+
|
31
|
+
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).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/tdd.
|
36
|
+
|
37
|
+
https://coveralls.io/repos/github/ULL-ESIT-LPP-1819/tdd-alu0100894646/badge.svg?branch=master(Coverage Status)!:https://coveralls.io/github/ULL-ESIT-LPP-1819/tdd-alu0100894646?branch=master
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "tdd"
|
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(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,194 @@
|
|
1
|
+
class Dieta_dsl
|
2
|
+
attr_accessor :name
|
3
|
+
|
4
|
+
def initialize(name, &block)
|
5
|
+
@dia = name
|
6
|
+
@titulo = ""
|
7
|
+
@ingesta = []
|
8
|
+
@desayuno = []
|
9
|
+
@almuerzo = []
|
10
|
+
@cena = []
|
11
|
+
|
12
|
+
|
13
|
+
if block_given?
|
14
|
+
if block.arity == 1
|
15
|
+
yield self
|
16
|
+
else
|
17
|
+
instance_eval(&block)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_s
|
23
|
+
output = "\n #{@titulo}"
|
24
|
+
output << "\n ###############################################################################"
|
25
|
+
output << "\n #{@dia}\t\t\t\tComposición nutricional"
|
26
|
+
output << "\n ==============================================================================="
|
27
|
+
output << "\n \t\t\tgrasas \t carbohidratos \t proteinas \t fibra \t sal \t valor energetico"
|
28
|
+
output << "\n Desayuno"
|
29
|
+
total_kcal = 0
|
30
|
+
@desayuno.each do |elemento|
|
31
|
+
|
32
|
+
if elemento[:descripcion] == nil
|
33
|
+
elemento[:descripcion] = 0.00
|
34
|
+
end
|
35
|
+
|
36
|
+
if elemento[:fibra] == nil
|
37
|
+
elemento[:fibra] = 0.00
|
38
|
+
end
|
39
|
+
|
40
|
+
if elemento[:grasas] == nil
|
41
|
+
elemento[:grasas] = 0.00
|
42
|
+
end
|
43
|
+
|
44
|
+
if elemento[:carbohidratos] == nil
|
45
|
+
elemento[:carbohidratos] = 0.00
|
46
|
+
end
|
47
|
+
|
48
|
+
if elemento[:proteinas] == nil
|
49
|
+
elemento[:proteinas] = 0.00
|
50
|
+
end
|
51
|
+
|
52
|
+
if elemento[:sal] == nil
|
53
|
+
elemento[:sal] = 0.00
|
54
|
+
end
|
55
|
+
output << "\n \"#{elemento[:descripcion]}\""
|
56
|
+
output << "\t #{ '%.2f' % elemento[:grasas]}"
|
57
|
+
output << "\t\t #{ '%.2f' % elemento[:carbohidratos]}"
|
58
|
+
output << "\t #{ '%.2f' % elemento[:proteinas]}"
|
59
|
+
output << "\t\t #{ '%.2f' % elemento[:fibra]}"
|
60
|
+
output << "\t #{ '%.2f' % elemento[:sal]}"
|
61
|
+
output << "\t #{ '%.2f' % kcal_calc(elemento)}"
|
62
|
+
total_kcal+=kcal_calc(elemento)
|
63
|
+
end
|
64
|
+
output << "\n\n\n Almuerzo"
|
65
|
+
@almuerzo.each do |elemento|
|
66
|
+
if elemento[:descripcion] == nil
|
67
|
+
elemento[:descripcion] = 0.00
|
68
|
+
end
|
69
|
+
|
70
|
+
if elemento[:fibra] == nil
|
71
|
+
elemento[:fibra] = 0.00
|
72
|
+
end
|
73
|
+
|
74
|
+
if elemento[:grasas] == nil
|
75
|
+
elemento[:grasas] = 0.00
|
76
|
+
end
|
77
|
+
|
78
|
+
if elemento[:carbohidratos] == nil
|
79
|
+
elemento[:carbohidratos] = 0.00
|
80
|
+
end
|
81
|
+
|
82
|
+
if elemento[:proteinas] == nil
|
83
|
+
elemento[:proteinas] = 0.00
|
84
|
+
end
|
85
|
+
|
86
|
+
if elemento[:sal] == nil
|
87
|
+
elemento[:sal] = 0.00
|
88
|
+
end
|
89
|
+
output << "\n \"#{elemento[:descripcion]}\""
|
90
|
+
output << "\t #{ '%.2f' % elemento[:grasas]}"
|
91
|
+
output << "\t\t #{ '%.2f' % elemento[:carbohidratos]}"
|
92
|
+
output << "\t #{ '%.2f' % elemento[:proteinas]}"
|
93
|
+
output << "\t\t #{ '%.2f' % elemento[:fibra]}"
|
94
|
+
output << "\t #{ '%.2f' % elemento[:sal]}"
|
95
|
+
output << "\t #{ '%.2f' % kcal_calc(elemento)}"
|
96
|
+
total_kcal+=kcal_calc(elemento)
|
97
|
+
end
|
98
|
+
output << "\n\n\n Cena"
|
99
|
+
@cena.each do |elemento|
|
100
|
+
if elemento[:descripcion] == nil
|
101
|
+
elemento[:descripcion] = 0.00
|
102
|
+
end
|
103
|
+
|
104
|
+
if elemento[:fibra] == nil
|
105
|
+
elemento[:fibra] = 0.00
|
106
|
+
end
|
107
|
+
|
108
|
+
if elemento[:grasas] == nil
|
109
|
+
elemento[:grasas] = 0.00
|
110
|
+
end
|
111
|
+
|
112
|
+
if elemento[:carbohidratos] == nil
|
113
|
+
elemento[:carbohidratos] = 0.00
|
114
|
+
end
|
115
|
+
|
116
|
+
if elemento[:proteinas] == nil
|
117
|
+
elemento[:proteinas] = 0.00
|
118
|
+
end
|
119
|
+
|
120
|
+
if elemento[:sal] == nil
|
121
|
+
elemento[:sal] = 0.00
|
122
|
+
end
|
123
|
+
output << "\n \"#{elemento[:descripcion]}\""
|
124
|
+
output << "\t #{ '%.2f' % elemento[:grasas]}"
|
125
|
+
output << "\t\t #{ '%.2f' % elemento[:carbohidratos]}"
|
126
|
+
output << "\t #{ '%.2f' % elemento[:proteinas]}"
|
127
|
+
output << "\t\t #{ '%.2f' % elemento[:fibra]}"
|
128
|
+
output << "\t #{ '%.2f' % elemento[:sal]}"
|
129
|
+
output << "\t #{ '%.2f' % kcal_calc(elemento)}"
|
130
|
+
total_kcal+=kcal_calc(elemento)
|
131
|
+
end
|
132
|
+
output << "\n Valor energetico total #{'%.2f' % total_kcal}"
|
133
|
+
output
|
134
|
+
end
|
135
|
+
|
136
|
+
def titulo(title)
|
137
|
+
|
138
|
+
@titulo = title
|
139
|
+
|
140
|
+
end
|
141
|
+
|
142
|
+
def ingesta(name, options={})
|
143
|
+
|
144
|
+
ingesta = name
|
145
|
+
ingesta << "(#{options[:min]})" if options[:min]
|
146
|
+
ingesta << "(#{options[:max]})" if options[:max]
|
147
|
+
|
148
|
+
@ingesta << ingesta
|
149
|
+
end
|
150
|
+
|
151
|
+
def desayuno(name, options={})
|
152
|
+
desayuno = name
|
153
|
+
desayuno << "(#{options[:descripcion]})" if options[:descripcion]
|
154
|
+
desayuno << "(#{options[:porcion]})" if options[:porcion]
|
155
|
+
desayuno << "(#{options[:gramos]})" if options[:gramos]
|
156
|
+
desayuno << "(#{options[:grasas]})" if options[:grasas]
|
157
|
+
desayuno << "(#{options[:carbohidratos]})" if options[:carbohidratos]
|
158
|
+
desayuno << "(#{options[:proteinas]})" if options[:proteinas]
|
159
|
+
desayuno << "(#{options[:fibra]})" if options[:fibra]
|
160
|
+
desayuno << "(#{options[:sal]})" if options[:sal]
|
161
|
+
@desayuno << desayuno
|
162
|
+
end
|
163
|
+
|
164
|
+
def almuerzo(name, options={})
|
165
|
+
almuerzo = name
|
166
|
+
almuerzo << "(#{options[:descripcion]})" if options[:descripcion]
|
167
|
+
almuerzo << "(#{options[:porcion]})" if options[:porcion]
|
168
|
+
almuerzo << "(#{options[:gramos]})" if options[:gramos]
|
169
|
+
almuerzo << "(#{options[:grasas]})" if options[:grasas]
|
170
|
+
almuerzo << "(#{options[:carbohidratos]})" if options[:carbohidratos]
|
171
|
+
almuerzo << "(#{options[:proteinas]})" if options[:proteinas]
|
172
|
+
almuerzo << "(#{options[:fibra]})" if options[:fibra]
|
173
|
+
almuerzo << "(#{options[:sal]})" if options[:sal]
|
174
|
+
@almuerzo << almuerzo
|
175
|
+
end
|
176
|
+
|
177
|
+
def cena(name, options={})
|
178
|
+
cena = name
|
179
|
+
cena << "(#{options[:descripcion]})" if options[:descripcion]
|
180
|
+
cena << "(#{options[:porcion]})" if options[:porcion]
|
181
|
+
cena << "(#{options[:gramos]})" if options[:gramos]
|
182
|
+
cena << "(#{options[:grasas]})" if options[:grasas]
|
183
|
+
cena << "(#{options[:carbohidratos]})" if options[:carbohidratos]
|
184
|
+
cena << "(#{options[:proteinas]})" if options[:proteinas]
|
185
|
+
cena << "(#{options[:fibra]})" if options[:fibra]
|
186
|
+
cena << "(#{options[:sal]})" if options[:sal]
|
187
|
+
@cena << cena
|
188
|
+
end
|
189
|
+
|
190
|
+
def kcal_calc(elemento)
|
191
|
+
(elemento[:grasas]*9 + elemento[:carbohidratos]*4 + elemento[:proteinas]*4 +elemento[:fibra]*2 + elemento[:sal]*6)/10
|
192
|
+
|
193
|
+
end
|
194
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
Node = Struct.new(:value,:next,:prev)
|
2
|
+
|
3
|
+
class Dll
|
4
|
+
include Enumerable
|
5
|
+
attr_accessor :head,:tail
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@head = nil
|
9
|
+
@tail = nil
|
10
|
+
end
|
11
|
+
|
12
|
+
def insert_head(value)
|
13
|
+
|
14
|
+
nodo = Node.new(value,nil,nil)
|
15
|
+
|
16
|
+
if(@head == nil)
|
17
|
+
@head = nodo
|
18
|
+
@tail = nodo
|
19
|
+
else
|
20
|
+
@head.prev = nodo
|
21
|
+
nodo.next = @head
|
22
|
+
@head = nodo
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def insert_tail(value)
|
28
|
+
|
29
|
+
nodo = Node.new(value,nil,nil)
|
30
|
+
|
31
|
+
if(@tail ==nil)
|
32
|
+
@tail=nodo
|
33
|
+
@head=nodo
|
34
|
+
else
|
35
|
+
@tail.next=nodo
|
36
|
+
nodo.prev=@tail
|
37
|
+
@tail=nodo
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_head
|
42
|
+
dummy = @head
|
43
|
+
@head = @head.next
|
44
|
+
dummy
|
45
|
+
end
|
46
|
+
|
47
|
+
def get_tail
|
48
|
+
dummy = @tail
|
49
|
+
@tail = @tail.prev
|
50
|
+
dummy
|
51
|
+
end
|
52
|
+
|
53
|
+
def empty?
|
54
|
+
@head == nil
|
55
|
+
@tail == nil
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
def to_s
|
60
|
+
it = @head
|
61
|
+
while it!=nil
|
62
|
+
puts it.value.to_s
|
63
|
+
it=it.next
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def each
|
68
|
+
|
69
|
+
it = @head
|
70
|
+
|
71
|
+
while it !=nil
|
72
|
+
yield it.value
|
73
|
+
it=it.next
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
class ValorEnergetico
|
2
|
+
|
3
|
+
include Comparable
|
4
|
+
attr_reader :etiqueta,:grasa,:saturada,:hidratos,:azucar,:proteinas,:sal,:valor_energetico,:porcion,:num_porciones
|
5
|
+
|
6
|
+
def initialize(etiqueta,grasa,saturada,hidratos,azucar,proteinas,sal,porcion,num_porciones)
|
7
|
+
|
8
|
+
@etiqueta = etiqueta
|
9
|
+
@grasa = grasa
|
10
|
+
@saturada = saturada
|
11
|
+
@hidratos= hidratos
|
12
|
+
@azucar= azucar
|
13
|
+
@proteinas=proteinas
|
14
|
+
@sal = sal
|
15
|
+
|
16
|
+
@valor_energetico = []
|
17
|
+
@num_porciones = num_porciones;
|
18
|
+
@porcion = porcion/100
|
19
|
+
|
20
|
+
calc_val_energetico_KJ
|
21
|
+
calc_val_energetico_Kcal
|
22
|
+
# Kj Kcal Fat Fsat HCar Azuc Prot Sal
|
23
|
+
@ingesta_recomendada = [8400.0,2000.0,70.0,20.0,260.0,90.0,50.0,6.0]
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def <=>(other)
|
28
|
+
return nil unless other.instance_of?ValorEnergetico
|
29
|
+
@etiqueta <=> other.etiqueta
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_salt
|
33
|
+
|
34
|
+
if(@sal < 6.0)
|
35
|
+
"Bajo"
|
36
|
+
else
|
37
|
+
"Alto"
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
def calc_val_energetico_KJ
|
43
|
+
|
44
|
+
if @valor_energetico.length < 3
|
45
|
+
valor_energetico << (37.0*@grasa) + (17.0*@hidratos) + (17.0*@proteinas) + (25.0*@sal)
|
46
|
+
end
|
47
|
+
|
48
|
+
valor_energetico[0]
|
49
|
+
end
|
50
|
+
|
51
|
+
def calc_val_energetico_Kcal
|
52
|
+
|
53
|
+
if @valor_energetico.length < 3
|
54
|
+
valor_energetico << (9.0*@grasa) + (4.0*@hidratos) + (4.0*@proteinas) + (6.0*@sal)
|
55
|
+
end
|
56
|
+
|
57
|
+
valor_energetico[1]
|
58
|
+
end
|
59
|
+
|
60
|
+
def +(other)
|
61
|
+
calc_val_energetico_Kcal+other.calc_val_energetico_Kcal
|
62
|
+
end
|
63
|
+
|
64
|
+
def to_s
|
65
|
+
|
66
|
+
#puts "Valores Nutricionales para #{@etiqueta} con porciones de tamaño #{@porcion*100}g y con #{@num_porciones} porcion(es)"
|
67
|
+
#puts "\t\t Por 100g/ml de producto | IR (por 100g/ml) | Porcion de #{@porcion*100}g/ml | IR por #{@porcion*100}g"
|
68
|
+
#puts "Valor Energético #{@valor_energetico[0]} Kj \t\t | #{(@valor_energetico[0]/@ingesta_recomendada[0]).round(2)*100}% \t\t| #{(@valor_energetico[0]*@porcion).round(2)}Kj \t\t| #{((@valor_energetico[0]/@ingesta_recomendada[0])*@porcion).round(2)*100}%"
|
69
|
+
#puts "(Kj/Kcal) #{@valor_energetico[1]} Kcal \t\t| #{(@valor_energetico[1]/@ingesta_recomendada[1]).round(2)*100}% \t\t| #{(@valor_energetico[1]*@porcion).round(2)}Kcal \t\t| #{((@valor_energetico[1]/@ingesta_recomendada[1])*@porcion).round(2)*100}%"
|
70
|
+
#puts "Grasas de las #{@grasa}g \t\t| #{(@grasa/@ingesta_recomendada[2]).round(2)*100}% \t\t| #{(@grasa*@porcion).round(2)} \t\t| #{((@grasa/@ingesta_recomendada[2])*@porcion).round(2)*100}%"
|
71
|
+
#puts "cuales:"
|
72
|
+
#puts "saturadas #{@saturada}g \t\t| #{(@saturada/@ingesta_recomendada[3]).round(2)*100}% \t\t| #{(@saturada*@porcion).round(2)}g \t\t| #{((@saturada/@ingesta_recomendada[3])*@porcion).round(2)*100}%"
|
73
|
+
#puts "Hidratos de #{@hidratos}g \t\t| #{(@hidratos/@ingesta_recomendada[4]).round(2)*100}% \t\t| #{(@hidratos*@porcion).round(2)}g \t\t| #{((@hidratos/@ingesta_recomendada[4])*@porcion).round(2)*100}%"
|
74
|
+
#puts "carbono de los "
|
75
|
+
#puts "cuales: "
|
76
|
+
#puts "Azucares: #{@azucar}g \t\t| #{(@azucar/@ingesta_recomendada[5]).round(2)*100}% \t\t| #{(@azucar*@porcion).round(2)}g \t\t| #{((@azucar/@ingesta_recomendada[5])*@porcion).round(2)*100}%"
|
77
|
+
#puts "Proteinas: #{@proteinas}g \t\t| #{(@proteinas/@ingesta_recomendada[6]).round(2)*100}% \t\t| #{(@proteinas*@porcion).round(2)}g \t\t| #{((@proteinas/@ingesta_recomendada[6])*@porcion).round(2)*100}%"
|
78
|
+
#puts "Sal: #{@sal}g \t\t| #{(@sal/@ingesta_recomendada[7]).round(2)*100}% \t\t| #{(@proteinas*@porcion).round(2)} \t\t| #{((@sal/@ingesta_recomendada[7])*@porcion).round(2)*100}%"
|
79
|
+
"#{@etiqueta}"
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
#prueba = ValorEnergetico.new("Galletas",10.5,5.1,77.0,24.0,7.6,0.83,6.1)
|
85
|
+
|
86
|
+
#prueba.to_s
|
@@ -0,0 +1,103 @@
|
|
1
|
+
class Individuo
|
2
|
+
include Comparable
|
3
|
+
attr_reader :nombre, :apellido
|
4
|
+
|
5
|
+
def initialize(nombre,apellido)
|
6
|
+
@nombre = nombre
|
7
|
+
@apellido = apellido
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_s
|
11
|
+
"#{@nombre} #{@apellido}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def <=>(other)
|
15
|
+
return nil unless other.instance_of?Individuo
|
16
|
+
@nombre <=> other.nombre
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Paciente < Individuo
|
21
|
+
attr_reader :peso,:talla, :edad,:sexo,:cintura,:cadera
|
22
|
+
|
23
|
+
def initialize(nombre,apellido,peso,talla,edad,sexo,cintura,cadera)
|
24
|
+
super(nombre,apellido)
|
25
|
+
@peso = peso
|
26
|
+
@talla = talla
|
27
|
+
@edad = edad
|
28
|
+
if(sexo == "Hombre")
|
29
|
+
@sexo = 1;
|
30
|
+
|
31
|
+
elsif(sexo == "Mujer")
|
32
|
+
@sexo = 0;
|
33
|
+
end
|
34
|
+
@cintura = (cintura[0] + cintura[1])/2
|
35
|
+
@cadera = (cadera[0]+cadera[1])/2
|
36
|
+
end
|
37
|
+
|
38
|
+
def imc_calc
|
39
|
+
|
40
|
+
@imc = (@peso/(@talla*@talla)).round(2)
|
41
|
+
|
42
|
+
if(@imc < 18.5)
|
43
|
+
"Delgado"
|
44
|
+
|
45
|
+
elsif (@imc > 18.5 && @imc < 24.9)
|
46
|
+
"Aceptable"
|
47
|
+
|
48
|
+
elsif (@imc > 25 && @imc <29.9)
|
49
|
+
"Sobrepeso"
|
50
|
+
|
51
|
+
elsif(@imc > 30)
|
52
|
+
"Obesidad"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def to_s
|
57
|
+
|
58
|
+
"#{super.to_s} #{@peso} #{@talla} #{@edad} #{@sexo} #{@cintura} #{@cadera}"
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
def peso_ideal
|
63
|
+
|
64
|
+
((@talla-150)*0.75 + 50).round(2)
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
def gasto_energetico_basal
|
69
|
+
|
70
|
+
return ((10*@peso)+(6.25*@talla)-(5*@edad)+5).round(2) if @sexo == 1
|
71
|
+
((10*@peso)+(6.25*@talla)-(5*@edad) - 161).round(2)
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
def efecto_termogeno
|
77
|
+
|
78
|
+
(gasto_energetico_basal * 0.10).round(2)
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
def actividad_fisica(actividad)
|
83
|
+
|
84
|
+
return 0.0 if actividad == "Reposo"
|
85
|
+
return 0.12 if actividad == "Ligera"
|
86
|
+
return 0.27 if actividad == "Moderada"
|
87
|
+
return 0.54 if actividad == "Intensa"
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
def gasto_act_fisica(actividad)
|
92
|
+
|
93
|
+
(actividad_fisica(actividad) * gasto_energetico_basal).round(2)
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
def gasto_total(actividad)
|
98
|
+
|
99
|
+
(gasto_energetico_basal + efecto_termogeno + actividad_fisica(actividad)).round(2)
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
data/lib/tdd/version.rb
ADDED
data/lib/tdd.rb
ADDED
data/tdd.gemspec
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "tdd/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "alu0100894646menu"
|
8
|
+
spec.version = Tdd::VERSION
|
9
|
+
spec.authors = ["alu0100894646"]
|
10
|
+
spec.email = ["alu0100894646@ull.edu.es"]
|
11
|
+
|
12
|
+
spec.summary = %q{"Gema para la práctica TDD LPP"}
|
13
|
+
spec.description = %q{"Desarrollar una práctica sobre el "}
|
14
|
+
spec.homepage = "https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100894646.git"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
#if spec.respond_to?(:metadata)
|
19
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
20
|
+
|
21
|
+
# spec.metadata["homepage_uri"] = spec.homepage
|
22
|
+
# spec.metadata["source_code_uri"] = "https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100894646.git"
|
23
|
+
#else
|
24
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
25
|
+
# "public gem pushes."
|
26
|
+
#end
|
27
|
+
|
28
|
+
# Specify which files should be added to the gem when it is released.
|
29
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
30
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
31
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
32
|
+
end
|
33
|
+
spec.bindir = "exe"
|
34
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
35
|
+
spec.require_paths = ["lib"]
|
36
|
+
|
37
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
38
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
39
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
40
|
+
spec.add_development_dependency "guard"
|
41
|
+
spec.add_development_dependency "guard-rspec"
|
42
|
+
spec.add_development_dependency "guard-bundler"
|
43
|
+
spec.add_development_dependency "coveralls"
|
44
|
+
end
|
data/travis.yml
ADDED
File without changes
|
metadata
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: alu0100894646menu
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- alu0100894646
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-01-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: guard
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard-rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard-bundler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: coveralls
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: '"Desarrollar una práctica sobre el "'
|
112
|
+
email:
|
113
|
+
- alu0100894646@ull.edu.es
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".coveralls.yml"
|
119
|
+
- ".gitignore"
|
120
|
+
- ".travis.yml"
|
121
|
+
- Gemfile
|
122
|
+
- Gemfile.lock
|
123
|
+
- Guardfile
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- bin/console
|
127
|
+
- bin/setup
|
128
|
+
- lib/tdd.rb
|
129
|
+
- lib/tdd/dietetico_desl.rb
|
130
|
+
- lib/tdd/dll_etiqueta.rb
|
131
|
+
- lib/tdd/valor_energetico.rb
|
132
|
+
- lib/tdd/valor_nutricional.rb
|
133
|
+
- lib/tdd/version.rb
|
134
|
+
- tdd.gemspec
|
135
|
+
- travis.yml
|
136
|
+
homepage: https://github.com/ULL-ESIT-LPP-1819/tdd-alu0100894646.git
|
137
|
+
licenses: []
|
138
|
+
metadata: {}
|
139
|
+
post_install_message:
|
140
|
+
rdoc_options: []
|
141
|
+
require_paths:
|
142
|
+
- lib
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
requirements: []
|
154
|
+
rubyforge_project:
|
155
|
+
rubygems_version: 2.6.8
|
156
|
+
signing_key:
|
157
|
+
specification_version: 4
|
158
|
+
summary: '"Gema para la práctica TDD LPP"'
|
159
|
+
test_files: []
|