tardvig 0.2.2 → 0.3.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/lib/tardvig/events/proxy.rb +1 -1
- data/lib/tardvig/toolkit.rb +13 -2
- data/lib/tardvig/version.rb +1 -1
- data/lib/tardvig.rb +0 -1
- metadata +2 -3
- data/lib/tardvig/saved_hash.rb +0 -53
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fe9a037789dc356015bea0018bb8ccb44a2dd5a
|
4
|
+
data.tar.gz: 4e2ec2d70b2069aafac8e5ef61656cf6ed82315b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4dc93d728efe0f10383979bf0b8c2026a0b501f163bfe821c0a34c70e34700c15b9207e21ca44a159081b2851919f0c2638f786ad59037654305d15400feb567
|
7
|
+
data.tar.gz: 45e1c052c8be479026378f558e8f4743278c5386109d979422bd1cd9b63375336c8fc683515a06c0a46727a739501c1852b90dceef83f5be0b8953bf67fb7599
|
data/lib/tardvig/events/proxy.rb
CHANGED
data/lib/tardvig/toolkit.rb
CHANGED
@@ -22,10 +22,21 @@ module Tardvig
|
|
22
22
|
end
|
23
23
|
|
24
24
|
# Creates a new toolbox instance and initializes its tools.
|
25
|
-
# @param params [Hash]
|
25
|
+
# @param params [Hash] you can set some options (see below) via this hash.
|
26
|
+
# It also will be available as the second argument passed to
|
26
27
|
# the `call` methods of your tools.
|
28
|
+
# @option params [boolean] :initialize_tools (true) initialize tools or not?
|
29
|
+
# If not, you will not able to use them, but you can initialize them
|
30
|
+
# later (see {#create_tools}).
|
27
31
|
def initialize(params = {})
|
28
|
-
|
32
|
+
default_params = { initialize_tools: true }
|
33
|
+
@params = default_params.merge params
|
34
|
+
create_tools if @params[:initialize_tools]
|
35
|
+
end
|
36
|
+
|
37
|
+
# You can create tools to use them through this method if you have not done
|
38
|
+
# this on toolkit initialize.
|
39
|
+
def create_tools
|
29
40
|
create_tools_readers
|
30
41
|
end
|
31
42
|
|
data/lib/tardvig/version.rb
CHANGED
data/lib/tardvig.rb
CHANGED
@@ -3,7 +3,6 @@ require 'yaml'
|
|
3
3
|
require_relative 'tardvig/version.rb'
|
4
4
|
require_relative 'tardvig/events.rb'
|
5
5
|
require_relative 'tardvig/command.rb'
|
6
|
-
require_relative 'tardvig/saved_hash.rb'
|
7
6
|
require_relative 'tardvig/toolkit.rb'
|
8
7
|
require_relative 'tardvig/gameio.rb'
|
9
8
|
require_relative 'tardvig/act.rb'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tardvig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vadim Saprykin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -85,7 +85,6 @@ files:
|
|
85
85
|
- lib/tardvig/events/proxy.rb
|
86
86
|
- lib/tardvig/gameio.rb
|
87
87
|
- lib/tardvig/hash_container.rb
|
88
|
-
- lib/tardvig/saved_hash.rb
|
89
88
|
- lib/tardvig/toolkit.rb
|
90
89
|
- lib/tardvig/version.rb
|
91
90
|
homepage: https://github.com/sprkweb/tardvig
|
data/lib/tardvig/saved_hash.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
module Tardvig
|
2
|
-
# This is a hash which can be saved to a file (via YAML). It also has some
|
3
|
-
# events.
|
4
|
-
#
|
5
|
-
# It is useful for progress saving, configuration and settings files,
|
6
|
-
# localization files and many other things.
|
7
|
-
#
|
8
|
-
# Events:
|
9
|
-
# * `save` happen before saving data to a file. Arguments: the hash itself
|
10
|
-
# * `load` happen after loading data from a file. Arguments: the hash itself
|
11
|
-
#
|
12
|
-
# @deprecated Use HashContainer instead.
|
13
|
-
class SavedHash < Hash
|
14
|
-
include Events
|
15
|
-
|
16
|
-
def initialize(io = nil)
|
17
|
-
load io unless io.nil?
|
18
|
-
end
|
19
|
-
|
20
|
-
# Save the hash to the file through YAML
|
21
|
-
# @param io [IO, String] the IO instance or the name of the file.
|
22
|
-
# The data will be saved here.
|
23
|
-
def save(io)
|
24
|
-
open_file io, 'w' do |f|
|
25
|
-
trigger :save, self
|
26
|
-
f.write YAML.dump(self)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# Loads the data from the YAML file to itself. If there are old data in the
|
31
|
-
# hash, it overrides them.
|
32
|
-
# @param io [IO, String] the IO instance or the name of the file.
|
33
|
-
# The data will be loaded from here.
|
34
|
-
def load(io)
|
35
|
-
open_file io, 'r' do |f|
|
36
|
-
merge! YAML.load(f.read)
|
37
|
-
trigger :load, self
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
def open_file(io, mode)
|
44
|
-
if io.respond_to?(:read) && io.respond_to?(:write)
|
45
|
-
yield io
|
46
|
-
elsif io.is_a? String
|
47
|
-
File.open(io, mode) { |f| yield f }
|
48
|
-
else
|
49
|
-
raise ArgumentError
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|