fat_table 0.2.7 → 0.2.8

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
- SHA1:
3
- metadata.gz: 4c545f67e0496d870adfa57ec7bdbe6b8b0b5af8
4
- data.tar.gz: 59a03a6b61876344facf14a5ec6a65bf47300b33
2
+ SHA256:
3
+ metadata.gz: 558944c93313d81954da19744fec105b8562a4634781f77accd0fd7677dce76b
4
+ data.tar.gz: e301c37c690d01a77a24679e676c35cefd0f68b01d72b4e16835e54e44223790
5
5
  SHA512:
6
- metadata.gz: ec213d073ddad80a8167b05e3a0fad399886c605a41160c41c428e2664f030f862c159bb077558521ce1bb32fd004527ec540fb8e3e51906d993712b9be0abeb
7
- data.tar.gz: e160d5bacf83be72296029835f22412565e27649c097869f2653b86b8b23a65d0d541593349221fde1c5b6dc381785b0d192f3cd434269c6a2647362f433cfdc
6
+ metadata.gz: 6430e39eb4261ab51eb855a0e3119e7bfae2e0f104215e637d8091d8d2ba4847f8b2e91ee1b1be08531bc69a72dc4a4b6233fbbc2d0f8fa7b43c11c73ac8c305
7
+ data.tar.gz: 1eec9ab1576cdda1ebdcd0833601573f343ecab9cd16244c6fd4038b6a3dc86ba7303b693e7c7d852ef1443e9b2b3d20b9ff32ccb652fcb73a92e7337d3511c7
@@ -16,4 +16,5 @@ rvm:
16
16
  - 2.2.2
17
17
  - 2.3
18
18
  - 2.4
19
+ - 2.5
19
20
  - ruby-head
data/.yardopts CHANGED
@@ -1 +1,5 @@
1
- --no-private lib/**/*.rb --markup=markdown --main=README.rdoc - README.rdoc
1
+ --no-private lib/**/*.rb
2
+ --markup=markdown
3
+ --main=md/README.md
4
+ -
5
+ md/README.md
data/README.org CHANGED
@@ -2,7 +2,11 @@
2
2
  #+LATEX_HEADER: \usepackage[margin=0.75in]{geometry}
3
3
 
4
4
  #+BEGIN_COMMENT
