shrift 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ffd10c8e7f662dcd01939712e0f864dd5b6e159
4
- data.tar.gz: 12153ba532ac676cfa55daeb6b017822c6427831
3
+ metadata.gz: e4bfec4ab473bf34570817c08cc69a55c2768bb9
4
+ data.tar.gz: 3a23d7520579fdb6f9cdd3a407f5ba10ed4bc51e
5
5
  SHA512:
6
- metadata.gz: 939ae77dd4dc6b30b350b6d9bd4467d5533d61a8b9ea6a3d891370eb6ffe402d83acff3edce152dfd7c3d006082225d6783b423053c7db4aa2dceb19067b2ad8
7
- data.tar.gz: 39c347c5b630b14d98a6a623ed4b3aae6ad65593d4195b39de7e993a62f0ecc2a6974e16bed2960cbfb2a6e771c9c5284455037859b1c4c0403b5fee61a5397a
6
+ metadata.gz: 8f8d933bb61710667bf5fc28dd87fd99513a3f4b26aac25910077499254d13221304db858244a231b9f6d6f6af0bab38861705906c2bea3868904b649fa3721f
7
+ data.tar.gz: 8ce25d22f9767651723117765a5cfbd72f3b1354a03d12da2b7c2212440cdec2045a79bb79ece918bcf569d8ba4fd9d50584a76902f8562a3284f5c51340c95e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shrift (0.0.1)
4
+ shrift (0.0.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Shrift
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/shrift.svg)](https://badge.fury.io/rb/shrift)
3
4
  [![Build Status](https://travis-ci.org/folkengine/shrift.svg?branch=master)](https://travis-ci.org/folkengine/shrift)
4
5
 
5
6
  Makes short shrift of objects.
@@ -10,6 +11,18 @@ This is alpha software and only works with basic Objects.
10
11
 
11
12
  Shrift is a simple DSL generator that turns Objects to single line Strings for easy storage and debugging.
12
13
 
14
+ An example 'Shrift String' would be:
15
+
16
+ example:st15dx14cn10w18i3ch6:4
17
+
18
+ When you split the String on ':', this first cell is a String, the second cell is a 'Shrift Map' of alternating
19
+ field shorthand Strings and integers, and the third cell maps to an integer.
20
+
21
+ Pass this String back into the Shrift object configured to make short shrift of the class and it will return the Object,
22
+ good as new.
23
+
24
+ I created this so that I had a way to pack as much informational punch into as short a space as possible.
25
+
13
26
  ## Installation
14
27
 
15
28
  Add this line to your application's Gemfile:
@@ -6,24 +6,24 @@ require_relative 'shrift_exception'
6
6
  # Shrift map keys are lowercase.
7
7
  #
8
8
  class ShriftMap
9
- attr_reader :hashmap, :shrift_map_string
9
+ attr_reader :schema, :shrift_map_string
10
10
 
11
11
  def initialize(shrift_map_string)
12
12
  @shrift_map_string = shrift_map_string
13
- @hashmap = {}
13
+ @schema = {}
14
14
  split(shrift_map_string)
15
15
  end
16
16
 
17
17
  def fetch(key)
18
- @hashmap[key.downcase.to_sym].to_i
18
+ @schema[key.downcase.to_sym].to_i
19
19
  end
20
20
 
21
21
  def store(key, value)
22
- @hashmap[key.downcase.to_sym] = value.to_i
22
+ @schema[key.downcase.to_sym] = value.to_i
23
23
  end
24
24
 
25
25
  def to_hash
26
- @hashmap
26
+ @schema
27
27
  end
28
28
 
29
29
  def to_s
@@ -2,38 +2,38 @@ require_relative 'shrift_map'
2
2
 
3
3
  # I map ShriftMaps
4
4
  class ShriftMapper
5
- attr_reader :hashmap
5
+ attr_reader :schema
6
6
 
7
- def initialize(hashmap: {})
8
- @hashmap = hashmap
7
+ def initialize(schema: {})
8
+ @schema = schema
9
9
  clean
10
10
  end
11
11
 
12
12
  def fetch(key)
13
- @hashmap[key.downcase.to_sym]
13
+ @schema[key.downcase.to_sym]
14
14
  end
15
15
 
16
16
  def store(key, value)
17
- @hashmap[key] = value
17
+ @schema[key] = value
18
18
  end
19
19
 
20
20
  def parse(shrift_map_string)
21
21
  hash = {}
22
- ShriftMap.new(shrift_map_string).hashmap.each do |key, val|
23
- hash[@hashmap[key]] = val
22
+ ShriftMap.new(shrift_map_string).schema.each do |key, val|
23
+ hash[@schema[key]] = val
24
24
  end
25
25
  hash
26
26
  end
27
27
 
28
28
  def to_hash
29
- @hashmap
29
+ @schema
30
30
  end
31
31
 
32
32
  # :reek:UncommunicativeVariableName :reek:FeatureEnvy
33
33
  def to_shrift_string(mappie)
34
34
  return mappie if mappie.is_a?(String)
35
- return mappie.map { |k, v| @hashmap.key(k).to_s.downcase + v.to_s }.join if mappie.is_a?(Hash)
36
- @hashmap.map { |k, v| k.to_s.downcase + mappie.send(v).to_s }.join
35
+ return mappie.map { |k, v| @schema.key(k).to_s.downcase + v.to_s }.join if mappie.is_a?(Hash)
36
+ @schema.map { |k, v| k.to_s.downcase + mappie.send(v).to_s }.join
37
37
  end
38
38
 
39
39
  def to_shrift_map(mappie)
@@ -49,13 +49,13 @@ class ShriftMapper
49
49
  # :reek:UncommunicativeVariableName
50
50
  def set(value, target)
51
51
  shrift_map = to_shrift_map(value)
52
- @hashmap.map { |k, v| target.send("#{v}=", shrift_map.fetch(k)) }
52
+ @schema.map { |k, v| target.send("#{v}=", shrift_map.fetch(k)) }
53
53
  end
54
54
 
55
55
  private
56
56
 
57
57
  # Convert Hash keys to symbols
58
58
  def clean
59
- @hashmap = Hash[@hashmap.map { |key, value| [key.downcase.to_sym, value] }]
59
+ @schema = Hash[@schema.map { |key, value| [key.downcase.to_sym, value] }]
60
60
  end
61
61
  end
@@ -1,3 +1,3 @@
1
1
  class ShriftVersion
2
- VERSION = '0.0.1'.freeze
2
+ VERSION = '0.0.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shrift
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Folkengine
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-04 00:00:00.000000000 Z
11
+ date: 2016-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler