softcover 1.2.4 → 1.2.5
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.
- checksums.yaml +4 -4
- data/lib/softcover.rb +1 -0
- data/lib/softcover/article_template/latex_styles/softcover.sty +1 -1
- data/lib/softcover/book_template/latex_styles/softcover.sty +1 -1
- data/lib/softcover/cli.rb +8 -0
- data/lib/softcover/commands/exercises.rb +47 -0
- data/lib/softcover/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: beb44ecebc6bebf2be2fa500ee8e5e73b9a47424
|
4
|
+
data.tar.gz: fb8e58a3ad4b45b6c8c39e3c6a264e29759ee7c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1186ee614dfd5ce61245693a7a76d8f3fc9c33d875be143c179ef712d3e4ed9d2817244d99a9d436ab01fb24920b9f61c15f7bdf0b104784747e62729e64f7b4
|
7
|
+
data.tar.gz: d02ace03fce223eb16940cbeb2177bb61a4321496a60ff80ecd9c516195f14ecfbfba4b03e18b4f56e5c878f5f379bb7d98aaadcdacf7442527eead95cb1dab7
|
data/lib/softcover.rb
CHANGED
@@ -33,6 +33,7 @@ require_relative 'softcover/commands/build'
|
|
33
33
|
require_relative 'softcover/commands/check'
|
34
34
|
require_relative 'softcover/commands/deployment'
|
35
35
|
require_relative 'softcover/commands/epub_validator'
|
36
|
+
require_relative 'softcover/commands/exercises'
|
36
37
|
require_relative 'softcover/commands/generator'
|
37
38
|
require_relative 'softcover/commands/opener'
|
38
39
|
require_relative 'softcover/commands/server'
|
data/lib/softcover/cli.rb
CHANGED
@@ -266,6 +266,14 @@ module Softcover
|
|
266
266
|
puts 'Config var removed.'
|
267
267
|
end
|
268
268
|
|
269
|
+
# ===============================================
|
270
|
+
# Utilities
|
271
|
+
# ===============================================
|
272
|
+
desc "add_exercises", "Add exercise id elements as spans (warning: files are overwritten)"
|
273
|
+
define_method "exercises" do
|
274
|
+
Softcover::Commands::Exercises.add_to_chapters!
|
275
|
+
end
|
276
|
+
|
269
277
|
protected
|
270
278
|
def ask_without_echo(*args)
|
271
279
|
system "stty -echo"
|
@@ -0,0 +1,47 @@
|
|
1
|
+
|
2
|
+
module Softcover
|
3
|
+
module Commands
|
4
|
+
module Exercises
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def add_to_chapters!
|
8
|
+
require 'securerandom'
|
9
|
+
|
10
|
+
Dir["chapters/*.tex"].each do |path|
|
11
|
+
|
12
|
+
str = ""
|
13
|
+
|
14
|
+
in_exercise = false
|
15
|
+
n = 0
|
16
|
+
line_number = 0
|
17
|
+
|
18
|
+
lines = []
|
19
|
+
File.read(path).each_line { |line| lines.push line }
|
20
|
+
|
21
|
+
lines.each do |line|
|
22
|
+
str += line
|
23
|
+
|
24
|
+
case line
|
25
|
+
when %r{\\subsubsection{Exercises}}
|
26
|
+
in_exercise = true
|
27
|
+
when %r{\\end{enumerate}}
|
28
|
+
in_exercise = false
|
29
|
+
when %r{\\item}
|
30
|
+
if in_exercise && !(lines[line_number + 1] =~ /^%= <span/)
|
31
|
+
str += "%= <span class='exercise' id='ex-#{SecureRandom.hex(3)}'></span>\n"
|
32
|
+
n += 1
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
line_number += 1
|
37
|
+
end
|
38
|
+
|
39
|
+
File.open(path, "w") { |f| f.write str }
|
40
|
+
|
41
|
+
puts "#{path}: wrote #{n} exercises"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/softcover/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: softcover
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Hartl
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-03-
|
12
|
+
date: 2016-03-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: polytexnic
|
@@ -1579,6 +1579,7 @@ files:
|
|
1579
1579
|
- lib/softcover/commands/check.rb
|
1580
1580
|
- lib/softcover/commands/deployment.rb
|
1581
1581
|
- lib/softcover/commands/epub_validator.rb
|
1582
|
+
- lib/softcover/commands/exercises.rb
|
1582
1583
|
- lib/softcover/commands/generator.rb
|
1583
1584
|
- lib/softcover/commands/opener.rb
|
1584
1585
|
- lib/softcover/commands/publisher.rb
|
@@ -1650,7 +1651,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1650
1651
|
version: '0'
|
1651
1652
|
requirements: []
|
1652
1653
|
rubyforge_project:
|
1653
|
-
rubygems_version: 2.
|
1654
|
+
rubygems_version: 2.2.2
|
1654
1655
|
signing_key:
|
1655
1656
|
specification_version: 4
|
1656
1657
|
summary: An ebook production system & sales and marketing platform for technical authors
|