sssummary 0.0.2 → 0.0.3
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.
- data/README.md +38 -11
- data/bin/sssummary +3 -6
- data/lib/Sssummary.rb +0 -4
- data/lib/sssummary/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -1,24 +1,50 @@
|
|
1
1
|
# Sssummary
|
2
2
|
|
3
|
-
|
3
|
+
Summarize a formatted data like CSV by sql on the shell.
|
4
|
+
|
5
|
+
example:
|
6
|
+
|
7
|
+
```zsh:test.tsv
|
8
|
+
$ cat test.tsv
|
9
|
+
2013/07/01 23:08 0.100 iPhone
|
10
|
+
2013/07/01 23:08 0.160 iPhone
|
11
|
+
2013/07/01 23:09 0.120 Andoid
|
12
|
+
2013/07/01 23:09 0.103 Andoid
|
13
|
+
2013/07/01 23:09 0.140 IE10
|
14
|
+
2013/07/01 23:10 0.130 Chrome
|
15
|
+
2013/07/01 23:10 0.190 Firefox
|
16
|
+
2013/07/01 23:11 0.600 Safari
|
17
|
+
2013/07/01 23:11 0.890 Android
|
18
|
+
$ cat test.tsv | sssummary 'select c1, avg(c2) from t group by c1 order by c1'
|
19
|
+
2013/07/01 23:08 0.13
|
20
|
+
2013/07/01 23:09 0.121
|
21
|
+
2013/07/01 23:10 0.16
|
22
|
+
2013/07/01 23:11 0.745
|
23
|
+
```
|
4
24
|
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
gem 'sssummary'
|
10
|
-
|
11
|
-
And then execute:
|
12
25
|
|
13
|
-
|
26
|
+
## Installation
|
14
27
|
|
15
|
-
|
28
|
+
$ yum install sqlite3 sqlite-devel
|
16
29
|
|
17
30
|
$ gem install sssummary
|
18
31
|
|
19
32
|
## Usage
|
20
33
|
|
21
|
-
|
34
|
+
usage: sssummary [OPTION]... SQL
|
35
|
+
-f, --file file path for aggregation.
|
36
|
+
If this option are not specified, read aggregation data from STANDARD INPUT.
|
37
|
+
-d, --database database name.
|
38
|
+
-p, --database file the path where you want to save the database file.
|
39
|
+
-t, --table table name.
|
40
|
+
-c, --columns column names. (e.g., date,url,elapsed_time)
|
41
|
+
-s, --import-separator The String placed between each field in import file. default string is TAB.
|
42
|
+
-o, --output-separator The String placed between each field in output. default string is TAB.
|
43
|
+
-l, --leave-database leave the database. If this option are not specified, delete the database file after processing.
|
44
|
+
-i, --ignore-header ignore header(first line) in import file
|
45
|
+
-v, --verbose explain what is being done.
|
46
|
+
-h, --help show this message
|
47
|
+
|
22
48
|
|
23
49
|
## Contributing
|
24
50
|
|
@@ -27,3 +53,4 @@ TODO: Write usage instructions here
|
|
27
53
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
54
|
4. Push to the branch (`git push origin my-new-feature`)
|
29
55
|
5. Create new Pull Request
|
56
|
+
|
data/bin/sssummary
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# -*- encoding: utf-8 -*-
|
3
3
|
|
4
|
-
|
5
4
|
require 'rubygems'
|
6
5
|
require_relative '../lib/Sssummary'
|
7
6
|
require 'optparse'
|
@@ -24,12 +23,10 @@ begin
|
|
24
23
|
rescue OptionParser::ParseError
|
25
24
|
options[:error] = true
|
26
25
|
end
|
27
|
-
show_help if options[:error] || options[:help]
|
28
|
-
sql = ARGV[0]
|
29
26
|
|
30
|
-
|
27
|
+
if options[:error] || options[:help]
|
31
28
|
puts <<"EOH"
|
32
|
-
usage:
|
29
|
+
usage: sssummary [OPTION]... SQL
|
33
30
|
-f, --file file path for aggregation.
|
34
31
|
If this option are not specified, read aggregation data from STANDARD INPUT.
|
35
32
|
-d, --database database name.
|
@@ -46,7 +43,7 @@ EOH
|
|
46
43
|
exit(0) if options[:help]
|
47
44
|
exit(1)
|
48
45
|
end
|
49
|
-
|
46
|
+
sql = ARGV[0]
|
50
47
|
|
51
48
|
exit_status, output = Sssummary.new.execute(options, sql)
|
52
49
|
puts output
|
data/lib/Sssummary.rb
CHANGED
@@ -51,8 +51,6 @@ class Sssummary
|
|
51
51
|
input_file
|
52
52
|
end
|
53
53
|
|
54
|
-
|
55
|
-
# get data from STANDARD INPUT or FILE
|
56
54
|
def get_records
|
57
55
|
raise FileEmptyError if @input_file.nil?
|
58
56
|
options = {:col_sep => @options[:import_separator], :skip_blanks => true}
|
@@ -162,5 +160,3 @@ class Sssummary
|
|
162
160
|
class FileEmptyError < StandardError;
|
163
161
|
end
|
164
162
|
end
|
165
|
-
|
166
|
-
|
data/lib/sssummary/version.rb
CHANGED