md_splitter 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,6 @@
1
1
  require 'json'
2
- require 'uuidtools'
2
+ require 'uuidtools'
3
+ require 'active_support/inflector'
3
4
 
4
5
  module MdSplitter
5
6
  class ElfManifestBuilder
@@ -52,7 +53,7 @@ module MdSplitter
52
53
  def get_page_object item
53
54
  {
54
55
  :id => File.basename(item, File.extname(item)),
55
- :name => File.basename(item, File.extname(item)),
56
+ :title => File.basename(item, File.extname(item)).humanize.titleize,
56
57
  :url => File.basename(item)
57
58
  }
58
59
  end
@@ -1,3 +1,3 @@
1
1
  module MdSplitter
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
data/md_splitter.gemspec CHANGED
@@ -31,5 +31,6 @@ Gem::Specification.new do |s|
31
31
  s.add_runtime_dependency "kramdown", "~> 0.13.3"
32
32
  s.add_runtime_dependency "commander", "~> 4.0.6"
33
33
  s.add_runtime_dependency "json", "~> 1.6.1"
34
- s.add_runtime_dependency "uuidtools", "~> 2.1.2"
34
+ s.add_runtime_dependency "uuidtools", "~> 2.1.2"
35
+ s.add_runtime_dependency "active_support", "~> 3.0.0"
35
36
  end
@@ -39,9 +39,9 @@ describe "Build an ELF manifest." do
39
39
  page[:id].should be_a String
40
40
  end
41
41
  end
42
- it "should have a name" do
42
+ it "should have a title" do
43
43
  @result[:pages].each do |page|
44
- page[:name].should be_a String
44
+ page[:title].should be_a String
45
45
  end
46
46
  end
47
47
  it "should have a url" do
@@ -50,12 +50,17 @@ describe "Build an ELF manifest." do
50
50
  end
51
51
  end
52
52
 
53
- it "id's and names should match source item names" do
53
+ it "ids should match source item ids" do
54
54
  get_test_object.each_index do |i|
55
- @result[:pages][i][:id].should eq get_test_object_names[i]
56
- @result[:pages][i][:name].should eq get_test_object_names[i]
55
+ @result[:pages][i][:id].should eq get_test_object_titles[i]
57
56
  end
58
- end
57
+ end
58
+
59
+ it "titles should be humanized and titleized" do
60
+ @result[:pages][0][:title].should eq "Page Number 1"
61
+ @result[:pages][1][:title].should eq "Page Number 2"
62
+ @result[:pages][2][:title].should eq "Page Number 3"
63
+ end
59
64
 
60
65
  it "url should match the source item" do
61
66
  get_test_object.each_index do |i|
@@ -85,15 +90,19 @@ private
85
90
 
86
91
  # Builds test object from which to test manifest
87
92
  def get_test_object
88
- test_obj = ["page1.html", "page2.html", "page3.html"]
93
+ test_obj = ["page_number_1.html", "page_number_2.html", "page_number_3.html"]
89
94
  end
90
95
 
91
- def get_test_object_names
92
- return ['page1', 'page2', 'page3']
96
+ def get_test_object_titles
97
+ return ['page_number_1', 'page_number_2', 'page_number_3']
98
+ end
99
+
100
+ def get_test_object_ids
101
+ return ['page_number_1', 'page_number_2', 'page_number_3']
93
102
  end
94
103
 
95
104
  def get_test_result
96
- "[\"page1.html\",\"page2.html\",\"page3.html\"]"
105
+ "[\"page_number_1.html\",\"page_number_2.html\",\"page_number_3.html\"]"
97
106
  end
98
107
 
99
108
  def sample_elf_template
@@ -110,17 +119,17 @@ def sample_elf_manifest
110
119
  [
111
120
  {
112
121
  "id":"page1",
113
- "name":"Page 1",
122
+ "title":"Page 1",
114
123
  "url":"page1.html"
115
124
  },
116
125
  {
117
126
  "id":"page2",
118
- "name":"Page 2",
127
+ "title":"Page 2",
119
128
  "url":"page2.html"
120
129
  },
121
130
  {
122
131
  "id":"page3",
123
- "name":"Page 3",
132
+ "title":"Page 3",
124
133
  "url":"page3.html"
125
134
  }
126
135
  ]
@@ -28,11 +28,11 @@ describe "Splitter" do
28
28
  end
29
29
 
30
30
  it "should deal with folder hierarchies" do
31
- mock_input_file_read "fake/path/sample.md"
31
+ mock_input_file_read "spec/fake/path/sample.md"
32
32
  # expect call to Kramdown
33
33
  mock_kramdown(sample_markdown.strip).should_receive(:to_html).and_return(simple_html)
34
- mock_output_file_write "fake/path/sample.html"
35
- @subject.split "fake/path/sample.md"
34
+ mock_output_file_write "spec/fake/path/sample.html"
35
+ @subject.split "spec/fake/path/sample.md"
36
36
  end
37
37
  end
38
38
 
@@ -43,35 +43,35 @@ describe "Splitter" do
43
43
  end
44
44
  it "should use the split_on option to split the src into multiple files" do
45
45
  mock_doc_split
46
- @subject.split "fake/path/sample.md", :split_on => "---\n"
46
+ @subject.split "spec/fake/path/sample.md", :split_on => "---\n"
47
47
  end
48
48
 
49
49
  it "should create the folder structure when necessary" do
50
50
  mock_doc_split
51
51
  # when splitting a file, should create the target path if necessary
52
- FileUtils.should_receive(:mkpath).with('fake/path/sample')
53
- @subject.split "fake/path/sample.md", :split_on => "---\n"
52
+ FileUtils.should_receive(:mkpath).with('spec/fake/path/sample')
53
+ @subject.split "spec/fake/path/sample.md", :split_on => "---\n"
54
54
  end
55
55
 
56
56
  # it "should 'say' what we're doing" do
57
57
  # mock_doc_split
58
58
  # STDOUT.should_receive(:puts).with(/Splitting sample.md/).once
59
- # @subject.split "fake/path/sample.md", :split_on => "---\n"
59
+ # @subject.split "spec/fake/path/sample.md", :split_on => "---\n"
60
60
  # end
61
61
  end
62
62
 
63
63
  describe "support a custom output path" do
64
64
  it "for single files" do
65
- mock_input_file_read "fake/path/sample.md"
66
- mock_output_file_write "fake/path/exports/sample.html"
67
- @subject.split "fake/path/sample.md", :output_path => "exports"
65
+ mock_input_file_read "spec/fake/path/sample.md"
66
+ mock_output_file_write "spec/fake/path/exports/sample.html"
67
+ @subject.split "spec/fake/path/sample.md", :output_path => "exports"
68
68
  end
69
69
 
70
70
  it "should use the custom path for split files" do
71
- mock_input_file_read "fake/path/sample.md"
72
- mock_output_file_write "fake/path/exports/sample.html", 3
73
- FileUtils.should_receive(:mkpath).with('fake/path/exports')
74
- @subject.split "fake/path/sample.md", :output_path => "exports", :split_on => "---"
71
+ mock_input_file_read "spec/fake/path/sample.md"
72
+ mock_output_file_write "spec/fake/path/exports/sample.html", 3
73
+ FileUtils.should_receive(:mkpath).with('spec/fake/path/exports')
74
+ @subject.split "spec/fake/path/sample.md", :output_path => "exports", :split_on => "---"
75
75
  end
76
76
  end
77
77
 
@@ -82,20 +82,20 @@ describe "Splitter" do
82
82
  it "should not perform any file actions" do
83
83
  make_safe_file_stubs
84
84
  File.should_not_receive(:open)
85
- @subject.split "fake/path/sample.md", :split_on => "---\n", :dry_run => true
85
+ @subject.split "spec/fake/path/sample.md", :split_on => "---\n", :dry_run => true
86
86
  end
87
87
  it "should say when we're in dry_run mode" do
88
88
  make_safe_file_stubs
89
89
  STDOUT.should_receive(:puts).with(/^Dry Run/i).at_least(:once)
90
- @subject.split "fake/path/sample.md", :split_on => "---\n", :dry_run => true
90
+ @subject.split "spec/fake/path/sample.md", :split_on => "---\n", :dry_run => true
91
91
  end
92
92
  end
93
93
 
94
94
  describe "create a manifest if requested" do
95
95
  before(:each) do
96
- mock_input_file_read "fake/path/sample.md"
97
- mock_output_file_write "fake/path/sample/sample.html", 3
98
- mock_output_file_write "fake/path/sample/manifest.json"
96
+ mock_input_file_read "spec/fake/path/sample.md"
97
+ mock_output_file_write "spec/fake/path/sample/sample.html", 3
98
+ mock_output_file_write "spec/fake/path/sample/manifest.json"
99
99
  @duff_builder = double()
100
100
  @duff_builder.stub(:json)
101
101
  @subject = MdSplitter::Splitter.new
@@ -103,12 +103,12 @@ describe "Splitter" do
103
103
 
104
104
  it "should create a manifest builder" do
105
105
  MdSplitter::ElfManifestBuilder.should_receive(:new).and_return(@duff_builder)
106
- @subject.split "fake/path/sample.md", :split_on => "---", :manifest => true
106
+ @subject.split "spec/fake/path/sample.md", :split_on => "---", :manifest => true
107
107
  end
108
108
 
109
109
  it "should pass a list of pages to the manifest builder" do
110
110
  MdSplitter::ElfManifestBuilder.should_receive(:new).with(["sample_1.html", "sample_2.html", "sample_3.html"]).and_return(@duff_builder)
111
- @subject.split "fake/path/sample.md", :split_on => "---", :manifest => true
111
+ @subject.split "spec/fake/path/sample.md", :split_on => "---", :manifest => true
112
112
  end
113
113
 
114
114
  describe "saving the manifest" do
@@ -118,9 +118,9 @@ describe "Splitter" do
118
118
  it "should request the json manifest and save it to the target directory" do
119
119
  @duff_builder.should_receive(:json).and_return(sample_elf_manifest)
120
120
  STDOUT.should_receive(:puts).with(/Splitting/i).at_least(:once)
121
- STDOUT.should_receive(:puts).with(/Writing fake\/path/i).at_least(:once)
121
+ STDOUT.should_receive(:puts).with(/Writing spec\/fake\/path/i).at_least(:once)
122
122
  STDOUT.should_receive(:puts).with(/Writing manifest/i).at_least(:once)
123
- @subject.split "fake/path/sample.md", :split_on => "---", :manifest => true
123
+ @subject.split "spec/fake/path/sample.md", :split_on => "---", :manifest => true
124
124
  end
125
125
  end
126
126
 
@@ -136,11 +136,11 @@ def make_safe_file_stubs
136
136
  end
137
137
 
138
138
  def mock_doc_split
139
- mock_input_file_read "fake/path/sample.md"
139
+ mock_input_file_read "spec/fake/path/sample.md"
140
140
  FileUtils.stub(:mkpath)
141
- mock_output_file_write "fake/path/sample/sample.html", 3
142
- # mock_output_file_write "fake/path/sample/sample_2.html"
143
- # mock_output_file_write "fake/path/sample/sample_3.html"
141
+ mock_output_file_write "spec/fake/path/sample/sample.html", 3
142
+ # mock_output_file_write "spec/fake/path/sample/sample_2.html"
143
+ # mock_output_file_write "spec/fake/path/sample/sample_3.html"
144
144
  # set expectations for the three calls to kramdown resulting from the split
145
145
  mock_kramdown('# Heading 1').should_receive(:to_html).and_return('<h1>Heading 1</h1>')
146
146
  mock_kramdown('## Heading 2').should_receive(:to_html).and_return('<h2>Heading 2</h2>')
@@ -198,17 +198,17 @@ def sample_elf_manifest
198
198
  [
199
199
  {
200
200
  "id":"page1",
201
- "name":"Page 1",
201
+ "title":"Page 1",
202
202
  "url":"page1.html"
203
203
  },
204
204
  {
205
205
  "id":"page2",
206
- "name":"Page 2",
206
+ "title":"Page 2",
207
207
  "url":"page2.html"
208
208
  },
209
209
  {
210
210
  "id":"page3",
211
- "name":"Page 3",
211
+ "title":"Page 3",
212
212
  "url":"page3.html"
213
213
  }
214
214
  ]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: md_splitter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-01 00:00:00.000000000Z
12
+ date: 2011-11-02 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70258434727600 !ruby/object:Gem::Requirement
16
+ requirement: &70125038532020 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.9.2
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70258434727600
24
+ version_requirements: *70125038532020
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &70258434726980 !ruby/object:Gem::Requirement
27
+ requirement: &70125038530500 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.0.21
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70258434726980
35
+ version_requirements: *70125038530500
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70258434726320 !ruby/object:Gem::Requirement
38
+ requirement: &70125038529220 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.7.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70258434726320
46
+ version_requirements: *70125038529220
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: guard-rspec
49
- requirement: &70258434725660 !ruby/object:Gem::Requirement
49
+ requirement: &70125038528100 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70258434725660
57
+ version_requirements: *70125038528100
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: growl
60
- requirement: &70258434724980 !ruby/object:Gem::Requirement
60
+ requirement: &70125038526420 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70258434724980
68
+ version_requirements: *70125038526420
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rb-fsevent
71
- requirement: &70258434724360 !ruby/object:Gem::Requirement
71
+ requirement: &70125038523000 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70258434724360
79
+ version_requirements: *70125038523000
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: kramdown
82
- requirement: &70258434715260 !ruby/object:Gem::Requirement
82
+ requirement: &70125038521720 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 0.13.3
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *70258434715260
90
+ version_requirements: *70125038521720
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: commander
93
- requirement: &70258434714320 !ruby/object:Gem::Requirement
93
+ requirement: &70125038519700 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 4.0.6
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *70258434714320
101
+ version_requirements: *70125038519700
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: json
104
- requirement: &70258434713360 !ruby/object:Gem::Requirement
104
+ requirement: &70125038517480 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: 1.6.1
110
110
  type: :runtime
111
111
  prerelease: false
112
- version_requirements: *70258434713360
112
+ version_requirements: *70125038517480
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: uuidtools
115
- requirement: &70258434712620 !ruby/object:Gem::Requirement
115
+ requirement: &70125038514480 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ~>
@@ -120,7 +120,18 @@ dependencies:
120
120
  version: 2.1.2
121
121
  type: :runtime
122
122
  prerelease: false
123
- version_requirements: *70258434712620
123
+ version_requirements: *70125038514480
124
+ - !ruby/object:Gem::Dependency
125
+ name: active_support
126
+ requirement: &70125038513180 !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ version: 3.0.0
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: *70125038513180
124
135
  description: Parses md docs for split markers and produces multiple html files and
125
136
  a json manifest
126
137
  email:
@@ -162,7 +173,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
162
173
  version: '0'
163
174
  segments:
164
175
  - 0
165
- hash: 2115208680507769727
176
+ hash: 864076252232225175
166
177
  required_rubygems_version: !ruby/object:Gem::Requirement
167
178
  none: false
168
179
  requirements:
@@ -171,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
182
  version: '0'
172
183
  segments:
173
184
  - 0
174
- hash: 2115208680507769727
185
+ hash: 864076252232225175
175
186
  requirements: []
176
187
  rubyforge_project: md_splitter
177
188
  rubygems_version: 1.8.10