inkcpp_rb 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b5890b2bbfe3d3c602e99799b9fd2fe650fdef4679bd42faeb6b8a7d9e08996
4
- data.tar.gz: 51a71c11f3584b110133d3285f4b7a7a7f249c9ad5a6155eee5999b1748878f5
3
+ metadata.gz: fc9836fdbf53db4e97756a16f1da5b5aaf2ceb687b5b0106625ef46dec583ee3
4
+ data.tar.gz: c31f75154ffb5e06f157954eeb84cadd52fa1455029a08aa3bdd3120134f583b
5
5
  SHA512:
6
- metadata.gz: f4e64b70c287fc7fd8e4e79e76d10d31b318abfcedf3e27a30ebe000247a55b1fdb93599ad6a4cd7cdc40da7035c3ebf4a8b4c3ec32533e2280d7ccfaa753a6f
7
- data.tar.gz: 41821d98ba8b4832325d8958e7e324d4218c77c6ef703aa64037cc5bd7028a55dff3629ed5cd5560667e7cc4791a7d0e2b1f2073cf4322fe45f87c5aaa2e052f
6
+ metadata.gz: c4000451548a7be40123e6be1f3293c62cb0575c78edef98842a6a62107798853b6cce24dbf849432ea771f8bd8e66a375c2cd37982fb224c0da576ade8abf49
7
+ data.tar.gz: 9cd7ce509dba7793eafc39e28503a93e9e8cdd31bf93de0be2eca35b334ffd405c543f95ee23c36297f0b97d25e580a0fb43e99203c46ecaa75a83f2c38c9013
data/CHANGELOG.md CHANGED
@@ -1 +1,4 @@
1
1
  0.1.0: Initial commit
2
+ 0.1.1: Adjust directory structure to fit Ruby norms
3
+ 0.1.2: Ensure Rice included as a dependency
4
+ 0.1.3: Fix typings for Ink::Story
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- inkcpp_rb (0.1.1)
4
+ inkcpp_rb (0.1.3)
5
+ rice (~> 4.3.3)
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
@@ -75,7 +76,6 @@ DEPENDENCIES
75
76
  minitest (~> 5.0)
76
77
  rake (~> 13.0)
77
78
  rake-compiler (~> 1.2.8)
78
- rice (~> 4.3.3)
79
79
  sorbet (~> 0.5.0)
80
80
  sorbet-runtime (~> 0.5.0)
81
81
  tapioca (~> 0.16.0)
data/README.md CHANGED
@@ -1,3 +1,19 @@
1
- # Ink RB
1
+ # InkCPP RB
2
2
 
3
3
  These are bindings for the InkCPP project in Ruby. They largely follow the same patterns as the official Python bindings, with a few small divergences.
4
+
5
+ Install:
6
+
7
+ ```
8
+ bundle add inkcpp_rb
9
+ ```
10
+
11
+ Sorbet typings are included.
12
+
13
+ ## REQUIREMENTS
14
+
15
+ In order to install this gem your destination must have `cmake` installed as well as have a functioning C++ compilation toolchain.
16
+
17
+ ## WARNING
18
+
19
+ This gem has largely been developed for my own purposes. I am not yet confident enough in the memory semantics between Rice and InkCPP to say that this is leak free or safe to use in any important environment. If you do use this gem, I strongly suggest you use it in situations where you are not parsing untrusted user input or anything like that.
data/bin/console CHANGED
@@ -4,12 +4,6 @@
4
4
  require "bundler/setup"
5
5
  require "inkcpp_rb"
6
6
 
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require "pry"
12
- # Pry.start
13
7
 
14
8
  require "irb"
15
9
  IRB.start(__FILE__)
data/bin/inkplay.rb ADDED
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ # typed: true
4
+ require "bundler/setup"
5
+ require "inkcpp_rb"
6
+ require "tempfile"
7
+ require "sorbet-runtime"
8
+
9
+ inklecate_path = %x{which inklecate}.chomp
10
+ raise "inklecate binary must be in your PATH - see https://github.com/inkle/ink/releases" if inklecate_path.empty?
11
+
12
+ story_path = ARGV[0]
13
+ raise "Must specify a story path" if story_path.nil? || story_path.empty?
14
+
15
+ file = Tempfile.new("inkplay.ink")
16
+ path = file.path
17
+ output = %x{inklecate -o #{path} #{story_path}}
18
+ raise "Could not compile ink json: #{output.inspect}" unless $?.success?
19
+ json_contents = File.read(T.must(path))
20
+ compiled = Ink.compile_json(json_contents)
21
+ story = T.must(Ink::Story.from_binary(compiled))
22
+ runner = T.must(story.new_runner(nil).get)
23
+ while true
24
+ puts runner.getline
25
+ if runner.num_choices > 0
26
+ all_choices = runner.each_choice.to_a
27
+ all_choices.each do |choice|
28
+ puts "#{choice.index}. #{choice.text}"
29
+ end
30
+ puts "Which choice?"
31
+ choice_num = STDIN.readline.chomp.to_i
32
+ chosen = all_choices.detect { |choice| choice.index == choice_num }
33
+ if chosen
34
+ runner.choose(choice_num - 1)
35
+ break if !runner.can_continue
36
+ end
37
+ end
38
+ end
39
+ puts "END"
data/bin/setup CHANGED
@@ -7,4 +7,3 @@ bundle install
7
7
  git submodule init
8
8
  git submodule update
9
9
 
10
- # Do any other automated setup that you need to do here
data/inkcpp_rb.gemspec CHANGED
@@ -12,6 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = "inkcpp bindings in Ruby"
13
13
  spec.homepage = "https://git.sr.ht/~netshade/inkcpp_rb"
14
14
  spec.required_ruby_version = ">= 2.6.0"
15
+ spec.requirements << "cmake"
15
16
 
16
17
  spec.metadata["allowed_push_host"] = "https://rubygems.org/"
17
18
 
@@ -19,8 +20,6 @@ Gem::Specification.new do |spec|
19
20
  spec.metadata["source_code_uri"] = "https://git.sr.ht/~netshade/inkcpp_rb"
20
21
  spec.metadata["changelog_uri"] = "https://git.sr.ht/~netshade/inkcpp_rb/tree/main/item/CHANGELOG.md"
21
22
 
22
- # Specify which files should be added to the gem when it is released.
23
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
23
  submodules = %w{inkcpp}
25
24
  submodule_files = submodules.flat_map do |module_name|
26
25
  base_submodule_path = File.join("ext", "inkcpp_rb", module_name)
@@ -41,15 +40,10 @@ Gem::Specification.new do |spec|
41
40
  spec.require_paths = ["lib"]
42
41
  spec.extensions = ["ext/inkcpp_rb/extconf.rb"]
43
42
 
44
- # Uncomment to register a new dependency of your gem
45
- # spec.add_dependency "example-gem", "~> 1.0"
43
+ spec.add_dependency "rice", "~> 4.3.3"
46
44
  spec.add_development_dependency "rake-compiler", "~> 1.2.8"
47
- spec.add_development_dependency "rice", "~> 4.3.3"
48
45
  spec.add_development_dependency "sorbet", "~> 0.5.0"
49
46
  spec.add_development_dependency "sorbet-runtime", "~> 0.5.0"
50
47
  spec.add_development_dependency "tapioca", "~> 0.16.0"
51
48
  spec.add_development_dependency "debug", "~> 1.1.0"
52
-
53
- # For more information and examples about making a new gem, check out our
54
- # guide at: https://bundler.io/guides/creating_gem.html
55
49
  end
@@ -1,3 +1,3 @@
1
1
  module InkcppRb
2
- VERSION = "0.1.1"
3
- end
2
+ VERSION = "0.1.3"
3
+ end
data/rbi/inkcpp_rb.rbi CHANGED
@@ -201,15 +201,15 @@ module Ink
201
201
  def self.from_binary(data); end
202
202
 
203
203
  sig { returns(T.nilable(Ink::StoryImpl)) }
204
- def self.new_globals(); end
204
+ def new_globals(); end
205
205
 
206
206
  sig { params(globals: T.nilable(Ink::StoryImpl)).returns(Ink::RunnerImpl) }
207
- def self.new_runner(globals); end
207
+ def new_runner(globals); end
208
208
 
209
209
  sig { params(snapshot: Ink::Snapshot).returns(Ink::StoryImpl) }
210
- def self.new_globals_from_snapshot(snapshot); end
210
+ def new_globals_from_snapshot(snapshot); end
211
211
 
212
212
  sig { params(snapshot: Ink::Snapshot, globals: T.nilable(Ink::StoryImpl), index: Integer).returns(Ink::StoryImpl) }
213
- def self.new_runner_from_snapshot(snapshot, globals, index); end
213
+ def new_runner_from_snapshot(snapshot, globals, index); end
214
214
  end
215
215
  end
metadata CHANGED
@@ -1,42 +1,42 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inkcpp_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Zelenak
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-01-10 00:00:00.000000000 Z
10
+ date: 2025-01-12 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
- name: rake-compiler
13
+ name: rice
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 1.2.8
19
- type: :development
18
+ version: 4.3.3
19
+ type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
- version: 1.2.8
25
+ version: 4.3.3
26
26
  - !ruby/object:Gem::Dependency
27
- name: rice
27
+ name: rake-compiler
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
30
  - - "~>"
31
31
  - !ruby/object:Gem::Version
32
- version: 4.3.3
32
+ version: 1.2.8
33
33
  type: :development
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 4.3.3
39
+ version: 1.2.8
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: sorbet
42
42
  requirement: !ruby/object:Gem::Requirement
@@ -109,6 +109,7 @@ files:
109
109
  - README.md
110
110
  - Rakefile
111
111
  - bin/console
112
+ - bin/inkplay.rb
112
113
  - bin/setup
113
114
  - bin/tapioca
114
115
  - ext/inkcpp_rb/extconf.rb
@@ -395,7 +396,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
395
396
  - - ">="
396
397
  - !ruby/object:Gem::Version
397
398
  version: '0'
398
- requirements: []
399
+ requirements:
400
+ - cmake
399
401
  rubygems_version: 3.6.2
400
402
  specification_version: 4
401
403
  summary: inkcpp bindings in Ruby