playgroundbook 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +110 -0
  3. data/Changelog.md +4 -0
  4. data/Gemfile +10 -9
  5. data/Gemfile.lock +4 -2
  6. data/Guardfile +2 -2
  7. data/Rakefile +3 -3
  8. data/bin/playgroundbook +9 -7
  9. data/lib/{playgroundbook_lint → linter}/abstract_linter.rb +2 -2
  10. data/lib/{playgroundbook_lint → linter}/chapter_linter.rb +4 -4
  11. data/lib/{playgroundbook_lint → linter}/chapter_manifest_linter.rb +5 -5
  12. data/lib/{playgroundbook_lint → linter}/contents_linter.rb +3 -3
  13. data/lib/{playgroundbook_lint → linter}/cutscene_page_linter.rb +2 -2
  14. data/lib/{playgroundbook_lint → linter}/cutscene_page_manifest_linter.rb +2 -2
  15. data/lib/{playgroundbook_lint → linter}/manifest_linter.rb +5 -5
  16. data/lib/{playgroundbook_lint → linter}/page_linter.rb +2 -2
  17. data/lib/{playgroundbook_lint → linter}/page_manifest_linter.rb +3 -3
  18. data/lib/{playgroundbook_lint → linter}/playgroundbook_lint.rb +6 -6
  19. data/lib/{playgroundbook_lint → linter}/root_manifest_linter.rb +9 -9
  20. data/lib/playgroundbook.rb +8 -7
  21. data/lib/{playgroundbook_renderer → renderer}/chapter_collator.rb +18 -18
  22. data/lib/renderer/contents_manifest_generator.rb +35 -0
  23. data/lib/{playgroundbook_renderer → renderer}/glossary_generator.rb +13 -16
  24. data/lib/{playgroundbook_renderer → renderer}/page_parser.rb +4 -3
  25. data/lib/{playgroundbook_renderer → renderer}/page_processor.rb +0 -0
  26. data/lib/{playgroundbook_renderer → renderer}/page_writer.rb +11 -11
  27. data/lib/{playgroundbook_renderer → renderer}/playgroundbook_renderer.rb +29 -29
  28. data/lib/version.rb +1 -1
  29. data/lib/wrapper/markdown_wrapper.rb +58 -0
  30. data/playground_book_lint.gemspec +14 -14
  31. data/spec/fixtures/wrapper/destination/swift_at_artsy_1.swift +199 -0
  32. data/spec/fixtures/wrapper/source/Swift-at-Artsy.playground/Contents.swift +199 -0
  33. data/spec/fixtures/wrapper/source/Swift-at-Artsy.playground/contents.xcplayground +4 -0
  34. data/spec/fixtures/wrapper/source/swift_at_artsy_1.md +183 -0
  35. data/spec/{playground_book_lint → linter}/chapter_linter_spec.rb +5 -5
  36. data/spec/{playground_book_lint → linter}/chapter_manifest_linter_spec.rb +12 -12
  37. data/spec/{playground_book_lint → linter}/contents_linter_spec.rb +3 -3
  38. data/spec/{playground_book_lint → linter}/cutscene_page_linter_spec.rb +2 -2
  39. data/spec/linter/cutscene_page_manifest_linter_spec.rb +63 -0
  40. data/spec/linter/manfiest_linter_spec.rb +71 -0
  41. data/spec/{playground_book_lint → linter}/page_linter_spec.rb +4 -4
  42. data/spec/{playground_book_lint → linter}/page_manifest_linter_spec.rb +13 -13
  43. data/spec/{playground_book_lint → linter}/playgroundbook_lint_spec.rb +6 -6
  44. data/spec/linter/root_manifest_linter_spec.rb +35 -0
  45. data/spec/renderer/chapter_collator_spec.rb +70 -0
  46. data/spec/renderer/contents_manfiest_generator_spec.rb +41 -0
  47. data/spec/renderer/glossary_generator_spec.rb +54 -0
  48. data/spec/{playgroundbook_renderer_spec → renderer}/page_processor_spec.rb +12 -12
  49. data/spec/{playgroundbook_renderer_spec → renderer}/page_writer_spec.rb +19 -19
  50. data/spec/renderer/playgroundbook_renderer_spec.rb +122 -0
  51. data/spec/spec_helper.rb +38 -38
  52. data/spec/wrapper/markdown_wrapper_spec.rb +33 -0
  53. metadata +43 -37
  54. data/lib/playgroundbook_renderer/contents_manifest_generator.rb +0 -35
  55. data/spec/playground_book_lint/cutscene_page_manifest_linter_spec.rb +0 -63
  56. data/spec/playground_book_lint/manfiest_linter_spec.rb +0 -71
  57. data/spec/playground_book_lint/root_manifest_linter_spec.rb +0 -35
  58. data/spec/playgroundbook_renderer_spec/chapter_collator_spec.rb +0 -70
  59. data/spec/playgroundbook_renderer_spec/contents_manfiest_generator_spec.rb +0 -41
  60. data/spec/playgroundbook_renderer_spec/glossary_generator_spec.rb +0 -52
  61. data/spec/playgroundbook_renderer_spec/playgroundbook_renderer_spec.rb +0 -122
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0cb1f23c12d4c4d5da05b5bd17d0c9309a7d9b68
4
- data.tar.gz: 06141cc3c18eb69eb0885438b2e60ab71cc75f67
3
+ metadata.gz: 74ed5b6506eab19b59be7917fe5314620e1dc893
4
+ data.tar.gz: 71c9d12ab78353b3b877e6a6379b14eeb8119c92
5
5
  SHA512:
