format_engine 0.0.2 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 53a90dc85e96a48d8f1b469ef5749f63102a4230
4
- data.tar.gz: 6555ef6261b11cd7feb5fe996b3e5143d593271b
3
+ metadata.gz: 9763561c83301a57758ba138e2a5e1baceaa9bd2
4
+ data.tar.gz: a358fc3401bc95e897b7eb3470e3a0583d1699d7
5
5
  SHA512:
6
- metadata.gz: 9bd665882c88cdb9ed4acb2e6bed688a3b69585630a74425e2fc14e15a098ebb36899dd609d1c5680ffcb89a68c61390ee808dbfb4535837624f4945fa26c636
7
- data.tar.gz: a726f4166591fe0683275b35eec562e4d4f9baadbdbe8f14c41e780736add9b38922941e4efedce6ffcc2e853fd3cec9bb5a1b5398d7d0fe32a21e72d88221eb
6
+ metadata.gz: 87ae5fcb562aa0a10b91dd6f7d599f8b50154e445e4fe56b62833e0d8d0e673cd49cca5295e24d86f0dbdfce542aabad41111e8688b7bc7462b2333c1043c995
7
+ data.tar.gz: 4894677c3a40eacf60946cf13b4d10e8d71a441283b81f5a2b7529a1d6a9cbe8fd08cd7992e614f67c58dc982a2158a4f53572313a612d5b4db5639b7e670abe
data/README.md CHANGED
@@ -54,9 +54,9 @@ class Customer
54
54
 
55
55
  #Demo defn of the strprs method for formatted string input!
56
56
  attr_parser :strprs,
57
- {"%f" => lambda { hsh[:fn] = found if parse(/(\w)+/ ) },
58
- "%l" => lambda { hsh[:ln] = found if parse(/(\w)+/ ) },
59
- :after => lambda { set dst.new(hsh[:fn], hsh[:ln]) } }
57
+ {"%f" => lambda { tmp[:fn] = found if parse(/(\w)+/ ) },
58
+ "%l" => lambda { tmp[:ln] = found if parse(/(\w)+/ ) },
59
+ :after => lambda { set dst.new(tmp[:fn], tmp[:ln]) } }
60
60
 
61
61
  #Create an instance of the demo customer.
62
62
  def initialize(first_name, last_name)
@@ -81,19 +81,22 @@ agent = Customer.strprs(in_str, "%f, %l")
81
81
 
82
82
  Format String Specification Syntax (BNF):
83
83
 
84
- * spec = { text | item }+
85
- * item = "%" {flag}* {parm {"." parm}?}? {command}
86
- * flag = { "~" | "@" | "#" | "&" | "^" |
84
+ * spec = ( text | item )+
85
+ * item = "%" flag* (parm ("." parm)?)? command
86
+ * flag = ( "~" | "@" | "#" | "&" | "^" |
87
87
  "&" | "*" | "-" | "+" | "=" |
88
88
  "?" | "_" | "<" | ">" | "\\" |
89
- "/" | "." | "," | "|" | "!" }
90
- * parm = { "0" .. "9" }+
91
- * command = { "a" .. "z" | "A" .. "Z" }
89
+ "/" | "." | "," | "|" | "!" )
90
+ * parm = ("0" .. "9")+
91
+ * command = ("a" .. "z" | "A" .. "Z")
92
92
 
93
93
 
94
- ###Sample:
94
+ ###Samples:
95
95
 
96
- The format specification "Elapsed = %*02H:%M:%5.2S!"
96
+ The format specification:
97
+ ```ruby
98
+ "Elapsed = %*02H:%M:%5.2S!"
99
+ ```
97
100
  creates the following format specification array:
98
101
 
