pyrosome 0.1.0 → 0.2.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: c3d0dbf93679bd83f9d493bd8ec11caedf7b266c
4
- data.tar.gz: 1e59c844075e5f6b0a14f177d94070fe4fe33efb
3
+ metadata.gz: a8c7f462ebcbd7ad7c2f1fbce5a6bda419e9f7d7
4
+ data.tar.gz: 1285e2335b94289a86f6268850d054aef584e126
5
5
  SHA512:
6
- metadata.gz: 5a89bbedf8ae8838702fd64d33749e0953b5b3de2eecc84e11d8c7c0c6fb74b721ebd503be111694a1dff84d920f73d2c87032bc421ac21678cc5f79b978ae07
7
- data.tar.gz: 3bfc77ca6d0831ef7ed848ac22a2ad3540106a52fe919a993cba667d6f2f17f746e212c9444759dd540de47063abb41f8b516c2049a58e1eb1dbc197618336ad
6
+ metadata.gz: 177a82d33c424b9a5cc7a4a2425088b685096c1c9cf75faf8c7f9d27f1a9a6c525b46a03456f24f2b450487f09edcb8f2a7ab30ef3a830ac9801eebff7af3474
7
+ data.tar.gz: 84505ba050f17f6904e3bcd76f360898c28871e86c667b244d66b748cc34bc9fd1b55f298138fb28112974554f8902c80db016a604e302532297431760746ceb
@@ -0,0 +1,23 @@
1
+ # Change Log
2
+ All notable changes to this project will be documented in this file.
3
+ This file should follow the standards specified on [http://keepachangelog.com/]
4
+ This project adheres to [Semantic Versioning](http://semver.org/).
5
+
6
+ ## [0.2.0] - 11-27-2015
7
+
8
+ ### Changed
9
+
10
+ - Change variable from `datum` to `_` to be like Ruby (not possible to set `$_` like Ruby)
11
+
12
+ ### Added
13
+
14
+ - Add `-p`/`--print` option for automatically printing like with Ruby.
15
+
16
+ ## [0.1.0] - 11-26-2015
17
+
18
+ ### Added
19
+
20
+ - First release!
21
+ - Ability to process JSON and CSV.
22
+ - Ability to specify headers
23
+
data/README.md CHANGED
@@ -23,9 +23,9 @@ Install the gem:
23
23
 
24
24
  The command to execute is `psome` (pronounced `p-some`, ryhmes with `roam`). It takes a stream like this:
25
25
 
26
- cat file.csv | psome -f csv -e "puts datum[0]"
26
+ cat file.csv | psome -f csv -e "puts _[0]"
27
27
 
28
- You can see that we specify the format that is expected and a bit of Ruby code which exects to use a `datum` variable
28
+ You can see that we specify the format that is expected and a bit of Ruby code which exects to use a `_` variable
29
29
 
30
30
  ### Arguments
31
31
 
@@ -35,7 +35,7 @@ Specify a format. `json` and `csv` currently supported
35
35
 
36
36
  #### -e [CODE] / --exec [CODE]
37
37
 
38
- Give some Ruby code to be executed. A `datum` variable will be in scope and will represent the object which is retrieved for each iteration
38
+ Give some Ruby code to be executed. A `_` variable will be in scope and will represent the object which is retrieved for each iteration
39
39
 
40
40
  #### -h / --headers
41
41
 
data/bin/psome CHANGED
@@ -23,18 +23,31 @@ OptionParser.new do |opts|
23
23
  opts.on('-h', "--headers", "Does the file have headers (if it is a tablular format)") do |headers|
24
24
  options[:headers] = headers
25
25
  end
26
+
27
+ opts.on('-p', '--print', "Prints the result of the evaluated code") do |print|
28
+ options[:print] = print
29
+ end
26
30
  end.parse!
27
31
 
32
+ def process_datum(_, options)
33
+ datum = _
34
+
35
+ eval(options[:code]).tap do |result|
36
+ if options[:print]
37
+ puts result
38
+ end
39
+ end
40
+ end
28
41
 
29
42
  case options[:format]
30
43
  when 'json'
31
44
  require 'yajl'
32
45
  Yajl::Parser.new.parse(STDIN).each do |datum|
33
- eval(options[:code])
46
+ process_datum(datum, options)
34
47
  end
35
48
  when 'csv'
36
49
  require 'csv'
37
50
  CSV.new(STDIN, headers: options[:headers]).each do |datum|
38
- eval(options[:code])
51
+ process_datum(datum, options)
39
52
  end
40
53
  end
@@ -1,3 +1,3 @@
1
1
  module Pyrosome
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pyrosome
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Underwood
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-26 00:00:00.000000000 Z
11
+ date: 2015-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yajl-ruby
@@ -76,6 +76,7 @@ files:
76
76
  - ".gitignore"
77
77
  - ".rspec"
78
78
  - ".travis.yml"
79
+ - CHANGELOG.md
79
80
  - CODE_OF_CONDUCT.md
80
81
  - Gemfile
81
82
  - LICENSE.txt