6
- metadata.gz: db1e4fe2b6a940c9bce9b1ebe085fb347bb2fd43efb8e422ed14a2c8e185da3e527d60e2d5ec8859e769f2cc7ba3b421d2f7520b45501e6eedee71e24f983922
7
- data.tar.gz: f0852a23faa7728b67a1cd4cca7eda21e7174ba487cfb8b4f3dbaf889213e6405b1229ec27e7ea5523af3074fb0e8a9ab7c3174b07fc81856f12b814ed014135
6
+ metadata.gz: 344b95c2eaeda147d21643d537d0c1e5d4e1bee09a277f6f493dac399e8e85fd94d082ee904c7d0420f9c8648378553068b2c9ca1a443eb2aa31bc55b9788eb4
7
+ data.tar.gz: 1d40b036c24852da1bcbbc992d0ad35e4240d07eec6d394f4e5961973d880d26d039edcde4617c5e170609239888939ecdf0589f3a05f0b4040006405029d6e0
@@ -1,2 +1,112 @@
1
1
  Metrics/LineLength:
2
2
  Enabled: false
3
+
4
+ Style/StringLiterals:
5
+ EnforcedStyle: double_quotes
6
+ Enabled: true
7
+
8
+ # kind_of? is a good way to check a type
9
+ Style/ClassCheck:
10
+ EnforcedStyle: kind_of?
11
+
12
+ # It's better to be more explicit about the type
13
+ Style/BracesAroundHashParameters:
14
+ Enabled: false
15
+
16
+ # specs sometimes have useless assignments, which is fine
17
+ Lint/UselessAssignment:
18
+ Exclude:
19
+ - '**/spec/**/*'
20
+
21
+ # We could potentially enable the 2 below:
22
+ Style/IndentHash:
23
+ Enabled: false
24
+
25
+ Style/AlignHash:
26
+ Enabled: false
27
+
28
+ # HoundCI doesn't like this rule
29
+ Style/DotPosition:
30
+ Enabled: false
31
+
32
+ # We allow !! as it's an easy way to convert ot boolean
33
+ Style/DoubleNegation:
34
+ Enabled: false
35
+
36
+ # Cop supports --auto-correct.
37
+ Lint/UnusedBlockArgument:
38
+ Enabled: false
39
+
40
+ # We want to allow class Fastlane::Class
41
+ Style/ClassAndModuleChildren:
42
+ Enabled: false
43
+
44
+ Metrics/AbcSize:
45
+ Max: 60
46
+
47
+ # The %w might be confusing for new users
48
+ Style/WordArray:
49
+ MinSize: 19
50
+
51
+ # raise and fail are both okay
52
+ Style/SignalException:
53
+ Enabled: false
54
+
55
+ # Better too much 'return' than one missing
56
+ Style/RedundantReturn:
57
+ Enabled: false
58
+
59
+ # Having if in the same line might not always be good
60
+ Style/IfUnlessModifier:
61
+ Enabled: false
62
+
63
+ # and and or is okay
64
+ Style/AndOr:
65
+ Enabled: false
66
+
67
+ # Configuration parameters: CountComments.
68
+ Metrics/ClassLength:
69
+ Max: 320
70
+
71
+ Metrics/CyclomaticComplexity:
72
+ Max: 17
73
+
74
+ # Configuration parameters: AllowURI, URISchemes.
75
+ Metrics/LineLength:
76
+ Max: 370
77
+
78
+ # Configuration parameters: CountKeywordArgs.
79
+ Metrics/ParameterLists:
80
+ Max: 10
81
+
82
+ Metrics/PerceivedComplexity:
83
+ Max: 18
84
+
85
+ # Sometimes it's easier to read without guards
86
+ Style/GuardClause:
87
+ Enabled: false
88
+
89
+ # something = if something_else
90
+ # that's confusing
91
+ Style/ConditionalAssignment:
92
+ Enabled: false
93
+
94
+ # Better to have too much self than missing a self
95
+ Style/RedundantSelf:
96
+ Enabled: false
97
+
98
+ Metrics/MethodLength:
99
+ Max: 60
100
+
101
+ # We're not there yet
102
+ Style/Documentation:
103
+ Enabled: false
104
+
105
+ # Adds complexity
106
+ Style/IfInsideElse:
107
+ Enabled: false
108
+
109
+ # danger specific
110
+
111
+ Style/BlockComments:
112
+ Enabled: false
@@ -2,6 +2,10 @@
2
2
 
