hitsuji 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hitsuji.rb +7 -76
  3. data/lib/subsystem.rb +0 -3
  4. metadata +12 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3912e8f0e280fa4d52a32b4e0bca248effd6f2f4e40fffc204b34b33f848219
4
- data.tar.gz: d74c445355211b3e8b391cb685b9d99cf6f3ce9d7f2c5b411239e115894b554c
3
+ metadata.gz: b084cd337a2aa754de2f5f8b0448964e30e1d352b7a59b7172f5817f89a7caf1
4
+ data.tar.gz: e8498e02136c8b754d37c96826bd84bb8f96da8fa7e17005f1af2eed34bbd66a
5
5
  SHA512:
6
- metadata.gz: 6fa911f19e45220bdee43a983b71b9c5af65b772facf572c053801c78e8500492e4f8007ab162ed79443684d2ce3f8ee37c4dd55410fbbac8382d6c57bde4388
7
- data.tar.gz: cae1ac537c14570d5a674e62969d674694c6612ea590872f882ee6ecd6ddc925aebc637f381ccfb49767fed4f3c96004c241627d40ba9e407855930d3af14bc7
6
+ metadata.gz: ce02e589408a6d7845a15d8aa11f231ed9d14056d369dd39dbbbc95286c393e73a1d3b218560e764edfe21b4d5d327b4040a1f36e71734fcca13c83082628e36
7
+ data.tar.gz: '09061782dc349c041754b64ed05d1cfaf2fad6badbcc34a9f2befcfa5c1cf13997cd3d39a6a0c74c54f42e1589d822142f5f04c15395c2d9d8cc0e2f0e737d53'
@@ -1,5 +1,6 @@
1
1
  require_relative 'transfer.rb'
2
2
  require_relative 'subsystem.rb'
3
+ require_relative 'control.rb'
3
4
 
4
5
  # The Hitsuji class is the interface to this module, and it contains
5
6
  # all the functions you need. Examples using this class can be found in the
@@ -101,7 +102,8 @@ class Hitsuji
101
102
  # my_system.bind(my_item, my_item2, my_linker) # binds items + linker
102
103
  def bind(*obj)
103
104
  @struct.concat obj
104
- update @struct
105
+ Control.update @struct
106
+ @metadata[:date_edited] = `date`
105
107
  end
106
108
 
107
109
  # Exports the current state of the system to a file. This process *does not*
@@ -138,7 +140,7 @@ class Hitsuji
138
140
  # my_system.import('oldfile.hitsuji') # imports 'oldfile.txt'
139
141
  def import(directory)
140
142
  @struct, @metadata = Transfer.import(directory)
141
- update @struct
143
+ Control.update @struct
142
144
  end
143
145
 
144
146
  # Finds a bound object in the system by name, and returns the object if it
@@ -154,7 +156,7 @@ class Hitsuji
154
156
  # my_system.import('oldfile.hitsuji') # imports 'oldfile.txt'
155
157
  # my_item = my_system.find(:foo) # finds an item
156
158
  def find(query)
157
- get(query, @struct, nil, false)
159
+ Control.get(query, @struct, nil, false)
158
160
  end
159
161
 
160
162
  # Finds a bound object in the system by name, edits the object if it exists,
@@ -171,7 +173,7 @@ class Hitsuji
171
173
  # my_system.import('oldfile.hitsuji') # imports 'oldfile.txt'
172
174
  # my_item = my_system.edit(:foo, 'bar') # changes an item
173
175
  def edit(query, value)
174
- get(query, @struct, value, false)
176
+ Control.get(query, @struct, value, false)
175
177
  end
176
178
 
177
179
  # Finds a bound object in the system by name, removes it if it exists, and
@@ -187,77 +189,6 @@ class Hitsuji
187
189
  # my_system.import('oldfile.hitsuji') # imports 'oldfile.txt'
188
190
  # my_item = my_system.remove(:foo) # removes an item
189
191
  def remove(query)
190
- get(query, @struct, nil, true)
192
+ Control.get(query, @struct, nil, true)
191
193
  end
