quizkarenjose 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ *.bundle
10
+ *.so
11
+ *.o
12
+ *.a
13
+ mkmf.log
14
+ *~
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in question_examen-pregunta.gemspec
4
+ gem 'guard'
5
+ gem 'guard-rspec'
6
+ gem 'guard-bundler'
7
+ gem 'guard-gitpusher'
8
+ gem 'rake'
9
+ gem 'coveralls', require: false
10
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Karen Mercedes
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,31 @@
1
+ # Quiz
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'quiz'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install quiz
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/quiz/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+
3
+
4
+ task :default => :spec
5
+
6
+ desc "Run RSpec code examples"
7
+ task :spec do
8
+ sh "rspec -I. -Ilib -Ispec spec/quiz_spec.rb"
9
+ end
10
+
data/lib/quiz.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "quiz/version"
2
+ require "quiz/codigo"
3
+
4
+ module Quiz
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,118 @@
1
+
2
+ module Quiz
3
+
4
+ class Question
5
+ attr_reader :pregunta, :opciones_respuestas
6
+
7
+ def initialize (pregunta, opciones_respuestas)
8
+ @pregunta = pregunta
9
+ @opciones_respuestas = opciones_respuestas
10
+ end
11
+
12
+ def to_s
13
+ imprimir = ""
14
+ imprimir << @pregunta << "\n\n\n"
15
+ n = 1
16
+ imprimir << "\t #{n}.-- #{opciones_respuestas[:right]}\n"
17
+ n+=1
18
+ opciones_respuestas[:wrong].each do |op|
19
+ imprimir << "\t #{n}.-- #{op}\n"
20
+ n+=1
21
+ end
22
+ imprimir
23
+ end
24
+
25
+ end
26
+
27
+ ############################################################################################################################
28
+
29
+ class Quest_Quiz
30
+
31
+ attr_accessor :titulo, :questions
32
+
33
+ def initialize(titulo, &block)
34
+ @titulo = titulo
35
+ @questions = []
36
+ if block_given?
37
+ if block.arity == 1
38
+ yield self
39
+ else
40
+ instance_eval &block
41
+ end
42
+ end
43
+ end
44
+
45
+ def to_s
46
+ imprimir = "\n\n\n"
47
+ imprimir << @titulo
48
+ imprimir << "\n\n\n"
49
+ cont = 1
50
+ questions.each do |question|
51
+ imprimir << " #{cont} => ) #{question}\n"
52
+ cont += 1
53
+ end
54
+ imprimir
55
+ end
56
+
57
+ def question(pregunta, options = {})
58
+ question = Question.new(pregunta,options)
59
+ questions << question
60
+ end
61
+
62
+ def wrong (option)
63
+ @questions[-1].opciones_respuestas[:wrong] << option #no machacar
64
+ # @questions.opciones_respuestas[:wrong].push (option)
65
+ #el ultimo objeto del array
66
+ end
67
+
68
+ end
69
+
70
+ ########################################################################################################################################
71
+ end#fin del modulo
72
+
73
+ if __FILE__ == $0 then #si se utiliza desde un require estas lineas no se ejecutan pero si lo ejecutamos en consola funciona para ejecutar
74
+
75
+
76
+ quiz = Quiz::Quest_Quiz.new("Cuestionario de LPP 05/12/2014") {
77
+ question 'Cual es el tipo del objeto en el siguiente codigo Ruby class Objeto',
78
+ :right => 'Un Objeto',
79
+ :wrong => []
80
+ wrong 'Una instancia de la clase Class'
81
+ wrong 'Una constante'
82
+ wrong 'Ninguna de las anteriores'
83
+
84
+ question 'Salida de:class Xyz tdef pots @nice tend end',
85
+ :right => 'nil',
86
+ :wrong => []
87
+ wrong '#<Xyz:0x00000002bf0ed0'
88
+ wrong '0'
89
+ wrong 'Ninguna de las anteriores'
90
+
91
+ question 'class Array def say_hi HEY! end end p[1,, bob].say_hi',
92
+ :right => 'Ninguna de las anteriores',
93
+ :wrong => []
94
+ wrong '1'
95
+ wrong 'bob'
96
+ wrong 'HEY!'
97
+
98
+ question 'Cuantos argumentos de tipo bloque puede recibir un metodo?',
99
+ :right => '1',
100
+ :wrong => []
101
+ wrong '2'
102
+ wrong 'muchos'
103
+ wrong 'los que defina el usuario'
104
+
105
+ question 'Es apropiado que una clase Tablero herede de una clase Juego',
106
+ :right=>'Cierto',
107
+ :wrong => []
108
+ wrong 'Falso'
109
+
110
+ question 'Salida class de hash_raro = {[1, 2, 3] => Object.new(),Hash.new => :toto}',
111
+ :right =>'Cierto',
112
+ :wrong => []
113
+ wrong 'Falso'
114
+ }
115
+ puts quiz.to_s
116
+
117
+
118
+ end
@@ -0,0 +1,3 @@
1
+ module Quiz
2
+ VERSION = "0.0.1"
3
+ end
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 = "quizkarenjose"
8
+ spec.version = Quiz::VERSION
9
+ spec.authors = ["Karen Mercedes"]
10
+ spec.email = ["alu0100402001@ull.edu.es"]
11
+ spec.summary = %q{Gema Quiz}
12
+ spec.description = %q{Gema Quiz}
13
+ spec.homepage = ""
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,59 @@
1
+ require "quiz"
2
+
3
+
4
+ module Quiz
5
+ describe Quiz::Quest_Quiz do
6
+ before :each do
7
+ @quiz = Quiz::Quest_Quiz.new("Cuestionario de LPP 05/12/2014") {
8
+
9
+ question 'Cual es el tipo del objeto en el siguiente codigo Ruby class Objeto',
10
+ :right => 'Un Objeto',
11
+ :wrong => []
12
+ wrong 'Una instancia de la clase Class'
13
+ wrong 'Una constante'
14
+ wrong 'Ninguna de las anteriores'
15
+
16
+ question 'Salida de:class Xyz tdef pots @nice tend end',
17
+ :right => 'nil',
18
+ :wrong => []
19
+ wrong '#<Xyz:0x00000002bf0ed0'
20
+ wrong '0'
21
+ wrong 'Ninguna de las anteriores'
22
+
23
+ question 'class Array def say_hi HEY! end end p[1,, bob].say_hi',
24
+ :right => 'Ninguna de las anteriores',
25
+ :wrong => []
26
+ wrong '1'
27
+ wrong 'bob'
28
+ wrong 'HEY!'
29
+
30
+ question 'Cuantos argumentos de tipo bloque puede recibir un metodo?',
31
+ :right => '1',
32
+ :wrong => []
33
+ wrong '2'
34
+ wrong 'muchos'
35
+ wrong 'los que defina el usuario'
36
+
37
+ question 'Es apropiado que una clase Tablero herede de una clase Juego',
38
+ :right=>'Cierto',
39
+ :wrong => []
40
+ wrong 'Falso'
41
+
42
+ question 'Salida class de hash_raro = {[1, 2, 3] => Object.new(),Hash.new => :toto}',
43
+ :right =>'Cierto',
44
+ :wrong => []
45
+ wrong 'Falso'
46
+ }
47
+ end#end del before
48
+
49
+ context "Pruebas para la clase Questionario_Quiz" do
50
+ it "El atributo es de la clase" do
51
+ expect(@quiz.class).to eq(Quest_Quiz )
52
+ end
53
+ it "Tiene un metodo to_s" do
54
+ expect(@quiz.class).to respond_to :to_s
55
+ end
56
+ end#end context
57
+ end#end describe quiz
58
+
59
+ end#fin del module
@@ -0,0 +1,89 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
+ # file to always be loaded, without a need to explicitly require it in any files.
5
+ #
6
+ # Given that it is always loaded, you are encouraged to keep this file as
7
+ # light-weight as possible. Requiring heavyweight dependencies from this file
8
+ # will add to the boot time of your test suite on EVERY test run, even for an
9
+ # individual file that may not need all of that loaded. Instead, consider making
10
+ # a separate helper file that requires the additional dependencies and performs
11
+ # the additional setup, and require it from the spec files that actually need it.
12
+ #
13
+ # The `.rspec` file also contains a few flags that are not defaults but that
14
+ # users commonly want.
15
+ #
16
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
+ RSpec.configure do |config|
18
+ # rspec-expectations config goes here. You can use an alternate
19
+ # assertion/expectation library such as wrong or the stdlib/minitest
20
+ # assertions if you prefer.
21
+ config.expect_with :rspec do |expectations|
22
+ # This option will default to `true` in RSpec 4. It makes the `description`
23
+ # and `failure_message` of custom matchers include text for helper methods
24
+ # defined using `chain`, e.g.:
25
+ # be_bigger_than(2).and_smaller_than(4).description
26
+ # # => "be bigger than 2 and smaller than 4"
27
+ # ...rather than:
28
+ # # => "be bigger than 2"
29
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
30
+ end
31
+
32
+ # rspec-mocks config goes here. You can use an alternate test double
33
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
34
+ config.mock_with :rspec do |mocks|
35
+ # Prevents you from mocking or stubbing a method that does not exist on
36
+ # a real object. This is generally recommended, and will default to
37
+ # `true` in RSpec 4.
38
+ mocks.verify_partial_doubles = true
39
+ end
40
+
41
+ # The settings below are suggested to provide a good initial experience
42
+ # with RSpec, but feel free to customize to your heart's content.
43
+ =begin
44
+ # These two settings work together to allow you to limit a spec run
45
+ # to individual examples or groups you care about by tagging them with
46
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
47
+ # get run.
48
+ config.filter_run :focus
49
+ config.run_all_when_everything_filtered = true
50
+
51
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
52
+ # For more details, see:
53
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
54
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
55
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
56
+ config.disable_monkey_patching!
57
+
58
+ # This setting enables warnings. It's recommended, but in some cases may
59
+ # be too noisy due to issues in dependencies.
60
+ config.warnings = true
61
+
62
+ # Many RSpec users commonly either run the entire suite or an individual
63
+ # file, and it's useful to allow more verbose output when running an
64
+ # individual spec file.
65
+ if config.files_to_run.one?
66
+ # Use the documentation formatter for detailed output,
67
+ # unless a formatter has already been configured
68
+ # (e.g. via a command-line flag).
69
+ config.default_formatter = 'doc'
70
+ end
71
+
72
+ # Print the 10 slowest examples and example groups at the
73
+ # end of the spec run, to help surface which specs are running
74
+ # particularly slow.
75
+ config.profile_examples = 10
76
+
77
+ # Run specs in random order to surface order dependencies. If you find an
78
+ # order dependency and want to debug it, you can fix the order by providing
79
+ # the seed, which is printed after each run.
80
+ # --seed 1234
81
+ config.order = :random
82
+
83
+ # Seed global randomization in this process using the `--seed` CLI option.
84
+ # Setting this allows you to use `--seed` to deterministically reproduce
85
+ # test failures related to randomization by passing the same `--seed` value
86
+ # as the one that triggered the failure.
87
+ Kernel.srand config.seed
88
+ =end
89
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: quizkarenjose
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Karen Mercedes
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-12-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.7'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.7'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '10.0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '10.0'
46
+ description: Gema Quiz
47
+ email:
48
+ - alu0100402001@ull.edu.es
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - LICENSE.txt
56
+ - README.md
57
+ - Rakefile
58
+ - lib/quiz.rb
59
+ - lib/quiz/codigo.rb
60
+ - lib/quiz/version.rb
61
+ - quiz-0.0.1.gem
62
+ - quiz.gemspec
63
+ - spec/quiz_spec.rb
64
+ - spec/spec_helper.rb
65
+ homepage: ''
66
+ licenses:
67
+ - MIT
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 1.8.23
87
+ signing_key:
88
+ specification_version: 3
89
+ summary: Gema Quiz
90
+ test_files:
91
+ - spec/quiz_spec.rb
92
+ - spec/spec_helper.rb