99
102
  ```ruby
@@ -123,11 +126,11 @@ Attributes:
123
126
  * dst - A string that receives the formatted output (RO).
124
127
  * fmt - The format specification currently being processed (RW).
125
128
  * engine - The formatting engine. Mostly for access to the library (RO).
126
- * hsh - A utility hash so that the formatting process can retain state (RO).
129
+ * tmp - A utility hash so that the formatting process can retain state (RO).
127
130
 
128
131
  Methods
129
132
  * cat - Append the string that follows to the formatted output. This is
130
- equivalent to dst << "string"
133
+ equivalent to the code dst << "string"
131
134
 
132
135
  ###When Parsing:
133
136
  Attributes:
@@ -135,7 +138,7 @@ Attributes:
135
138
  * dst - The class of the object being created (RO).
136
139
  * fmt - The parse specification currently being processed (RW).
137
140
  * engine - The parsing engine. Mostly for access to the library (RO).
138
- * hsh - A utility hash so that the parsing process can retain state RO.
141
+ * tmp - A utility hash so that the parsing process can retain state (RO).
139
142
 
140
143
  Methods
141
144
  * set - Set the return value of the parsing operation to the value that follows.
@@ -162,8 +165,20 @@ most welcomed.
162
165
 
163
166
  ## Contributing
164
167
 
168
+ #### Plan A
169
+
165
170
  1. Fork it ( https://github.com/[my-github-username]/format_engine/fork )
166
171
  2. Create your feature branch (`git checkout -b my-new-feature`)
167
172
  3. Commit your changes (`git commit -am 'Add some feature'`)
168
173
  4. Push to the branch (`git push origin my-new-feature`)
169
174
  5. Create a new Pull Request
175
+
176
+ #### Plan B
177
+
178
+ Go to the GitHub repository and raise an issue calling attention to some
179
+ aspect that could use some TLC or a suggestion or idea. Apply labels to
180
+ the issue that match the point you are trying to make. Then follow your
181
+ issue and keep up-to-date as it is worked on. Or not as pleases you.
182
+ All input are greatly appreciated.
183
+
184
+
@@ -2,15 +2,16 @@ require_relative 'format_spec/literal'
2
2
  require_relative 'format_spec/variable'
3
3
 
4
4
  # Format String Specification Syntax (BNF):
5
- # spec = { text | item }+
6
- # item = "%" {flag}* {parm {"." parm}?}? {command}
7
- # flag = { "~" | "@" | "#" | "&" | "^" |
5
+ # spec = (text | item)+
6
+ # item = "%" flag* (parm ("." parm)? )? command
7
+ # flag = ( "~" | "@" | "#" | "&" | "^" |
8
8
  # "&" | "*" | "-" | "+" | "=" |
9
9
  # "?" | "_" | "<" | ">" | "\\" |
10
- # "/" | "." | "," | "|" | "!" }
11
- # parm = { "0" .. "9" }+
12
- # command = { "a" .. "z" | "A" .. "Z" }
13
- # Sample: x = FormatSpec.get_spec "Elapsed = %*03.1H:%M:%S!"
10
+ # "/" | "." | "," | "|" | "!" )
11
+ # parm = ("0" .. "9" )+
12
+ # command = ("a" .. "z" | "A" .. "Z")
13
+ #
14
+ # Sample: x = FormatSpec.get_spec "Elapsed = %*3.1H:%02M!"
14
15
 
15
16
  module FormatEngine
16
17
 
@@ -11,7 +11,7 @@ module FormatEngine
11
11
  #* dst - A string that receives the formatted output.
12
12
  #* fmt - The format specification currently being processed.
13
13
  #* engine - The formatting engine. Mostly for access to the library.
14
- #* hsh - A utility hash so that the formatting process can retain state.
14
+ #* tmp - A utility hash so that the formatting process can retain state.
15
15
  #<br>Methods
16
16
  #* cat - Append the string that follows to the formatted output.
17
17
  #<br>
@@ -20,7 +20,7 @@ module FormatEngine
20
20
  #* dst - The class of the object being created.
21
21
  #* fmt - The parse specification currently being processed.
22
22
  #* engine - The parsing engine. Mostly for access to the library.
23
- #* hsh - A utility hash so that the parsing process can retain state.
23
+ #* tmp - A utility hash so that the parsing process can retain state.
24
24
  #<br>Methods
25
25
  #* set - Set the return value of the parsing operation to the value that follows.
26
26
  #* parse - Look for the string or regex parm that follows. Return the data found or nil.
@@ -30,14 +30,14 @@ module FormatEngine
30
30
  class SpecInfo
31
31
 
32
32
  # General readers
33
- attr_reader :src, :dst, :engine, :hsh
33
+ attr_reader :src, :dst, :engine, :tmp
34
34
 
35
35
  #General accessors
36
36
  attr_accessor :fmt
37
37
 
38
38
  # Set up the spec info.
39
- def initialize(src, dst, fmt, engine, hsh = {})
40
- @src, @dst, @fmt, @engine, @hsh = src, dst, fmt, engine, hsh
39
+ def initialize(src, dst, fmt, engine, tmp = {})
40
+ @src, @dst, @fmt, @engine, @tmp = src, dst, fmt, engine, tmp
41
41
  end
42
42
 
43
43
  # Concatenate onto the formatted output string.
@@ -1,5 +1,5 @@
1
1
 
2
2
  module FormatEngine
3
3
  # The version of the format_engine gem.
4
- VERSION = "0.0.2"
4
+ VERSION = "0.1.0"
5
5
  end
@@ -7,8 +7,8 @@ class Customer
7
7
  #The specification of the parser method of the demo \Customer class.
8
8
 
9
9
  attr_parser :strprs,
10
- {"%f" => lambda { hsh[:fn] = found if parse(/(\w)+/ ) },
11
- "%l" => lambda { hsh[:ln] = found if parse(/(\w)+/ ) },
12
- :after => lambda { set dst.new(hsh[:fn], hsh[:ln]) } }
10
+ {"%f" => lambda { tmp[:fn] = found if parse(/(\w)+/ ) },
11
+ "%l" => lambda { tmp[:ln] = found if parse(/(\w)+/ ) },
12
+ :after => lambda { set dst.new(tmp[:fn], tmp[:ln]) } }
13
13
 
14
14
  end
@@ -13,18 +13,18 @@ class ParserTester < Minitest::Test
13
13
 
14
14
  def make_parser
15
15
  FormatEngine::Engine.new(
16
- "%f" => lambda { hsh[:fn] = found if parse(/(\w)+/ ) },
17
- "%F" => lambda { hsh[:fn] = found.upcase if parse(/(\w)+/) },
18
- "%-F" => lambda { hsh[:fn] = found.capitalize if parse(/(\w)+/) },
19
- "%l" => lambda { hsh[:ln] = found if parse(/(\w)+/ ) },
20
- "%L" => lambda { hsh[:ln] = found.upcase if parse(/(\w)+/) },
21
- "%-L" => lambda { hsh[:ln] = found.capitalize if parse(/(\w)+/) },
16
+ "%f" => lambda { tmp[:fn] = found if parse(/(\w)+/ ) },
17
+ "%F" => lambda { tmp[:fn] = found.upcase if parse(/(\w)+/) },
18
+ "%-F" => lambda { tmp[:fn] = found.capitalize if parse(/(\w)+/) },
19
+ "%l" => lambda { tmp[:ln] = found if parse(/(\w)+/ ) },
20
+ "%L" => lambda { tmp[:ln] = found.upcase if parse(/(\w)+/) },
21
+ "%-L" => lambda { tmp[:ln] = found.capitalize if parse(/(\w)+/) },
22
22
  "%s" => lambda { parse(/\s+/) },
23
23
  "%,s" => lambda { parse(/[,\s]\s*/) },
24
24
  "%t" => lambda { parse("\t") },
25
25
  "%!t" => lambda { parse!("\t") },
26
26
 
27
- :after => lambda { set TestPerson.new(hsh[:fn], hsh[:ln]) })
27
+ :after => lambda { set TestPerson.new(tmp[:fn], tmp[:ln]) })
28
28
  end
29
29
 
30
30
  def test_that_it_can_parse
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: format_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Camilleri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-30 00:00:00.000000000 Z
11
+ date: 2015-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler