lessons_indexer 0.0.2.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,28 @@
1
+ RSpec.describe LessonsIndexer::Models::Heading do
2
+ let(:name) {'lesson1.2.jpg'}
3
+ subject {described_class.new(name)}
4
+
5
+ specify "#file_name" do
6
+ expect(subject.file_name).to eq(name)
7
+ end
8
+
9
+ specify "#path" do
10
+ expect(subject.path).to eq(File.expand_path(name))
11
+ end
12
+
13
+ specify "#major" do
14
+ expect(subject.major).to eq(1)
15
+ end
16
+
17
+ specify "#minor" do
18
+ expect(subject.minor).to eq(2)
19
+ end
20
+
21
+ context "comparable" do
22
+ let(:other_heading) {described_class.new('lesson2.5.jpg')}
23
+
24
+ it "should be comparable" do
25
+ expect(subject < other_heading).to be_truthy
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,36 @@
1
+ RSpec.describe LessonsIndexer::Models::Lesson do
2
+ let(:name) {'lesson1.2.md'}
3
+ subject {described_class.new(name)}
4
+
5
+ specify "#file_name" do
6
+ expect(subject.file_name).to eq(name)
7
+ end
8
+
9
+ specify "#path" do
10
+ expect(subject.path).to eq(File.expand_path(name))
11
+ end
12
+
13
+ specify "#major" do
14
+ expect(subject.major).to eq(1)
15
+ end
16
+
17
+ specify "#minor" do
18
+ expect(subject.minor).to eq(2)
19
+ end
20
+
21
+ specify "#name" do
22
+ expect(subject.name).to eq('Lesson 1.2')
23
+ end
24
+
25
+ specify "#link" do
26
+ expect(subject.link('dir')).to eq("* [Lesson 1.2](dir/#{name})\n")
27
+ end
28
+
29
+ context "comparable" do
30
+ let(:other_lesson) {described_class.new('lesson1.1.md')}
31
+
32
+ it "should be comparable" do
33
+ expect(subject > other_lesson).to be_truthy
34
+ end
35
+ end
36
+ end
@@ -1,28 +1,24 @@
1
- module LessonsIndexer
2
- RSpec.describe Options do
3
- let(:argv) { Array.new }
4
-
5
- it "should assign default options if no arguments are given" do
6
- options = Options.new(argv)
7
- expect(options.path).to eq('.')
8
- expect(options.skip_index).to be_falsey
9
- expect(options.output).to eq('README.md')
10
- expect(options.git).to be_falsey
11
- expect(options.message).to eq('Added index')
12
- expect(options.all).to be_falsey
13
- expect(options.headings).to be_falsey
14
- expect(options.headings_dir).to eq('headers')
15
- end
1
+ RSpec.describe LessonsIndexer::Options do
2
+ it "should assign default options if no arguments are given" do
3
+ options = described_class.new([])
4
+ expect(options.path).to eq('.')
5
+ expect(options.skip_index).to be_falsey
6
+ expect(options.output).to eq('README.md')
7
+ expect(options.git).to be_falsey
8
+ expect(options.message).to eq('Added index')
9
+ expect(options.all).to be_falsey
10
+ expect(options.headings).to be_falsey
11
+ expect(options.headings_dir).to eq('headings')
12
+ end
16
13
 
17
- it "should allow to override some options" do
18
- argv = ['-p', 'test_path', '-g', '-o', 'test.md']
19
- options = Options.new(argv)
20
- expect(options.path).to eq('test_path')
21
- expect(options.output).to eq('test.md')
22
- expect(options.git).to be_truthy
23
- expect(options.message).to eq('Added index')
24
- expect(options.all).to be_falsey
25
- expect(options.headings).to be_falsey
26
- end
14
+ it "should allow to override some options" do
15
+ argv = ['-p', 'test_path', '-g', '-o', 'test.md']
16
+ options = described_class.new(argv)
17
+ expect(options.path).to eq('test_path')
18
+ expect(options.output).to eq('test.md')
19
+ expect(options.git).to be_truthy
20
+ expect(options.message).to eq('Added index')
21
+ expect(options.all).to be_falsey
22
+ expect(options.headings).to be_falsey
27
23
  end
28
24
  end
@@ -8,4 +8,6 @@ require 'lessons_indexer'
8
8
 
9
9
  RSpec.configure do |config|
10
10
  config.include SpecUtils
11
+ config.include SpecSamples
12
+ config.include SpecFilesSetup
11
13
  end
