Bibliografia 0.4.0
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/.gemfile +3 -0
- data/.gitignore +11 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +7 -0
- data/Guardfile +82 -0
- data/LICENSE.txt +21 -0
- data/README.md +8 -0
- data/Rakefile +11 -0
- data/bibliografia.gemspec +34 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/bibliografia/bibliografia_impl.rb +217 -0
- data/lib/bibliografia/lista2_impl.rb +70 -0
- data/lib/bibliografia/lista_impl.rb +82 -0
- data/lib/bibliografia/version.rb +5 -0
- data/lib/bibliografia.rb +12 -0
- metadata +119 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 43628f86d3d25d7084b012f261aa6be61229137e
|
4
|
+
data.tar.gz: 79416042ff79b3f850b6bc955d6bb1077a9823ca
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ba6cb095fa61082b6841b9e1e635d6ace6e37fcccfd9e4b00fe30755e25777c3070b8d1a086af38c800cd51ee61e854f42e538c98af26735a07eb251f24fef70
|
7
|
+
data.tar.gz: 2e4889b7f753133ab84e650c8a8b276c201026cd6ce6b81baffd8504c55e3b9161dbad4bae08d159c1456f98b87992a17c6a7c5b603bed32bf6886b5e678d424
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gemfile
ADDED
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
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.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.("routing/#{m[1]}_routing"),
|
63
|
+
rspec.spec.("controllers/#{m[1]}_controller"),
|
64
|
+
rspec.spec.("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.("features/#{m[1]}") }
|
75
|
+
watch(rails.layouts) { |m| rspec.spec.("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/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 alu0100502107
|
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,8 @@
|
|
1
|
+
|Coveralls|
|
2
|
+
|--------:|
|
3
|
+
|[![Coverage Status](https://coveralls.io/repos/alu0100502114/LPP_1_prct11/badge.svg?branch=jesus%2Fdev&service=github)](https://coveralls.io/github/alu0100502114/LPP_1_prct11?branch=jesus%2Fdev)|
|
4
|
+
Lenguajes y Paradigmas de Programación
|
5
|
+
Práctica de Laboratorio #11. Programación Funcional. Funciones de orden superior
|
6
|
+
Autor:
|
7
|
+
- Jesús Marín Ruiz (jesus/dev): encargado de desarrollar la pruebas y el código que las verifique
|
8
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bibliografia/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "Bibliografia"
|
8
|
+
spec.version = Bibliografia::VERSION
|
9
|
+
spec.authors = ["alu0100502114"]
|
10
|
+
spec.email = ["alu0100502114@ull.edu.es"]
|
11
|
+
|
12
|
+
spec.summary = %q{Práctica 11 de LPP.}
|
13
|
+
spec.description = %q{Referencias en una Bibliografía en una Lista enlazada de doble entrada}
|
14
|
+
spec.homepage = "https://bitbucket.org/jesus_marin/lpp_1_prct11"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "rspec"
|
33
|
+
spec.add_development_dependency "coveralls"
|
34
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "bibliografia"
|
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,217 @@
|
|
1
|
+
|
2
|
+
# Módulo Bibliográfico
|
3
|
+
module Bibliografia
|
4
|
+
|
5
|
+
# Clase Referencia para gestionar las de una Bibliografía
|
6
|
+
class Referencia
|
7
|
+
include Comparable
|
8
|
+
# Getters + Setters
|
9
|
+
attr_accessor :autores, :titulo, :serie, :editorial, :num_edicion, :fecha_publicacion, :num_isbns
|
10
|
+
|
11
|
+
# Comparador
|
12
|
+
def <=> (anOther)
|
13
|
+
# @autores <=> anOther.autores
|
14
|
+
this_year = @fecha_publicacion[/.*, ([^\)]*)/,1]
|
15
|
+
that_year = anOther.fecha_publicacion[/.*, ([^\)]*)/,1]
|
16
|
+
# self.autores <=> anOther.autores == 0 ? this_year <=> that_year : self.autores <=> anOther.autores
|
17
|
+
[self.autores, this_year, self.titulo] <=> [anOther.autores, that_year, anOther.titulo]
|
18
|
+
end
|
19
|
+
|
20
|
+
# Constructor
|
21
|
+
def initialize(autores, titulo, serie, editorial, num_edicion, fecha_publicacion, num_isbns)
|
22
|
+
if titulo == nil
|
23
|
+
return
|
24
|
+
end
|
25
|
+
@autores = autores
|
26
|
+
set_titulo(titulo)
|
27
|
+
set_serie(serie)
|
28
|
+
@editorial = editorial
|
29
|
+
@num_edicion = num_edicion
|
30
|
+
@fecha_publicacion = fecha_publicacion
|
31
|
+
@num_isbns = num_isbns
|
32
|
+
end
|
33
|
+
|
34
|
+
# setter de título
|
35
|
+
def titulo=(args)
|
36
|
+
set_titulo(args)
|
37
|
+
end
|
38
|
+
|
39
|
+
# soporte de setter de título
|
40
|
+
def set_titulo(args)
|
41
|
+
args == "" ? @titulo = "" : @titulo = args.split.map(&:capitalize).join(' ')
|
42
|
+
end
|
43
|
+
|
44
|
+
# setter de serie
|
45
|
+
def serie=(args)
|
46
|
+
set_serie(args)
|
47
|
+
end
|
48
|
+
|
49
|
+
# soporte de setter de serie
|
50
|
+
def set_serie(args)
|
51
|
+
args == "" ? @serie = "" : @serie = "(" + args[1..-1].split.map(&:capitalize).join(' ')
|
52
|
+
end
|
53
|
+
|
54
|
+
# Invierte nombre
|
55
|
+
def autor_rev(autor)
|
56
|
+
name_parts = autor.split - [" "]
|
57
|
+
first_name, last_name = name_parts[0], name_parts[-1]
|
58
|
+
last_name + ", " + first_name[0]
|
59
|
+
end
|
60
|
+
|
61
|
+
# Muestra lista de autores
|
62
|
+
def print_autor
|
63
|
+
count = 0
|
64
|
+
lista = ""
|
65
|
+
autores.each do |autor|
|
66
|
+
count += 1
|
67
|
+
lista += autor_rev(autor)
|
68
|
+
lista += " & " if count != autores.size
|
69
|
+
end
|
70
|
+
lista
|
71
|
+
end
|
72
|
+
|
73
|
+
# Muestra lista de isbn
|
74
|
+
def print_isbn
|
75
|
+
lista = ""
|
76
|
+
num_isbns.each do |isbn|
|
77
|
+
count = 0
|
78
|
+
lista += "ISBN-" + isbn.delete('^0-9').size.to_s + ": " + isbn
|
79
|
+
lista += "\n\t" if count != num_isbns.size
|
80
|
+
end
|
81
|
+
lista
|
82
|
+
end
|
83
|
+
|
84
|
+
# Para método puts
|
85
|
+
def to_s
|
86
|
+
"#{print_autor}\n\t#{titulo}\n\t#{serie}\n\t#{editorial}; #{num_edicion} #{fecha_publicacion}\n\t#{print_isbn}"
|
87
|
+
end
|
88
|
+
|
89
|
+
# Para método puts
|
90
|
+
def mi_puts(sufijo)
|
91
|
+
this_year = @fecha_publicacion[/.*, ([^\)]*)/,1]
|
92
|
+
puts "#{print_autor} (#{this_year})#{sufijo}.\n\t#{titulo}\n\t#{serie}\n\t#{editorial}; #{num_edicion} #{fecha_publicacion}\n\t#{print_isbn}"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
# Tipos Libros hijos de Referencia
|
97
|
+
class Libro < Referencia
|
98
|
+
# Constructor
|
99
|
+
def initialize(*referencia)
|
100
|
+
super(*referencia)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# Tipos Publicaciones hijos de Referencia
|
105
|
+
class Publicacion < Referencia
|
106
|
+
# Constructor
|
107
|
+
def initialize(*referencia)
|
108
|
+
super(*referencia)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# Artículo de Revista hijo de Tipos Publicaciones
|
113
|
+
class Articulo_Revista < Publicacion
|
114
|
+
# Constructor
|
115
|
+
def initialize(*referencia)
|
116
|
+
super(*referencia)
|
117
|
+
end
|
118
|
+
def mi_puts(sufijo)
|
119
|
+
puts "#{print_autor} #{fecha_publicacion}#{sufijo}.\n\t#{titulo}\n\t#{serie}\n\t#{editorial}; #{num_edicion}\n\t#{print_isbn}"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
# Artículo de Periódico hijo de Tipos Publicaciones
|
124
|
+
class Articulo_Periodico < Publicacion
|
125
|
+
# Constructor
|
126
|
+
def initialize(*referencia)
|
127
|
+
super(*referencia)
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
# Documento electrónico hijo de Tipos Publicaciones
|
133
|
+
class Documento_Electronico < Publicacion
|
134
|
+
# Constructor
|
135
|
+
def initialize(*referencia)
|
136
|
+
super(*referencia)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
# Referencia natural
|
141
|
+
class Referencia_Natural < Referencia
|
142
|
+
|
143
|
+
# Constructor
|
144
|
+
def initialize &code
|
145
|
+
self.instance_eval &code
|
146
|
+
end
|
147
|
+
|
148
|
+
# Sobrecarga de Accessors para uso en bloque
|
149
|
+
# getter+setter de autores
|
150
|
+
def authors(*args)
|
151
|
+
if args.length == 1
|
152
|
+
args_new = args[0].split(", ")
|
153
|
+
Referencia.instance_method(:autores=).bind(self).call(args_new)
|
154
|
+
else
|
155
|
+
Referencia.instance_method(:autores).bind(self).call
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
# getter+setter de título
|
160
|
+
def title(*args)
|
161
|
+
if args.length == 1
|
162
|
+
Referencia.instance_method(:titulo=).bind(self).call(*args)
|
163
|
+
else
|
164
|
+
Referencia.instance_method(:titulo).bind(self).call
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
# getter+setter de serie
|
169
|
+
def serie(*args)
|
170
|
+
if args.length == 1
|
171
|
+
Referencia.instance_method(:serie=).bind(self).call(*args)
|
172
|
+
else
|
173
|
+
Referencia.instance_method(:serie).bind(self).call
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
# getter+setter de editorial
|
178
|
+
def editorial(*args)
|
179
|
+
if args.length == 1
|
180
|
+
Referencia.instance_method(:editorial=).bind(self).call(*args)
|
181
|
+
else
|
182
|
+
Referencia.instance_method(:editorial).bind(self).call
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
# getter+setter de edición
|
187
|
+
def edition(*args)
|
188
|
+
if args.length == 1
|
189
|
+
Referencia.instance_method(:num_edicion=).bind(self).call(*args)
|
190
|
+
else
|
191
|
+
Referencia.instance_method(:num_edicion).bind(self).call
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
# getter+setter de fecha
|
196
|
+
def date(*args)
|
197
|
+
if args.length == 1
|
198
|
+
Referencia.instance_method(:fecha_publicacion=).bind(self).call(*args)
|
199
|
+
else
|
200
|
+
Referencia.instance_method(:fecha_publicacion).bind(self).call
|
201
|
+
end end
|
202
|
+
|
203
|
+
# getter+setter de isbns
|
204
|
+
def isbns(*args)
|
205
|
+
if args.length == 1
|
206
|
+
args_new = args[0].split(", ")
|
207
|
+
Referencia.instance_method(:num_isbns=).bind(self).call(args_new)
|
208
|
+
else
|
209
|
+
Referencia.instance_method(:num_isbns).bind(self).call
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
# Artículo de Revista Natural
|
215
|
+
class Articulo_Revista_Natural < Referencia_Natural
|
216
|
+
end
|
217
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
|
4
|
+
# Gestionar una Lista doblemente enlazada
|
5
|
+
class List2 < List
|
6
|
+
include Enumerable
|
7
|
+
|
8
|
+
# Lee lista de nodos
|
9
|
+
def each
|
10
|
+
n = @head
|
11
|
+
while n != nil
|
12
|
+
yield n.value
|
13
|
+
n = n.next
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Inserta un nodo al principio de la lista
|
18
|
+
def ins_start(value)
|
19
|
+
if @head != nil && @head.next != nil
|
20
|
+
n = @head
|
21
|
+
@head = Node.new(value, n, nil)
|
22
|
+
n.prev = @head
|
23
|
+
elsif @head != nil
|
24
|
+
n = @head
|
25
|
+
@head = Node.new(value, n, nil)
|
26
|
+
n.prev = @head
|
27
|
+
@tail = n
|
28
|
+
else
|
29
|
+
@head = Node.new(value, nil, nil)
|
30
|
+
@tail = @head
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Insertar un nodo al final de la lista
|
35
|
+
def ins_end(value)
|
36
|
+
if @tail != nil
|
37
|
+
@tail = Node.new(value, nil, @tail)
|
38
|
+
n = @tail.prev
|
39
|
+
n.next = @tail
|
40
|
+
else
|
41
|
+
@head = Node.new(value, nil, nil)
|
42
|
+
@tail = @head
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Extrae primer elemento
|
47
|
+
def extract_first
|
48
|
+
e = @head
|
49
|
+
@head = e.next
|
50
|
+
if @head != nil
|
51
|
+
@head.prev = nil
|
52
|
+
else
|
53
|
+
@tail = @head
|
54
|
+
end
|
55
|
+
e
|
56
|
+
end
|
57
|
+
|
58
|
+
# Extrae último elemento
|
59
|
+
def extract_last
|
60
|
+
e = @tail
|
61
|
+
@tail = e.prev
|
62
|
+
if @tail != nil
|
63
|
+
@tail.next = nil
|
64
|
+
else
|
65
|
+
@head = @tail
|
66
|
+
end
|
67
|
+
e
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# Nodo para Lista
|
4
|
+
# con "value" para valor del Nodo
|
5
|
+
# "next" para puntero a siguiente nodo
|
6
|
+
# "prev" para puntero a anterior nodo
|
7
|
+
Node = Struct.new(:value, :next, :prev) do
|
8
|
+
|
9
|
+
# Mostrar por pantalla un nodo
|
10
|
+
def to_s
|
11
|
+
if @next == nil
|
12
|
+
"#{value}"
|
13
|
+
else
|
14
|
+
"#{value}\n<->\n"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
# Gestionar una Lista enlazada
|
21
|
+
class List
|
22
|
+
|
23
|
+
# head para cabecera
|
24
|
+
# tail para cola
|
25
|
+
attr_accessor :head, :tail
|
26
|
+
|
27
|
+
# Constructor
|
28
|
+
def initialize
|
29
|
+
@head = nil
|
30
|
+
@tail = nil
|
31
|
+
end
|
32
|
+
|
33
|
+
# Inserta un nodo al principio de la lista
|
34
|
+
def ins_start(value)
|
35
|
+
if @head != nil && @head.next != nil
|
36
|
+
n = @head
|
37
|
+
@head = Node.new(value, n)
|
38
|
+
elsif @head != nil
|
39
|
+
n = @head
|
40
|
+
@head = Node.new(value, n)
|
41
|
+
@tail = n
|
42
|
+
else
|
43
|
+
@head = Node.new(value, nil)
|
44
|
+
@tail = @head
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Insertar un nodo al final de la lista
|
49
|
+
def ins_end(value)
|
50
|
+
if @tail != nil
|
51
|
+
n = Node.new(value, nil)
|
52
|
+
@tail.next = n
|
53
|
+
@tail = n
|
54
|
+
else
|
55
|
+
@head = Node.new(value, nil)
|
56
|
+
@tail = @head
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Número de nodos de una lista
|
61
|
+
def length
|
62
|
+
if @head == nil
|
63
|
+
num = 0
|
64
|
+
else
|
65
|
+
n = @head
|
66
|
+
num = 1
|
67
|
+
while n.next != nil
|
68
|
+
num += 1
|
69
|
+
n = n.next
|
70
|
+
end
|
71
|
+
end
|
72
|
+
num
|
73
|
+
end
|
74
|
+
|
75
|
+
# Extrae primer elemento
|
76
|
+
def extract_first
|
77
|
+
e = @head
|
78
|
+
@head = e.next
|
79
|
+
e
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
data/lib/bibliografia.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "bibliografia/version"
|
3
|
+
require "bibliografia/bibliografia_impl"
|
4
|
+
require "bibliografia/lista_impl"
|
5
|
+
require "bibliografia/lista2_impl"
|
6
|
+
|
7
|
+
# Para usarlo como interfaz
|
8
|
+
module Bibliografia
|
9
|
+
|
10
|
+
# aquí va e el código
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: Bibliografia
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- alu0100502114
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-13 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.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
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: '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: coveralls
|
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
|
+
description: Referencias en una Bibliografía en una Lista enlazada de doble entrada
|
70
|
+
email:
|
71
|
+
- alu0100502114@ull.edu.es
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".coveralls.yml"
|
77
|
+
- ".gemfile"
|
78
|
+
- ".gitignore"
|
79
|
+
- ".travis.yml"
|
80
|
+
- CODE_OF_CONDUCT.md
|
81
|
+
- Gemfile
|
82
|
+
- Guardfile
|
83
|
+
- LICENSE.txt
|
84
|
+
- README.md
|
85
|
+
- Rakefile
|
86
|
+
- bibliografia.gemspec
|
87
|
+
- bin/console
|
88
|
+
- bin/setup
|
89
|
+
- lib/bibliografia.rb
|
90
|
+
- lib/bibliografia/bibliografia_impl.rb
|
91
|
+
- lib/bibliografia/lista2_impl.rb
|
92
|
+
- lib/bibliografia/lista_impl.rb
|
93
|
+
- lib/bibliografia/version.rb
|
94
|
+
homepage: https://bitbucket.org/jesus_marin/lpp_1_prct11
|
95
|
+
licenses:
|
96
|
+
- MIT
|
97
|
+
metadata:
|
98
|
+
allowed_push_host: https://rubygems.org
|
99
|
+
post_install_message:
|
100
|
+
rdoc_options: []
|
101
|
+
require_paths:
|
102
|
+
- lib
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
requirements: []
|
114
|
+
rubyforge_project:
|
115
|
+
rubygems_version: 2.4.8
|
116
|
+
signing_key:
|
117
|
+
specification_version: 4
|
118
|
+
summary: Práctica 11 de LPP.
|
119
|
+
test_files: []
|