tableware 0.1.3 → 0.2.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: f277a6e8ac29aa0ba9072515a2dc07c54b5bb320
4
- data.tar.gz: f0981e473a524701ab700f22d98a4df99d7528ff
3
+ metadata.gz: 008bc899c66b79add438462dfff36b63dfe6465e
4
+ data.tar.gz: 627aa77b932393e933a3b44a6cbef16cc31da48c
5
5
  SHA512:
6
- metadata.gz: ee68863b22ae9a7d91146fdc99d9c429b1119b4352117399e936403f6a099aa2a1d9dc6863e2cf9276c113c1020d8583df8619a2772ef27b9ded040864d351c1
7
- data.tar.gz: a79187d9baac74596286f2652227bb3dceeba2b6761fc5841094a5c683bdad4fd4330a1da015506eaaa253c9cc0d7939aecd920e8d23ea06aec1b28e0eb211e1
6
+ metadata.gz: 1fc51b626f8e553462e713e67d75b2ead6e09171269794e704b075cc6a7a22189b1e2a9058d59772e3a0cf3f389bc348be773e9ad914fcace90802eb3ebc3ab9
7
+ data.tar.gz: e6cc38365860817dc00842e318bcde7c89b2d47b0b31af1dd450e841d7a3a1a54c3d237bf942bea55f72ac0cd47751b92f553c62d01e226739890435251187ae
@@ -10,6 +10,7 @@ AllCops:
10
10
  - 'vendor/**/*'
11
11
  - 'bin/**/*'
12
12
  - 'log/**/*'
13
+ - 'node_modules/**/*'
13
14
 
14
15
  Rails:
15
16
  Enabled: true
@@ -32,9 +33,15 @@ Style/MethodDefParentheses:
32
33
  Style/Encoding:
33
34
  Enabled: false
34
35
 
36
+ Style/SingleLineBlockParams:
37
+ Enabled: false
38
+
39
+ Style/EmptyCaseCondition:
40
+ Enabled: false
41
+
35
42
  Style/PercentLiteralDelimiters:
36
43
  PreferredDelimiters:
37
- '%': ()
44
+ '%': '""'
38
45
  '%i': '[]'
39
46
  '%q': '[]'
40
47
  '%Q': '[]'
@@ -59,6 +66,11 @@ Style/SignalException:
59
66
  Style/EmptyLinesAroundClassBody:
60
67
  EnforcedStyle: empty_lines
61
68
 
69
+ Style/TrailingCommaInLiteral:
70
+ EnforcedStyleForMultiline: comma
71
+
62
72
  Metrics/LineLength:
73
+ Exclude:
74
+ - 'spec/**/*'
63
75
  Max: 140
64
76
  AllowURI: true
data/.semver CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  :major: 0
3
- :minor: 1
4
- :patch: 3
3
+ :minor: 2
4
+ :patch: 0
5
5
  :special: ''
6
6
  :metadata: ''
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ == v0.2.0 (06 November 2016)
2
+
3
+ * Allow a single line to be processed by prepending it with a `>` character
4
+
1
5
  == v0.1.3 (16 August 2016)
2
6
 
3
7
  * Allow spaces in the header delimiter row