@@ -0,0 +1,9 @@
1
+ RSpec.describe LessonsIndexer::Starter do
2
+ subject { described_class.new([]) }
3
+
4
+ specify { expect(subject.options).to be_a LessonsIndexer::Options }
5
+
6
+ context "#start!" do
7
+ it {is_expected.to respond_to(:start!)}
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ require 'fileutils'
2
+
3
+ module SpecFilesSetup
4
+ def setup_env!
5
+ FileUtils.mkdir_p('my_course_handouts/headings')
6
+ lessons_array_with_incorrect.each do |file|
7
+ File.new("my_course_handouts/#{file}", 'w+').close
8
+ end
9
+
10
+ headings_array_with_incorrect.each do |file|
11
+ File.new("my_course_handouts/headings/#{file}", 'w+').close
12
+ end
13
+ end
14
+
15
+ def clear_env!
16
+ FileUtils.remove_entry('my_course_handouts')
17
+ FileUtils.remove_entry('test.md', true)
18
+ end
19
+ end
@@ -0,0 +1,38 @@
1
+ module SpecSamples
2
+ def sample_lessons(additional = false)
3
+ arr = (additional ? lessons_array_additional : lessons_array)
4
+ LessonsIndexer::Collections::LessonsList.new(arr.map do |name|
5
+ LessonsIndexer::Models::Lesson.new(name)
6
+ end)
7
+ end
8
+
9
+ def sample_headings
10
+ LessonsIndexer::Collections::HeadingsList.new(headings_array.map do |name|
11
+ LessonsIndexer::Models::Heading.new(name)
12
+ end)
13
+ end
14
+
15
+ def lessons_array
16
+ %w(lesson2.5.md lesson10.2.md lesson1.3.md lesson5.8.md)
17
+ end
18
+
19
+ def lessons_array_additional
20
+ lessons_array.insert(2, 'lesson6.3.md')
21
+ end
22
+
23
+ def lessons_array_with_incorrect
24
+ lessons_array.insert(2, 'test.txt')
25
+ end
26
+
27
+ def headings_array
28
+ %w(lesson2.5.jpg lesson10.2.jpg lesson1.3.jpg lesson5.8.jpg)
29
+ end
30
+
31
+ def headings_array_with_incorrect
32
+ headings_array.insert(2, 'test2.png')
33
+ end
34
+
35
+ def sample_options
36
+ ['-o', 'test.md']
37
+ end
38
+ end
@@ -20,4 +20,15 @@ module SpecUtils
20
20
  end
21
21
  fake.string
22
22
  end
23
+
24
+ def capture_stdin(&block)
25
+ original_stdin = $stdin
26
+ $stdin = fake = StringIO.new
27
+ begin
28
+ yield
29
+ ensure
30
+ $stdin = original_stdin
31
+ end
32
+ fake.string
33
+ end
23
34
  end
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: 0.0.2.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Bodrov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-13 00:00:00.000000000 Z
11
+ date: 2015-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slop
@@ -56,58 +56,44 @@ dependencies:
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '10.4'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '10.4'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: pry
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
73
+ - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: '0'
75
+ version: '3.2'
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
- - - ">="
80
+ - - "~>"
95
81
  - !ruby/object:Gem::Version
96
- version: '0'
82
+ version: '3.2'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: codeclimate-test-reporter
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
- - - ">="
87
+ - - "~>"
102
88
  - !ruby/object:Gem::Version
103
- version: '0'
89
+ version: '0.4'
104
90
  type: :development
105
91
  prerelease: false
106
92
  version_requirements: !ruby/object:Gem::Requirement
107
93
  requirements:
108
- - - ">="
94
+ - - "~>"
109
95
  - !ruby/object:Gem::Version
110
- version: '0'
96
+ version: '0.4'
111
97
  description: Lessons Indexer for Learnable
112
98
  email:
113
99
  - golosizpru@gmail.com
@@ -130,15 +116,31 @@ files:
130
116
  - lib/lessons_indexer/addons/file_manager.rb
131
117
  - lib/lessons_indexer/addons/git_manager.rb
132
118
  - lib/lessons_indexer/addons/utils.rb
119
+ - lib/lessons_indexer/collections/base.rb
120
+ - lib/lessons_indexer/collections/headings_list.rb
121
+ - lib/lessons_indexer/collections/lessons_list.rb
133
122
  - lib/lessons_indexer/course.rb
134
123
  - lib/lessons_indexer/indexer.rb
124
+ - lib/lessons_indexer/models/base.rb
125
+ - lib/lessons_indexer/models/heading.rb
126
+ - lib/lessons_indexer/models/lesson.rb
135
127
  - lib/lessons_indexer/options.rb
136
128
  - lib/lessons_indexer/starter.rb
137
129
  - lib/lessons_indexer/version.rb
138
130
  - spec/addons/file_manager_spec.rb
131
+ - spec/addons/git_manager_spec.rb
139
132
  - spec/addons/utils_spec.rb
133
+ - spec/collections/headings_list_spec.rb
134
+ - spec/collections/lessons_list_spec.rb
135
+ - spec/course_spec.rb
136
+ - spec/indexer_spec.rb
137
+ - spec/models/heading_spec.rb
138
+ - spec/models/lesson_spec.rb
140
139
  - spec/options_spec.rb
141
140
  - spec/spec_helper.rb
141
+ - spec/starter_spec.rb
142
+ - spec/support/spec_files_setup.rb
143
+ - spec/support/spec_samples.rb
142
144
  - spec/support/spec_utils.rb
143
145
  homepage: https://github.com/bodrovis/lessons_indexer
144
146
  licenses:
@@ -166,7 +168,18 @@ specification_version: 4
166
168
  summary: Lessons Indexer for Learnable
167
169
  test_files:
168
170
  - spec/addons/file_manager_spec.rb
171
+ - spec/addons/git_manager_spec.rb
169
172
  - spec/addons/utils_spec.rb
173
+ - spec/collections/headings_list_spec.rb
174
+ - spec/collections/lessons_list_spec.rb
175
+ - spec/course_spec.rb
176
+ - spec/indexer_spec.rb
177
+ - spec/models/heading_spec.rb
178
+ - spec/models/lesson_spec.rb
170
179
  - spec/options_spec.rb
171
180
  - spec/spec_helper.rb
181
+ - spec/starter_spec.rb
182
+ - spec/support/spec_files_setup.rb
183
+ - spec/support/spec_samples.rb
172
184
  - spec/support/spec_utils.rb
185
+ has_rdoc: