tardvig 0.2.2 → 0.3.0

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
  SHA1:
3
- metadata.gz: 9e5efc7f9212fc72c23ca3e0eb60ea50c41370b7
4
- data.tar.gz: b471b0c34344b11fa98c475a18aebcac5ec20ea9
3
+ metadata.gz: 1fe9a037789dc356015bea0018bb8ccb44a2dd5a
4
+ data.tar.gz: 4e2ec2d70b2069aafac8e5ef61656cf6ed82315b
5
5
  SHA512:
6
- metadata.gz: 861878ba9b5a3fb3cc2cfd77dd3f3d6f6caab5dfd3c7ed805cc0866f89a43f60a9b4a50938fab37f7ef1ba7769f23d4976c9aa80914c5633c6b56ba9beeba626
7
- data.tar.gz: 8a696bb84b3e59391b8fd087ff3ff454f8cb732e6ca66fe0bf934ff48f1ea8acfc58dd806aaf636fd30addcabc3fb2400f37129a52150a0a45cc63fcdcdea857
6
+ metadata.gz: 4dc93d728efe0f10383979bf0b8c2026a0b501f163bfe821c0a34c70e34700c15b9207e21ca44a159081b2851919f0c2638f786ad59037654305d15400feb567
7
+ data.tar.gz: 45e1c052c8be479026378f558e8f4743278c5386109d979422bd1cd9b63375336c8fc683515a06c0a46727a739501c1852b90dceef83f5be0b8953bf67fb7599
@@ -6,7 +6,7 @@ module Tardvig
6
6
  # from a display.
7
7
  module Proxy
8
8
  # Adds objects to tracked list so you can bind proxy listeners to them
9
- # @param [Hash] name => object pairs.
9
+ # @param [Hash] `name: object` pairs.
10
10
  def spy_on(objects)
11
11
  tracked_list.merge! objects
12
12
  end
@@ -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] it will be available as the second argument passed to
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
- @params = params
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
 
@@ -1,3 +1,3 @@
1
1
  module Tardvig
2
- VERSION = '0.2.2'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
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.2.2
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-27 00:00:00.000000000 Z
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
@@ -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