fictive 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/LICENSE +21 -0
- data/README.md +11 -0
- data/fictive.gemspec +24 -0
- data/lib/fictive/story.rb +59 -0
- data/lib/fictive/syntax.rb +81 -0
- data/lib/fictive/version.rb +3 -0
- data/lib/fictive.rb +3 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1a97bf0b37a8a63c69badc17c3394010d6741d04
|
4
|
+
data.tar.gz: 9aa8e1adf2ae5ea63bd868fa3e322a8af3d610c6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b18429033172f8db37b368ed0d71305de31d7de71bbd434d50d88ffada93fad155d096cc15315551133e8dfb18ed6577a7e73a8cb3fd9f0558738cc2863f7cd9
|
7
|
+
data.tar.gz: fac3046f8e96b793a0e98e470c423757df2659ea460cd38f96a9c6364b70f26219a43f88845acd7e292b6bed76c458385a73743e558e68bf9c8d38e4ca0779e4
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015-2016 Editorial Technology <http://editorial.technology>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Fictive
|
2
|
+
|
3
|
+
Authoring framework for choice fiction. An extraction from **[Muturangi](http://maetl.net/talks/narrative-anxiety)**.
|
4
|
+
|
5
|
+
## Disclaimer
|
6
|
+
|
7
|
+
This is a very basic, very sketchy draft extraction of some of the components I wrote to support turning my novel manuscript into an interactive choice-driven experience. It doesn’t yet support the full range of features of the original code and won’t be considered production ready until **Muturangi** is in production.
|
8
|
+
|
9
|
+
## License
|
10
|
+
|
11
|
+
MIT for now. Copyright (c) 2015-2016 [Editorial Technology](http://editorial.technology). See the `LICENSE` file at the root of this software distribution for more information.
|
data/fictive.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fictive/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'fictive'
|
8
|
+
spec.version = Fictive::VERSION
|
9
|
+
spec.authors = ['Mark Rickerby']
|
10
|
+
spec.email = ['me@maetl.net']
|
11
|
+
|
12
|
+
spec.summary = %q{An authoring framework for choice fiction}
|
13
|
+
spec.description = %q{An authoring framework for creating choice fiction and interactive stories}
|
14
|
+
spec.homepage = 'https://github.com/maetl/fictive'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
+
spec.add_development_dependency 'rspec', '~> 3.4'
|
24
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Fictive
|
2
|
+
class Scene
|
3
|
+
attr_reader :passage
|
4
|
+
|
5
|
+
def initialize(metadata, passage)
|
6
|
+
@metadata = metadata
|
7
|
+
@passage = passage
|
8
|
+
end
|
9
|
+
|
10
|
+
def path
|
11
|
+
@metadata.fetch(:path)
|
12
|
+
end
|
13
|
+
|
14
|
+
def choices
|
15
|
+
@metadata.fetch(:choices, [])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class Choice
|
20
|
+
def initialize(metadata)
|
21
|
+
@metadata = metadata
|
22
|
+
end
|
23
|
+
|
24
|
+
def path
|
25
|
+
@metadata.fetch(:path)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class Story
|
30
|
+
def self.demo
|
31
|
+
self.new([
|
32
|
+
Scene.new({path: 'hello', choices: [Choice.new({path: 'goodbye'})]}, 'Hello world'),
|
33
|
+
Scene.new({path: 'goodbye'}, 'Goodbye world')
|
34
|
+
])
|
35
|
+
end
|
36
|
+
|
37
|
+
def initialize(scenes)
|
38
|
+
@scenes = scenes
|
39
|
+
@scenes_index = {}
|
40
|
+
@scenes.each_with_index do |scene, id|
|
41
|
+
@scenes_index[scene.path] = id
|
42
|
+
end
|
43
|
+
|
44
|
+
@index = 0
|
45
|
+
end
|
46
|
+
|
47
|
+
def has_next?
|
48
|
+
!@scenes.at(@index).nil? && !@scenes.at(@index + 1).nil?
|
49
|
+
end
|
50
|
+
|
51
|
+
def next
|
52
|
+
@scenes.at(@index)
|
53
|
+
end
|
54
|
+
|
55
|
+
def choose_path(path)
|
56
|
+
@index = @scenes_index[path]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'strscan'
|
2
|
+
|
3
|
+
module Fictive
|
4
|
+
module Syntax
|
5
|
+
class Element
|
6
|
+
attr_reader :type, :text
|
7
|
+
attr_accessor :children
|
8
|
+
|
9
|
+
def initialize(type, text = nil)
|
10
|
+
@type = type
|
11
|
+
@text = text
|
12
|
+
@children = []
|
13
|
+
end
|
14
|
+
|
15
|
+
def empty?
|
16
|
+
@children.empty?
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
EOL = "\n".freeze
|
21
|
+
|
22
|
+
class Parser
|
23
|
+
def initialize(input)
|
24
|
+
@input = clean_input(input)
|
25
|
+
end
|
26
|
+
|
27
|
+
def parse
|
28
|
+
reset_parser
|
29
|
+
|
30
|
+
document = Element.new(:document)
|
31
|
+
|
32
|
+
while !@scanner.eos?
|
33
|
+
document.children << parse_block_level
|
34
|
+
end
|
35
|
+
|
36
|
+
document
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def reset_parser
|
42
|
+
@scanner = StringScanner.new(@input)
|
43
|
+
end
|
44
|
+
|
45
|
+
def parse_block_level
|
46
|
+
return parse_atx_header if @scanner.scan(/#/)
|
47
|
+
return parse_blank_line if @scanner.scan(/#{EOL}/)
|
48
|
+
|
49
|
+
parse_paragraph
|
50
|
+
end
|
51
|
+
|
52
|
+
def parse_blank_line
|
53
|
+
Element.new(:blank_line)
|
54
|
+
end
|
55
|
+
|
56
|
+
def parse_atx_header
|
57
|
+
level = 1
|
58
|
+
level += 1 while @scanner.scan(/#/)
|
59
|
+
|
60
|
+
if @scanner.scan(/\s/)
|
61
|
+
Element.new("h#{level}".to_sym, scan_to_eol)
|
62
|
+
else
|
63
|
+
Element.new(:id, scan_to_eol)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def parse_paragraph
|
68
|
+
text = scan_to_eol
|
69
|
+
Element.new(:paragraph, text)
|
70
|
+
end
|
71
|
+
|
72
|
+
def scan_to_eol
|
73
|
+
@scanner.scan_until(/#{EOL}/).rstrip
|
74
|
+
end
|
75
|
+
|
76
|
+
def clean_input(input)
|
77
|
+
input.gsub(/\r\n?/, EOL).chomp + EOL
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
data/lib/fictive.rb
ADDED
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fictive
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mark Rickerby
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.4'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.4'
|
55
|
+
description: An authoring framework for creating choice fiction and interactive stories
|
56
|
+
email:
|
57
|
+
- me@maetl.net
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- LICENSE
|
64
|
+
- README.md
|
65
|
+
- fictive.gemspec
|
66
|
+
- lib/fictive.rb
|
67
|
+
- lib/fictive/story.rb
|
68
|
+
- lib/fictive/syntax.rb
|
69
|
+
- lib/fictive/version.rb
|
70
|
+
homepage: https://github.com/maetl/fictive
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
metadata: {}
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 2.2.2
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: An authoring framework for choice fiction
|
94
|
+
test_files: []
|
95
|
+
has_rdoc:
|