3
3
  - Nothing yet.
4
4
 
5
+ # 0.4.0
6
+
7
+ - Support converting a random Markdown file into a playground. See [#29](https://github.com/ashfurrow/playgroundbook/pull/29).
8
+
5
9
  # 0.3.0
6
10
 
7
11
  - Glossary support. See [#18](https://github.com/ashfurrow/playgroundbook/issues/18).
data/Gemfile CHANGED
@@ -1,12 +1,13 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
- gem 'guard-rspec'
4
- gem 'mocha'
5
- gem 'bacon'
6
- gem 'mocha-on-bacon'
7
- gem 'prettybacon'
8
- gem 'fakefs'
9
- gem 'rubocop', '~> 0.41.2', require: false
3
+ gem "rake"
4
+ gem "guard-rspec"
5
+ gem "mocha"
6
+ gem "bacon"
7
+ gem "mocha-on-bacon"
8
+ gem "prettybacon"
9
+ gem "fakefs"
10
+ gem "rubocop", "~> 0.41.2", require: false
10
11
 
11
- require 'pp' # https://github.com/defunkt/fakefs/issues/99
12
+ require "pp" # https://github.com/defunkt/fakefs/issues/99
12
13
  gemspec
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- playgroundbook (0.2.1)
4
+ playgroundbook (0.3.0)
5
5
  colored (~> 1.2)
6
6
  cork (~> 0.1)
7
7
  plist (~> 3.2)
@@ -13,7 +13,7 @@ GEM
13
13
  bacon (1.2.0)
14
14
  coderay (1.1.1)
15
15
  colored (1.2)
16
- cork (0.1.0)
16
+ cork (0.2.0)
17
17
  colored (~> 1.2)
18
18
  diff-lcs (1.2.5)
19
19
  fakefs (0.9.0)
@@ -58,6 +58,7 @@ GEM
58
58
  method_source (~> 0.8.1)
59
59
  slop (~> 3.4)
60
60
  rainbow (2.1.0)
61
+ rake (11.2.2)
61
62
  rb-fsevent (0.9.7)
62
63
  rb-inotify (0.9.7)
63
64
  ffi (>= 0.5.0)
@@ -97,6 +98,7 @@ DEPENDENCIES
97
98
  mocha-on-bacon
98
99
  playgroundbook!
99
100
  prettybacon
101
+ rake
100
102
  rubocop (~> 0.41.2)
101
103
 
102
104
  BUNDLED WITH
data/Guardfile CHANGED
@@ -1,5 +1,5 @@
1
- guard :rspec, cmd: 'bundle exec rspec' do
2
- require 'guard/rspec/dsl'
1
+ guard :rspec, cmd: "bundle exec rspec" do
2
+ require "guard/rspec/dsl"
3
3
  dsl = Guard::RSpec::Dsl.new(self)
4
4
 
5
5
  # RSpec files
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
- require 'rubocop/rake_task'
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "rubocop/rake_task"
4
4
 
5
5
  RSpec::Core::RakeTask.new(:spec)
6
6
  RuboCop::RakeTask.new
@@ -1,22 +1,24 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  unless ARGV.length >= 2
4
- puts 'You must specify either lint or render. Example usage:'
5
- puts ' playgroundbook [lint|render] file_name'
4
+ puts "You must specify either lint or render. Example usage:"
5
+ puts " playgroundbook [lint|render] file_name"
6
6
  exit 1
7
7
  end
8
8
 
9
9
  command = ARGV[0]
10
10
  file_name = ARGV[1]
11
11
 
12
- require 'playgroundbook'
12
+ require "playgroundbook"
13
13
 
14
- if command == 'lint'
14
+ if command == "lint"
15
15
  Playgroundbook::Linter.new(file_name).lint
16
- elsif command == 'render'
17
- Playgroundbook::Renderer.new(file_name).render!
16
+ elsif command == "render"
17
+ Playgroundbook::Renderer.new(file_name).render
18
+ elsif command == "wrapper"
19
+ playground_name = ARGV[2]
20
+ Playgroundbook::MarkdownWrapper.new(file_name, playground_name).generate
18
21
  else
19
22
  puts "Unknown command: #{command}"
20
23
  exit 1
21
24
  end
22
-
@@ -1,5 +1,5 @@
1
- require 'colored'
2
- require 'cork'
1
+ require "colored"
2
+ require "cork"
3
3
 
4
4
  module Playgroundbook
5
5
  # AbstractLinter provides a base implementation of a linter which a concrete
@@ -1,9 +1,9 @@
1
- require 'plist'
2
- require 'playgroundbook_lint/abstract_linter'
3
- require 'playgroundbook_lint/chapter_manifest_linter'
1
+ require "plist"
2
+ require "linter/abstract_linter"
3
+ require "linter/chapter_manifest_linter"
4
4
 
5
5
  module Playgroundbook
6
- PAGES_DIRECTORY_NAME = 'Pages'.freeze
6
+ PAGES_DIRECTORY_NAME = "Pages".freeze
7
7
 
8
8
  # A linter for verifying a chapter directory
9
9
  class ChapterLinter < AbstractLinter
@@ -1,6 +1,6 @@
1
- require 'playgroundbook_lint/manifest_linter'
2
- require 'playgroundbook_lint/page_linter'
3
- require 'playgroundbook_lint/cutscene_page_linter'
1
+ require "linter/manifest_linter"
2
+ require "linter/page_linter"
3
+ require "linter/cutscene_page_linter"
4
4
 
5
5
  module Playgroundbook
6
6
  # A linter for verifying the contents of a chapter's Manifest.plist
@@ -17,7 +17,7 @@ module Playgroundbook
17
17
 
18
18
  fail_lint "Chapter has no pages in #{Dir.pwd}" unless chapter_has_manifest_pages?
19
19
 
20
- manifest_plist_contents['Pages'].each do |page_directory_name|
20
+ manifest_plist_contents["Pages"].each do |page_directory_name|
21
21
  # All pages exist inside the /Pages subdirectory, we need to chdir to there first.
22
22
  Dir.chdir PAGES_DIRECTORY_NAME do
23
23
  fail_lint "Chapter page directory #{page_directory_name} missing in #{Dir.pwd}" unless Dir.exist?(page_directory_name)
@@ -37,7 +37,7 @@ module Playgroundbook
37
37
  end
38
38
 
39
39
  def chapter_has_manifest_pages?
40
- value_defined_in_manifest?('Pages')
40
+ value_defined_in_manifest?("Pages")
41
41
  end
42
42
  end
43
43
  end
@@ -1,5 +1,5 @@
1
- require 'playgroundbook_lint/abstract_linter'
2
- require 'playgroundbook_lint/root_manifest_linter'
1
+ require "linter/abstract_linter"
2
+ require "linter/root_manifest_linter"
3
3
 
4
4
  module Playgroundbook
5
5
  # A linter for verifying the contents directory of a playground book
@@ -11,7 +11,7 @@ module Playgroundbook
11
11
  end
12
12
 
13
13
  def lint
14
- Dir.chdir 'Contents' do
14
+ Dir.chdir "Contents" do
15
15
  root_manfiest_linter.lint
16
16
  # TODO: Other linting?
17
17
  end
@@ -1,5 +1,5 @@
1
- require 'playgroundbook_lint/abstract_linter'
2
- require 'playgroundbook_lint/cutscene_page_manifest_linter'
1
+ require "linter/abstract_linter"
2
+ require "linter/cutscene_page_manifest_linter"
3
3
 
4
4
  module Playgroundbook
5
5
  # A linter for verifying cutscene pages
@@ -1,4 +1,4 @@
1
- require 'playgroundbook_lint/manifest_linter'
1
+ require "linter/manifest_linter"
2
2
 
3
3
  module Playgroundbook
4
4
  # A linter for verifying the contents of a cutscene page's manifest
@@ -9,7 +9,7 @@ module Playgroundbook
9
9
  super()
10
10
 
11
11
  # Cutscene references should point to an existent HTML file
12
- cutscene_reference = manifest_plist_contents['CutsceneReference']
12
+ cutscene_reference = manifest_plist_contents["CutsceneReference"]
13
13
  fail_lint "Cutscene manifest doesn't reference a cutscene file" if cutscene_reference.nil?
14
14
  fail_lint "Cutscene file at '#{cutscene_reference}' isn't HTML" unless cutscene_reference =~ /^.+\.html$/i
15
15
  fail_lint "Cutscene file at '#{cutscene_reference}' doesn't exist" unless File.exist? cutscene_reference
@@ -1,8 +1,8 @@
1
- require 'plist'
2
- require 'playgroundbook_lint/abstract_linter'
1
+ require "plist"
2
+ require "linter/abstract_linter"
3
3
 
4
4
  module Playgroundbook
5
- MANIFEST_FILE_NAME = 'Manifest.plist'.freeze
5
+ MANIFEST_FILE_NAME = "Manifest.plist".freeze
6
6
 
7
7
  # A base inplementation of a linter for verifying the contents of manifest
8
8
  # files.
@@ -20,13 +20,13 @@ module Playgroundbook
20
20
 
21
21
  def manifest_plist_contents
22
22
  return @manifest_plist_contents unless @manifest_plist_contents.nil?
23
- require 'plist'
23
+ require "plist"
24
24
  @manifest_plist_contents = Plist.parse_xml(MANIFEST_FILE_NAME)
25
25
  @manifest_plist_contents
26
26
  end
27
27
 
28
28
  def name?
29
- value_defined_in_manifest?('Name')
29
+ value_defined_in_manifest?("Name")
30
30
  end
31
31
 
32
32
  def value_defined_in_manifest?(key)
@@ -1,5 +1,5 @@
1
- require 'playgroundbook_lint/abstract_linter'
2
- require 'playgroundbook_lint/page_manifest_linter'
1
+ require "linter/abstract_linter"
2
+ require "linter/page_manifest_linter"
3
3
 
4
4
  module Playgroundbook
5
5
  # A linter for verifying the contents of a page directory
@@ -1,5 +1,5 @@
1
- require 'plist'
2
- require 'playgroundbook_lint/manifest_linter'
1
+ require "plist"
2
+ require "linter/manifest_linter"
3
3
 
4
4
  module Playgroundbook
5
5
  # A linter for verifying the contents of a page's Manifest.plist
@@ -9,7 +9,7 @@ module Playgroundbook
9
9
  def lint
10
10
  super()
11
11
 
12
- live_view_mode = manifest_plist_contents['LiveViewMode']
12
+ live_view_mode = manifest_plist_contents["LiveViewMode"]
13
13
  unless live_view_mode.nil?
14
14
  fail_lint "Unsopported LiveViewMoode '#{live_view_mode}'" unless SUPPORTED_LIVE_VIEW_MODES.include? live_view_mode
15
15
  end
@@ -1,7 +1,7 @@
1
- require 'colored'
2
- require 'playgroundbook_lint/abstract_linter'
3
- require 'playgroundbook_lint/contents_linter'
4
- require 'pathname'
1
+ require "colored"
2
+ require "linter/abstract_linter"
3
+ require "linter/contents_linter"
4
+ require "pathname"
5
5
 
6
6
  module Playgroundbook
7
7
  # A linter for verifying a playground book
@@ -17,7 +17,7 @@ module Playgroundbook
17
17
  def lint
18
18
  message "Validating #{playground_file_name.yellow}..."
19
19
 
20
- fail_lint 'No Contents directory' unless contents_dir_exists?
20
+ fail_lint "No Contents directory" unless contents_dir_exists?
21
21
 
22
22
  Dir.chdir playground_file_name do
23
23
  contents_linter.lint
@@ -25,7 +25,7 @@ module Playgroundbook
25
25
  end
26
26
 
27
27
  def contents_dir_exists?
28
- Dir.exist?(playground_file_name + '/Contents')
28
+ Dir.exist?(playground_file_name + "/Contents")
29
29
  end
30
30
  end
31
31
  end
@@ -1,6 +1,6 @@
1
- require 'plist'
2
- require 'playgroundbook_lint/manifest_linter'
3
- require 'playgroundbook_lint/chapter_linter'
1
+ require "plist"
2
+ require "linter/manifest_linter"
3
+ require "linter/chapter_linter"
4
4
 
5
5
  module Playgroundbook
6
6
  # A linter for verifying the contents of a playground book's root manifest
@@ -14,23 +14,23 @@ module Playgroundbook
14
14
  def lint
15
15
  super()
16
16
 
17
- fail_lint 'No Chapters directory' unless chapters_directory_exist?
18
- fail_lint 'No Chapters specified' unless chapters_exist?
17
+ fail_lint "No Chapters directory" unless chapters_directory_exist?
18
+ fail_lint "No Chapters specified" unless chapters_exist?
19
19
 
20
20
  # Go into Chapters/ and then each chapter directory, then lint it.
21
- Dir.chdir 'Chapters' do
22
- manifest_plist_contents['Chapters'].each do |chapter_directory_name|
21
+ Dir.chdir "Chapters" do
22
+ manifest_plist_contents["Chapters"].each do |chapter_directory_name|
23
23
  chapter_linter.lint(chapter_directory_name)
24
24
  end
25
25
  end
26
26
  end
27
27
 
28
28
  def chapters_directory_exist?
29
- Dir.exist? 'Chapters'
29
+ Dir.exist? "Chapters"
30
30
  end
31
31
 
32
32
  def chapters_exist?
33
- value_defined_in_manifest?('Chapters')
33
+ value_defined_in_manifest?("Chapters")
34
34
  end
35
35
  end
36
36
  end