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 +4 -4
- data/CHANGELOG.md +23 -0
- data/README.md +3 -3
- data/bin/psome +15 -2
- data/lib/pyrosome/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8c7f462ebcbd7ad7c2f1fbce5a6bda419e9f7d7
|
4
|
+
data.tar.gz: 1285e2335b94289a86f6268850d054aef584e126
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 177a82d33c424b9a5cc7a4a2425088b685096c1c9cf75faf8c7f9d27f1a9a6c525b46a03456f24f2b450487f09edcb8f2a7ab30ef3a830ac9801eebff7af3474
|
7
|
+
data.tar.gz: 84505ba050f17f6904e3bcd76f360898c28871e86c667b244d66b748cc34bc9fd1b55f298138fb28112974554f8902c80db016a604e302532297431760746ceb
|
data/CHANGELOG.md
ADDED
@@ -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
|
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 `
|
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 `
|
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
|
-
|
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
|
-
|
51
|
+
process_datum(datum, options)
|
39
52
|
end
|
40
53
|
end
|
data/lib/pyrosome/version.rb
CHANGED
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.
|
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-
|
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
|