playgroundbook 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +4 -0
- data/Gemfile.lock +2 -2
- data/README.md +9 -4
- data/lib/playgroundbook_renderer/chapter_collator.rb +3 -3
- data/lib/playgroundbook_renderer/contents_manifest_generator.rb +3 -1
- data/lib/version.rb +1 -1
- data/spec/fixtures/book.yml +1 -0
- data/spec/playgroundbook_renderer_spec/contents_manfiest_generator_spec.rb +4 -0
- data/spec/spec_helper.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9284005e400363b56c6ad72c74da1d147b5f63b
|
4
|
+
data.tar.gz: e082821228fd38d19d3af795a62d5c80988ecc86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 351ca7d6d4c5af5c6246ccfeb76c7139adde5eeec7a5bcc666b8ed1d1ecf7afc1de90a05ccfca3eacc9d9297af53e7c26947acf9b4a0abfc4f6c0738e7b99b1e
|
7
|
+
data.tar.gz: 380e9c62a03fab27bfff3e64b8f9262f9ebc895b992306eaa49a85428197ec8989b54180aa85013e7ef8e87f901394ee816e3c4c8ee653cda3d3ab61903740ad
|
data/Changelog.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
|
4
|
+
playgroundbook (0.2.1)
|
5
5
|
colored (~> 1.2)
|
6
6
|
cork (~> 0.1)
|
7
7
|
plist (~> 3.2)
|
@@ -95,7 +95,7 @@ DEPENDENCIES
|
|
95
95
|
guard-rspec
|
96
96
|
mocha
|
97
97
|
mocha-on-bacon
|
98
|
-
|
98
|
+
playgroundbook!
|
99
99
|
prettybacon
|
100
100
|
rubocop (~> 0.41.2)
|
101
101
|
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
[![CircleCI](https://circleci.com/gh/ashfurrow/
|
1
|
+
[![CircleCI](https://circleci.com/gh/ashfurrow/playgroundbook.svg?style=svg)](https://circleci.com/gh/ashfurrow/playgroundbook)
|
2
2
|
|
3
3
|
# playgroundbook
|
4
4
|
|
@@ -30,6 +30,7 @@ The yml file should be in the following format:
|
|
30
30
|
name: Testing book
|
31
31
|
identifier: com.ashfurrow.example
|
32
32
|
resources: assets # Optional
|
33
|
+
cover: cover.jpeg # Optional
|
33
34
|
deployment_target: ios10.0 # Optional
|
34
35
|
imports: # Optional, defaults to UIKit
|
35
36
|
- UIKit
|
@@ -40,12 +41,16 @@ chapters:
|
|
40
41
|
- etc...
|
41
42
|
```
|
42
43
|
|
43
|
-
Each chapter needs to have a corresponding playground; so `Chapter 1` requires there be a `Chapter 1.playground` playground. The playgrounds can reference (not copy) resources from an optionally specified directory. `import` frameworks are specified in the yaml file and are added to every page of the book.
|
44
|
+
Each chapter needs to have a corresponding playground; so `Chapter 1` requires there be a `Chapter 1.playground` playground. The playgrounds can reference (not copy) resources from an optionally specified directory. `import` frameworks are specified in the yaml file and are added to every page of the book. You can specify a cover image file name that's stored in the `resources` directory (it should be 400x300 pixels).
|
45
|
+
|
46
|
+
Each chapter needs to be in the following format:
|
44
47
|
|
45
48
|
```swift
|
46
49
|
// This is the preamble that is shared among all the pages within this chapter.
|
47
50
|
|
48
|
-
|
51
|
+
public var str = "Hi!"
|
52
|
+
|
53
|
+
public func sharedFunc() {
|
49
54
|
print("This should be accessible to all pages.")
|
50
55
|
}
|
51
56
|
|
@@ -64,7 +69,7 @@ Pages are divided by lines beginning with a quadruple slash, followed by that pa
|
|
64
69
|
|
65
70
|
### Limitations of Book Rendering
|
66
71
|
|
67
|
-
Preamble (anything about the first `////` page) is put in its own file. That means declarations there need to be `public` to be visible within individual pages (even though when you're writing, everything is in one file). Additionally, the preamble is at the top-level and can't contain
|
72
|
+
Preamble (anything about the first `////` page) is put in its own file. That means declarations there need to be `public` to be visible within individual pages (even though when you're writing, everything is in one file). Additionally, the preamble is at the top-level and can't contain expressions. This would cause a compiler error in the Swift Playrounds iPad app:
|
68
73
|
|
69
74
|
```swift
|
70
75
|
public let layout = UICollectionViewFlowLayout()
|
@@ -14,9 +14,9 @@ module Playgroundbook
|
|
14
14
|
def collate!(chapter_name, chapter_file_contents, imports)
|
15
15
|
@ui.puts "Processing #{chapter_name.green}."
|
16
16
|
|
17
|
-
|
18
|
-
Dir.mkdir(
|
19
|
-
Dir.chdir(
|
17
|
+
chapter_directory_name = "#{chapter_name}.playgroundchapter"
|
18
|
+
Dir.mkdir(chapter_directory_name) unless Dir.exist?(chapter_directory_name)
|
19
|
+
Dir.chdir(chapter_directory_name) do
|
20
20
|
pages = parse_pages(chapter_file_contents)
|
21
21
|
|
22
22
|
Dir.mkdir(PagesDirectoryName) unless Dir.exist?(PagesDirectoryName)
|
@@ -20,7 +20,7 @@ module Playgroundbook
|
|
20
20
|
|
21
21
|
def manifest_contents(book_metadata)
|
22
22
|
chapters = book_metadata['chapters'].map{ |c| "#{c}.playgroundchapter" }
|
23
|
-
{
|
23
|
+
manifest_contents = {
|
24
24
|
'Name' => book_metadata['name'],
|
25
25
|
'ContentIdentifier' => book_metadata['identifier'],
|
26
26
|
'DeploymentTarget' => book_metadata['deployment_target'] || 'ios10.0',
|
@@ -28,6 +28,8 @@ module Playgroundbook
|
|
28
28
|
'Version' => '1.0',
|
29
29
|
'ContentVersion' => '1.0',
|
30
30
|
}
|
31
|
+
manifest_contents['ImageReference'] = book_metadata['cover'] unless book_metadata['cover'].nil?
|
32
|
+
manifest_contents
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|
data/lib/version.rb
CHANGED
data/spec/fixtures/book.yml
CHANGED
@@ -32,6 +32,10 @@ module Playgroundbook
|
|
32
32
|
it 'has chapters specified' do
|
33
33
|
expect(get_manifest['Chapters']).to eq(['test_chapter.playgroundchapter'])
|
34
34
|
end
|
35
|
+
|
36
|
+
it 'has a ImageReference' do
|
37
|
+
expect(get_manifest['ImageReference']).to eq('file.jpeg')
|
38
|
+
end
|
35
39
|
end
|
36
40
|
end
|
37
41
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: playgroundbook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ash Furrow
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: plist
|