gamefic-sdk 3.1.0 → 3.2.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/gamefic-sdk.gemspec +33 -29
- data/lib/gamefic-sdk/scaffold.rb +14 -6
- data/lib/gamefic-sdk/shell.rb +2 -1
- data/lib/gamefic-sdk/version.rb +1 -1
- data/scaffolds/project/.gitignore +4 -2
- data/scaffolds/project/.rspec.gf.erb +4 -0
- data/scaffolds/project/{Gemfile → Gemfile.gf.erb} +8 -0
- data/scaffolds/project/README.md.gf.erb +12 -0
- data/scaffolds/project/Rakefile.gf.erb +21 -0
- data/scaffolds/project/lib/__name__.rb.gf.erb +9 -0
- data/scaffolds/project/main.rb.gf.erb +1 -5
- data/scaffolds/project/spec/__name__/plot_spec.rb.gf.erb +24 -0
- data/scaffolds/project/spec/__name__/subplot_spec.rb.gf.erb +10 -0
- data/scaffolds/project/spec/gameplay_spec.rb +21 -0
- data/scaffolds/project/spec/opal_helper.rb +3 -0
- data/scaffolds/project/spec/shared_helper.rb +17 -0
- data/scaffolds/project/spec/spec_helper.rb +5 -0
- metadata +17 -6
- data/scaffolds/project/Rakefile +0 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4b98f8d00bed8b7baaadddfceade62d8974c805e425e63b174f335bb0baa1874
|
|
4
|
+
data.tar.gz: f9b74e8df206e6b648316a06c4a9481873af3acade70a6d15a1cec794d216fcb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 36e1db4ce3268b0e86fa3a20f30a91b339d31a092ef8f598a23ea7bfbffd0cbbca6403032cad866d1d7f5a5d04560ed5013331656890346674204e9d7842bfdb
|
|
7
|
+
data.tar.gz: fbcd4fe1d2f68fdd64540d725cbee8d107ed9d17817fdc6abc3bd93d3a961951f2dfcb69150b8ecbd42f14e2d30e272f188fd0b23295debb3d99c42981867368
|
data/CHANGELOG.md
CHANGED
data/gamefic-sdk.gemspec
CHANGED
|
@@ -1,42 +1,46 @@
|
|
|
1
|
-
lib = File.expand_path('
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
require 'gamefic-sdk/version'
|
|
4
4
|
require 'date'
|
|
5
5
|
|
|
6
|
-
Gem::Specification.new do |
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = 'gamefic-sdk'
|
|
8
|
+
spec.version = Gamefic::Sdk::VERSION
|
|
9
|
+
spec.date = Date.today.strftime('%Y-%m-%d')
|
|
10
|
+
spec.summary = 'Gamefic SDK'
|
|
11
|
+
spec.description = 'Development and command-line tools for Gamefic'
|
|
12
|
+
spec.authors = ['Fred Snyder']
|
|
13
|
+
spec.email = 'fsnyder@gamefic.com'
|
|
14
|
+
spec.homepage = 'https://gamefic.com'
|
|
15
|
+
spec.license = 'MIT'
|
|
16
|
+
|
|
17
|
+
spec.metadata['homepage_uri'] = 'https://gamefic.com'
|
|
18
|
+
spec.metadata['source_code_uri'] = 'https://github.com/castwide/gamefic-sdk'
|
|
19
|
+
spec.metadata['changelog_uri'] = 'https://github.com/castwide/gamefic-sdk/blob/master/CHANGELOG.md'
|
|
16
20
|
|
|
17
21
|
# Specify which files should be added to the gem when it is released.
|
|
18
22
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
19
|
-
|
|
23
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
20
24
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|examples|guides)/}) }
|
|
21
25
|
end
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
spec.executables = ['gamefic']
|
|
27
|
+
spec.require_paths = ['lib']
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
spec.required_ruby_version = '>= 2.7.0'
|
|
26
30
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
spec.add_runtime_dependency 'gamefic', '~> 3.0'
|
|
32
|
+
spec.add_runtime_dependency 'gamefic-standard', '~> 3.0'
|
|
33
|
+
spec.add_runtime_dependency 'gamefic-tty', '~> 3.0'
|
|
34
|
+
spec.add_runtime_dependency 'listen', '~> 3.0'
|
|
35
|
+
spec.add_runtime_dependency 'opal', '~> 1.1'
|
|
36
|
+
spec.add_runtime_dependency 'puma', '~> 6'
|
|
37
|
+
spec.add_runtime_dependency 'sinatra', '~> 2'
|
|
38
|
+
spec.add_runtime_dependency 'thor', '~> 1.0'
|
|
35
39
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
|
41
|
+
spec.add_development_dependency 'capybara', '~> 3.3'
|
|
42
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
|
43
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
44
|
+
spec.add_development_dependency 'selenium-webdriver', '~> 4.2'
|
|
45
|
+
spec.add_development_dependency 'simplecov', '~> 0.14'
|
|
42
46
|
end
|
data/lib/gamefic-sdk/scaffold.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'bundler'
|
|
2
2
|
require 'erb'
|
|
3
|
+
require 'fileutils'
|
|
3
4
|
require 'ostruct'
|
|
4
5
|
require 'pathname'
|
|
5
6
|
require 'securerandom'
|
|
@@ -26,28 +27,33 @@ module Gamefic
|
|
|
26
27
|
|
|
27
28
|
def render(file, data)
|
|
28
29
|
template = File.read(file)
|
|
29
|
-
erb = ERB.new(template)
|
|
30
|
+
erb = ERB.new(template, trim_mode: '-')
|
|
30
31
|
erb.result(data.get_binding)
|
|
31
32
|
end
|
|
32
33
|
|
|
33
34
|
def custom_copy origin, destination, data
|
|
34
35
|
FileUtils.mkdir_p File.dirname(destination)
|
|
35
36
|
if origin.end_with?('.gf.erb')
|
|
36
|
-
|
|
37
|
+
content = render(origin, data)
|
|
38
|
+
return if content.empty?
|
|
39
|
+
|
|
40
|
+
File.write destination[0..-8], content
|
|
37
41
|
else
|
|
38
42
|
FileUtils.cp_r origin, destination
|
|
39
43
|
end
|
|
40
44
|
end
|
|
41
45
|
|
|
42
|
-
def build name, destination
|
|
46
|
+
def build name, destination, **opts
|
|
43
47
|
dir = File.join(SCAFFOLDS_PATH, name)
|
|
44
48
|
raise LoadError, "Scaffold `#{name}` does not exist" unless File.directory?(dir)
|
|
45
49
|
|
|
46
50
|
path = Pathname.new('.').join(destination).realdirpath
|
|
47
|
-
data = Binder.new(name: File.basename(path))
|
|
51
|
+
data = Binder.new(name: File.basename(path), **opts)
|
|
48
52
|
files = Dir.glob(File.join(dir, '**', '*'), File::FNM_DOTMATCH).select { |entry| File.file?(entry) }
|
|
49
53
|
map = {}
|
|
50
54
|
files.each do |file|
|
|
55
|
+
next if file.include?('/spec') && !opts[:specs]
|
|
56
|
+
|
|
51
57
|
rename = File.join(File.dirname(file), File.basename(file)).gsub('__name__', data.name)
|
|
52
58
|
dst = File.join(destination, rename[dir.length..-1])
|
|
53
59
|
raise "Gamefic generation would overwrite existing file #{rename}" if File.file?(dst)
|
|
@@ -55,7 +61,9 @@ module Gamefic
|
|
|
55
61
|
map[file] = dst
|
|
56
62
|
end
|
|
57
63
|
map.each_pair { |src, dst| custom_copy src, dst, data }
|
|
58
|
-
|
|
64
|
+
Bundler.with_unbundled_env do
|
|
65
|
+
Dir.chdir(path) { system 'bundle install' }
|
|
66
|
+
end
|
|
59
67
|
end
|
|
60
68
|
end
|
|
61
69
|
end
|
data/lib/gamefic-sdk/shell.rb
CHANGED
|
@@ -14,9 +14,10 @@ module Gamefic
|
|
|
14
14
|
|
|
15
15
|
desc 'init DIRECTORY_NAME', 'Create a new project in DIRECTORY_NAME'
|
|
16
16
|
option :gem, type: :boolean, aliases: [:g, :library, :rubygem], desc: 'Make a gem project'
|
|
17
|
+
option :specs, type: :boolean, desc: 'Add RSpec and Opal::RSpec test suites', default: true
|
|
17
18
|
def init(directory_name)
|
|
18
19
|
scaffold = options[:gem] ? 'library' : 'project'
|
|
19
|
-
Gamefic::Sdk::Scaffold.build scaffold, directory_name
|
|
20
|
+
Gamefic::Sdk::Scaffold.build scaffold, directory_name, specs: options[:specs]
|
|
20
21
|
puts "Gamefic project initialized at #{File.realpath(directory_name)}"
|
|
21
22
|
end
|
|
22
23
|
|
data/lib/gamefic-sdk/version.rb
CHANGED
|
@@ -39,6 +39,18 @@ Open http://localhost:9000 in a browser.
|
|
|
39
39
|
|
|
40
40
|
The application will be saved in the `web/build` directory.
|
|
41
41
|
|
|
42
|
+
## Unit Tests
|
|
43
|
+
|
|
44
|
+
To run the test suite with Ruby:
|
|
45
|
+
|
|
46
|
+
$ rspec
|
|
47
|
+
|
|
48
|
+
To run the test suite with Opal:
|
|
49
|
+
|
|
50
|
+
$ rake opal
|
|
51
|
+
|
|
52
|
+
The Opal tests can be useful for finding bugs in the web build that do not occur in standard Ruby.
|
|
53
|
+
|
|
42
54
|
## More Information
|
|
43
55
|
|
|
44
56
|
Go to https://gamefic.com for documentation.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'bundler'
|
|
4
|
+
require 'bundler/setup'
|
|
5
|
+
require 'gamefic-sdk'
|
|
6
|
+
require 'opal/rspec/rake_task'
|
|
7
|
+
|
|
8
|
+
# Add the default Gamefic tasks for building and running games
|
|
9
|
+
# Run `rake --tasks` for a list of commands and descriptions
|
|
10
|
+
Gamefic::Sdk::Tasks.define_all
|
|
11
|
+
<% if specs %>
|
|
12
|
+
Opal::RSpec::RakeTask.new(:opal) do |_, config|
|
|
13
|
+
Bundler.definition
|
|
14
|
+
.dependencies_for([:default])
|
|
15
|
+
.each { |dep| Opal.use_gem dep.name }
|
|
16
|
+
Opal.append_path __dir__
|
|
17
|
+
Opal.append_path File.join(__dir__, 'lib')
|
|
18
|
+
config.pattern = 'spec/**/*_spec.rb'
|
|
19
|
+
config.requires = ['spec/opal_helper']
|
|
20
|
+
end
|
|
21
|
+
<% end %>
|
|
@@ -3,11 +3,7 @@
|
|
|
3
3
|
lib = File.expand_path('./lib', File.dirname(__FILE__))
|
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
|
|
6
|
-
require '
|
|
7
|
-
require 'gamefic-standard'
|
|
8
|
-
|
|
9
|
-
require '<%= name %>/plot'
|
|
10
|
-
require '<%= name %>/subplot'
|
|
6
|
+
require '<%= name %>'
|
|
11
7
|
|
|
12
8
|
# The Gamefic SDK uses this constant to select the main Plot for game engines.
|
|
13
9
|
GAMEFIC_PLOT_CLASS = <%= camelcase(name) %>::Plot
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
RSpec.describe <%= camelcase(name) %>::Plot do
|
|
2
|
+
let(:plot) { <%= camelcase(name) %>::Plot.new }
|
|
3
|
+
|
|
4
|
+
it 'gives all entities a description' do
|
|
5
|
+
undescribed = plot.entities
|
|
6
|
+
.reject(&:has_description?)
|
|
7
|
+
|
|
8
|
+
expect(undescribed).to be_empty
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'uniquely identifies entities by name' do
|
|
12
|
+
actor = plot.introduce
|
|
13
|
+
|
|
14
|
+
plot.entities.that_are(Openable).each { |entity| entity.open = true }
|
|
15
|
+
|
|
16
|
+
plot.entities.that_are(Room).each do |room|
|
|
17
|
+
actor.parent = room
|
|
18
|
+
plot.available.select(actor).each do |entity|
|
|
19
|
+
result = plot.available(ambiguous: true).query(actor, entity.name)
|
|
20
|
+
expect(result.match).to eq([entity])
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
RSpec.describe <%= camelcase(name) %>::Subplot do
|
|
2
|
+
let(:plot) { <%= camelcase(name) %>::Plot.new }
|
|
3
|
+
|
|
4
|
+
it 'branches from plots' do
|
|
5
|
+
actor = plot.introduce
|
|
6
|
+
subplot = plot.branch(<%= camelcase(name) %>::Subplot, introduce: actor)
|
|
7
|
+
expect(plot.subplots).to eq([subplot])
|
|
8
|
+
expect(subplot.players).to eq([actor])
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
RSpec.describe 'gameplay' do
|
|
2
|
+
let(:plot) { GAMEFIC_PLOT_CLASS.new }
|
|
3
|
+
|
|
4
|
+
let(:commands) do
|
|
5
|
+
# Customize this array of commands to reach a conclusion
|
|
6
|
+
[
|
|
7
|
+
'look around'
|
|
8
|
+
]
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'reaches a conclusion' do
|
|
12
|
+
player = plot.introduce
|
|
13
|
+
player.queue.concat commands
|
|
14
|
+
plot.ready
|
|
15
|
+
until player.queue.empty?
|
|
16
|
+
plot.update
|
|
17
|
+
plot.ready
|
|
18
|
+
end
|
|
19
|
+
expect(plot).to be_concluding
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../main'
|
|
4
|
+
|
|
5
|
+
RSpec.configure do |config|
|
|
6
|
+
# Run specs in random order to surface order dependencies. If you find an
|
|
7
|
+
# order dependency and want to debug it, you can fix the order by providing
|
|
8
|
+
# the seed, which is printed after each run.
|
|
9
|
+
# --seed 1234
|
|
10
|
+
# config.order = :random
|
|
11
|
+
|
|
12
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
|
13
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
|
14
|
+
# test failures related to randomization by passing the same `--seed` value
|
|
15
|
+
# as the one that triggered the failure.
|
|
16
|
+
# Kernel.srand config.seed
|
|
17
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gamefic-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Fred Snyder
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-07-
|
|
11
|
+
date: 2024-07-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: gamefic
|
|
@@ -242,16 +242,27 @@ files:
|
|
|
242
242
|
- scaffolds/library/lib/__name__.rb.gf.erb
|
|
243
243
|
- scaffolds/library/lib/__name__/version.rb.gf.erb
|
|
244
244
|
- scaffolds/project/.gitignore
|
|
245
|
-
- scaffolds/project
|
|
245
|
+
- scaffolds/project/.rspec.gf.erb
|
|
246
|
+
- scaffolds/project/Gemfile.gf.erb
|
|
246
247
|
- scaffolds/project/README.md.gf.erb
|
|
247
|
-
- scaffolds/project/Rakefile
|
|
248
|
+
- scaffolds/project/Rakefile.gf.erb
|
|
249
|
+
- scaffolds/project/lib/__name__.rb.gf.erb
|
|
248
250
|
- scaffolds/project/lib/__name__/plot.rb.gf.erb
|
|
249
251
|
- scaffolds/project/lib/__name__/subplot.rb.gf.erb
|
|
250
252
|
- scaffolds/project/main.rb.gf.erb
|
|
251
|
-
|
|
253
|
+
- scaffolds/project/spec/__name__/plot_spec.rb.gf.erb
|
|
254
|
+
- scaffolds/project/spec/__name__/subplot_spec.rb.gf.erb
|
|
255
|
+
- scaffolds/project/spec/gameplay_spec.rb
|
|
256
|
+
- scaffolds/project/spec/opal_helper.rb
|
|
257
|
+
- scaffolds/project/spec/shared_helper.rb
|
|
258
|
+
- scaffolds/project/spec/spec_helper.rb
|
|
259
|
+
homepage: https://gamefic.com
|
|
252
260
|
licenses:
|
|
253
261
|
- MIT
|
|
254
|
-
metadata:
|
|
262
|
+
metadata:
|
|
263
|
+
homepage_uri: https://gamefic.com
|
|
264
|
+
source_code_uri: https://github.com/castwide/gamefic-sdk
|
|
265
|
+
changelog_uri: https://github.com/castwide/gamefic-sdk/blob/master/CHANGELOG.md
|
|
255
266
|
post_install_message:
|
|
256
267
|
rdoc_options: []
|
|
257
268
|
require_paths:
|