asker-tool 2.5.0 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c80632141abb14dfce16fd8c30023f56a807d20ad4c93fb664d89409e7f7261c
4
- data.tar.gz: 7c478c4175f7cf7d689dc08c35443eafd55066ea8e173ce0ad0c1e675d178941
3
+ metadata.gz: ecd775d21f7d85f15daa5307be5947fc9d36d22dccd8448bf477c885ea639758
4
+ data.tar.gz: d145bb6b6ae9af56a917f9c98ccd8f33e09b0e9640c93382854d20c733714bd5
5
5
  SHA512:
6
- metadata.gz: 339b987ca596d8f40ac9767214311e7c90cc23e1a32bce078f656a8984bb4a8afed9fce6e7af526a42989c82901af66eb81c8eb9789f7d4069a2493f262c1564
7
- data.tar.gz: 9b7387a951854aec90e288128af94cd3adaf06b8acc133a42e972a42d534c7f3093aa09e0c13f4e65eba1a9dff3cba4c848d16ed7071140882c765fc537d5528
6
+ metadata.gz: 87f02c406e8a659bcad86e246982b1192aae902476939fb77e69f533fb648b7962054068a5084f06c0ac6f8cf8349bce8602e55f8e2f20d973f645801cbc6a09
7
+ data.tar.gz: b030b96ca377a1170961dbf1c6aa1026493756baea1e58a455e4bf454e13cb7af47a53f72807d66f2dbb8c0b93d12ff10881bda617897205f69fb0a977f83844
data/README.md CHANGED
@@ -11,7 +11,6 @@ ASKER helps trainers to create a huge amount of questions, from a definitions (_
11
11
 
12
12
  * Free Software [LICENSE](LICENSE).
13
13
  * Multiplatform.
14
- * [Ruby program](https://rubygems.org/gems/asker-tool)
15
14
 
16
15
  ## Installation
17
16
 
@@ -22,20 +21,14 @@ ASKER helps trainers to create a huge amount of questions, from a definitions (_
22
21
 
23
22
  ## Usage
24
23
 
25
- Steps:
26
-
27
- 1. Create an input file with your inputs (_conceptual map_).
28
- 1. Run _asker_ and get the results into `output` directory.
29
-
30
- Example: Running `asker` with our example input file as argument (`acdc.haml`):
31
-
32
- ```
24
+ 1. **Create input file** with your content (_conceptual map_). Examples at [Asker inputs folder](./docs/examples).
25
+ 2. **Run `asker PATH/TO/INPUT`**. Example: Create questions from ACDC input example file:
26
+ ```bash
33
27
  asker docs/examples/bands/acdc.haml
34
28
  ```
29
+ 3. Output files created into the `output` folder.
35
30
 
36
- * Output files created into the `output` folder.
37
- * More [example input files](./docs/examples).
38
- * More asker input files at [github/dvarrui/asker-inputs](https://github.com/dvarrui/asker-inputs) repository.
31
+ > More input examples at [dvarrui/asker-input](https://github.com/dvarrui/asker-inputs) repository.
39
32
 
40
33
  ## Documentation
41
34
 
@@ -43,6 +36,7 @@ asker docs/examples/bands/acdc.haml
43
36
  * [Videos](docs/videos.md)
44
37
  * [Inputs](docs/inputs/README.md)
45
38
  * [Usage](docs/usage.md)
39
+ * [Reference](docs/reference.md)
46
40
  * [Contributions](docs/contributions.md)
47
41
  * [Problem to solve](docs/idea.md)
48
42
  * [History](docs/history.md)
@@ -50,4 +44,3 @@ asker docs/examples/bands/acdc.haml
50
44
  ## Contact
51
45
 
52
46
  * **Email**: `teuton.software@protonmail.com`
53
- * **Twitter**: `@SoftwareTeuton`
@@ -5,7 +5,8 @@ require 'set'
5
5
  require_relative 'base_stage'
6
6
  require_relative '../question'
7
7
 
8
- # range d1-d4
8
+ ##
9
+ # range d1-d4: d1choice, d1none-misspelled, d1none
9
10
  class StageD < BaseStage
10
11
  def run
11
12
  # Stage D: process every definition, I mean every <def> tag
@@ -15,6 +16,7 @@ class StageD < BaseStage
15
16
  lang = concept.lang
16
17
  # for every <text> do this
17
18
  concept.texts.each do |t|
19
+ # s => concept name, none and neighbors
18
20
  s = Set.new [name(:raw), lang.text_for(:none)]
19
21
  concept.neighbors.each { |n| s.add n[:concept].name(:decorated) }
20
22
  a = s.to_a
@@ -81,13 +83,20 @@ class StageD < BaseStage
81
83
 
82
84
  # Question choice => true
83
85
  q = Question.new(:choice)
84
- q.name = "#{name(:id)}-#{num}-d2true"
86
+ q.name = "#{name(:id)}-#{num}-d2true-misspelled"
85
87
  q.text = random_image_for(name(:raw)) + lang.text_for(:d2, name(:raw), t)
86
88
  q.good = lang.text_for(:true)
87
89
  q.bads << lang.text_for(:misspelling)
88
90
  q.bads << lang.text_for(:false)
89
91
  questions << q
90
92
 
93
+ # Question boolean => true
94
+ q = Question.new(:boolean)
95
+ q.name = "#{name(:id)}-#{num}-d2true"
96
+ q.text = random_image_for(name(:raw)) + lang.text_for(:d2, name(:raw), t)
97
+ q.good = 'TRUE'
98
+ questions << q
99
+
91
100
  # Question choice => false
92
101
  if a.size > 1
93
102
  q = Question.new(:choice)
@@ -97,6 +106,13 @@ class StageD < BaseStage
97
106
  q.bads << lang.text_for(:misspelling)
98
107
  q.bads << lang.text_for(:true)
99
108
  questions << q
109
+
110
+ # Question boolean => false
111
+ q = Question.new(:boolean)
112
+ q.name = "#{name(:id)}-#{num}-d2false"
113
+ q.text = random_image_for(name(:raw)) + lang.text_for(:d2, a[1], t)
114
+ q.good = 'FALSE'
115
+ questions << q
100
116
  end
101
117
 
102
118
  # Question hidden name questions
@@ -130,10 +146,4 @@ class StageD < BaseStage
130
146
 
131
147
  questions
132
148
  end
133
- # rubocop:enable Lint/BooleanSymbol
134
- # rubocop:enable Metrics/MethodLength
135
- # rubocop:enable Metrics/AbcSize
136
- # rubocop:enable Metrics/BlockLength
137
- # rubocop:enable Metrics/CyclomaticComplexity
138
- # rubocop:enable Metrics/PerceivedComplexity
139
149
  end
@@ -1,4 +1,5 @@
1
1
  [global]
2
+ version = ">= 2.5.0"
2
3
  ; Connect Google and download find images URLs
3
4
  ; Accept yes|no
4
5
  internet = yes
@@ -4,13 +4,13 @@
4
4
  %names AC/DC, ACDC
5
5
  %tags rock, band, australia
6
6
  %def Australian rock band formed by Scottish-born brothers Malcolm and Angus Young
7
- %table{ fields: 'members'}
7
+ %table{ fields: 'members' }
8
8
  %row Bon Scott
9
9
  %row Angus Young
10
10
  %row Malcolm Young
11
11
  %row Phil Rudd
12
12
  %row Cliff Williams
13
- %table{ fields: 'attribute, value'}
13
+ %table{ fields: 'attribute, value' }
14
14
  %row
15
15
  %col Genres
16
16
  %col Hard rock blues rock rock and roll
@@ -20,7 +20,7 @@
20
20
  %row
21
21
  %col Formed in
22
22
  %col Sydney
23
- %table{ fields: 'Albums', sequence: 'Albums sorted by date'}
23
+ %table{ fields: 'Albums', sequence: 'Albums sorted by date' }
24
24
  %row Albums High Voltage
25
25
  %row Powerage
26
26
  %row Highway to Hell
@@ -11,47 +11,24 @@ module EmbeddedFile
11
11
  # @param localdir (String) Input file base folder
12
12
  # @return Hash
13
13
  def self.load(value, localdir)
14
- # When filename is an URL
15
- if value.start_with?('https://') || value.start_with?('http://')
16
- if is_image? value
17
- html_text = "<img src=\"#{value}\" alt=\"image\" width=\"400\" height=\"300\">"
18
- elsif is_audio? value
19
- html_text = "<audio src=\"#{value}\" controls></audio>"
20
- else
21
- html_text = "<b> #{value}: Unkown file type!</b>"
22
- end
23
- return { text: html_text, file: :none }
14
+ return load_image(value, localdir) if is_image? value
15
+ return load_audio(value, localdir) if is_audio? value
16
+ return load_video(value, localdir) if is_video? value
17
+
18
+ if is_url? value
19
+ Logger.verbose Rainbow("[ERROR] Unkown URL type!: #{value}").red.bright
20
+ exit 1
24
21
  end
25
22
 
26
23
  filepath = File.join(localdir, value)
27
24
  unless File.exist?(filepath)
28
- # When filename is unkown!
29
- Logger.verbose Rainbow("[ERROR] Unknown file! #{filepath}").red.bright
25
+ Logger.verbose Rainbow("[ERROR] File does not exist!: #{filepath}").red.bright
26
+ # return { text: "URI error", file: :none, type: :unkown }
30
27
  exit 1
31
28
  end
32
- if is_image? filepath
33
- text = '<img src="@@PLUGINFILE@@/' + File.basename(filepath) \
34
- + '" alt="imagen" class="img-responsive atto_image_button_text-bottom">'
35
- data = '<file name="' + File.basename(filepath) + '" path="/" encoding="base64">' \
36
- + Base64.strict_encode64(File.open(filepath, 'rb').read) + '</file>'
37
- return { text: text, file: data }
38
- elsif is_audio? filepath
39
- text = '<audio controls><source src="@@PLUGINFILE@@/' + File.basename(filepath) \
40
- + '">Your browser does not support the audio tag.</audio>'
41
- data = '<file name="' + File.basename(filepath) + '" path="/" encoding="base64">' \
42
- + Base64.strict_encode64(File.open(filepath, 'rb').read) + '</file>'
43
- return { text: text, file: data }
44
- elsif is_video? filepath
45
- text = '<video controls><source src="@@PLUGINFILE@@/' + File.basename(filepath) \
46
- + '">Your browser does not support the video tag.</video>'
47
- data = '<file name="' + File.basename(filepath) + '" path="/" encoding="base64">' \
48
- + Base64.strict_encode64(File.open(filepath, 'rb').read) + '</file>'
49
- return { text: text, file: data }
50
- end
51
- # Suposse that filename is TXT file
52
- return { text: "<pre>#{File.read(filepath)}</pre>", file: :none } if File.exist?(filepath)
53
29
 
54
- { text: :error, file: :none}
30
+ # Suposse that filename is TEXT file
31
+ return { text: "<pre>#{File.read(filepath)}</pre>", file: :none, type: :text }
55
32
  end
56
33
 
57
34
  def self.is_audio?(filename)
@@ -72,5 +49,81 @@ module EmbeddedFile
72
49
  false
73
50
  end
74
51
 
52
+ def self.is_url?(value)
53
+ return true if value.start_with?('https://') || value.start_with?('http://')
54
+ false
55
+ end
56
+
57
+ def self.load_audio(value, localdir)
58
+ output = { text: :error, file: :none, type: :audio}
59
+
60
+ if is_url? value
61
+ output[:text] = "<audio src=\"#{value}\" controls></audio>"
62
+ output[:file] = :none
63
+ output[:type] = :url
64
+ return output
65
+ end
66
+
67
+ filepath = File.join(localdir, value)
68
+ unless File.exist?(filepath)
69
+ Logger.verbose Rainbow("[ERROR] Audio file no exists!: #{filepath}").red.bright
70
+ exit 1
71
+ end
72
+ output[:text] = '<audio controls><source src="@@PLUGINFILE@@/' + File.basename(filepath) \
73
+ + '">Your browser does not support the audio tag.</audio>'
74
+ output[:file] = '<file name="' + File.basename(filepath) \
75
+ + '" path="/" encoding="base64">' \
76
+ + Base64.strict_encode64(File.open(filepath, 'rb').read) + '</file>'
77
+ output[:type] = :audio
78
+ output
79
+ end
80
+
81
+ def self.load_image(value, localdir)
82
+ output = { text: :error, file: :none, type: :image}
83
+
84
+ if is_url? value
85
+ output[:text] = "<img src=\"#{value}\" alt=\"image\" width=\"400\" height=\"300\">"
86
+ output[:file] = :none
87
+ output[:type] = :url
88
+ return output
89
+ end
90
+
91
+ filepath = File.join(localdir, value)
92
+ unless File.exist?(filepath)
93
+ Logger.verbose Rainbow("[ERROR] Unknown file! #{filepath}").red.bright
94
+ exit 1
95
+ end
96
+ output[:text] = '<img src="@@PLUGINFILE@@/' + File.basename(filepath) \
97
+ + '" alt="imagen" class="img-responsive atto_image_button_text-bottom">'
98
+ output[:file] = '<file name="' + File.basename(filepath) \
99
+ + '" path="/" encoding="base64">' \
100
+ + Base64.strict_encode64(File.open(filepath, 'rb').read) + '</file>'
101
+ output[:type] = :image
102
+ output
103
+ end
104
+
105
+ def self.load_video(value, localdir)
106
+ output = { text: :error, file: :none, type: :video}
75
107
 
108
+ if is_url? value
109
+ output[:text] = "<video controls width=\"400\" height=\"300\">" \
110
+ + "<source src=\"#{value}\"/></video>"
111
+ output[:file] = :none
112
+ output[:type] = :url
113
+ return output
114
+ end
115
+
116
+ filepath = File.join(localdir, value)
117
+ unless File.exist?(filepath)
118
+ Logger.verbose Rainbow("[ERROR] Unknown file! #{filepath}").red.bright
119
+ exit 1
120
+ end
121
+ output[:text] = '<video controls><source src="@@PLUGINFILE@@/' + File.basename(filepath) \
122
+ + '"/>Your browser does not support the video tag.</video>'
123
+ output[:file] = '<file name="' + File.basename(filepath) \
124
+ + '" path="/" encoding="base64">' \
125
+ + Base64.strict_encode64(File.open(filepath, 'rb').read) + '</file>'
126
+ output[:type] = :video
127
+ output
128
+ end
76
129
  end
data/lib/asker/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  class Asker
3
- VERSION = '2.5.0'
3
+ VERSION = '2.5.1'
4
4
  NAME = 'asker'
5
5
  GEM = 'asker-tool'
6
6
  CONFIGFILE = 'asker.ini'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asker-tool
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Vargas Ruiz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-07 00:00:00.000000000 Z
11
+ date: 2022-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: haml