MenuDieteticoComparable 0.3.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
+ SHA1:
3
+ metadata.gz: 8116ddb8c4a261a5620d227b41680b4f885d6493
4
+ data.tar.gz: 98b458b7ae3c7869e29f766d709c27caf5839392
5
+ SHA512:
6
+ metadata.gz: 5c6c430e0fa1c9a253128a70757d4d19b7f4f9f6ee22bae707f3cbbe5abe242ed300185d889704cd3b9d7c6e041c2273d9017cb4be45650cafc2e6d29323764e
7
+ data.tar.gz: 4d317babd2f77164b9aee2940810fc78f6e301e2364a2aa95cf0702bd69f533733b88e1e3c05cb1ec0ce1550955566cdd650ff6a09fb3a36d1bee6140bb85af3
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.0
5
+ before_install: gem install bundler -v 1.13.6
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'yard'
4
+ # Specify your gem's dependencies in dieta.gemspec
5
+ gemspec
@@ -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,36 @@
1
+ # Dieta Mediante Lista Enlazada y Herencia
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/dieta`. 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 'dieta'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install dieta
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]/dieta.
36
+
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+ #desc "Ejecutar las pruebas de la clase Dieta"
8
+ #task :spec do
9
+ # sh "rspec -I. spec/dieta_test.rb"
10
+ #end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "dieta"
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
@@ -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,40 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib/dieta', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require '/home/ubuntu/workspace/LPP/p8/dieta/lib/dieta/version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "MenuDieteticoComparable"
8
+ spec.version = Dieta::VERSION
9
+ spec.authors = ["zdiabolo"]
10
+ spec.email = ["daniel_an10@hotmail.com"]
11
+
12
+ spec.summary = %q{TDD: Pruebas Lista Practica9}
13
+ spec.description = %q{TDD: Pruebas Lista Practica9}
14
+ spec.homepage = "https://rubygems.org"
15
+
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ #else
22
+ # raise "RubyGems 2.0 or newer is required to protect against " \
23
+ # "public gem pushes."
24
+ # end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.13"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rspec", "~> 3.0"
36
+ spec.add_development_dependency "guard"
37
+ spec.add_development_dependency "guard-rspec"
38
+ spec.add_development_dependency "guard-bundler"
39
+ spec.metadata["yard.run"] = "yri" # use "yard" to build full HTML docs.
40
+ end
@@ -0,0 +1,8 @@
1
+ require "dieta/version"
2
+ require "dieta/List.rb"
3
+ require "dieta/dieta.rb"
4
+ require "dieta/Menu.rb"
5
+
6
+ module Dieta
7
+
8
+ end
@@ -0,0 +1,79 @@
1
+ class Lista
2
+
3
+ attr_accessor :top, :last
4
+ Node = Struct.new(:value, :prev, :next)
5
+
6
+ def initialize(top)
7
+ if top === nil
8
+ @top = nil
9
+ @last = nil
10
+ else
11
+ @top = Node.new(top,nil,nil)
12
+ @last = Node.new(top,nil,nil)
13
+ end
14
+ end
15
+ def insertarMultiple(elementos)
16
+ elementos.each do |elemento|
17
+ insertar(elemento)
18
+ end
19
+ end
20
+ def insertar(elemento)
21
+ if empty
22
+ @top = Node.new(elemento,nil, nil)
23
+ @last = Node.new(elemento,nil, nil)
24
+ else
25
+ @top[:next] = elemento;
26
+ nmenu = Node.new(elemento, @top, nil)
27
+ @top = nmenu
28
+ end
29
+ end
30
+
31
+ def mostrarUltimo
32
+ if empty
33
+ puts "Lista vacia. Empty!"
34
+ else
35
+ aux = @top;
36
+ while aux[:prev] != nil
37
+ aux = aux[:prev]
38
+ end
39
+
40
+ aux[:value]
41
+
42
+ end
43
+
44
+ end
45
+
46
+ def getPrevTop
47
+ aux = top[:prev]
48
+ val = aux[:value]
49
+ val
50
+ end
51
+
52
+ def extraer
53
+ if empty
54
+ puts "Lista vacia. Empty!"
55
+ else
56
+ extraer = @top[:value]
57
+ aux_to = @top[:prev]
58
+
59
+ if @top == @last
60
+ @last = nil;
61
+ end
62
+
63
+ aux_to[:next] = nil
64
+ @top = aux_to
65
+
66
+ extraer
67
+ end
68
+
69
+ end
70
+
71
+ def empty
72
+ if @top == nil
73
+ true
74
+ else
75
+ false
76
+ end
77
+ end
78
+
79
+ end
@@ -0,0 +1,65 @@
1
+ #Representa un Menu
2
+ class Menu
3
+
4
+ attr_accessor :platos, :titulo_porcentaje, :porcentaje, :title, :name
5
+
6
+ include Comparable
7
+
8
+ # Constructor
9
+ def initialize(name, &block)
10
+ self.name = name
11
+ self.title = ""
12
+ self.titulo_porcentaje = []
13
+ self.platos = []
14
+ self.porcentaje = []
15
+
16
+ if block_given?
17
+ if block.arity == 1
18
+ yield self
19
+ else
20
+ instance_eval(&block)
21
+ end
22
+ end
23
+
24
+ end
25
+
26
+ def titulo(text)
27
+ title << text
28
+ end
29
+
30
+ def ingesta(options = {})
31
+ titulo_porcentaje << "#{options[:min]}" if options[:min]
32
+ titulo_porcentaje << "#{options[:max]}" if options[:max]
33
+ end
34
+
35
+
36
+ def porcentajes(options = {})
37
+ porcentaje << "#{options[:vct]}" if options[:vct]
38
+ porcentaje << "#{options[:proteinas]}" if options[:proteinas]
39
+ porcentaje << "#{options[:hidratos]}" if options[:hidratos]
40
+ porcentaje << "#{options[:grasas]}" if options[:grasas]
41
+ end
42
+ def plato(options = {})
43
+ plat = []
44
+ plat << "#{options[:descripcion]}" if options[:descripcion]
45
+ plat << "#{options[:porcion]}" if options[:porcion]
46
+ plat << "#{options[:gramos]}" if options[:gramos]
47
+ platos << plat
48
+ end
49
+ def to_s
50
+ formato = "#{title} "
51
+ output = formato
52
+ output << "(" + titulo_porcentaje.map { |k| "#{k}%" }.join(" - ") + ")\n"
53
+ platos.each do |plato|
54
+ output << "- #{plato[0]}, #{plato[1]}, #{plato[2]}gr\n"
55
+ end
56
+ output << "V.C.T. | %\t #{porcentaje[0]} kcal | #{porcentaje[1]}% - #{porcentaje[2]}% - #{porcentaje[3]}%"
57
+ return output
58
+ end
59
+
60
+ def <=> (other)
61
+ porcentajes <=> other.porcentajes
62
+ end
63
+
64
+ end
65
+
@@ -0,0 +1,82 @@
1
+ class Dieta
2
+
3
+ include Comparable #include COmparable
4
+ attr_accessor :titulo, :porcentajes, :gramos, :platos, :vct
5
+
6
+ def initialize(titulo, platos, vct, kcal, porcentaje, porcentajes)
7
+ @titulo = titulo
8
+ @kcal = kcal
9
+ @porcentaje = porcentaje
10
+ @porcentajes = porcentajes
11
+ @platos = platos
12
+ @vct = vct
13
+ end
14
+
15
+ def to_s #Prueba to_s
16
+
17
+ cout = "#{@title.upcase} (#{@percentage}%)\n"
18
+
19
+ for i in 0..platos.size-1
20
+
21
+ cout << "- #{platos[i].to_s}\n"
22
+ end
23
+
24
+ cout << "V.C.T. | %\t#{@vct} kcal | #{@kcal}% - #{@gramos}%"
25
+
26
+ cout
27
+
28
+ end
29
+
30
+ def <=> (other)
31
+ porcentajes <=> other.porcentajes
32
+
33
+ end
34
+
35
+ end
36
+
37
+ class Plato < Dieta
38
+
39
+ attr_accessor :titulo, :porciones, :cantidad
40
+
41
+ def initialize(titulo, porciones, cantidad)
42
+ @titulo = titulo
43
+ @porciones = porciones
44
+ @cantidad = cantidad
45
+ end
46
+
47
+ def to_s
48
+ cout = "#{@title.upcase} #{@porciones} #{@cantidad}"
49
+ cout
50
+ end
51
+
52
+ end
53
+
54
+ class DietaEdad < Dieta
55
+
56
+ attr_accessor :edad
57
+ def initialize(edad, titulo, platos, vct, kcal, porcentaje, porcentajes)
58
+ @edad = edad
59
+ super(titulo, platos, vct, kcal, porcentaje, porcentajes)
60
+ end
61
+
62
+ def to_s
63
+ cout = super.to_s + "Edad: #{edad}\n"
64
+ cout
65
+ end
66
+
67
+ end
68
+
69
+ class DietaAlimentos < Dieta
70
+
71
+ attr_accessor :grupo
72
+ def initialize(grupo, titulo, platos, vct, kcal, porcentaje, porcentajes)
73
+ @grupo = grupo
74
+ super(titulo, platos, vct, kcal, porcentaje, porcentajes)
75
+ end
76
+
77
+ def to_s
78
+ cout = super.to_s + "Grupo: #{grupo}\n"
79
+ cout
80
+ end
81
+
82
+ end
@@ -0,0 +1,3 @@
1
+ module Dieta
2
+ VERSION = "0.5.0"
3
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: MenuDieteticoComparable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ platform: ruby
6
+ authors:
7
+ - zdiabolo
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-12-16 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.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
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
+ description: 'TDD: Pruebas Lista Practica9'
98
+ email:
99
+ - daniel_an10@hotmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".travis.yml"
106
+ - Gemfile
107
+ - Guardfile
108
+ - README.md
109
+ - Rakefile
110
+ - bin/console
111
+ - bin/setup
112
+ - dieta.gemspec
113
+ - lib/dieta.rb
114
+ - lib/dieta/List.rb
115
+ - lib/dieta/Menu.rb
116
+ - lib/dieta/dieta.rb
117
+ - lib/dieta/version.rb
118
+ homepage: https://rubygems.org
119
+ licenses: []
120
+ metadata:
121
+ yard.run: yri
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.5.1
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: 'TDD: Pruebas Lista Practica9'
142
+ test_files: []