einutricional 0.2.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c60814ef661b3f00993c1247c9b04f9650cab52e8a34513689af777263bc7798
4
+ data.tar.gz: e7e9ab1b1b905b1fc06c3b1a33903fa6b947790134b5a22d8edc757f22a22b10
5
+ SHA512:
6
+ metadata.gz: fa060b1a217a1ad8521c012b33a5f74e6f92873c90415729fca0a7c80d908b83281328f171c2f99b03694a76b96c82d6c1808b06aada755a3e9ac8c35ef17653
7
+ data.tar.gz: 8a6d04f6cfea6f4c00f3e04ed8dedf9b516f5170678067a75efe1395401e6301669357c34915ff15b8fe05ad0344aa70ee6cdae8e12006f83a0496488e7bdc93
@@ -0,0 +1,2 @@
1
+ service_name: travis-pro
2
+ repo_token: 3NxkKeF7FfJzjNbN6mxRnS53MkDK70pbH
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ # personal
14
+ .idea/
15
+ .rubocop*
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,10 @@
1
+ sudo: false
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.5.3
6
+ before_install:
7
+ - gem update --system
8
+ - gem --version
9
+ - gem install bundler
10
+ - bundle install
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at cruzelante098@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in einutricional.gemspec
6
+ gemspec
@@ -0,0 +1,134 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ einutricional (0.2.0)
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
+ ffi (1.9.25-x64-mingw32)
22
+ ffi (1.9.25-x86-mingw32)
23
+ formatador (0.2.5)
24
+ guard (2.14.2)
25
+ formatador (>= 0.2.4)
26
+ listen (>= 2.7, < 4.0)
27
+ lumberjack (>= 1.0.12, < 2.0)
28
+ nenv (~> 0.1)
29
+ notiffany (~> 0.0)
30
+ pry (>= 0.9.12)
31
+ shellany (~> 0.0)
32
+ thor (>= 0.18.1)
33
+ guard-bundler (2.1.0)
34
+ bundler (~> 1.0)
35
+ guard (~> 2.2)
36
+ guard-compat (~> 1.1)
37
+ guard-compat (1.2.1)
38
+ guard-rspec (4.7.3)
39
+ guard (~> 2.1)
40
+ guard-compat (~> 1.1)
41
+ rspec (>= 2.99.0, < 4.0)
42
+ http-cookie (1.0.3)
43
+ domain_name (~> 0.5)
44
+ json (2.1.0)
45
+ listen (3.1.5)
46
+ rb-fsevent (~> 0.9, >= 0.9.4)
47
+ rb-inotify (~> 0.9, >= 0.9.7)
48
+ ruby_dep (~> 1.2)
49
+ lumberjack (1.0.13)
50
+ method_source (0.9.2)
51
+ mime-types (3.2.2)
52
+ mime-types-data (~> 3.2015)
53
+ mime-types-data (3.2018.0812)
54
+ multi_json (1.13.1)
55
+ nenv (0.3.0)
56
+ netrc (0.11.0)
57
+ notiffany (0.1.1)
58
+ nenv (~> 0.1)
59
+ shellany (~> 0.0)
60
+ pry (0.12.2)
61
+ coderay (~> 1.1.0)
62
+ method_source (~> 0.9.0)
63
+ rake (10.5.0)
64
+ rb-fsevent (0.10.3)
65
+ rb-inotify (0.9.10)
66
+ ffi (>= 0.5.0, < 2)
67
+ rest-client (2.0.2)
68
+ http-cookie (>= 1.0.2, < 2.0)
69
+ mime-types (>= 1.16, < 4.0)
70
+ netrc (~> 0.8)
71
+ rest-client (2.0.2-x64-mingw32)
72
+ ffi (~> 1.9)
73
+ http-cookie (>= 1.0.2, < 2.0)
74
+ mime-types (>= 1.16, < 4.0)
75
+ netrc (~> 0.8)
76
+ rest-client (2.0.2-x86-mingw32)
77
+ ffi (~> 1.9)
78
+ http-cookie (>= 1.0.2, < 2.0)
79
+ mime-types (>= 1.16, < 4.0)
80
+ netrc (~> 0.8)
81
+ rspec (3.8.0)
82
+ rspec-core (~> 3.8.0)
83
+ rspec-expectations (~> 3.8.0)
84
+ rspec-mocks (~> 3.8.0)
85
+ rspec-core (3.8.0)
86
+ rspec-support (~> 3.8.0)
87
+ rspec-expectations (3.8.2)
88
+ diff-lcs (>= 1.2.0, < 2.0)
89
+ rspec-support (~> 3.8.0)
90
+ rspec-mocks (3.8.0)
91
+ diff-lcs (>= 1.2.0, < 2.0)
92
+ rspec-support (~> 3.8.0)
93
+ rspec-support (3.8.0)
94
+ ruby_dep (1.5.0)
95
+ shellany (0.0.1)
96
+ simplecov (0.16.1)
97
+ docile (~> 1.1)
98
+ json (>= 1.8, < 3)
99
+ simplecov-html (~> 0.10.0)
100
+ simplecov-html (0.10.2)
101
+ table_print (1.5.6)
102
+ term-ansicolor (1.7.0)
103
+ tins (~> 1.0)
104
+ thor (0.20.3)
105
+ tins (1.20.2)
106
+ unf (0.1.4)
107
+ unf_ext
108
+ unf_ext (0.0.7.5)
109
+ unf_ext (0.0.7.5-x64-mingw32)
110
+ unf_ext (0.0.7.5-x86-mingw32)
111
+ wdm (0.1.1)
112
+ yard (0.9.16)
113
+
114
+ PLATFORMS
115
+ ruby
116
+ x64-mingw32
117
+ x86-mingw32
118
+ x86_64-linux
119
+
120
+ DEPENDENCIES
121
+ bundler (~> 1.17)
122
+ coveralls
123
+ einutricional!
124
+ guard
125
+ guard-bundler
126
+ guard-rspec
127
+ rake (~> 10.0)
128
+ rspec (~> 3.0)
129
+ table_print
130
+ wdm (>= 0.1.0)
131
+ yard
132
+
133
+ BUNDLED WITH
134
+ 1.17.1
@@ -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.exists?(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
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Francisco Cruz
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.
@@ -0,0 +1,43 @@
1
+ # Einutricional
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/einutricional`. 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 'einutricional'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install einutricional
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]/einutricional. 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.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Einutricional project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/einutricional/blob/master/CODE_OF_CONDUCT.md).
@@ -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
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'einutricional'
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__)
@@ -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
@@ -0,0 +1,47 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'einutricional/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'einutricional'
7
+ spec.version = Einutricional::VERSION
8
+ spec.authors = ['Francisco Cruz']
9
+ spec.email = ['cruzelante098@gmail.com']
10
+
11
+ spec.summary = 'Esta aplicación ofrece la estructura para gestionar los datos de las etiquetas de información nutricional-'
12
+ spec.description = ''
13
+ spec.homepage = 'https://github.com/ULL-ESIT-LPP-1819/tdd-cruzelante098'
14
+ spec.license = 'MIT'
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'] = 'https://rubygems.org'
20
+
21
+ spec.metadata['homepage_uri'] = spec.homepage
22
+ spec.metadata['source_code_uri'] = spec.homepage
23
+ spec.metadata['changelog_uri'] = spec.homepage
24
+ else
25
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
26
+ 'public gem pushes.'
27
+ end
28
+
29
+ # Specify which files should be added to the gem when it is released.
30
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
32
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
33
+ end
34
+ spec.bindir = 'exe'
35
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
+ spec.require_paths = ['lib']
37
+
38
+ spec.add_development_dependency 'bundler', '~> 1.17'
39
+ spec.add_development_dependency 'coveralls'
40
+ spec.add_development_dependency 'guard'
41
+ spec.add_development_dependency 'guard-bundler'
42
+ spec.add_development_dependency 'guard-rspec'
43
+ spec.add_development_dependency 'rake', '~> 10.0'
44
+ spec.add_development_dependency 'rspec', '~> 3.0'
45
+ spec.add_development_dependency 'wdm', '>= 0.1.0' if Gem.win_platform?
46
+ spec.add_development_dependency 'yard'
47
+ end
@@ -0,0 +1,71 @@
1
+ require_relative 'einutricional/version'
2
+ require_relative 'einutricional/etiqueta'
3
+ require_relative 'einutricional/double_linked_list'
4
+ require_relative 'einutricional/person'
5
+ require_relative 'einutricional/patient'
6
+ require_relative 'einutricional/menu_dietetico'
7
+
8
+ # Modulo de la gema. Agrupa todas las clases
9
+ module Einutricional
10
+ # Clase base para lanzar excepciones
11
+ class Error < StandardError; end
12
+ #
13
+ # menu = Einutricional::MenuDietetico.new('Lunes') do
14
+ # titulo 'Menú especial'
15
+ # ingesta min: 30, max: 45
16
+ # desayuno descripcion: 'el desayunaco',
17
+ # porcion: "1 porcion",
18
+ # gramos: 100,
19
+ # grasas: 30,
20
+ # hidratos: 70,
21
+ # azucares: 80,
22
+ # polialcoholes: 90,
23
+ # almidon: 100,
24
+ # fibra: 110,
25
+ # proteinas: 120,
26
+ # sal: 130,
27
+ # vitaminas: 140,
28
+ # minerales: 150
29
+ # almuerzo descripcion: 'almuerzo to bueno',
30
+ # porcion: '1 porcion',
31
+ # gramos: 100,
32
+ # grasas: 70,
33
+ # hidratos: 1000,
34
+ # azucares: 80,
35
+ # polialcoholes: 90,
36
+ # almidon: 100,
37
+ # fibra: 110,
38
+ # proteinas: 120,
39
+ # sal: 130,
40
+ # vitaminas: 140,
41
+ # minerales: 150
42
+ # almuerzo descripcion: 'almuerzo to bueno',
43
+ # porcion: '1 porcion',
44
+ # gramos: 100,
45
+ # grasas: 70,
46
+ # hidratos: 1000,
47
+ # azucares: 80,
48
+ # polialcoholes: 90,
49
+ # almidon: 100,
50
+ # fibra: 110,
51
+ # proteinas: 120,
52
+ # sal: 130,
53
+ # vitaminas: 140,
54
+ # minerales: 150
55
+ # cena descripcion: 'almuerzo to bueno',
56
+ # porcion: '1 porcion',
57
+ # gramos: 100,
58
+ # grasas: 70,
59
+ # hidratos: 1000,
60
+ # azucares: 80,
61
+ # polialcoholes: 90,
62
+ # almidon: 100,
63
+ # fibra: 110,
64
+ # proteinas: 120,
65
+ # sal: 130,
66
+ # vitaminas: 140,
67
+ # minerales: 150
68
+ # end
69
+ # menu.to_s
70
+
71
+ end
@@ -0,0 +1,147 @@
1
+ module Einutricional
2
+ # Lista doblemente enlazada. Contenedor para cualquier tipo de objeto
3
+ class DoubleLinkedList
4
+ include Enumerable
5
+ attr_reader :head, :tail, :count
6
+
7
+ # Nodo para almacenar un objeto y referencias a los nodos contiguos
8
+ Node = Struct.new(:value, :prev, :next)
9
+
10
+ # Inicializa la lista. No recibe parámetros
11
+ def initialize
12
+ @head = nil
13
+ @tail = nil
14
+ @count = 0
15
+ end
16
+
17
+ # Añade un elemento a la lista por la cola.
18
+ # @param value es el valor que se añade y puede ser cualquier objeto
19
+ # @return la cantidad de elementos que hay en la lista
20
+ def push_back(value)
21
+ node = Node.new(value)
22
+
23
+ if @head.nil? # lista vacía
24
+ node.prev = nil
25
+ node.next = nil
26
+ @head = node
27
+ @tail = node
28
+ else # hay al menos un elemento en la lista
29
+ node.prev = @tail
30
+ @tail.next = node
31
+ @tail = node
32
+ node.next = nil
33
+ end
34
+
35
+ @count += 1
36
+ end
37
+
38
+ # Operador de consulta al elemento
39
+ # @param pos es la posición del elemento que se quiere consultar
40
+ # @return el elemento buscado
41
+ def [](pos)
42
+ raise 'ERROR: index out of limits' unless pos >= 0 && pos < @count
43
+
44
+ node = @head
45
+ i = 0
46
+ while i < pos
47
+ node = node.next
48
+ i += 1
49
+ end
50
+ node.value
51
+ end
52
+
53
+ def []=(pos, value)
54
+ raise 'ERROR: index out of limits' unless pos >= 0 && pos < @count
55
+
56
+ node = @head
57
+ i = 0
58
+ while i < pos
59
+ node = node.next
60
+ i += 1
61
+ end
62
+ node.value = value
63
+ end
64
+
65
+ # Permite recorrer todos los elementos a su vez que admite bloques para modificarlos
66
+ # @return void
67
+ def each
68
+ i = 0
69
+ while i < @count
70
+ yield self[i]
71
+ i += 1
72
+ end
73
+ end
74
+
75
+ def size
76
+ @count
77
+ end
78
+
79
+ # Elimina un elemento por el frente de la lista
80
+ # @return el elemento eliminado
81
+ def pop_front
82
+ unless empty?
83
+ if @count == 1
84
+ value = @head.value
85
+ @head = nil
86
+ @tail = nil
87
+ ret = value
88
+ else
89
+ aux = @head.next
90
+ aux.prev = nil
91
+ value = @head.value
92
+ @head = aux
93
+ ret = value
94
+ end
95
+ @count -= 1
96
+ ret
97
+ end
98
+ end
99
+
100
+ # Dice si la lista está vacía
101
+ # @return [true,false] según haya o no elementos
102
+ def empty?
103
+ @count.zero?
104
+ end
105
+
106
+ def sorted?
107
+ each_cons(2).all? { |left, right| left <= right }
108
+ end
109
+
110
+ def sort_for
111
+ list = self
112
+ return list if list.size <= 1 # already sorted
113
+
114
+ swapped = true
115
+ while swapped do
116
+ swapped = false
117
+ for i in 0..(list.size - 2)
118
+ if list[i] > list[i + 1]
119
+ list[i], list[i + 1] = list[i + 1], list[i] # swap values
120
+ swapped = true
121
+ end
122
+ end
123
+ end
124
+
125
+ list
126
+ end
127
+
128
+ def sort_each
129
+ temp = 0
130
+ list = self
131
+ list.each do
132
+ k = 0
133
+ j = 1
134
+ while j < list.size
135
+ if list[k] > list[j]
136
+ temp = list[k]
137
+ list[k] = list[j]
138
+ list[j] = temp
139
+ end
140
+ k += 1
141
+ j += 1
142
+ end
143
+ end
144
+ list
145
+ end
146
+ end
147
+ end
@@ -0,0 +1,102 @@
1
+ module Einutricional
2
+ # Almacena los datos nutricionales de un alimento
3
+ class Etiqueta
4
+ include Comparable
5
+ attr_accessor :nombre, :grasas, :grasas_sat, :grasas_monosat, :grasas_polisat,
6
+ :hidratos, :azucares, :polialcoholes, :almidon, :fibra, :proteinas, :sal,
7
+ :vitaminas, :minerales
8
+
9
+ # Constructor que recibe los datos de cada uno de los parametros alimenticios del alimento en cuestión.
10
+ # @param nombre [String]
11
+ # @note el resto de los parámetros son float
12
+ def initialize(nombre, grasas, grasas_sat, grasas_monosat, grasas_polisat,
13
+ hidratos, azucares, polialcoholes, almidon, fibra, proteinas, sal, vitaminas, minerales)
14
+ @nombre = nombre
15
+ @grasas = grasas
16
+ @grasas_sat = grasas_sat
17
+ @grasas_monosat = grasas_monosat
18
+ @grasas_polisat = grasas_polisat
19
+ @hidratos = hidratos
20
+ @azucares = azucares
21
+ @polialcoholes = polialcoholes
22
+ @almidon = almidon
23
+ @fibra = fibra
24
+ @proteinas = proteinas
25
+ @sal = sal
26
+ @vitaminas = vitaminas
27
+ @minerales = minerales
28
+ end
29
+
30
+ # Operador de comparación
31
+ # @return [Fixnum] 0 si VE1 == VE2, -1 si VE1 < VE2 y 1 si VE1 > VE2
32
+ def <=>(other)
33
+ valor_energetico <=> other.valor_energetico
34
+ end
35
+
36
+ # Calcula el valor energético del alimento
37
+ # @param medida [String] 'cal' si calorias (predeterminado), 'kj' si kilojulios.
38
+ # @return [Fixnum] valor energético
39
+ def valor_energetico(medida = 'cal')
40
+ if medida == 'cal'
41
+ ve = 0.0
42
+ ve += @grasas * 9
43
+ ve += (@hidratos - @azucares - @polialcoholes - @almidon) * 4
44
+ ve += @azucares * 4 # TODO: ¿cual es el factor de conversión del azucar?)
45
+ ve += @polialcoholes * 2.4
46
+ ve += @almidon * 4
47
+ ve += @fibra * 2
48
+ ve += @proteinas * 4
49
+ ve += @sal * 6
50
+ ve.truncate(0)
51
+ elsif medida == 'kj'
52
+ ve = 0.0
53
+ ve += @grasas * 37
54
+ ve += (@hidratos - @azucares - @polialcoholes - @almidon) * 17
55
+ ve += @azucares * 17 # TODO: ¿cual es el factor de conversión del azucar?)
56
+ ve += @polialcoholes * 10
57
+ ve += @almidon * 17
58
+ ve += @fibra * 8
59
+ ve += @proteinas * 17
60
+ ve += @sal * 25
61
+ ve.truncate(0)
62
+ else
63
+ raise 'No se ha pasado el argumento correcto a la función.'
64
+ end
65
+ end
66
+
67
+ # Imprime la etiqueta
68
+ # @return [String] los valores de la etiqueta
69
+ def to_s
70
+ %(Denominación: #{@nombre}
71
+ Valor energético.......#{valor_energetico} cal
72
+ Grasas.................#{@grasas}
73
+ de las cuales
74
+ saturadas............#{@grasas_sat}
75
+ monosaturadas........#{@grasas_monosat}
76
+ poliinsaturadas......#{@grasas_polisat}
77
+ Hidratos...............#{@hidratos}
78
+ de los cuales
79
+ azucares.............#{@azucares}
80
+ polialcoholes........#{@polialcoholes}
81
+ almidon..............#{@almidon}
82
+ Fibra..................#{@fibra}
83
+ Proteinas..............#{@proteinas}
84
+ Sal....................#{@sal}
85
+ Vitaminas..............#{@vitaminas}
86
+ Minerales..............#{@minerales})
87
+ end
88
+
89
+ # Ingesta de referencia
90
+ # @return [String] la ingesta de referencia de la etiqueta con los porcentajes calculados
91
+ def ir
92
+ %(Ingesta de referencia con respecto a 100g
93
+ Valor energético: #{((valor_energetico / 2000.0) * 100.0).truncate(2)}%
94
+ Grasa total: #{((@grasas / 70.0) * 100.0).truncate(2)}%
95
+ Acidos grasos sat.: #{((@grasas_sat / 20.0) * 100.0).truncate(2)}%
96
+ Hidratos de carbono: #{((@hidratos / 260.0) * 100.0).truncate(2)}%
97
+ Azúcares: #{((@azucares / 90.0) * 100.0).truncate(2)}%
98
+ Proteínas: #{((@proteinas / 50.0) * 100.0).truncate(2)}%
99
+ Sal: #{((@sal / 6.0) * 100.0).truncate(2)}%)
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,146 @@
1
+ module Einutricional
2
+ class MenuDietetico
3
+ include Comparable
4
+ attr_accessor :des, :alm, :cen, :alimentos, :tit, :dia_semana, :ingesta_min, :ingesta_max
5
+
6
+ def initialize(dia_semana, &block)
7
+ @dia_semana = dia_semana
8
+ @des = Array.new
9
+ @alm = Array.new
10
+ @cen = Array.new
11
+ if block_given?
12
+ if block.arity == 1
13
+ yield self
14
+ else
15
+ instance_eval(&block)
16
+ end
17
+ end
18
+ end
19
+
20
+ def titulo(t)
21
+ @tit = t
22
+ end
23
+
24
+ def ingesta(datos)
25
+ @ingesta_min = datos[:min]
26
+ @ingesta_max = datos[:max]
27
+ end
28
+
29
+ def desayuno(des)
30
+ des[:ve] = valor_energetico(des)
31
+ @des << des
32
+ end
33
+
34
+ def almuerzo(alm)
35
+ alm[:ve] = valor_energetico(alm)
36
+ @alm << alm
37
+ end
38
+
39
+ def cena(cen)
40
+ cen[:ve] = valor_energetico(cen)
41
+ @cen << cen
42
+ end
43
+
44
+ def valor_energetico(hash)
45
+ ve = 0
46
+ ve += hash[:grasas] * 9
47
+ ve += (hash[:hidratos] - hash[:azucares] - hash[:polialcoholes] - hash[:almidon]) * 4
48
+ ve += hash[:azucares] * 4
49
+ ve += hash[:polialcoholes] * 2.4
50
+ ve += hash[:almidon] * 4
51
+ ve += hash[:fibra] * 2
52
+ ve += hash[:proteinas] * 4
53
+ ve += hash[:sal] * 6
54
+ end
55
+
56
+ def <=>(other)
57
+ valor_energetico_menu <=> other.valor_energetico_menu
58
+ end
59
+
60
+ def to_s
61
+ # Barra superior de información
62
+ print @tit.upcase.ljust(55), "COMPOSICIÓN NUTRICIONAL\n"
63
+ print ' ' * 35,
64
+ 'Grasas'.ljust(9),
65
+ 'Hidratos'.ljust(11),
66
+ 'Proteínas'.ljust(12),
67
+ 'Fibra'.ljust(8),
68
+ 'Sal'.ljust(6),
69
+ 'Valor energético', "\n"
70
+ puts '=' * 97
71
+ ve = 0
72
+ # Datos
73
+ [@des, @alm, @cen].each do |momento_del_dia|
74
+ unless momento_del_dia.empty?
75
+ if momento_del_dia == @des
76
+ puts '>> DESAYUNO'
77
+ elsif momento_del_dia == @alm
78
+ puts '>> ALMUERZO'
79
+ else
80
+ puts '>> CENA'
81
+ end
82
+ end
83
+
84
+ momento_del_dia.each do |menu|
85
+ ve += menu[:ve]
86
+ print menu[:descripcion].ljust(35),
87
+ menu[:grasas].to_s.ljust(9),
88
+ menu[:hidratos].to_s.ljust(11),
89
+ menu[:proteinas].to_s.ljust(12),
90
+ menu[:fibra].to_s.ljust(8),
91
+ menu[:sal].to_s.ljust(6),
92
+ menu[:ve].round(0).to_s
93
+ print "\n"
94
+ end
95
+ end
96
+ puts '=' * 97
97
+ print 'Total '.rjust(81), ve
98
+ end
99
+ end
100
+ end
101
+
102
+
103
+
104
+ class Array
105
+ def sorted?
106
+ each_cons(2).all? {|left, right| left <= right}
107
+ end
108
+
109
+ def sort_for
110
+ final = []
111
+ final << shift
112
+ for i in self
113
+ final_index = 0
114
+ while final_index < final.length
115
+ if i <= final[final_index]
116
+ final.insert(final_index, i)
117
+ break
118
+ elsif final_index == final.length - 1
119
+ final.insert(final_index + 1, i)
120
+ break
121
+ end
122
+ final_index += 1
123
+ end
124
+ end
125
+ final
126
+ end
127
+
128
+ def sort_each
129
+ final = []
130
+ final << shift
131
+ each do |i|
132
+ final_index = 0
133
+ while final_index < final.length
134
+ if i <= final[final_index]
135
+ final.insert(final_index, i)
136
+ break
137
+ elsif final_index == final.length - 1
138
+ final.insert(final_index + 1, i)
139
+ break
140
+ end
141
+ final_index += 1
142
+ end
143
+ end
144
+ final
145
+ end
146
+ end
@@ -0,0 +1,76 @@
1
+ module Einutricional
2
+ # Clase para almacenar los valores antropométricos de una persona
3
+ class Patient < Person
4
+ include Comparable
5
+ attr_accessor :weight, :height, :waist, :hip
6
+
7
+ # Constructor que recibe los datos de esa persona.
8
+ # @note Solo name y surname son [String], el resto son [Fixnum]
9
+ def initialize(name, surname, sex, age, weight, height, waist, hip, activity)
10
+ super(name, surname, sex, age)
11
+ @weight = weight
12
+ @height = height
13
+ @waist = waist
14
+ @hip = hip
15
+ @activity = activity
16
+ end
17
+
18
+ # Operador de comparación
19
+ # @return -1, 0, 1 según si el imc del paciente 'self' es menor, igual o mayor que el del paciente con el que se compara
20
+ def <=>(other)
21
+ imc <=> other.imc
22
+ end
23
+
24
+ # Indice de Masa Corporal
25
+ # @return [Fixnum] el IMC
26
+ def imc
27
+ (@weight.to_f / @height ** 2).round(2)
28
+ end
29
+
30
+ # Radio Cintura Cadera
31
+ # @return [Fixnum] el RCC
32
+ def rcc
33
+ (@waist.to_f / @hip).round(2)
34
+ end
35
+
36
+ # Imprime los datos del paciente
37
+ # @return [String] los datos del paciente
38
+ def to_s
39
+ "#{@surname}, #{@name}, #{@sex}, #{@age}, #{@weight}, #{@height}, #{@waist}, #{@hip}"
40
+ end
41
+
42
+ def peso_teorico_ideal
43
+ (@height * 100 - 150) * 0.75 + 50
44
+ end
45
+
46
+ def gasto_energetico_basal
47
+ geb = (10 * @weight) + (6.25 * @height * 100) - (5 * @age)
48
+ geb += (@age == 'h' ? 5 : -161)
49
+ geb.round(0)
50
+ end
51
+
52
+ def efecto_termogeno
53
+ (gasto_energetico_basal * 0.10).round(0)
54
+ end
55
+
56
+ def gasto_actividad_fisica
57
+ f = case @activity
58
+ when 'reposo'
59
+ 0.0
60
+ when 'ligera'
61
+ 0.12
62
+ when 'moderada'
63
+ 0.27
64
+ when 'intensa'
65
+ 0.54
66
+ else
67
+ 0.0
68
+ end
69
+ (gasto_energetico_basal * f).round(0)
70
+ end
71
+
72
+ def gasto_energetico
73
+ (gasto_energetico_basal + efecto_termogeno + gasto_actividad_fisica).round(0)
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,19 @@
1
+ module Einutricional
2
+ # Clase base para almacenar los datos identificativos del paciente
3
+ class Person
4
+ attr_accessor :name, :surname, :sex, :age
5
+
6
+ def initialize(name, surname, sex, age)
7
+ @name = name
8
+ @surname = surname
9
+ @sex = sex
10
+ @age = age
11
+ end
12
+
13
+ # Imprime los datos del paciente
14
+ # @return [String] los datos del paciente
15
+ def to_s
16
+ "#{@surname}, #{@name}, #{@sex}, #{@age}"
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,4 @@
1
+ module Einutricional
2
+ # Version de la gema
3
+ VERSION = '0.2.0'.freeze
4
+ end
metadata ADDED
@@ -0,0 +1,196 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: einutricional
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Francisco Cruz
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-01-08 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: coveralls
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: guard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-bundler
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: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: wdm
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: 0.1.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: 0.1.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: yard
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: ''
140
+ email:
141
+ - cruzelante098@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".coveralls.yml"
147
+ - ".gitignore"
148
+ - ".rspec"
149
+ - ".travis.yml"
150
+ - CODE_OF_CONDUCT.md
151
+ - Gemfile
152
+ - Gemfile.lock
153
+ - Guardfile
154
+ - LICENSE.txt
155
+ - README.md
156
+ - Rakefile
157
+ - bin/console
158
+ - bin/setup
159
+ - einutricional.gemspec
160
+ - lib/einutricional.rb
161
+ - lib/einutricional/double_linked_list.rb
162
+ - lib/einutricional/etiqueta.rb
163
+ - lib/einutricional/menu_dietetico.rb
164
+ - lib/einutricional/patient.rb
165
+ - lib/einutricional/person.rb
166
+ - lib/einutricional/version.rb
167
+ homepage: https://github.com/ULL-ESIT-LPP-1819/tdd-cruzelante098
168
+ licenses:
169
+ - MIT
170
+ metadata:
171
+ allowed_push_host: https://rubygems.org
172
+ homepage_uri: https://github.com/ULL-ESIT-LPP-1819/tdd-cruzelante098
173
+ source_code_uri: https://github.com/ULL-ESIT-LPP-1819/tdd-cruzelante098
174
+ changelog_uri: https://github.com/ULL-ESIT-LPP-1819/tdd-cruzelante098
175
+ post_install_message:
176
+ rdoc_options: []
177
+ require_paths:
178
+ - lib
179
+ required_ruby_version: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - ">="
182
+ - !ruby/object:Gem::Version
183
+ version: '0'
184
+ required_rubygems_version: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ requirements: []
190
+ rubyforge_project:
191
+ rubygems_version: 2.7.8
192
+ signing_key:
193
+ specification_version: 4
194
+ summary: Esta aplicación ofrece la estructura para gestionar los datos de las etiquetas
195
+ de información nutricional-
196
+ test_files: []