quizHanielMaria 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +2 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.travis.yml +9 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +22 -0
- data/README.md +30 -0
- data/Rakefile +8 -0
- data/lib/quiz/version.rb +3 -0
- data/lib/quiz.rb +63 -0
- data/quiz-0.0.1.gem +0 -0
- data/quiz.gemspec +23 -0
- data/spec/quiz_spec.rb +44 -0
- data/spec/spec_helper.rb +91 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2e5b41bd8df02c190b9ee46d49e24d0c8d05a323
|
4
|
+
data.tar.gz: dbdb23374eb787d5794da801407e4c454d69947a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b4be7ba4a13b71d34ac1bad360969d95ee79798f93b91a967fe09b55e93969ef7f75f8928b687a355edcc9d9ecfe32f8f67ec355ff0afa244da35756326fd2ca
|
7
|
+
data.tar.gz: bdfb3e9310847ba9c8e329defdfda59dc56aa3f8b83c7ecbe23fca5987705743442b7da184f9ef290963a880fbfb8e0363f25ba7c7e8bd50e0ac4670b2da9b6c
|
data/.coveralls.yml
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Haniel
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# Quiz
|
2
|
+
|
3
|
+
Practica 11: DSL (Lenguaje de Dominio Específico)
|
4
|
+
|
5
|
+
## Haniel Y María
|
6
|
+
|
7
|
+
## Enunciado
|
8
|
+
|
9
|
+
Diseñar e implementar un Lenguaje de Dominio Especıfico Domain Specific Language - DSL,
|
10
|
+
siguiendo la filosofıa de Ruby que permita la definicion de un examen.
|
11
|
+
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'quiz'
|
18
|
+
```
|
19
|
+
|
20
|
+
Ejecuta:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
O instala la gema tu mismo:
|
25
|
+
|
26
|
+
$ gem install quiz
|
27
|
+
|
28
|
+
Haniel Y Maria
|
29
|
+
|
30
|
+
|
data/Rakefile
ADDED
data/lib/quiz/version.rb
ADDED
data/lib/quiz.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
require "quiz/version"
|
3
|
+
|
4
|
+
module Quiz
|
5
|
+
class Question
|
6
|
+
attr_reader :enun, :answers
|
7
|
+
|
8
|
+
def initialize (enun, answers)
|
9
|
+
@enun = enun
|
10
|
+
@answers = answers
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_s
|
14
|
+
out = ""
|
15
|
+
out << enun << "\n"
|
16
|
+
n = 1
|
17
|
+
out << "\n\t #{n}.- #{answers[:right]}\n"
|
18
|
+
n+=1
|
19
|
+
answers[:wrong].each do |op|
|
20
|
+
out<<"\t #{n}.- #{op}\n"
|
21
|
+
n+=1
|
22
|
+
end
|
23
|
+
out
|
24
|
+
end
|
25
|
+
|
26
|
+
end #fin clase Question
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
class P_Quiz
|
31
|
+
attr_accessor :name, :questions
|
32
|
+
|
33
|
+
def initialize(name, &block)
|
34
|
+
self.name = name
|
35
|
+
self.questions = []
|
36
|
+
|
37
|
+
instance_eval &block
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_s
|
41
|
+
out = "\n#{'*' * (name.size + 6)}\n"
|
42
|
+
out << "** " + name + " **"
|
43
|
+
out << "\n#{'*' * (name.size + 6)}\n\n"
|
44
|
+
contador = 0
|
45
|
+
questions.each do |question|
|
46
|
+
out << "#{contador +1}) #{question}\n"
|
47
|
+
contador += 1
|
48
|
+
end
|
49
|
+
out
|
50
|
+
end
|
51
|
+
|
52
|
+
def question(text, answers = {})
|
53
|
+
question = Question.new(text,answers)
|
54
|
+
questions << question
|
55
|
+
end
|
56
|
+
|
57
|
+
def wrong (option)
|
58
|
+
self.questions[-1].answers[:wrong] << option
|
59
|
+
end
|
60
|
+
|
61
|
+
end #fin clase P_Quiz
|
62
|
+
|
63
|
+
end #fin module Quiz
|
data/quiz-0.0.1.gem
ADDED
Binary file
|
data/quiz.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'quiz/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "quizHanielMaria"
|
8
|
+
spec.version = Quiz::VERSION
|
9
|
+
spec.authors = ["Haniel"]
|
10
|
+
spec.email = ["alu0100721690@ull.edu.es"]
|
11
|
+
spec.summary = %q{DSL Para Examenes}
|
12
|
+
spec.description = %q{DSL Para Examenes}
|
13
|
+
spec.homepage = "https://github.com/alu4421/LPP_T_7B_P11"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
data/spec/quiz_spec.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require "quiz"
|
2
|
+
|
3
|
+
module Quiz
|
4
|
+
describe Quiz::P_Quiz do
|
5
|
+
before :each do
|
6
|
+
@v_quiz=P_Quiz.new("Cuestionario de LPP 05/12/2014") {
|
7
|
+
question 'Cuantos argumentos de tipo bloque puede recibir un metodo?',
|
8
|
+
:right => '1',
|
9
|
+
:wrong => []
|
10
|
+
wrong '2'
|
11
|
+
wrong 'muchos'
|
12
|
+
wrong 'los que defina el usuario'
|
13
|
+
|
14
|
+
question 'En Ruby los bloque son objetos que continen codigo',
|
15
|
+
:right=>'Falso',
|
16
|
+
:wrong => []
|
17
|
+
wrong 'Cierto'
|
18
|
+
|
19
|
+
question '¿En que año Cristobal Colón descubrió América?',
|
20
|
+
:right => '1492',
|
21
|
+
:wrong =>[]
|
22
|
+
wrong '1942'
|
23
|
+
wrong '1808'
|
24
|
+
wrong '1914'
|
25
|
+
|
26
|
+
a = rand(10)
|
27
|
+
b = rand(10)
|
28
|
+
question "#{a}+#{b} = ",
|
29
|
+
:right => "#{a + b}",
|
30
|
+
:wrong => []
|
31
|
+
wrong "44"
|
32
|
+
wrong "#{a + b + 2}"
|
33
|
+
wrong "#{a + b - 2}"
|
34
|
+
}
|
35
|
+
puts @v_quiz.to_s
|
36
|
+
end
|
37
|
+
|
38
|
+
it "La clase es la que debe ser" do
|
39
|
+
expect(@v_quiz.class).to eq(P_Quiz)
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
end #fin describe
|
44
|
+
end #fin module
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'coveralls'
|
2
|
+
Coveralls.wear!
|
3
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
4
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
5
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
6
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
7
|
+
#
|
8
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
9
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
10
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
11
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
12
|
+
# a separate helper file that requires the additional dependencies and performs
|
13
|
+
# the additional setup, and require it from the spec files that actually need it.
|
14
|
+
#
|
15
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
16
|
+
# users commonly want.
|
17
|
+
#
|
18
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
19
|
+
RSpec.configure do |config|
|
20
|
+
# rspec-expectations config goes here. You can use an alternate
|
21
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
22
|
+
# assertions if you prefer.
|
23
|
+
config.expect_with :rspec do |expectations|
|
24
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
25
|
+
# and `failure_message` of custom matchers include text for helper methods
|
26
|
+
# defined using `chain`, e.g.:
|
27
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
28
|
+
# # => "be bigger than 2 and smaller than 4"
|
29
|
+
# ...rather than:
|
30
|
+
# # => "be bigger than 2"
|
31
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
32
|
+
end
|
33
|
+
|
34
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
35
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
36
|
+
config.mock_with :rspec do |mocks|
|
37
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
38
|
+
# a real object. This is generally recommended, and will default to
|
39
|
+
# `true` in RSpec 4.
|
40
|
+
mocks.verify_partial_doubles = true
|
41
|
+
end
|
42
|
+
|
43
|
+
# The settings below are suggested to provide a good initial experience
|
44
|
+
# with RSpec, but feel free to customize to your heart's content.
|
45
|
+
=begin
|
46
|
+
# These two settings work together to allow you to limit a spec run
|
47
|
+
# to individual examples or groups you care about by tagging them with
|
48
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
49
|
+
# get run.
|
50
|
+
config.filter_run :focus
|
51
|
+
config.run_all_when_everything_filtered = true
|
52
|
+
|
53
|
+
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
54
|
+
# For more details, see:
|
55
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
56
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
57
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
58
|
+
config.disable_monkey_patching!
|
59
|
+
|
60
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
61
|
+
# be too noisy due to issues in dependencies.
|
62
|
+
config.warnings = true
|
63
|
+
|
64
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
65
|
+
# file, and it's useful to allow more verbose output when running an
|
66
|
+
# individual spec file.
|
67
|
+
if config.files_to_run.one?
|
68
|
+
# Use the documentation formatter for detailed output,
|
69
|
+
# unless a formatter has already been configured
|
70
|
+
# (e.g. via a command-line flag).
|
71
|
+
config.default_formatter = 'doc'
|
72
|
+
end
|
73
|
+
|
74
|
+
# Print the 10 slowest examples and example groups at the
|
75
|
+
# end of the spec run, to help surface which specs are running
|
76
|
+
# particularly slow.
|
77
|
+
config.profile_examples = 10
|
78
|
+
|
79
|
+
# Run specs in random order to surface order dependencies. If you find an
|
80
|
+
# order dependency and want to debug it, you can fix the order by providing
|
81
|
+
# the seed, which is printed after each run.
|
82
|
+
# --seed 1234
|
83
|
+
config.order = :random
|
84
|
+
|
85
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
86
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
87
|
+
# test failures related to randomization by passing the same `--seed` value
|
88
|
+
# as the one that triggered the failure.
|
89
|
+
Kernel.srand config.seed
|
90
|
+
=end
|
91
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: quizHanielMaria
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Haniel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-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.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
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
|
+
description: DSL Para Examenes
|
42
|
+
email:
|
43
|
+
- alu0100721690@ull.edu.es
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".coveralls.yml"
|
49
|
+
- ".gitignore"
|
50
|
+
- ".rspec"
|
51
|
+
- ".travis.yml"
|
52
|
+
- Gemfile
|
53
|
+
- LICENSE.txt
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- lib/quiz.rb
|
57
|
+
- lib/quiz/version.rb
|
58
|
+
- quiz-0.0.1.gem
|
59
|
+
- quiz.gemspec
|
60
|
+
- spec/quiz_spec.rb
|
61
|
+
- spec/spec_helper.rb
|
62
|
+
homepage: https://github.com/alu4421/LPP_T_7B_P11
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 2.4.3
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: DSL Para Examenes
|
86
|
+
test_files:
|
87
|
+
- spec/quiz_spec.rb
|
88
|
+
- spec/spec_helper.rb
|