playgroundbook 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +110 -0
- data/Changelog.md +4 -0
- data/Gemfile +10 -9
- data/Gemfile.lock +4 -2
- data/Guardfile +2 -2
- data/Rakefile +3 -3
- data/bin/playgroundbook +9 -7
- data/lib/{playgroundbook_lint → linter}/abstract_linter.rb +2 -2
- data/lib/{playgroundbook_lint → linter}/chapter_linter.rb +4 -4
- data/lib/{playgroundbook_lint → linter}/chapter_manifest_linter.rb +5 -5
- data/lib/{playgroundbook_lint → linter}/contents_linter.rb +3 -3
- data/lib/{playgroundbook_lint → linter}/cutscene_page_linter.rb +2 -2
- data/lib/{playgroundbook_lint → linter}/cutscene_page_manifest_linter.rb +2 -2
- data/lib/{playgroundbook_lint → linter}/manifest_linter.rb +5 -5
- data/lib/{playgroundbook_lint → linter}/page_linter.rb +2 -2
- data/lib/{playgroundbook_lint → linter}/page_manifest_linter.rb +3 -3
- data/lib/{playgroundbook_lint → linter}/playgroundbook_lint.rb +6 -6
- data/lib/{playgroundbook_lint → linter}/root_manifest_linter.rb +9 -9
- data/lib/playgroundbook.rb +8 -7
- data/lib/{playgroundbook_renderer → renderer}/chapter_collator.rb +18 -18
- data/lib/renderer/contents_manifest_generator.rb +35 -0
- data/lib/{playgroundbook_renderer → renderer}/glossary_generator.rb +13 -16
- data/lib/{playgroundbook_renderer → renderer}/page_parser.rb +4 -3
- data/lib/{playgroundbook_renderer → renderer}/page_processor.rb +0 -0
- data/lib/{playgroundbook_renderer → renderer}/page_writer.rb +11 -11
- data/lib/{playgroundbook_renderer → renderer}/playgroundbook_renderer.rb +29 -29
- data/lib/version.rb +1 -1
- data/lib/wrapper/markdown_wrapper.rb +58 -0
- data/playground_book_lint.gemspec +14 -14
- data/spec/fixtures/wrapper/destination/swift_at_artsy_1.swift +199 -0
- data/spec/fixtures/wrapper/source/Swift-at-Artsy.playground/Contents.swift +199 -0
- data/spec/fixtures/wrapper/source/Swift-at-Artsy.playground/contents.xcplayground +4 -0
- data/spec/fixtures/wrapper/source/swift_at_artsy_1.md +183 -0
- data/spec/{playground_book_lint → linter}/chapter_linter_spec.rb +5 -5
- data/spec/{playground_book_lint → linter}/chapter_manifest_linter_spec.rb +12 -12
- data/spec/{playground_book_lint → linter}/contents_linter_spec.rb +3 -3
- data/spec/{playground_book_lint → linter}/cutscene_page_linter_spec.rb +2 -2
- data/spec/linter/cutscene_page_manifest_linter_spec.rb +63 -0
- data/spec/linter/manfiest_linter_spec.rb +71 -0
- data/spec/{playground_book_lint → linter}/page_linter_spec.rb +4 -4
- data/spec/{playground_book_lint → linter}/page_manifest_linter_spec.rb +13 -13
- data/spec/{playground_book_lint → linter}/playgroundbook_lint_spec.rb +6 -6
- data/spec/linter/root_manifest_linter_spec.rb +35 -0
- data/spec/renderer/chapter_collator_spec.rb +70 -0
- data/spec/renderer/contents_manfiest_generator_spec.rb +41 -0
- data/spec/renderer/glossary_generator_spec.rb +54 -0
- data/spec/{playgroundbook_renderer_spec → renderer}/page_processor_spec.rb +12 -12
- data/spec/{playgroundbook_renderer_spec → renderer}/page_writer_spec.rb +19 -19
- data/spec/renderer/playgroundbook_renderer_spec.rb +122 -0
- data/spec/spec_helper.rb +38 -38
- data/spec/wrapper/markdown_wrapper_spec.rb +33 -0
- metadata +43 -37
- data/lib/playgroundbook_renderer/contents_manifest_generator.rb +0 -35
- data/spec/playground_book_lint/cutscene_page_manifest_linter_spec.rb +0 -63
- data/spec/playground_book_lint/manfiest_linter_spec.rb +0 -71
- data/spec/playground_book_lint/root_manifest_linter_spec.rb +0 -35
- data/spec/playgroundbook_renderer_spec/chapter_collator_spec.rb +0 -70
- data/spec/playgroundbook_renderer_spec/contents_manfiest_generator_spec.rb +0 -41
- data/spec/playgroundbook_renderer_spec/glossary_generator_spec.rb +0 -52
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74ed5b6506eab19b59be7917fe5314620e1dc893
|
4
|
+
data.tar.gz: 71c9d12ab78353b3b877e6a6379b14eeb8119c92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 344b95c2eaeda147d21643d537d0c1e5d4e1bee09a277f6f493dac399e8e85fd94d082ee904c7d0420f9c8648378553068b2c9ca1a443eb2aa31bc55b9788eb4
|
7
|
+
data.tar.gz: 1d40b036c24852da1bcbbc992d0ad35e4240d07eec6d394f4e5961973d880d26d039edcde4617c5e170609239888939ecdf0589f3a05f0b4040006405029d6e0
|
data/.rubocop.yml
CHANGED
@@ -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
|
data/Changelog.md
CHANGED
@@ -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
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
|
-
gem
|
4
|
-
gem
|
5
|
-
gem
|
6
|
-
gem
|
7
|
-
gem
|
8
|
-
gem
|
9
|
-
gem
|
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
|
12
|
+
require "pp" # https://github.com/defunkt/fakefs/issues/99
|
12
13
|
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
playgroundbook (0.
|
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.
|
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
data/Rakefile
CHANGED
data/bin/playgroundbook
CHANGED
@@ -1,22 +1,24 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
unless ARGV.length >= 2
|
4
|
-
puts
|
5
|
-
puts
|
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
|
12
|
+
require "playgroundbook"
|
13
13
|
|
14
|
-
if command ==
|
14
|
+
if command == "lint"
|
15
15
|
Playgroundbook::Linter.new(file_name).lint
|
16
|
-
elsif command ==
|
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,9 +1,9 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "plist"
|
2
|
+
require "linter/abstract_linter"
|
3
|
+
require "linter/chapter_manifest_linter"
|
4
4
|
|
5
5
|
module Playgroundbook
|
6
|
-
PAGES_DIRECTORY_NAME =
|
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
|
2
|
-
require
|
3
|
-
require
|
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[
|
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?(
|
40
|
+
value_defined_in_manifest?("Pages")
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
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
|
14
|
+
Dir.chdir "Contents" do
|
15
15
|
root_manfiest_linter.lint
|
16
16
|
# TODO: Other linting?
|
17
17
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
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[
|
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
|
2
|
-
require
|
1
|
+
require "plist"
|
2
|
+
require "linter/abstract_linter"
|
3
3
|
|
4
4
|
module Playgroundbook
|
5
|
-
MANIFEST_FILE_NAME =
|
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
|
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?(
|
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
|
2
|
-
require
|
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[
|
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
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
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
|
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 +
|
28
|
+
Dir.exist?(playground_file_name + "/Contents")
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
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
|
18
|
-
fail_lint
|
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
|
22
|
-
manifest_plist_contents[
|
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?
|
29
|
+
Dir.exist? "Chapters"
|
30
30
|
end
|
31
31
|
|
32
32
|
def chapters_exist?
|
33
|
-
value_defined_in_manifest?(
|
33
|
+
value_defined_in_manifest?("Chapters")
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|