bookbindery 1.0.3 → 2.0.0

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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/{bin → install_bin}/bookbinder +0 -0
  3. data/lib/bookbinder.rb +2 -9
  4. data/lib/bookbinder/archive.rb +1 -1
  5. data/lib/bookbinder/archive_menu_configuration.rb +34 -0
  6. data/lib/bookbinder/book.rb +17 -17
  7. data/lib/bookbinder/cli.rb +25 -36
  8. data/lib/bookbinder/code_example.rb +5 -38
  9. data/lib/bookbinder/code_example_reader.rb +40 -0
  10. data/lib/bookbinder/colorizer.rb +14 -0
  11. data/lib/bookbinder/command_runner.rb +9 -16
  12. data/lib/bookbinder/command_validator.rb +14 -7
  13. data/lib/bookbinder/commands/bind.rb +321 -0
  14. data/lib/bookbinder/commands/build_and_push_tarball.rb +7 -6
  15. data/lib/bookbinder/commands/chain.rb +11 -0
  16. data/lib/bookbinder/commands/generate_pdf.rb +4 -3
  17. data/lib/bookbinder/commands/help.rb +49 -10
  18. data/lib/bookbinder/commands/naming.rb +9 -1
  19. data/lib/bookbinder/commands/push_local_to_staging.rb +4 -3
  20. data/lib/bookbinder/commands/push_to_prod.rb +36 -4
  21. data/lib/bookbinder/commands/run_publish_ci.rb +21 -24
  22. data/lib/bookbinder/commands/tag.rb +3 -3
  23. data/lib/bookbinder/commands/update_local_doc_repos.rb +5 -4
  24. data/lib/bookbinder/commands/version.rb +11 -8
  25. data/lib/bookbinder/configuration.rb +8 -3
  26. data/lib/bookbinder/configuration_fetcher.rb +7 -25
  27. data/lib/bookbinder/configuration_validator.rb +21 -0
  28. data/lib/bookbinder/distributor.rb +1 -1
  29. data/lib/bookbinder/dita_html_to_middleman_formatter.rb +37 -0
  30. data/lib/bookbinder/dita_section.rb +7 -0
  31. data/lib/bookbinder/dita_section_gatherer.rb +28 -0
  32. data/lib/bookbinder/git_accessor.rb +17 -0
  33. data/lib/bookbinder/git_client.rb +10 -7
  34. data/lib/bookbinder/git_hub_repository.rb +46 -41
  35. data/lib/bookbinder/local_dita_preprocessor.rb +27 -0
  36. data/lib/bookbinder/local_dita_to_html_converter.rb +49 -0
  37. data/lib/bookbinder/local_file_system_accessor.rb +68 -0
  38. data/lib/bookbinder/middleman_runner.rb +30 -17
  39. data/lib/bookbinder/publisher.rb +16 -80
  40. data/lib/bookbinder/remote_yaml_credential_provider.rb +2 -3
  41. data/lib/bookbinder/repositories/command_repository.rb +156 -0
  42. data/lib/bookbinder/repositories/section_repository.rb +31 -0
  43. data/lib/bookbinder/section.rb +5 -67
  44. data/lib/bookbinder/shell_out.rb +1 -0
  45. data/lib/bookbinder/sheller.rb +19 -0
  46. data/lib/bookbinder/sieve.rb +6 -1
  47. data/lib/bookbinder/terminal.rb +10 -0
  48. data/lib/bookbinder/user_message.rb +6 -0
  49. data/lib/bookbinder/user_message_presenter.rb +21 -0
  50. data/lib/bookbinder/yaml_loader.rb +18 -7
  51. data/master_middleman/archive_drop_down_menu.rb +46 -0
  52. data/master_middleman/bookbinder_helpers.rb +47 -40
  53. metadata +33 -87
  54. data/lib/bookbinder/commands/publish.rb +0 -138
  55. data/lib/bookbinder/usage_messenger.rb +0 -33
@@ -4,6 +4,7 @@ module Bookbinder
4
4
  module ShellOut
5
5
  def shell_out(command, failure_okay = false)
6
6
  Open3.popen3(command) do |input, stdout, stderr, wait_thr|
7
+
7
8
  command_failed = (wait_thr.value != 0)
8
9
  announce_failure(failure_okay, stderr, stdout) if command_failed
9
10
  stdout.read
@@ -0,0 +1,19 @@
1
+ module Bookbinder
2
+ class Sheller
3
+ ShelloutFailure = Class.new(RuntimeError)
4
+
5
+ def initialize(view_updater)
6
+ @view_updater = view_updater
7
+ end
8
+
9
+ def run_command(command)
10
+ IO.popen(command) do |stdout|
11
+ stdout.each { |line| view_updater.log line }
12
+ end
13
+
14
+ raise ShelloutFailure.new "Shelling out failed." unless $?.success?
15
+ end
16
+
17
+ attr_reader :view_updater
18
+ end
19
+ end
@@ -1,3 +1,5 @@
1
+ require_relative 'spider'
2
+
1
3
  module Bookbinder
2
4
  class Sieve
3
5
  def initialize(domain: ->(){ raise 'You must supply a domain parameter.' }.call)
@@ -6,9 +8,12 @@ module Bookbinder
6
8
  end
7
9
 
8
10
  def links_from(page, is_first_pass)
9
- if page.not_found?
11
+ if page.not_found? && page.referer
10
12
  working = []
11
13
  broken = [Spider.prepend_location(page.referer, page.url)]
14
+ elsif page.not_found?
15
+ working = []
16
+ broken = []
12
17
  else
13
18
  working = [page.url.to_s]
14
19
  broken = broken_fragments_targeting(page, is_first_pass)
@@ -0,0 +1,10 @@
1
+ require_relative 'command_validator'
2
+ require_relative 'colorizer'
3
+
4
+ module Bookbinder
5
+ class Terminal
6
+ def update(user_message)
7
+ puts user_message
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,6 @@
1
+ module Bookbinder
2
+
3
+ UserMessage = Struct.new(:message, :escalation_type)
4
+ EscalationType = OpenStruct.new(success: 0, error: 1, warn: 2)
5
+
6
+ end
@@ -0,0 +1,21 @@
1
+ require_relative 'colorizer'
2
+
3
+ module Bookbinder
4
+ class UserMessagePresenter
5
+ def initialize(colorizer)
6
+ @colorizer = colorizer
7
+ end
8
+
9
+ def get_error(user_message)
10
+ colorizer.colorize(user_message.message, Colorizer::Colors.red)
11
+ end
12
+
13
+ def get_warning(user_message)
14
+ colorizer.colorize(user_message.message, Colorizer::Colors.yellow)
15
+ end
16
+
17
+ private
18
+
19
+ attr_reader :colorizer
20
+ end
21
+ end
@@ -1,22 +1,33 @@
1
- module Bookbinder
1
+ require 'yaml'
2
2
 
3
+ module Bookbinder
3
4
  FileNotFoundError = Class.new(RuntimeError)
4
5
  InvalidSyntaxError = Class.new(RuntimeError)
5
6
 
6
7
  class YAMLLoader
7
8
  def load(path)
8
- unless File.exist? path
9
+ if File.exist?(path)
10
+ config(path)
11
+ else
9
12
  raise FileNotFoundError.new, "YAML"
10
13
  end
14
+ rescue Psych::SyntaxError => e
15
+ raise InvalidSyntaxError.new e
16
+ end
11
17
 
12
- begin
13
- YAML.load_file(path)
14
- rescue Psych::SyntaxError => e
15
- raise InvalidSyntaxError.new e
18
+ def load_key(path, key)
19
+ if File.exist?(path)
20
+ config(path)[key]
16
21
  end
22
+ rescue Psych::SyntaxError => e
23
+ raise InvalidSyntaxError.new e
24
+ end
25
+
26
+ private
17
27
 
28
+ def config(path)
29
+ YAML.load_file(path) || {}
18
30
  end
19
31
  end
20
-
21
32
  end
22
33
 
@@ -0,0 +1,46 @@
1
+ module Bookbinder
2
+ class ArchiveDropDownMenu
3
+ def initialize(config, current_path: nil)
4
+ @config = config || default_config
5
+ @current_path = current_path
6
+ end
7
+
8
+ def title
9
+ directory_config.first
10
+ end
11
+
12
+ def dropdown_links
13
+ versions_to_paths.map { |version_path|
14
+ {version_path.keys.first => "/#{version_path.values.first}"}
15
+ }
16
+ end
17
+
18
+ private
19
+
20
+ attr_reader :config, :current_path
21
+
22
+ def versions_to_paths
23
+ directory_config[1..-1]
24
+ end
25
+
26
+ def directory_config
27
+ config.fetch(directory, config.fetch(root_menu_reference)) || empty_menu
28
+ end
29
+
30
+ def directory
31
+ File.dirname(current_path)
32
+ end
33
+
34
+ def default_config
35
+ { root_menu_reference => empty_menu }
36
+ end
37
+
38
+ def empty_menu
39
+ [nil]
40
+ end
41
+
42
+ def root_menu_reference
43
+ '.'
44
+ end
45
+ end
46
+ end
@@ -1,15 +1,9 @@
1
1
  require 'date'
2
- # mostly from https://github.com/multiscan/middleman-navigation but modified slightly
2
+ require_relative 'archive_drop_down_menu'
3
3
  require_relative 'quicklinks_renderer'
4
4
 
5
5
  I18n.enforce_available_locales = false
6
6
 
7
- class ArchiveMenuTemplateNotFound < StandardError;
8
- end
9
-
10
- class ArchiveConfigFormatError < StandardError;
11
- end
12
-
13
7
  module Bookbinder
14
8
  module Navigation
15
9
  class << self
@@ -23,8 +17,44 @@ module Bookbinder
23
17
  module HelperMethods
24
18
 
25
19
  def yield_for_code_snippet(from: nil, at: nil)
26
- example = CodeExample.get_instance(bookbinder_logger, section_hash: {'repository' => {'name' => from}}, local_repo_dir: config[:local_repo_dir], git_accessor: config[:git_accessor])
27
- snippet, language = example.get_snippet_and_language_at(at)
20
+ git_accessor = config[:git_accessor]
21
+ local_repo_dir = config[:local_repo_dir]
22
+ attributes = {'repository' => {'name' => from}}
23
+ workspace = config[:workspace]
24
+ code_example_reader = CodeExampleReader.new(bookbinder_logger)
25
+
26
+ vcs_repo =
27
+ if local_repo_dir
28
+ GitHubRepository.
29
+ build_from_local(bookbinder_logger,
30
+ attributes,
31
+ local_repo_dir,
32
+ git_accessor).
33
+ tap { |repo| repo.copy_from_local(workspace) }
34
+ else
35
+ GitHubRepository.
36
+ build_from_remote(bookbinder_logger, attributes, nil, git_accessor).
37
+ tap { |repo| repo.copy_from_remote(workspace) }
38
+ end
39
+ example = code_example_repo.get_instance(attributes,
40
+ vcs_repo: vcs_repo,
41
+ build: ->(path_to_repository,
42
+ full_name,
43
+ copied,
44
+ _,
45
+ destination_dir,
46
+ directory_name) {
47
+ CodeExample.new(path_to_repository,
48
+ full_name,
49
+ copied,
50
+ destination_dir,
51
+ directory_name)
52
+ })
53
+ snippet, language = code_example_reader.get_snippet_and_language_at(at,
54
+ example.path_to_repository,
55
+ example.copied,
56
+ example.full_name)
57
+
28
58
  delimiter = '```'
29
59
 
30
60
  snippet.prepend("#{delimiter}#{language}\n").concat("\n#{delimiter}")
@@ -43,20 +73,13 @@ module Bookbinder
43
73
  end
44
74
 
45
75
  def yield_for_archive_drop_down_menu
46
- if config.respond_to?(:archive_menu)
47
- title = config[:archive_menu].first
48
- links = config[:archive_menu][1..-1]
49
-
50
- new_links_based_from_root = links.map do |link|
51
- link_from_root = link.dup
52
- link_from_root.map do |k, v|
53
- link_from_root[k] = "/#{v}"
54
- end
55
- link_from_root
56
- end
76
+ menu = ArchiveDropDownMenu.new(
77
+ config[:archive_menu],
78
+ current_path: current_page.path
79
+ )
57
80
 
58
- partial 'archive_menus/default', locals: { menu_title: title, dropdown_links: new_links_based_from_root }
59
- end
81
+ partial 'archive_menus/default', locals: { menu_title: menu.title,
82
+ dropdown_links: menu.dropdown_links }
60
83
  end
61
84
 
62
85
  def breadcrumbs
@@ -72,13 +95,6 @@ module Bookbinder
72
95
  OpenStruct.new config[:template_variables]
73
96
  end
74
97
 
75
- def modified_date(format=nil)
76
- current_file_in_repo = current_path.dup.gsub(File.basename(current_path), File.basename(current_page.source_file))
77
- current_section = get_section_or_book_for(current_file_in_repo)
78
- modified_time = current_section.get_modification_date_for(file: current_file_in_repo, full_path: current_page.source_file)
79
- (format.nil? ? modified_time : modified_time.strftime(format))
80
- end
81
-
82
98
  def quick_links
83
99
  page_src = File.read(current_page.source_file)
84
100
  quicklinks_renderer = QuicklinksRenderer.new(vars)
@@ -87,17 +103,8 @@ module Bookbinder
87
103
 
88
104
  private
89
105
 
90
- def get_section_or_book_for(path)
91
- sections = config[:sections]
92
- book = config[:book]
93
-
94
- raise "Book or Selections are incorrectly specified for Middleman." if book.nil? || sections.nil?
95
-
96
- current_section = nil
97
- sections.each { |section| current_section = section if File.dirname(current_path).match(/^#{section.directory}/) }
98
-
99
- return book if current_section.nil?
100
- return current_section
106
+ def code_example_repo
107
+ @code_example_repo ||= Repositories::SectionRepository.new(bookbinder_logger)
101
108
  end
102
109
 
103
110
  def index_subnav
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bookbindery
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Grafton
@@ -13,24 +13,24 @@ authors:
13
13
  - Matthew Boedicker
14
14
  - Frank Kotsianas
15
15
  autorequire:
16
- bindir: bin
16
+ bindir: install_bin
17
17
  cert_chain: []
18
- date: 2015-02-12 00:00:00.000000000 Z
18
+ date: 2015-02-17 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: fog
21
+ name: fog-aws
22
22
  requirement: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.17'
26
+ version: 0.0.6
27
27
  type: :runtime
28
28
  prerelease: false
29
29
  version_requirements: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.17'
33
+ version: 0.0.6
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: octokit
36
36
  requirement: !ruby/object:Gem::Requirement
@@ -73,20 +73,6 @@ dependencies:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0.1'
76
- - !ruby/object:Gem::Dependency
77
- name: padrino-contrib
78
- requirement: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- type: :runtime
84
- prerelease: false
85
- version_requirements: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
76
  - !ruby/object:Gem::Dependency
91
77
  name: middleman
92
78
  requirement: !ruby/object:Gem::Requirement
@@ -157,34 +143,6 @@ dependencies:
157
143
  - - '='
158
144
  - !ruby/object:Gem::Version
159
145
  version: 0.12.3
160
- - !ruby/object:Gem::Dependency
161
- name: faraday
162
- requirement: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - "~>"
165
- - !ruby/object:Gem::Version
166
- version: 0.8.8
167
- type: :runtime
168
- prerelease: false
169
- version_requirements: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - "~>"
172
- - !ruby/object:Gem::Version
173
- version: 0.8.8
174
- - !ruby/object:Gem::Dependency
175
- name: faraday_middleware
176
- requirement: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - "~>"
179
- - !ruby/object:Gem::Version
180
- version: 0.9.0
181
- type: :runtime
182
- prerelease: false
183
- version_requirements: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - "~>"
186
- - !ruby/object:Gem::Version
187
- version: 0.9.0
188
146
  - !ruby/object:Gem::Dependency
189
147
  name: anemone
190
148
  requirement: !ruby/object:Gem::Requirement
@@ -255,20 +213,6 @@ dependencies:
255
213
  - - ">="
256
214
  - !ruby/object:Gem::Version
257
215
  version: '0'
258
- - !ruby/object:Gem::Dependency
259
- name: ruby-progressbar
260
- requirement: !ruby/object:Gem::Requirement
261
- requirements:
262
- - - ">="
263
- - !ruby/object:Gem::Version
264
- version: '0'
265
- type: :runtime
266
- prerelease: false
267
- version_requirements: !ruby/object:Gem::Requirement
268
- requirements:
269
- - - ">="
270
- - !ruby/object:Gem::Version
271
- version: '0'
272
216
  - !ruby/object:Gem::Dependency
273
217
  name: therubyracer
274
218
  requirement: !ruby/object:Gem::Requirement
@@ -353,20 +297,6 @@ dependencies:
353
297
  - - ">="
354
298
  - !ruby/object:Gem::Version
355
299
  version: '0'
356
- - !ruby/object:Gem::Dependency
357
- name: webmock
358
- requirement: !ruby/object:Gem::Requirement
359
- requirements:
360
- - - ">="
361
- - !ruby/object:Gem::Version
362
- version: '0'
363
- type: :development
364
- prerelease: false
365
- version_requirements: !ruby/object:Gem::Requirement
366
- requirements:
367
- - - ">="
368
- - !ruby/object:Gem::Version
369
- version: '0'
370
300
  description: A command line utility to be run in Book repositories to stitch together
371
301
  their constituent Markdown repos into a static-HTML-serving application
372
302
  email: gmorgan@gopivotal.com
@@ -375,10 +305,9 @@ executables:
375
305
  extensions: []
376
306
  extra_rdoc_files: []
377
307
  files:
378
- - bin/bookbinder
379
- - lib/bookbinder.rb
380
308
  - lib/bookbinder/app_fetcher.rb
381
309
  - lib/bookbinder/archive.rb
310
+ - lib/bookbinder/archive_menu_configuration.rb
382
311
  - lib/bookbinder/artifact_namer.rb
383
312
  - lib/bookbinder/blue_green_app.rb
384
313
  - lib/bookbinder/book.rb
@@ -388,14 +317,17 @@ files:
388
317
  - lib/bookbinder/cli.rb
389
318
  - lib/bookbinder/cli_error.rb
390
319
  - lib/bookbinder/code_example.rb
320
+ - lib/bookbinder/code_example_reader.rb
321
+ - lib/bookbinder/colorizer.rb
391
322
  - lib/bookbinder/command_runner.rb
392
323
  - lib/bookbinder/command_validator.rb
324
+ - lib/bookbinder/commands/bind.rb
393
325
  - lib/bookbinder/commands/bookbinder_command.rb
394
326
  - lib/bookbinder/commands/build_and_push_tarball.rb
327
+ - lib/bookbinder/commands/chain.rb
395
328
  - lib/bookbinder/commands/generate_pdf.rb
396
329
  - lib/bookbinder/commands/help.rb
397
330
  - lib/bookbinder/commands/naming.rb
398
- - lib/bookbinder/commands/publish.rb
399
331
  - lib/bookbinder/commands/push_local_to_staging.rb
400
332
  - lib/bookbinder/commands/push_to_prod.rb
401
333
  - lib/bookbinder/commands/run_publish_ci.rb
@@ -408,33 +340,47 @@ files:
408
340
  - lib/bookbinder/css_link_checker.rb
409
341
  - lib/bookbinder/directory_helpers.rb
410
342
  - lib/bookbinder/distributor.rb
343
+ - lib/bookbinder/dita_html_to_middleman_formatter.rb
344
+ - lib/bookbinder/dita_section.rb
345
+ - lib/bookbinder/dita_section_gatherer.rb
346
+ - lib/bookbinder/git_accessor.rb
411
347
  - lib/bookbinder/git_client.rb
412
348
  - lib/bookbinder/git_hub_repository.rb
349
+ - lib/bookbinder/local_dita_preprocessor.rb
350
+ - lib/bookbinder/local_dita_to_html_converter.rb
413
351
  - lib/bookbinder/local_file_system_accessor.rb
414
352
  - lib/bookbinder/middleman_runner.rb
415
353
  - lib/bookbinder/pdf_generator.rb
416
354
  - lib/bookbinder/publisher.rb
417
355
  - lib/bookbinder/pusher.rb
418
356
  - lib/bookbinder/remote_yaml_credential_provider.rb
357
+ - lib/bookbinder/repositories/command_repository.rb
358
+ - lib/bookbinder/repositories/section_repository.rb
419
359
  - lib/bookbinder/section.rb
420
360
  - lib/bookbinder/server_director.rb
421
361
  - lib/bookbinder/shell_out.rb
362
+ - lib/bookbinder/sheller.rb
422
363
  - lib/bookbinder/sieve.rb
423
364
  - lib/bookbinder/sitemap_generator.rb
424
365
  - lib/bookbinder/spider.rb
425
366
  - lib/bookbinder/stabilimentum.rb
426
- - lib/bookbinder/usage_messenger.rb
367
+ - lib/bookbinder/terminal.rb
368
+ - lib/bookbinder/user_message.rb
369
+ - lib/bookbinder/user_message_presenter.rb
427
370
  - lib/bookbinder/yaml_loader.rb
428
- - master_middleman/bookbinder_helpers.rb
429
- - master_middleman/config.rb
430
- - master_middleman/quicklinks_renderer.rb
431
- - master_middleman/submodule_aware_assets.rb
432
- - template_app/Gemfile
433
- - template_app/Gemfile.lock
371
+ - lib/bookbinder.rb
434
372
  - template_app/app.rb
435
373
  - template_app/config.ru
374
+ - template_app/Gemfile
375
+ - template_app/Gemfile.lock
436
376
  - template_app/lib/rack_static.rb
437
377
  - template_app/lib/vienna_application.rb
378
+ - master_middleman/archive_drop_down_menu.rb
379
+ - master_middleman/bookbinder_helpers.rb
380
+ - master_middleman/config.rb
381
+ - master_middleman/quicklinks_renderer.rb
382
+ - master_middleman/submodule_aware_assets.rb
383
+ - install_bin/bookbinder
438
384
  homepage: https://github.com/cloudfoundry-incubator/bookbinder
439
385
  licenses:
440
386
  - MIT
@@ -455,7 +401,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
455
401
  version: '0'
456
402
  requirements: []
457
403
  rubyforge_project:
458
- rubygems_version: 2.4.1
404
+ rubygems_version: 2.0.14
459
405
  signing_key:
460
406
  specification_version: 4
461
407
  summary: Markdown to Rackup application documentation generator