5
+ This is for markdown output:
6
+
5
7
  [![Build Status](https://travis-ci.org/ddoherty03/fat_table.svg?branch=master)](https://travis-ci.org/ddoherty03/fat_table)
8
+
9
+ The following is for org.
6
10
  #+END_COMMENT
7
11
 
8
12
  [[https://travis-ci.org/ddoherty03/fat_table.svg?branch=master]]
@@ -12,7 +16,7 @@
12
16
  ~FatTable~ is a gem that treats tables as a data type. It provides methods for
13
17
  constructing tables from a variety of sources, building them row-by-row,
14
18
  extracting rows, columns, and cells, and performing aggregate operations on
15
- columns. It also provides as set of SQL-esque methods for manipulating table
19
+ columns. It also provides a set of SQL-esque methods for manipulating table
16
20
  objects: ~select~ for filtering by columns or for creating new columns, ~where~
17
21
  for filtering by rows, ~order_by~ for sorting rows, ~distinct~ for eliminating
18
22
  duplicate rows, ~group_by~ for aggregating multiple rows into single rows and
@@ -31,7 +35,7 @@ no-ops.
31
35
  ~FatTable~ can be used to perform operations on data that are naturally best
32
36
  conceived of as tables, which in my experience is quite often. It can also serve
33
37
  as a foundation for providing reporting functions where flexibility about the
34
- output medium can be quite useful. Finally ~FatTable~ can be used within Emacs
38
+ output medium can be useful. Finally ~FatTable~ can be used within Emacs
35
39
  ~org-mode~ files in code blocks targeting the Ruby language. Org mode tables are
36
40
  presented to a ruby code block as an array of arrays, so ~FatTable~ can read
37
41
  them in with its ~.from_aoa~ constructor. A ~FatTable~ table output as an array
@@ -76,7 +80,7 @@ Or install it yourself as:
76
80
 
77
81
  ~FatTable~ provides table objects as a data type that can be constructed and
78
82
  operated on in a number of ways. Here's a quick example to illustrate the use of
79
- the main features of ~FatTable~. See the detailed explanations further on down.
83
+ ~FatTable~. See the detailed explanations further on down.
80
84
 
81
85
  #+HEADER: :colnames no :session readme :hlines yes :wrap EXAMPLE :exports both
82
86
  #+BEGIN_SRC ruby
@@ -165,11 +169,12 @@ the main features of ~FatTable~. See the detailed explanations further on down.
165
169
 
166
170
  ** A Word About the Examples
167
171
 
168
- When you install the ~fat_table~ gem, you have access to a program ~ft_console~
172
+ When you install the ~fat_table~ gem, you have access to a program ~ft_console~,
169
173
  which opens a ~pry~ session with ~fat_table~ loaded and the tables used in the
170
174
  examples in this ~README~ defined as instance variables so you can experiment
171
175
  with them. Because they are defined as instance variables, you have to write
172
- ~tab1~ as ~@tab1~ in ~ft_console~, but otherwise the examples should work.
176
+ ~tab1~ as ~@tab1~ in ~ft_console~, but otherwise the examples should work as
177
+ shown in this ~README~.
173
178
 
174
179
  The examples in this ~README~ file are executed as code blocks within the
175
180
  ~README.org~ file, so they typically end with a call to ~.to_aoa~. That causes
@@ -231,7 +236,7 @@ locals: _ __ _dir_ _ex_ _file_ _in_ _out_ _pry_ lib str version
231
236
  [4] pry(main)>
232
237
  #+END_EXAMPLE
233
238
 
234
- And if you use ~.to_term~, you can see the effect of the color formatting
239
+ If you use ~puts table.to_term~, you can see the effect of the color formatting
235
240
  directives.
236
241
 
237
242
  ** Anatomy of a Table
@@ -478,15 +483,15 @@ This example illustrates several things:
478
483
  where the number of shares is greater than 500. More on that later.
479
484
  4. ~FatTable~ passes back to org-mode an array of arrays using the ~.to_aoa~
480
485
  method. In an ~org-mode~ buffer, these are rendered as tables. We'll often
481
- apply ~.to_aoa~ at the end of example blocks to render the results inside
482
- this ~README.org~ file. As we'll see below, this method can also take a block
483
- to which formatting directives and footers can be attached.
486
+ apply ~.to_aoa~ at the end of example blocks in this ~README~ to render the
487
+ results as a table inside this file. As we'll see below, ~.to_aoa~ can also
488
+ take a block to which formatting and footer directives can be attached.
484
489
 
485
490
  *** From Arrays of Hashes
486
491
 
487
492
  A second ruby data structure that can be used to initialize a ~FatTable~ table
488
493
  is an array of ruby Hashes. Each hash represents a row of the table, and the
489
- headers of the table are take from the keys of the hashes. Accordingly, all the
494
+ headers of the table are taken from the keys of the hashes. Accordingly, all the
490
495
  hashes should have the same keys.
491
496
 
492
497
  This same method can in fact take an array of any objects that can be converted
@@ -517,7 +522,7 @@ tab = FatTable.from_aoh(aoh)
517
522
  #+END_SRC
518
523
 
519
524
  Notice, again, that the values can either be ruby objects, such as ~Date.today~,
520
- or strings that can parsed into one of the permissible column types.
525
+ or strings that can be parsed into one of the permissible column types.
521
526
 
522
527
  *** From SQL queries
523
528
 
@@ -528,29 +533,19 @@ database parameters to be used for the queries.
528
533
  #+BEGIN_SRC ruby
529
534
  # This automatically requires sequel.
530
535
  require 'fat_table'
531
- FatTable.set_db(driver: 'Pg',
536
+ FatTable.set_db(adapter: 'postgres',
532
537
  database: 'XXX_development',
533
- user: 'dtd',
534
- password: 'slflpowert',
535
- host: 'localhost',
536
- socket: '/tmp/.s.PGSQL.5432')
538
+ user: 'ken',
539
+ password: 'imsecret',
540
+ host: 'db.lan')
537
541
  tab = FatTable.from_sql('select * from trades;')
538
542
  #+END_SRC
539
543
 
540
- Some of the parameters to the ~.set_db~ function have defaults. The driver
541
- defaults to ~'Pg'~ for postgresql and the socket defaults to
542
- ~/tmp/.s.PGSQL.5432~ if the host is 'localhost', which it is by default. If the
543
- host is not ~'localhost'~, the dsn uses a port rather than a socket and defaults
544
- to port ~'5432'~. While user and password default to nil, the database parameter
545
- is required.
546
-
547
- The ~.set_db~ function need only be called once, and the database handle it
548
- creates will be used for all subsequent ~.from_sql~ calls until ~.set_db~ is
549
- called again.
550
-
551
- Alternatively, you can build the ~Sequel~ connection with ~Sequel.connect~ or
552
- with adapter-specific ~Sequel~ connection methods and let ~FatTable~ know to use
553
- that connection:
544
+ The arguments to ~set_db~ are simply passed on to ~sequel~'s connect method, so
545
+ any set of arguments that work for it should work for ~set_db~. Alternatively,
546
+ you can build the ~Sequel~ connection directly with ~Sequel.connect~ or with
547
+ adapter-specific ~Sequel~ connection methods and let ~FatTable~ know to use that
548
+ connection:
554
549
 
555
550
  #+BEGIN_SRC ruby
556
551
  require 'fat_table'
@@ -561,8 +556,15 @@ that connection:
561
556
  Consult ~Sequel's~ documentation for details on its connection methods.
562
557
  [[http://sequel.jeremyevans.net/rdoc/files/doc/opening_databases_rdoc.html]]
563
558
 
559
+ The ~.set_db~ function need only be called once, and the database handle it
560
+ creates will be used for all subsequent ~.from_sql~ calls until ~.set_db~ is
561
+ called again.
562
+
564
563
  *** Marking Groups in Input
565
564
 
565
+ ~FatTable~ tables has a concept of "groups" of rows that play a role in many of
566
+ the methods for operating on them as explained [[Groups][below]].
567
+
566
568
  The ~.from_aoa~ and ~.from_aoh~ functions take an optional keyword parameter
567
569
  ~hlines:~ that, if set to ~true~, causes them to mark group boundaries in the
568
570
  table wherever a row Array (for ~.from_aoa~) or Hash (for ~.from_aoh~) is
@@ -582,6 +584,7 @@ beginning with something like '~|---~'. The ~.from_org_...~ functions always
582
584
  recognizes hlines in the input, so it takes no ~hlines:~ keyword parameter.
583
585
 
584
586
  ** Accessing Parts of Tables
587
+
585
588
  *** Rows
586
589
 
587
590
  A ~FatTable~ table is an Enumerable, yielding each row of the table as a Hash
@@ -637,6 +640,7 @@ operation, which mutates the receiver table by removing its group boundaries.
637
640
  Second, because each operation returns a ~FatTable::Table~ object, the
638
641
  operations are chainable.
639
642
 
643
+ <<Groups>>
640
644
  Third, ~FatTable::Table~ objects can have "groups" of rows within the table.
641
645
  These can be decorated with hlines and group footers on output. Some of these
642
646
  operations result in marking group boundaries in the result table, others remove
@@ -72,6 +72,7 @@ Gem::Specification.new do |spec|
72
72
  spec.add_development_dependency 'rake', '~> 10.0'
73
73
  spec.add_development_dependency 'redcarpet'
74
74
  spec.add_development_dependency 'rspec', '~> 3.0'
75
+ spec.add_development_dependency 'rubocop-rspec'
75
76
  spec.add_development_dependency 'simplecov'
76
77
 
77
78
  spec.add_runtime_dependency 'activesupport', '>3.0'
@@ -18,7 +18,7 @@ module FatTable
18
18
  # Sequel's adapter-specific connection methods.
19
19
  # http://sequel.jeremyevans.net/rdoc/files/doc/opening_databases_rdoc.html
20
20
  #
21
- # +driver+::
21
+ # +adapter+::
22
22
  # One of 'pg' (for Postgresql), 'mysql' or 'mysql2' (for Mysql), or
23
23
  # 'sqlite' (for SQLite3) to specify the +Sequel+ driver to use. You may
24
24
  # have to install the driver to make this work. By default use 'Pg'.
@@ -61,46 +61,6 @@ module FatTable
61
61
  handle
62
62
  end
63
63
 
64
- # def self.set_db(adapter: 'postgres',
65
- # database:,
66
- # user: ENV['LOGNAME'],
67
- # password: nil,
68
- # host: 'localhost',
69
- # port: nil,
70
- # socket: '/tmp/.s.PGSQL.5432')
71
- # if db
72
- # self.handle = db
73
- # else
74
- # raise UserError, 'must supply database name to set_db' unless database
75
-
76
- # valid_drivers = %w[postgres mysql mysql2 sqlite]
77
- # unless valid_drivers.include?(driver)
78
- # msg = "'#{driver}' driver must be one of #{valid_drivers.join(' or ')}"
79
- # raise UserError, msg
80
- # end
81
- # if database.blank?
82
- # raise UserError, 'must supply database parameter to set_db'
83
- # end
84
-
85
- # if driver == 'sqlite'
86
- # dsn = "sqlite://#{database}"
87
- # else
88
- # pw_part = password ? ":#{password}" : ''
89
- # hst_part = host ? "@#{host}" : ''
90
- # prt_part = port ? ":#{port}" : ''
91
- # dsn = "#{driver}:://#{user}#{pw_part}#{hst_part}#{prt_part}/#{database}"
92
- # end
93
-
94
- # # Set the dsn for Sequel
95
- # begin
96
- # self.handle = Sequel.connect(dsn)
97
- # rescue Sequel::Error => ex
98
- # raise TransientError, "#{dsn}: #{ex}"
99
- # end
100
- # end
101
- # handle
102
- # end
103
-
104
64
  # Return the +Sequel+ database handle.
105
65
  def self.db
106
66
  handle
@@ -1270,7 +1270,7 @@ module FatTable
1270
1270
 
1271
1271
  # :category: Constructors
1272
1272
 
1273
- # Add a +row+ without marking it as a group boundary.
1273
+ # Add a +row+ to this Table without marking it as a group boundary.
1274
1274
  def <<(row)
1275
1275
  add_row(row)
1276
1276
  end
@@ -1,4 +1,4 @@
1
1
  module FatTable
2
2
  # The current version of FatTable
3
- VERSION = '0.2.7'.freeze
3
+ VERSION = '0.2.8'.freeze
4
4
  end
@@ -44,8 +44,7 @@
44
44
  4. [Development](#org62e325b)
45
45
  5. [Contributing](#orgf51a2c9)
46
46
 
47
- <https://travis-ci.org/ddoherty03/fat_table.svg?branch=master>
48
-
47
+ [![Build Status](https://travis-ci.org/ddoherty03/fat_table.svg?branch=v0.2.7)](https://travis-ci.org/ddoherty03/fat_table)
49
48
 
50
49
  <a id="org23d768e"></a>
51
50
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fat_table
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel E. Doherty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-29 00:00:00.000000000 Z
11
+ date: 2018-08-28 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: '3.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop-rspec
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
  - !ruby/object:Gem::Dependency
126
140
  name: simplecov
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -280,7 +294,6 @@ files:
280
294
  - ".yardopts"
281
295
  - Gemfile
282
296
  - LICENSE.txt
283
- - README.md
284
297
  - README.org
285
298
  - README.rdoc
286
299
  - Rakefile
@@ -304,6 +317,7 @@ files:
304
317
  - lib/fat_table/patches.rb
305
318
  - lib/fat_table/table.rb
306
319
  - lib/fat_table/version.rb
320
+ - md/README.md
307
321
  homepage: https://github.com/ddoherty03/fat_table
308
322
  licenses: []
309
323
  metadata:
@@ -325,7 +339,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
325
339
  version: '0'
326
340
  requirements: []
327
341
  rubyforge_project:
328
- rubygems_version: 2.6.11
342
+ rubygems_version: 2.7.3
329
343
  signing_key:
330
344
  specification_version: 4
331
345
  summary: Provides tools for working with tables as a data type.