prct10 0.0.1

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: bf26791fd2a92bef993adf3e5bbe662089badfd7
4
+ data.tar.gz: 99ff1b91b5e14df203c22fa6999af8b605777766
5
+ SHA512:
6
+ metadata.gz: cb923f85700528990aaf0ba46f253d489f50be7a9de48ec4f5acc3ef106f1f4a8bc94756b090be4354bfc3ad494e72535c3b4685c49b4a9f9d34943e8f5cd3da
7
+ data.tar.gz: bfaf5c323aa192703c0b7c061e1154561e6695fa68e7e00a59b0b368d603c832b74731aa15684117ae692d9d2bb0b30b8dc0f2dff52b6343509f9fa22bf09945
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in prct10.gemspec
4
+ gemspec
@@ -0,0 +1,27 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ prct10 (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.2.5)
10
+ rake (10.4.2)
11
+ rspec (2.99.0)
12
+ rspec-core (~> 2.99.0)
13
+ rspec-expectations (~> 2.99.0)
14
+ rspec-mocks (~> 2.99.0)
15
+ rspec-core (2.99.2)
16
+ rspec-expectations (2.99.2)
17
+ diff-lcs (>= 1.1.3, < 2.0)
18
+ rspec-mocks (2.99.2)
19
+
20
+ PLATFORMS
21
+ ruby
22
+
23
+ DEPENDENCIES
24
+ bundler (~> 1.7)
25
+ prct10!
26
+ rake (~> 10.0)
27
+ rspec (~> 2.11)
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Fabián Díaz Lorenzo
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.
@@ -0,0 +1,31 @@
1
+ # Prct10
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 'prct10'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install prct10
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/prct10/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
@@ -0,0 +1,6 @@
1
+ $:.unshift File.dirname(__FILE__) + 'lib'
2
+ require "bundler/gem_tasks"
3
+
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new
6
+ task :default => :spec
@@ -0,0 +1,2 @@
1
+ require "prct10/version"
2
+ require "prct10/DSL_prct11"
@@ -0,0 +1,82 @@
1
+ module Prct10
2
+ class Question
3
+ attr_accessor :name, :opciones
4
+
5
+ def initialize(name1, options)
6
+ @name = name1
7
+ @opciones = options
8
+ end
9
+
10
+ def to_s #mostramos pregunta y opciones
11
+ cadena = ""
12
+ cadena << name << "\n"
13
+ n = 1
14
+ cadena << " -> #{opciones[:right]}\n"
15
+ n+=1
16
+ opciones[:wrong].each do |op|
17
+ cadena << " -> #{op}\n"
18
+ n+=1
19
+ end
20
+ cadena
21
+ end
22
+ end
23
+
24
+ class Quiz
25
+ attr_accessor :title, :questions
26
+
27
+
28
+ def initialize(title = "", &block) #titulo y bloque con question(cadena) y hash
29
+ self.title = title
30
+ self.questions = []
31
+
32
+
33
+ if block_given?
34
+ if block.arity == 1
35
+ yield
36
+ else
37
+ instance_eval &block
38
+ end
39
+ end
40
+ end
41
+
42
+ def to_s
43
+ output = title
44
+ output << "\n#{'*' * title.size}\n\n"
45
+ questions.each_with_index do |pregunta, contador|
46
+ output << "#{contador+1}) #{pregunta}\n"
47
+ end
48
+ # output = "#{self.title} \n\n"
49
+ # output << "#{self.questions.join("\n")+ "Su Respuesta"}"
50
+ output
51
+ end
52
+
53
+ def pregunta(name1, options = {})
54
+ pregunta = Question.new(name1, options)
55
+ questions << pregunta
56
+ #pregunta << " (#{options[:wrong]})" if options[:wrong]
57
+ end
58
+
59
+ def wrong (option)
60
+ self.questions[-1].opciones[:wrong] << option
61
+ end
62
+ end
63
+ end
64
+
65
+
66
+
67
+
68
+ # def respuesta(text, options = {})
69
+ # respuesta= text
70
+ # respuesta << " (#{options[:during]})" if options[:during]
71
+ #
72
+ # answers << respuesta
73
+ # end
74
+
75
+ # def run
76
+ # counter = 0
77
+ # puts self.name+ "\n\n"
78
+ # self.questions.each { |q| counter +=1}
79
+ # puts "#{counter} respuestas correctas de un total de #{questions.size}."
80
+ # end
81
+
82
+
@@ -0,0 +1,96 @@
1
+ module Prct10
2
+ class Question
3
+ attr_accessor :name, :opciones
4
+
5
+ def initialize(name1, options)
6
+ @name = name1
7
+ @opciones = options
8
+ end
9
+
10
+ def to_s #mostramos pregunta y opciones
11
+ cadena = ""
12
+ cadena << name << "\n"
13
+ n = 1
14
+ cadena << " -> #{opciones[:right]}\n"
15
+ n+=1
16
+ opciones[:wrong].each do |op|
17
+ cadena << " -> #{op}\n"
18
+ n+=1
19
+ end
20
+ cadena
21
+ end
22
+ end
23
+
24
+ class Quiz
25
+ attr_accessor :title, :questions
26
+
27
+
28
+ def initialize(title = "", &block) #titulo y bloque con question(cadena) y hash
29
+ self.title = title
30
+ self.questions = []
31
+
32
+
33
+ if block_given?
34
+ if block.arity == 1
35
+ yield
36
+ else
37
+ instance_eval &block
38
+ end
39
+ end
40
+ end
41
+
42
+ def to_s
43
+ output = title
44
+ output << "\n#{'*' * title.size}\n\n"
45
+ questions.each_with_index do |pregunta, contador|
46
+ output << "#{contador+1} ) #{pregunta}\n"
47
+ end
48
+ # output = "#{self.title} \n\n"
49
+ # output << "#{self.questions.join("\n")+ "Su Respuesta"}"
50
+ output
51
+ end
52
+
53
+ def pregunta(name1, options = {})
54
+ pregunta = Question.new(name1, options)
55
+ questions << pregunta
56
+ #pregunta << " (#{options[:wrong]})" if options[:wrong]
57
+ end
58
+
59
+ def wrong (option)
60
+ self.questions[-1].opciones[:wrong] << option
61
+ end
62
+ end
63
+ end
64
+
65
+ quiz = Prct10::Quiz.new("Cuestionario de LPP 05/12/2014") {
66
+ pregunta 'Cuantos argumentos de tipo bloque puede recibir un metodo?',
67
+ :right => '1',
68
+ :wrong => []
69
+ wrong '2'
70
+ wrong 'muchos'
71
+ wrong 'los que defina el usuario'
72
+
73
+ pregunta 'En Ruby los bloque son objetos que continen codigo',
74
+ :right=>'Falso',
75
+ :wrong => []
76
+ wrong 'Cierto'
77
+
78
+ }
79
+ puts quiz.to_s
80
+
81
+
82
+ # def respuesta(text, options = {})
83
+ # respuesta= text
84
+ # respuesta << " (#{options[:during]})" if options[:during]
85
+ #
86
+ # answers << respuesta
87
+ # end
88
+
89
+ # def run
90
+ # counter = 0
91
+ # puts self.name+ "\n\n"
92
+ # self.questions.each { |q| counter +=1}
93
+ # puts "#{counter} respuestas correctas de un total de #{questions.size}."
94
+ # end
95
+
96
+
@@ -0,0 +1,3 @@
1
+ module Prct10
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'prct10/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "prct10"
8
+ spec.version = Prct10::VERSION
9
+ spec.authors = ["Fabián Díaz Lorenzo"]
10
+ spec.email = ["alu0100702545@ull.edu.es"]
11
+ spec.summary = %q{Practica Finalizada}
12
+ spec.description = %q{Chiquito tonto el que use esta gema }
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
+ spec.add_development_dependency 'rspec' ,'~> 2.11'
24
+ end
25
+ #gem.add_development_dependency 'rspec', '~> 2.11'
@@ -0,0 +1,103 @@
1
+ require 'spec_helper'
2
+ require 'prct10'
3
+
4
+ describe Prct10 do
5
+ describe Prct10::Quiz do
6
+ before :each do
7
+ @quiz = Prct10::Quiz.new("Cuestionario de PFS 10/12/2011"){
8
+ pregunta 'En que anyo Cristobal Colon descubrio America',
9
+ :right =>'1492',:wrong => []
10
+ wrong '1942'
11
+ wrong '1808'
12
+ wrong '1914'
13
+ a = rand(10)
14
+ b = rand(10)
15
+ pregunta "#{a}+#{b} = ",
16
+ :right =>"#{a + b}",:wrong => []
17
+ wrong '44'
18
+ wrong "#{a + b + 2}"
19
+ wrong "#{a + b - 2}"
20
+ pregunta 'En Ruby los bloque son objetos que continen codigo',
21
+ :right=>'Falso',:wrong => []
22
+ wrong 'Cierto'
23
+ pregunta 'Cuantos argumentos de tipo bloque puede recibir un metodo?',
24
+ :right => '1',:wrong => []
25
+ wrong '2'
26
+ wrong 'muchos'
27
+ wrong 'los que defina el usuario'
28
+
29
+ }
30
+ end
31
+ context "La clase Quiz contiene los siguientes metodos" do
32
+ it "metodo to_s" do
33
+ expect(@quiz).to respond_to :to_s
34
+ end
35
+ it "metodo pregunta" do
36
+ expect(@quiz.to_s).to match('En Ruby los bloque son objetos que continen codigo')
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ # if __FILE__ == $0
43
+ # quiz = Quiz.new("Cuestionario de PFS 10/12/2011") {
44
+ # questions 'En que anyo Cristobal Colon descubrio America',
45
+ # wrong =>'1942',
46
+ # right =>'1492',
47
+ # wrong =>'1808',
48
+ # wrong =>'1914'
49
+ #
50
+ # a = rand(10)
51
+ # b = rand(10)
52
+ # questions "#{a}+#{b} = ",
53
+ # wrong =>"44",
54
+ # wrong =>"#{a + b + 2}",
55
+ # right =>"#{a + b}",
56
+ # wrong =>"#{a + b - 2}"
57
+ # }
58
+ #
59
+ #
60
+ # puts quiz
61
+ # puts "************************"
62
+ # quiz.run
63
+ # end
64
+
65
+ #
66
+ # @preg3=Preguntas::EleccionSimple.new(
67
+ # :pregunta => "salida de :
68
+ # class Array \n
69
+ # def say_hi \n
70
+ # HEY!
71
+ # end
72
+ # end \n
73
+ # p[1,, bob].say_hi",
74
+ # :op_correcta => "Ninguna de las anteriores",
75
+ # :op_incorrecta => ['1', 'bob', 'HEY!'])
76
+ #
77
+ #
78
+ #
79
+ # quiz = Prct10::Quiz.new("Cuestionario de LPP 05/12/2014") {
80
+ # pregunta 'Cuantos argumentos de tipo bloque puede recibir un metodo?',
81
+ # :right => '1',
82
+ # :wrong => []
83
+ # wrong '2'
84
+ # wrong 'muchos'
85
+ # wrong 'los que defina el usuario'
86
+ #
87
+ # pregunta 'En Ruby los bloque son objetos que continen codigo',
88
+ # :right=>'Falso',
89
+ # :wrong => []
90
+ # wrong 'Cierto'
91
+ #
92
+ # }
93
+ #
94
+ #
95
+ #
96
+ #
97
+ #
98
+ #
99
+ #
100
+
101
+
102
+
103
+
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+ require 'prct10'
3
+
4
+ describe Prct10 do
5
+ describe Prct10::Quiz do
6
+ before :each do
7
+ @quiz = Prct10::Quiz.new("Cuestionario de PFS 10/12/2011") do
8
+ pregunta 'En que anyo Cristobal Colon descubrio America',
9
+ :wrong => []
10
+ :wrong << '1942',
11
+ :right =>'1492',
12
+ :wrong << '1808',
13
+ :wrong << '1914'
14
+ pregunta "Noodles", :right => "1 cup"
15
+ end
16
+ end
17
+ context "La clase Quiz contiene los siguientes metodos" do
18
+ it "tiene que tener un enunciado" do
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ # if __FILE__ == $0ingredient "Noodles", :amount => "1 cup"
25
+ # quiz = Quiz.new("Cuestionario de PFS 10/12/2011") {
26
+ # questions 'En que anyo Cristobal Colon descubrio America',
27
+ # wrong =>'1942',
28
+ # right =>'1492',
29
+ # wrong =>'1808',
30
+ # wrong =>'1914'
31
+ #
32
+ # a = rand(10)
33
+ # b = rand(10)
34
+ # questions "#{a}+#{b} = ",
35
+ # wrong =>"44",
36
+ # wrong =>"#{a + b + 2}",
37
+ # right =>"#{a + b}",
38
+ # wrong =>"#{a + b - 2}"
39
+ # }
40
+ #
41
+ #
42
+ # puts quiz
43
+ # puts "************************"
44
+ # quiz.run
45
+ # end
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
@@ -0,0 +1,17 @@
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
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ RSpec.configure do |config|
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ config.run_all_when_everything_filtered = true
10
+ config.filter_run :focus
11
+
12
+ # Run specs in random order to surface order dependencies. If you find an
13
+ # order dependency and want to debug it, you can fix the order by providing
14
+ # the seed, which is printed after each run.
15
+ # --seed 1234
16
+ config.order = 'random'
17
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: prct10
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Fabián Díaz Lorenzo
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
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.11'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.11'
55
+ description: 'Chiquito tonto el que use esta gema '
56
+ email:
57
+ - alu0100702545@ull.edu.es
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - Gemfile
63
+ - Gemfile.lock
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/prct10.rb
68
+ - lib/prct10/DSL_prct11.rb
69
+ - lib/prct10/DSL_prct11.rb~
70
+ - lib/prct10/version.rb
71
+ - prct10.gemspec
72
+ - spec/prct10_spec.rb
73
+ - spec/prct10_spec.rb~
74
+ - spec/spec_helper.rb
75
+ homepage: ''
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.4.3
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Practica Finalizada
99
+ test_files:
100
+ - spec/prct10_spec.rb
101
+ - spec/prct10_spec.rb~
102
+ - spec/spec_helper.rb