chell 0.1.1
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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +52 -0
- data/Rakefile +1 -0
- data/bin/chell +39 -0
- data/chell.gemspec +26 -0
- data/lib/chell.rb +56 -0
- data/lib/chell/version.rb +3 -0
- data/resources/logo.png +0 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 460c398803a032b51a1d432bac5803d66ea207df
|
4
|
+
data.tar.gz: dee8eea47a2feb303fe8462a1bbcdb76573e2276
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 63119efdca92d63c4ac762d88924e0eb53d4fc577bc87ebc3a7ad46b634bfe91d729de71bd532ec87a14b468169a5e05f66c81f43731b033a82b1a30d6ca7b78
|
7
|
+
data.tar.gz: 90884347b119d218bd1802dfde6117a054bc2d2be2460d5a353d2d18e1da0790903a13b1189871feb4e4250705cb904225a9893d1af3129ec840ae834675bf5c
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 toooooooby
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# Chell
|
2
|
+
|
3
|
+

|
4
|
+
|
5
|
+
Ruby + csv + [pry] + [lambda_driver] => csv-shell => **Chell!!**
|
6
|
+
|
7
|
+
`Chell` is a servant who helps us with our cooking of CSV(Comma-separated values)
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
$ gem install chell
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
```
|
16
|
+
$ cat foobar.csv
|
17
|
+
:
|
18
|
+
$ chell foobar.csv
|
19
|
+
> size
|
20
|
+
10
|
21
|
+
> headers
|
22
|
+
: # Show first column of CSV
|
23
|
+
> col 3
|
24
|
+
:
|
25
|
+
> row 2
|
26
|
+
:
|
27
|
+
> col(3).map.sort.uniq
|
28
|
+
:
|
29
|
+
> col(3){|x| x.upcase }
|
30
|
+
:
|
31
|
+
> col!(3){|x| x.upcase }
|
32
|
+
:
|
33
|
+
> write 'test.csv'
|
34
|
+
```
|
35
|
+
|
36
|
+
with [Lambda Driver][lambda_driver]
|
37
|
+
|
38
|
+
```
|
39
|
+
> col(3).map(&:to_s >> :upcase)
|
40
|
+
```
|
41
|
+
|
42
|
+
## Todos
|
43
|
+
|
44
|
+
* todo: Add some badges below title after finishing configurations their services.
|
45
|
+
* todo: Make a proper graphical logo( like a servant with a machine toolkit )
|
46
|
+
* todo: Write spec(It's a shame that this project is not test first!!)
|
47
|
+
* todo: Write usage.
|
48
|
+
|
49
|
+
----
|
50
|
+
|
51
|
+
[pry]: http://pryrepl.org/ "Pry - an IRB alternative and runtime developer console"
|
52
|
+
[lambda_driver]: http://yuroyoro.github.io/lambda_driver/ "LambdaDriver by yuroyoro"
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/chell
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '../lib')
|
4
|
+
require 'chell'
|
5
|
+
|
6
|
+
# Parse options
|
7
|
+
require 'optparse'
|
8
|
+
program_name = File.basename(__FILE__)
|
9
|
+
opt = OptionParser.new do |opts|
|
10
|
+
opts.banner = File.read(File.join(File.dirname(__FILE__), "../README.md")).scan(/^`Chell` .*/).first
|
11
|
+
opts.define_head "Usage: #{program_name} FILE.CSV"
|
12
|
+
opts.separator <<-EOD
|
13
|
+
|
14
|
+
Examples:
|
15
|
+
$ #{program_name} --encoding cp932 foobar.csv
|
16
|
+
|
17
|
+
Options:
|
18
|
+
EOD
|
19
|
+
|
20
|
+
opts.on('-E', '--encoding ENCODING',
|
21
|
+
'Set external encoding(Default: depending ruby version)') do |encoding|
|
22
|
+
Encoding.default_external = encoding
|
23
|
+
puts "Encoding.default_external: #{Encoding.default_external}"
|
24
|
+
end
|
25
|
+
|
26
|
+
opts.on_tail('-h', '--help', 'Show this message') do
|
27
|
+
puts opts
|
28
|
+
exit
|
29
|
+
end
|
30
|
+
end
|
31
|
+
opt.parse!
|
32
|
+
|
33
|
+
if ARGV.empty?
|
34
|
+
puts opt
|
35
|
+
exit
|
36
|
+
end
|
37
|
+
|
38
|
+
filename = ARGV.shift
|
39
|
+
Chell::CSV.new(File.read(filename)).run_shell!
|
data/chell.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'chell/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "chell"
|
8
|
+
spec.version = Chell::VERSION
|
9
|
+
spec.authors = ["toooooooby"]
|
10
|
+
spec.email = ["toby.net.info.mail+git@gmail.com"]
|
11
|
+
spec.summary = %q{csv + pry + lambda_driver => csv-shell => Chell}
|
12
|
+
spec.description = %q{Chell is a tool which is easy to manipulate CSV}
|
13
|
+
spec.homepage = "https://github.com/toooooooby/chell"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'pry', '~> 0.9.12'
|
22
|
+
spec.add_dependency 'lambda_driver', '~> 1.2'
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
end
|
data/lib/chell.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require "chell/version"
|
2
|
+
|
3
|
+
require 'csv'
|
4
|
+
require 'pry'
|
5
|
+
|
6
|
+
module Chell
|
7
|
+
class CSV
|
8
|
+
def initialize(data, options = {})
|
9
|
+
@options = {headers: true}.merge(options)
|
10
|
+
@table = ::CSV.new(data, @options).read
|
11
|
+
@table.extend ReinforcedCSVTable
|
12
|
+
end
|
13
|
+
|
14
|
+
def run_shell!
|
15
|
+
@table.pry
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
module ReinforcedCSVTable
|
20
|
+
def col(index = 0, &block)
|
21
|
+
map_wrapper(block){ map{|x| x[index] } }
|
22
|
+
end
|
23
|
+
|
24
|
+
def col!(index = 0, &block)
|
25
|
+
map.with_index{|x,i| x[index] = (yield x[index], i) } if block_given?
|
26
|
+
end
|
27
|
+
|
28
|
+
def row(index = 0, &block)
|
29
|
+
map_wrapper(block){ self[index] }
|
30
|
+
end
|
31
|
+
|
32
|
+
def write(filename)
|
33
|
+
File.write(filename, self.to_csv(write_headers: true))
|
34
|
+
end
|
35
|
+
|
36
|
+
# Alias methods
|
37
|
+
def csv; self; end
|
38
|
+
def s; size; end
|
39
|
+
def l; length; end
|
40
|
+
# def column(*args); col(*args); end
|
41
|
+
# def c(*args); col(*args); end
|
42
|
+
# def r(*args); row(*args); end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def map_wrapper(proc)
|
47
|
+
if proc
|
48
|
+
(yield).map(&proc)
|
49
|
+
else
|
50
|
+
yield
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
data/resources/logo.png
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chell
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- toooooooby
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pry
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.9.12
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.9.12
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: lambda_driver
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Chell is a tool which is easy to manipulate CSV
|
70
|
+
email:
|
71
|
+
- toby.net.info.mail+git@gmail.com
|
72
|
+
executables:
|
73
|
+
- chell
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/chell
|
83
|
+
- chell.gemspec
|
84
|
+
- lib/chell.rb
|
85
|
+
- lib/chell/version.rb
|
86
|
+
- resources/logo.png
|
87
|
+
homepage: https://github.com/toooooooby/chell
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.2.0
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: csv + pry + lambda_driver => csv-shell => Chell
|
111
|
+
test_files: []
|