192
-
193
- #--
194
- # BEGINNING OF FUCKED UP FUNCTIONS
195
- #++
196
-
197
- # Updates state of system to monitor name usageand dependencies on operations.
198
- # This is run every time Hitsuji.bind or Hitsuji.import is run.
199
- #
200
- # ==== Attributes
201
- #
202
- # * +obj+ - the object to update (usually @struct)
203
- #
204
- # ==== Example
205
- #
206
- # class MyHitsuji < Hitsuji # creates dependent class
207
- # def linker_update # my new special function!
208
- # @struct.each do |i|
209
- # update(@struct) if i.class == Linker # uses update function
210
- # end
211
- # end
212
- # end
213
- def update(obj)
214
- names = []
215
- obj.each do |i|
216
- throw 'err' unless i.name.nil? || !names.include?(i.name)
217
- names << update(i.value) if i.class == Linker
218
- end
219
-
220
- @metadata[:date_edited] = `date`
221
- names
222
- end
223
-
224
- # Gets value of item from @struct and returns it. It can perform additional
225
- # operations such as editing and removal.
226
- #
227
- # ==== Attributes
228
- #
229
- # * +query+ - the name of the object to perform the actions on
230
- # * +obj+ - the object to search in (usually @struct)
231
- # * +edit+ - the edit to make to the object (nil if not)
232
- # * +remove+ - whether to remove the object (false if not)
233
- #
234
- # ==== Example
235
- #
236
- # class MyHitsuji < Hitsuji # creates dependent class
237
- # def remove_from_linkers(query) # my new special function!
238
- # @struct.each do |i|
239
- # if i.class == Linker
240
- # get(query, @struct, nil, true) # uses get function
241
- # end
242
- # end
243
- # end
244
- # end
245
- def get(query, obj, edit, remove)
246
- answer = nil
247
- obj.each do |i|
248
- if i.name == query
249
- answer = i
250
- if edit
251
- i.value = edit
252
- elsif remove
253
- i.name = nil
254
- end
255
- elsif i.class == Linker
256
- answer = view(query, i.value, edit, remove)
257
- end
258
- end
259
- answer
260
- end
261
-
262
- private :update, :get
263
194
  end
@@ -3,7 +3,6 @@
3
3
  # Item is bound, a seperate method must be used to read and change it. Examples
4
4
  # of its use can be seen in the documentation for the Hitsuji.item method.
5
5
  class Item
6
- # @private
7
6
  def initialize(name, value)
8
7
  @name = name
9
8
  @value = value
@@ -19,7 +18,6 @@ end
19
18
  # Examples of its use can be seen in the documentation for the Hitsuji.linker
20
19
  # method.
21
20
  class Linker
22
- # @private
23
21
  def initialize(name, value)
24
22
  @name = name
25
23
  @value = value
@@ -37,7 +35,6 @@ end
37
35
  # between Items and Operations. Examples of its use can be seen in the
38
36
  # documentation for the Hitsuji.operation method.
39
37
  class Operation
40
- # @private
41
38
  def initialize(name, input, block)
42
39
  @name = name
43
40
  @input = input
metadata CHANGED
@@ -1,20 +1,23 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hitsuji
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Quail
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-23 00:00:00.000000000 Z
11
+ date: 2019-02-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |-
14
- Hitsuji is a library that lets you easily create, edit,
15
- manage and apply custom management systems. It is scalable from library card
16
- databases to performance analysis all the way to complete content management
17
- systems (like Wordpress.com).
14
+ Hitsuji is a library that implements a tree data structure,
15
+ where each node is represented by a value, points to other values, or performs
16
+ a function on some values. When the tree is updated, the inputs to the
17
+ functions will change, hence changing the outputs, eventually propagating the
18
+ update through the entire tree. Data structures can also be exported to disk,
19
+ allowing for wide applications of this software, e.g. handling big data,
20
+ managing content, etc.
18
21
  email: josh@madbean.com
19
22
  executables:
20
23
  - hitsuji
@@ -31,7 +34,7 @@ licenses:
31
34
  metadata:
32
35
  source_code_uri: https://github.com/realtable/hitsuji
33
36
  bug_tracker_uri: https://github.com/realtable/hitsuji/issues
34
- documentation_uri: https://www.rubydoc.info/gems/hitsuji/0.2.1
37
+ documentation_uri: https://www.rubydoc.info/gems/hitsuji/0.2.2
35
38
  post_install_message:
36
39
  rdoc_options: []
37
40
  require_paths:
@@ -47,9 +50,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
47
50
  - !ruby/object:Gem::Version
48
51
  version: '0'
49
52
  requirements: []
50
- rubyforge_project:
51
- rubygems_version: 2.7.7
53
+ rubygems_version: 3.0.2
52
54
  signing_key:
53
55
  specification_version: 4
54
- summary: A utility for creating custom management systems.
56
+ summary: A utility in Ruby for tree data structures with functions.
55
57
  test_files: []