data/CODE_OF_CONDUCT.md CHANGED
@@ -46,4 +46,4 @@ version 1.3.0, available at
46
46
  [http://contributor-covenant.org/version/1/3/0/][version]
47
47
 
48
48
  [homepage]: http://contributor-covenant.org
49
- [version]: http://contributor-covenant.org/version/1/3/0/
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tableware (0.1.3)
4
+ tableware (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -48,8 +48,8 @@ GEM
48
48
  procto (0.0.3)
49
49
  rainbow (2.1.0)
50
50
  rake (10.5.0)
51
- rake-n-bake (1.4.0)
52
- rake (~> 10)
51
+ rake-n-bake (1.4.2)
52
+ rake (>= 10)
53
53
  term-ansicolor (~> 1.3)
54
54
  reek (3.8.1)
55
55
  codeclimate-engine-rb (~> 0.1.0)
@@ -92,7 +92,7 @@ GEM
92
92
  json (~> 1.8)
93
93
  simplecov-html (~> 0.10.0)
94
94
  simplecov-html (0.10.0)
95
- term-ansicolor (1.3.2)
95
+ term-ansicolor (1.4.0)
96
96
  tins (~> 1.0)
97
97
  thread_safe (0.3.5)
98
98
  tins (1.12.0)
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Tableware
2
2
 
3
- Tableware is a tiny gem for making it easier to define data in an text table.
3
+ Tableware is a tiny gem for making it easier to define data in a text table.
4
4
  Table rows are parsed into either arrays or hashes.
5
5
 
6
6
  For example:
@@ -27,7 +27,7 @@ Tableware.hashes(stats)
27
27
  ]
28
28
  ```
29
29
 
30
- Writing test data or a matrix of permissions in a big hash or nested array is fine, but it can be a pain to format at work with, especially for larger data setsa or with item of very different lengths.
30
+ Writing test data or a matrix of permissions in a big hash or nested array is fine, but it can be a pain to format and work with, especially for larger data sets or with items of very different lengths.
31
31
 
32
32
  Tableware lets you use a more human friendly format so that you can more easily scan and understand the data.
33
33
 
@@ -35,7 +35,20 @@ The downside is that everything is treated as a string, so you may need to do so
35
35
 
36
36
  This isn't always going to be better than defining your data in another format, but it is another option. Or perhaps you just like Cucumber scenario outlines and want something similar in rspec!
37
37
 
38
- This gem has been created as a quick experiment to see if or how ofen this feature could be useful.
38
+ You can also focus a single row, to help with debugging, by prepending a line with `>`.
39
+ For example:
40
+
41
+ ```ruby
42
+ words = ' Foo | Bar
43
+ > Yay | Woo
44
+ Zip | Zap '
45
+
46
+ Tableware.arrays(words)
47
+ #=> [ ['Yay', 'Woo'] ]
48
+ ```
49
+
50
+
51
+ This gem has been created as a quick experiment to see if or how often this feature could be useful.
39
52
  If you find it useful, please like it or better yet, extend it!
40
53
 
41
54
 
data/Rakefile CHANGED
@@ -11,5 +11,5 @@ task default: [
11
11
  :"bake:rubocop",
12
12
  :"bake:rubycritic",
13
13
  :"bake:fasterer",
14
- :"bake:ok_rainbow"
14
+ :"bake:ok_rainbow",
15
15
  ]
@@ -4,8 +4,8 @@ class Tableware
4
4
 
5
5
  class TableWithoutHeaderError < StandardError; end
6
6
 
7
- ROW_START = /^\s*\|/
8
- ROW_END = /\|\s*$/
7
+ ROW_START = /^>?\s*\|?/
8
+ ROW_END = /\|?\s*$/
9
9
 
10
10
  def arrays(input)
11
11
  make_arrays(input)
@@ -13,13 +13,17 @@ class Tableware
13
13
 
14
14
  def hashes(input)
15
15
  items = make_arrays(input)
16
- raise TableWithoutHeaderError, 'Sorry, only text tables with headers rows can be turned into hashes' unless @headers
16
+ raise TableWithoutHeaderError, 'Sorry, only text tables with header rows can be turned into hashes' unless @headers
17
17
  items.map! { |row| @headers.zip(row).to_h }
18
18
  end
19
19
 
20
20
  private def make_arrays(input)
21
21
  lines = prepare_lines(input)
22
- lines[@data_start..-1].map { |line| parse_line(line) }
22
+ lines[@data_start..-1].map do |line|
23
+ parsed = parse_line(line)
24
+ return [parsed] if @focused_line
25
+ parsed
26
+ end
23
27
  end
24
28
 
25
29
  private def prepare_lines(input)
@@ -38,9 +42,11 @@ class Tableware
38
42
 
39
43
  private def parse_line(line)
40
44
  line
45
+ .strip
46
+ .tap { |ln| @focused_line = ln[0] == '>' }
41
47
  .sub(ROW_START, '')
42
48
  .sub(ROW_END, '')
43
- .split('|')
49
+ .split(' | ')
44
50
  .map!(&:strip)
45
51
  end
46
52
 
@@ -1,5 +1,5 @@
1
1
  class Tableware
2
2
 
3
- VERSION = '0.1.3'.freeze
3
+ VERSION = '0.2.0'
4
4
 
5
5
  end
data/rspec.json ADDED
@@ -0,0 +1 @@
1
+ {"version":"3.4.4","examples":[{"description":"parses a table without a header row","full_description":"Tableware::Parser.arrays parses a table without a header row","status":"passed","file_path":"./spec/tableware/parser_spec.rb","line_number":13,"run_time":0.0016,"pending_message":null},{"description":"parses a table with a header row","full_description":"Tableware::Parser.arrays parses a table with a header row","status":"passed","file_path":"./spec/tableware/parser_spec.rb","line_number":23,"run_time":0.000186,"pending_message":null},{"description":"parses a table with a header row with alternate formatting","full_description":"Tableware::Parser.arrays parses a table with a header row with alternate formatting","status":"passed","file_path":"./spec/tableware/parser_spec.rb","line_number":35,"run_time":0.000127,"pending_message":null},{"description":"parses a table without side delimiters","full_description":"Tableware::Parser.arrays parses a table without side delimiters","status":"passed","file_path":"./spec/tableware/parser_spec.rb","line_number":45,"run_time":0.000567,"pending_message":null},{"description":"parses a table with side delimiters","full_description":"Tableware::Parser.arrays parses a table with side delimiters","status":"passed","file_path":"./spec/tableware/parser_spec.rb","line_number":55,"run_time":0.000117,"pending_message":null},{"description":"parses tables with columns including blank spaces","full_description":"Tableware::Parser.arrays parses tables with columns including blank spaces","status":"passed","file_path":"./spec/tableware/parser_spec.rb","line_number":65,"run_time":0.000469,"pending_message":null},{"description":"parses tables with header rows","full_description":"Tableware::Parser.hashes parses tables with header rows","status":"passed","file_path":"./spec/tableware/parser_spec.rb","line_number":81,"run_time":0.000139,"pending_message":null},{"description":"does some simple transformations on headings to make them more like idiomatic Ruby symbols","full_description":"Tableware::Parser.hashes does some simple transformations on headings to make them more like idiomatic Ruby symbols","status":"passed","file_path":"./spec/tableware/parser_spec.rb","line_number":97,"run_time":0.000111,"pending_message":null},{"description":"raises a sensible exception if called on a table without a heading row","full_description":"Tableware::Parser.hashes raises a sensible exception if called on a table without a heading row","status":"passed","file_path":"./spec/tableware/parser_spec.rb","line_number":102,"run_time":0.002377,"pending_message":null},{"description":"has a version number","full_description":"Tableware has a version number","status":"passed","file_path":"./spec/tableware_spec.rb","line_number":4,"run_time":0.00152,"pending_message":null},{"description":"parses a text table into a 2D array","full_description":"Tableware.arrays parses a text table into a 2D array","status":"passed","file_path":"./spec/tableware_spec.rb","line_number":19,"run_time":0.000194,"pending_message":null},{"description":"parases a text table into an array of hashes","full_description":"Tableware.hashes parases a text table into an array of hashes","status":"passed","file_path":"./spec/tableware_spec.rb","line_number":31,"run_time":0.000135,"pending_message":null}],"summary":{"duration":0.009868,"example_count":12,"failure_count":0,"pending_count":0},"summary_line":"12 examples, 0 failures"}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tableware
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Whittingham
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-16 00:00:00.000000000 Z
11
+ date: 2016-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -163,6 +163,7 @@ files:
163
163
  - lib/tableware.rb
164
164
  - lib/tableware/parser.rb
165
165
  - lib/tableware/version.rb
166
+ - rspec.json
166
167
  - tableware.gemspec
167
168
  homepage: https://github.com/AdamWhittingham/tableware
168
169
  licenses: