lessons_indexer 1.0.2.1 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lessons_indexer.gemspec +1 -0
- data/lib/lessons_indexer/course.rb +3 -3
- data/lib/lessons_indexer/indexer.rb +5 -5
- data/lib/lessons_indexer/messages/messages.yml +33 -0
- data/lib/lessons_indexer/options.rb +10 -10
- data/lib/lessons_indexer/starter.rb +2 -2
- data/lib/lessons_indexer/version.rb +1 -1
- data/lib/lessons_indexer.rb +11 -4
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cf9dd26d4596d4b4fe904c7e1cfa6989a89de64
|
4
|
+
data.tar.gz: b6e93014db8823c91920027df9a5c2884554a3ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98cffc5c91e39187dfc5cde41e3a18b76d4709d8a69d781f0e058082a4fa8de141f47a00256b1641d9fdbfe6b02b11f18937e8c2a4664e71dec6cdaa9c802785
|
7
|
+
data.tar.gz: 4407bfebba3ec618c353d92db5c817e03313d6fe22b09e964a8cc3f79223eed71725e7ba52b67e2b6d4cb5a1e6388a777dd420c5d38b8a0bc0c5fdaf08ca6615
|
data/README.md
CHANGED
@@ -7,6 +7,8 @@
|
|
7
7
|
|
8
8
|
Builds an index in Markdown format for the lesson files in the provided directory, adds heading images to the files, generates PDFs from Markdown, pushes changes to GitHub. Can work with multiple branches.
|
9
9
|
|
10
|
+
Relies on [messages_dictionary](https://github.com/bodrovis-learning/messages_dictionary) to store messages.
|
11
|
+
|
10
12
|
## Installation and Usage
|
11
13
|
|
12
14
|
Requires [Ruby](https://www.ruby-lang.org) 2.0+ and [RubyGems](https://rubygems.org/). `Ruby\bin` should be added
|
data/lessons_indexer.gemspec
CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.add_dependency "slop", "~> 4.2"
|
21
21
|
spec.add_dependency "facets", "~> 3.0"
|
22
22
|
spec.add_dependency "colorize", "~> 0.7.7"
|
23
|
+
spec.add_dependency "messages_dictionary", "~> 0.1.0"
|
23
24
|
|
24
25
|
spec.add_development_dependency "rake", "~> 11.1"
|
25
26
|
spec.add_development_dependency "rspec", "~> 3.4"
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module LessonsIndexer
|
2
|
-
class Course
|
2
|
+
class Course < Messenger
|
3
3
|
include Models
|
4
4
|
include Collections
|
5
5
|
|
@@ -13,7 +13,7 @@ module LessonsIndexer
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def generate_index
|
16
|
-
lessons.list.sort.inject(
|
16
|
+
lessons.list.sort.inject(pou('course.index_title', title: title)) do |memo, lesson|
|
17
17
|
memo + lesson.link(dir)
|
18
18
|
end
|
19
19
|
end
|
@@ -24,7 +24,7 @@ module LessonsIndexer
|
|
24
24
|
if lesson_heading
|
25
25
|
yield "![](#{headings_dir}/#{lesson_heading.file_name})\n\n", lesson.path
|
26
26
|
else
|
27
|
-
warning
|
27
|
+
warning pou('warnings.heading_not_found', lesson: lesson.name)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module LessonsIndexer
|
2
|
-
class Indexer
|
2
|
+
class Indexer < Messenger
|
3
3
|
include Addons::FileManager
|
4
4
|
include Addons::GitManager
|
5
5
|
|
@@ -20,7 +20,7 @@ module LessonsIndexer
|
|
20
20
|
|
21
21
|
def build_index(course)
|
22
22
|
course.load_lessons!
|
23
|
-
with_messages(
|
23
|
+
with_messages(pou('index.starting'), pou('index.done', title: course.title)) do
|
24
24
|
write! course.generate_index, options.output
|
25
25
|
end
|
26
26
|
end
|
@@ -28,21 +28,21 @@ module LessonsIndexer
|
|
28
28
|
def add_headings(course)
|
29
29
|
course.load_lessons!
|
30
30
|
course.load_headings!
|
31
|
-
with_messages(
|
31
|
+
with_messages(pou('heading.starting'), pou('heading.done', title: course.title)) do
|
32
32
|
course.generate_headings { |heading_line, lesson_file| prepend!(heading_line, lesson_file) }
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
def generate_pdfs(course)
|
37
37
|
course.load_lessons!
|
38
|
-
with_messages(
|
38
|
+
with_messages(pou('pdf.starting'), pou('pdf.done', title: course.title)) do
|
39
39
|
course.generate_pdfs
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
def get_course_dir
|
44
44
|
dir = Dir.entries('.').detect {|el| el =~ /_handouts\z/i}
|
45
|
-
exit_msg(
|
45
|
+
exit_msg(pou('errors.files_not_found')) if dir.nil?
|
46
46
|
dir
|
47
47
|
end
|
48
48
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
starter:
|
2
|
+
welcome: "=== [ Welcome to Lessons Indexer ver{{version}}! ] ==="
|
3
|
+
done: "=== [ DONE. ] ==="
|
4
|
+
index:
|
5
|
+
starting: "Starting to build index..."
|
6
|
+
done: "Index for the {{title}} course is generated!"
|
7
|
+
course:
|
8
|
+
index_title: "# Index for the {{title}} course\n\n"
|
9
|
+
heading:
|
10
|
+
starting: "Starting to add headings..."
|
11
|
+
done: "Headings for the lesson files of {{title}} course were added!"
|
12
|
+
pdf:
|
13
|
+
starting: "Starting to generate PDFs..."
|
14
|
+
done: "PDFs for the course {{title}} were generated!"
|
15
|
+
warnings:
|
16
|
+
heading_not_found: "I was not able to find heading image for the {{lesson}}"
|
17
|
+
errors:
|
18
|
+
files_not_found: "Lesson files were not found inside the provided directory. Aborting..."
|
19
|
+
options:
|
20
|
+
default:
|
21
|
+
path: '.'
|
22
|
+
output: 'README.md'
|
23
|
+
message: 'Added index'
|
24
|
+
headings_dir: 'headings'
|
25
|
+
path: 'Path to the directory with the course'
|
26
|
+
skip_index: 'Skip index generation for the course'
|
27
|
+
output: 'Output file'
|
28
|
+
git: 'Push changes to the remote Git branch?'
|
29
|
+
message: 'Commit message'
|
30
|
+
all: 'Work with all branches (except for master)'
|
31
|
+
headings: 'Add heading images to the beginning of the lesson files?'
|
32
|
+
headings_dir: 'Relative path to the directory with heading images'
|
33
|
+
pdf: 'Should PDFs be generated?'
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module LessonsIndexer
|
2
|
-
class Options
|
2
|
+
class Options < Messenger
|
3
3
|
def initialize(argv)
|
4
4
|
parse_args(argv).each do |k, v|
|
5
5
|
# attr_accessor for each possible option
|
@@ -17,15 +17,15 @@ module LessonsIndexer
|
|
17
17
|
def parse_args(argv)
|
18
18
|
begin
|
19
19
|
Slop.parse argv do |o|
|
20
|
-
o.string '-p', '--path', '
|
21
|
-
o.bool '-s', '--skip_index', '
|
22
|
-
o.string '-o', '--output', '
|
23
|
-
o.bool '-g', '--git', '
|
24
|
-
o.string '-m', '--message', '
|
25
|
-
o.bool '-a', '--all', '
|
26
|
-
o.bool '-i', '--headings', '
|
27
|
-
o.string '-d', '--headings_dir', '
|
28
|
-
o.bool '-f', '--pdf', '
|
20
|
+
o.string '-p', '--path', pou('options.path'), default: pou('options.default.path')
|
21
|
+
o.bool '-s', '--skip_index', pou('options.skip_index'), default: false
|
22
|
+
o.string '-o', '--output', pou('options.output'), default: pou('options.default.output')
|
23
|
+
o.bool '-g', '--git', pou('options.git'), default: false
|
24
|
+
o.string '-m', '--message', pou('options.message'), default: pou('options.default.message')
|
25
|
+
o.bool '-a', '--all', pou('options.all'), default: false
|
26
|
+
o.bool '-i', '--headings', pou('options.headings'), default: false
|
27
|
+
o.string '-d', '--headings_dir', pou('options.headings_dir'), default: pou('options.default.headings_dir')
|
28
|
+
o.bool '-f', '--pdf', pou('options.pdf'), default: false
|
29
29
|
o.on '--help' do
|
30
30
|
puts o
|
31
31
|
exit
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module LessonsIndexer
|
2
|
-
class Starter
|
2
|
+
class Starter < Messenger
|
3
3
|
attr_reader :options
|
4
4
|
|
5
5
|
def initialize(argv)
|
@@ -7,7 +7,7 @@ module LessonsIndexer
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def start!
|
10
|
-
with_messages(
|
10
|
+
with_messages(pou('starter.welcome', version: LessonsIndexer::VERSION), pou('starter.done'), false) do
|
11
11
|
indexer = Indexer.new(options)
|
12
12
|
|
13
13
|
within options.path do
|
data/lib/lessons_indexer.rb
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
require 'facets/string/titlecase'
|
2
2
|
require 'slop'
|
3
3
|
require 'colorize'
|
4
|
+
require 'messages_dictionary'
|
5
|
+
|
6
|
+
module LessonsIndexer
|
7
|
+
class Messenger
|
8
|
+
include MessagesDictionary
|
9
|
+
has_messages_dictionary file: 'messages.yml',
|
10
|
+
dir: 'lib/lessons_indexer/messages',
|
11
|
+
transform: ->(msg) {msg}
|
12
|
+
end
|
13
|
+
end
|
4
14
|
|
5
15
|
require 'lessons_indexer/addons/file_manager'
|
6
16
|
require 'lessons_indexer/addons/git_manager'
|
@@ -18,7 +28,4 @@ require 'lessons_indexer/version'
|
|
18
28
|
require 'lessons_indexer/options'
|
19
29
|
require 'lessons_indexer/course'
|
20
30
|
require 'lessons_indexer/indexer'
|
21
|
-
require 'lessons_indexer/starter'
|
22
|
-
|
23
|
-
module LessonsIndexer
|
24
|
-
end
|
31
|
+
require 'lessons_indexer/starter'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lessons_indexer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Bodrov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slop
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.7.7
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: messages_dictionary
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.1.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.1.0
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rake
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,6 +150,7 @@ files:
|
|
136
150
|
- lib/lessons_indexer/collections/lessons_list.rb
|
137
151
|
- lib/lessons_indexer/course.rb
|
138
152
|
- lib/lessons_indexer/indexer.rb
|
153
|
+
- lib/lessons_indexer/messages/messages.yml
|
139
154
|
- lib/lessons_indexer/models/base.rb
|
140
155
|
- lib/lessons_indexer/models/heading.rb
|
141
156
|
- lib/lessons_indexer/models/lesson.rb
|
@@ -177,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
177
192
|
version: '0'
|
178
193
|
requirements: []
|
179
194
|
rubyforge_project:
|
180
|
-
rubygems_version: 2.6.
|
195
|
+
rubygems_version: 2.6.3
|
181
196
|
signing_key:
|
182
197
|
specification_version: 4
|
183
198
|
summary: Lessons Indexer for Learnable
|