tableware 0.1.0 → 0.1.1

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: bdf63d976f7bc10b88173faff66b1648b68f121e
4
- data.tar.gz: 5ec2eeb4cc455f7732329d5d1720c792327cae7e
3
+ metadata.gz: 726ade1c9944387517bd3d7bbac38f5ba2584a30
4
+ data.tar.gz: e2fddc4507e8fa04c3144290e104b9d171c30e26
5
5
  SHA512:
6
- metadata.gz: 9118c0d6f8c9d9e17b5521e6b08c51f5a221627c4168b5f452612790e75bcca1cbd63bc517a010d55620a9aca02b55ce27e264e3f6099436e9cfbe1544ed31b8
7
- data.tar.gz: 99e85bec1a7fd1a8e72f1e64536ec2454227e65e023af07adb2038ca0eb6686900658118829f8ab8f813356729bdb66dfb369ad023fc7a1eabe7eaeb1b167830
6
+ metadata.gz: 6f8611a0c543306410ac5e9252e8614c386931d83d1511f5edf41ef4bd198a10fdf63f2cc98f807edaea2d9a221903151a8fa6371a9ab585e2a4f1d98e78eb93
7
+ data.tar.gz: 3e4ec20fcd80ef69f7ff38d05d6ec0bbcc02ad14775a468ba3ba5eadb21c52843865bb5ba08b430606ce5d4db61a9218031ad5f873e3ec729e76770a07011b2b
data/.semver ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 1
4
+ :patch: 1
5
+ :special: ''
6
+ :metadata: ''
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1
4
+ - 2.2
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ == v0.1.1 (16 August 2016)
2
+
3
+ # v0.1.0
4
+
5
+ * Initial release
6
+ * Parsing basic tables into 2D arrays or an array of hashes
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tableware (0.1.0)
4
+ tableware (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -85,6 +85,7 @@ GEM
85
85
  parser (>= 2.2.0, < 3.0)
86
86
  reek (= 3.8.1)
87
87
  virtus (~> 1.0)
88
+ semver2 (3.4.2)
88
89
  sexp_processor (4.6.1)
89
90
  simplecov (0.11.2)
90
91
  docile (~> 1.1.0)
@@ -121,6 +122,7 @@ DEPENDENCIES
121
122
  rspec (~> 3.0)
122
123
  rubocop
123
124
  rubycritic
125
+ semver2
124
126
  simplecov
125
127
  tableware!
126
128
 
data/README.md CHANGED
@@ -3,43 +3,42 @@
3
3
  Tableware is a tiny gem for making it easier to define data in an text table.
4
4
  Table rows are parsed into either arrays or hashes.
5
5
 
6
- For example, writing:
6
+ For example:
7
7
 
8
- ```
9
- [
10
- [ "Type A", true, false, 2016 ],
11
- [ "Type B", "only on alternating Wednesdays", false, 2017 ],
12
- [ "Type C", :never, true, 2016 ]
13
- ].each do |args|
14
- // Some test or permissions check or something
15
- end
16
- ```
17
- is fine but it can be a pain to format at work with, especially for larger data sets.
8
+ ```ruby
9
+ stats = ' Hero | Value | Hours Played
10
+ ------------------------------------------
11
+ Phara | 10 | 22
12
+ Mercy | 9 | 11
13
+ Winston | 3 | 2 '
18
14
 
19
- Tableware lets you trade a bit of parsing for nicer text tables. Instead of the above, you could write:
15
+ Tableware.arrays(stats)
16
+ # => [
17
+ ['Phara', '10', '22'],
18
+ ['Mercy', '9', '11'],
19
+ ['Winston', '3', '2']
20
+ ]
20
21
 
22
+ Tableware.hashes(stats)
23
+ #=> [
24
+ { hero: 'Phara', value: '10', hours_played: 22 },
25
+ { hero: 'Mercy', value: '9', hours_played: 11 },
26
+ { hero: 'Winston', value: '3', hours_played: 2 }
27
+ ]
21
28
  ```
22
- table = %q[
23
- | Type | Valid | Infinite | Year Introduced |
24
- ----------------------------------------------------------------------------------
25
- | Type A | true | false | 2016 |
26
- | Type B | Only on alternating Wednesdays | false | 2017 |
27
- | Type C | never | true | 2016 |
28
- ]
29
- Tableware.arrays.each do |args|
30
- // Some test or permissions check or something
31
- end
32
- ```
33
29
 
34
- The upside is that you get a much more human friendly table to read, which will save you time by making it something you can quickly scan over.
35
- The downside is that everything appears on the other side as a string, so you may need to do some `.to_i`ing to convert things back into the type you're expecting.
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.
31
+
32
+ Tableware lets you use a more human friendly format so that you can more easily scan and understand the data.
36
33
 
37
- *Please note* that this isn't always going to be better than defining your data in another format; arrays, giant hashes of doom, JSON/YAML or even CSV may me easier to work with. This is another option and one which may be better for that middle ground when your data makes arrays hard to format but it's not big enough for you to want to extract it to an external file. Or perhaps you just like Cucumber scenario outlines and want something similar in rspec!
38
- Whatever your reasoning, this is just one more option for formatting your data.
34
+ The downside is that everything is treated as a string, so you may need to do some `.to_i`ing to convert things back into the type you're expecting. However, this is a one-time cost and [optimising for reading code is a good idea](http://va.lent.in/optimize-for-readability-first/).
39
35
 
40
- This gem has been created as a quick experiement to see if or how ofen this feature could be useful.
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
+
38
+ This gem has been created as a quick experiment to see if or how ofen this feature could be useful.
41
39
  If you find it useful, please like it or better yet, extend it!
42
40
 
41
+
43
42
  ## Installation
44
43
 
45
44
  Add this line to your application's Gemfile:
@@ -70,38 +69,8 @@ Tableware provides two main methods for getting your data back out of the table:
70
69
  1. `Tableware.arrays` returns an array of arrays
71
70
  2. `Tableware.hashes` returns an array of hashes, where the keys come from the headings row
72
71
 
72
+ Both of these can be seen in use in the example at the top of this README.
73
73
 
74
- For example:
75
-
76
- ```
77
- input = '
78
- Hero | Value | Hours Played
79
- ------------------------------------------
80
- Phara | 10 | 22
81
- Mercy | 9 | 11
82
- Winston | 3 | 2
83
- '
84
-
85
- Tableware.arrays(input)
86
- # => [
87
- ['Phara', '10', '22'],
88
- ['Mercy', '9', '11'],
89
- ['Winston', '3', '2']
90
- ]
91
-
92
- Tableware.hashes(input)
93
- #=> [
94
- { hero: 'Phara', value: '10', hours_played: 22 },
95
- { hero: 'Mercy', value: '9', hours_played: 11 },
96
- { hero: 'Winston', value: '3', hours_played: 2 }
97
- ]
98
- ```
99
-
100
- ## Development
101
-
102
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
103
-
104
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
105
74
 
106
75
  ## Contributing
107
76
 
data/Rakefile CHANGED
@@ -5,7 +5,6 @@ require 'rake-n-bake'
5
5
  RSpec::Core::RakeTask.new(:spec)
6
6
 
7
7
  task default: [
8
- :clean,
9
8
  :"bake:code_quality:all",
10
9
  :"bake:rspec",
11
10
  :"bake:coverage:check_specs",
@@ -25,7 +25,7 @@ class Tableware
25
25
  private def prepare_lines(input)
26
26
  lines = input.strip.lines
27
27
 
28
- @data_start = lines[1] =~ /^\s*[-=]+\s*$/ ? 2 : 0
28
+ @data_start = lines[1] =~ /^\s*[-=\|]+\s*$/ ? 2 : 0
29
29
  if @data_start.nonzero?
30
30
  @headers = parse_line(lines[0])
31
31
  .map!(&:downcase)
@@ -1,5 +1,5 @@
1
1
  class Tableware
2
2
 
3
- VERSION = '0.1.0'.freeze
3
+ VERSION = '0.1.1'.freeze
4
4
 
5
5
  end
data/tableware.gemspec CHANGED
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency 'rubycritic'
28
28
  spec.add_development_dependency 'rubocop'
29
29
  spec.add_development_dependency 'fasterer'
30
+ spec.add_development_dependency 'semver2'
30
31
  end
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.0
4
+ version: 0.1.1
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-13 00:00:00.000000000 Z
11
+ date: 2016-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: semver2
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  description: A nice way of parsing text tables into Ararys or Hashes, for clearer
126
140
  code. Great for tests and permissions matrixes!
127
141
  email:
@@ -135,6 +149,9 @@ files:
135
149
  - ".rubocop-https---raw-githubusercontent-com-dvmtn-house-style-master-rubocop-yml"
136
150
  - ".rubocop.yml"
137
151
  - ".ruby-version"
152
+ - ".semver"
153
+ - ".travis.yml"
154
+ - CHANGELOG.md
138
155
  - CODE_OF_CONDUCT.md
139
156
  - Gemfile
140
157
  - Gemfile.lock