galileo 0.1.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 +7 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +33 -0
- data/Rakefile +1 -0
- data/bin/galileo +9 -0
- data/galileo.gemspec +29 -0
- data/lib/galileo/version.rb +3 -0
- data/lib/galileo.rb +136 -0
- data/lib/terminal-table/.DS_Store +0 -0
- data/lib/terminal-table/Gemfile +7 -0
- data/lib/terminal-table/History.rdoc +48 -0
- data/lib/terminal-table/Manifest +24 -0
- data/lib/terminal-table/README.rdoc +240 -0
- data/lib/terminal-table/Rakefile +15 -0
- data/lib/terminal-table/Todo.rdoc +14 -0
- data/lib/terminal-table/examples/examples.rb +83 -0
- data/lib/terminal-table/lib/terminal-table/cell.rb +98 -0
- data/lib/terminal-table/lib/terminal-table/core_ext.rb +8 -0
- data/lib/terminal-table/lib/terminal-table/row.rb +53 -0
- data/lib/terminal-table/lib/terminal-table/separator.rb +14 -0
- data/lib/terminal-table/lib/terminal-table/style.rb +65 -0
- data/lib/terminal-table/lib/terminal-table/table.rb +261 -0
- data/lib/terminal-table/lib/terminal-table/table_helper.rb +9 -0
- data/lib/terminal-table/lib/terminal-table/version.rb +5 -0
- data/lib/terminal-table/lib/terminal-table.rb +13 -0
- data/lib/terminal-table/spec/cell_spec.rb +60 -0
- data/lib/terminal-table/spec/core_ext_spec.rb +18 -0
- data/lib/terminal-table/spec/import_spec.rb +11 -0
- data/lib/terminal-table/spec/row_spec.rb +25 -0
- data/lib/terminal-table/spec/spec.opts +1 -0
- data/lib/terminal-table/spec/spec_helper.rb +8 -0
- data/lib/terminal-table/spec/table_spec.rb +544 -0
- data/lib/terminal-table/tasks/docs.rake +13 -0
- data/lib/terminal-table/tasks/gemspec.rake +3 -0
- data/lib/terminal-table/tasks/spec.rake +25 -0
- data/lib/terminal-table/terminal-table.gemspec +30 -0
- data/lib/time/time-ago-in-words.rb +32 -0
- metadata +181 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 97832f9101052c99da643d726058352280d8f1d4
|
4
|
+
data.tar.gz: cd2a510e09161c4b547300dfb1b612c721e73192
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ce3804bb5de76eb8f13b9e615b4a119d4db6ef4a3edcf6d5b897bdeffd7c6a3dbe1b6f836ea7413528104d5de9f1e981e2f0aa204aab27a7fee1e4d68629fc6e
|
7
|
+
data.tar.gz: c810592f07efc4ac524317b8f8c606799750461dadc13954efcc1437e914e1e5839065d74a4c5543f31146ede512894e24c6351aa5f8db29857648e006932ed0
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Jackson Gariety
|
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,33 @@
|
|
1
|
+
# Galileo
|
2
|
+
|
3
|
+
Search your starred GitHub repos from your shell.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
gem install galileo
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
See your most recent GitHub stars:
|
12
|
+
|
13
|
+
galileo
|
14
|
+
|
15
|
+
Search through the names & descriptions of the starred repos:
|
16
|
+
|
17
|
+
galileo markdown parser
|
18
|
+
|
19
|
+
Filter by language:
|
20
|
+
|
21
|
+
galileo markdown parser -l javascript
|
22
|
+
|
23
|
+
Refresh the repo cache from GitHub:
|
24
|
+
|
25
|
+
galileo -r
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
1. Fork it ( http://github.com/JacksonGariety/galileo/fork )
|
30
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
32
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
33
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/galileo
ADDED
data/galileo.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'galileo/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "galileo"
|
8
|
+
spec.version = Galileo::VERSION
|
9
|
+
spec.authors = ["Jackson Gariety"]
|
10
|
+
spec.email = ["personal@jacksongariety.com"]
|
11
|
+
spec.summary = "Search your starred GitHub repos from the command line."
|
12
|
+
spec.description = "Search starred GitHub repos."
|
13
|
+
spec.homepage = "http://jacksongariety.github.io/galileo"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
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_runtime_dependency "octokit"
|
22
|
+
spec.add_runtime_dependency "colorize"
|
23
|
+
spec.add_runtime_dependency "netrc"
|
24
|
+
spec.add_runtime_dependency "api_cache"
|
25
|
+
spec.add_runtime_dependency "moneta"
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
28
|
+
spec.add_development_dependency "rake"
|
29
|
+
end
|
data/lib/galileo.rb
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
require "galileo/version"
|
2
|
+
require "octokit"
|
3
|
+
require "terminal-table/lib/terminal-table.rb"
|
4
|
+
require "time/time-ago-in-words"
|
5
|
+
require "colorize"
|
6
|
+
require "netrc"
|
7
|
+
require "api_cache"
|
8
|
+
require "moneta"
|
9
|
+
require "tmpdir"
|
10
|
+
|
11
|
+
class Galileo
|
12
|
+
def initialize(query)
|
13
|
+
repos = []
|
14
|
+
config = Netrc.read
|
15
|
+
|
16
|
+
unless config["api.github.com"]
|
17
|
+
puts "" # \n
|
18
|
+
login = [(print 'GitHub Username: '), $stdin.gets.rstrip][1]
|
19
|
+
password = [(print 'GitHub Password: '), $stdin.gets.rstrip][1]
|
20
|
+
config["api.github.com"] = login, password
|
21
|
+
config.save
|
22
|
+
end
|
23
|
+
|
24
|
+
Octokit.configure do |client|
|
25
|
+
client.netrc = true
|
26
|
+
client.auto_paginate = true
|
27
|
+
end
|
28
|
+
|
29
|
+
APICache.store = Moneta.new(:File, dir: Dir.tmpdir)
|
30
|
+
|
31
|
+
repos = APICache.get("starred", fail: [], timeout: 20, cache: 3600) do
|
32
|
+
repos = []
|
33
|
+
|
34
|
+
puts "" # \n
|
35
|
+
puts "Searching the stars..."
|
36
|
+
|
37
|
+
# GET
|
38
|
+
Octokit.starred(Octokit.user.login).each do |repo|
|
39
|
+
repos << [
|
40
|
+
repo.name || '',
|
41
|
+
repo.description || '',
|
42
|
+
repo.language || '',
|
43
|
+
repo.owner.login || '',
|
44
|
+
repo.stargazers_count || '',
|
45
|
+
repo.updated_at || ''
|
46
|
+
]
|
47
|
+
end
|
48
|
+
|
49
|
+
repos
|
50
|
+
end
|
51
|
+
|
52
|
+
if repos.any?
|
53
|
+
if query.any?
|
54
|
+
languages = []
|
55
|
+
|
56
|
+
# If the language parameter if present
|
57
|
+
if query.index('-l')
|
58
|
+
languages = query.delete(query[query.index('-l') + 1]).split(',')
|
59
|
+
query.delete('-l')
|
60
|
+
end
|
61
|
+
|
62
|
+
# Filter by the query
|
63
|
+
repos.select! do |repo|
|
64
|
+
|
65
|
+
|
66
|
+
# Join the arguments into a query
|
67
|
+
q = query.join(' ').downcase
|
68
|
+
repo[0].downcase.include?(q) or
|
69
|
+
repo[1].downcase.include?(q)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Sort by stars
|
73
|
+
repos.sort_by! { |repo| -repo[4] } if query and repos.any?
|
74
|
+
|
75
|
+
# If languages
|
76
|
+
if languages.any?
|
77
|
+
languages.map!(&:downcase)
|
78
|
+
|
79
|
+
repos.select! do |repo|
|
80
|
+
languages.include? repo[2].downcase
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
if repos.any?
|
86
|
+
# Formatting
|
87
|
+
repos.map! do |repo|
|
88
|
+
repo[0] = repo[0].yellow
|
89
|
+
|
90
|
+
# Language color-coating
|
91
|
+
case repo[2]
|
92
|
+
when 'Clojur' then repo[2] = repo[2].colorize(:light_red)
|
93
|
+
when 'Ruby' then repo[2] = repo[2].red
|
94
|
+
when 'CSS', 'CoffeeScript', 'Python' then repo[2] = repo[2].blue
|
95
|
+
when 'Perl', 'Shell', 'Objective-C' then repo[2] = repo[2].colorize(:light_blue)
|
96
|
+
when 'PHP', 'C#' then repo[2] = repo[2].magenta
|
97
|
+
when 'Emacs Lisp', 'C++' then repo[2] = repo[2].colorize(:light_magenta)
|
98
|
+
when 'Smalltalk' then repo[2] = repo[2].green
|
99
|
+
when 'VimL', 'Scala' then repo[2] = repo[2].colorize(:light_green)
|
100
|
+
when 'C' then repo[2] = repo[2].black
|
101
|
+
when 'Go' then repo[2] = repo[2].yellow
|
102
|
+
when 'Assembly', 'Java', 'JavaScript' then repo[2] = repo[2].colorize(:light_yellow)
|
103
|
+
when 'Common Lisp' then repo[2] = repo[2].cyan
|
104
|
+
end
|
105
|
+
|
106
|
+
repo[4] = repo[4].to_s.blue
|
107
|
+
repo[3] = repo[3].red
|
108
|
+
repo[5] = repo[5].time_ago_in_words
|
109
|
+
repo[6] = "github.com/#{repo[3].uncolorize}/#{repo[0].uncolorize}".magenta
|
110
|
+
repo
|
111
|
+
end
|
112
|
+
|
113
|
+
# Add separators
|
114
|
+
repos = repos.product([:separator]).flatten(1)[0...-1]
|
115
|
+
|
116
|
+
# Construct the table
|
117
|
+
table = Terminal::Table.new
|
118
|
+
table.headings = ['Name', 'Description', 'Language', 'Author', 'Stars', 'Last Updated', 'Link (⌘ + Click)']
|
119
|
+
table.rows = repos[0..20]
|
120
|
+
table.style = { width: `/usr/bin/env tput cols`.to_i }
|
121
|
+
|
122
|
+
# Print the table
|
123
|
+
puts "\n#{table}\n\n"
|
124
|
+
else
|
125
|
+
puts "\nNo results for that query.\n\n"
|
126
|
+
end
|
127
|
+
else
|
128
|
+
puts "\nNo results found. Have you starred any repos? Have you exceeded your rate limit?\n\n"
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def self.refresh
|
133
|
+
FileUtils.rm_rf(Dir.tmpdir)
|
134
|
+
self.new([])
|
135
|
+
end
|
136
|
+
end
|
Binary file
|
@@ -0,0 +1,48 @@
|
|
1
|
+
1.4.3 / 2011-10-13
|
2
|
+
==================
|
3
|
+
|
4
|
+
* Optimize for faster table output.
|
5
|
+
|
6
|
+
1.4.2 / 2010-01-14
|
7
|
+
==================
|
8
|
+
|
9
|
+
* Fixed some bugs with colspan
|
10
|
+
|
11
|
+
=== 1.4.1 / 2009-12-18
|
12
|
+
|
13
|
+
* Fix column alignment with separators.
|
14
|
+
|
15
|
+
=== 1.4.0 / 2009-12-18
|
16
|
+
|
17
|
+
* Can now add :seperator arbitrarily in a table [thanks splattael]
|
18
|
+
* Fix common typo: seperator -> separator [thanks splattael]
|
19
|
+
|
20
|
+
=== 1.3.0 / 2009-10-16
|
21
|
+
|
22
|
+
* Major refactoring (functionality remains the same)
|
23
|
+
|
24
|
+
=== 1.2.0 / 2009-08-06
|
25
|
+
|
26
|
+
* Added colspan support to table
|
27
|
+
|
28
|
+
=== 1.1.0 / 2009-08-06
|
29
|
+
|
30
|
+
* Added colspan support to table
|
31
|
+
|
32
|
+
=== 1.1.0 / 2009-07-13
|
33
|
+
|
34
|
+
* Added Table#==
|
35
|
+
|
36
|
+
=== 1.0.5 / 2009-03-14
|
37
|
+
|
38
|
+
* Allowing nil to be passed to table for headings
|
39
|
+
* Revised doc to show that rows can be splatted now
|
40
|
+
* Misc refactoring
|
41
|
+
|
42
|
+
=== 1.0.3 / 2009-01-15
|
43
|
+
|
44
|
+
* Moved yield or eval to Terminal::Table initialize where it belongs
|
45
|
+
|
46
|
+
=== 1.0.0 / 2009-01-13
|
47
|
+
|
48
|
+
* Initial release
|
@@ -0,0 +1,24 @@
|
|
1
|
+
History.rdoc
|
2
|
+
Manifest
|
3
|
+
README.rdoc
|
4
|
+
Rakefile
|
5
|
+
Todo.rdoc
|
6
|
+
examples/examples.rb
|
7
|
+
lib/terminal-table.rb
|
8
|
+
lib/terminal-table/cell.rb
|
9
|
+
lib/terminal-table/core_ext.rb
|
10
|
+
lib/terminal-table/heading.rb
|
11
|
+
lib/terminal-table/import.rb
|
12
|
+
lib/terminal-table/table.rb
|
13
|
+
lib/terminal-table/table_helper.rb
|
14
|
+
lib/terminal-table/version.rb
|
15
|
+
spec/cell_spec.rb
|
16
|
+
spec/core_ext_spec.rb
|
17
|
+
spec/import_spec.rb
|
18
|
+
spec/spec.opts
|
19
|
+
spec/spec_helper.rb
|
20
|
+
spec/table_spec.rb
|
21
|
+
tasks/docs.rake
|
22
|
+
tasks/gemspec.rake
|
23
|
+
tasks/spec.rake
|
24
|
+
terminal-table.gemspec
|
@@ -0,0 +1,240 @@
|
|
1
|
+
= Terminal Table
|
2
|
+
|
3
|
+
== Description
|
4
|
+
|
5
|
+
Terminal Table is a fast and simple, yet feature rich ASCII table generator written in Ruby.
|
6
|
+
|
7
|
+
== Installation
|
8
|
+
|
9
|
+
Install http://gemcutter.org and execute:
|
10
|
+
|
11
|
+
$ gem install terminal-table
|
12
|
+
|
13
|
+
== Usage
|
14
|
+
|
15
|
+
=== Basics
|
16
|
+
|
17
|
+
To use Terminal Table:
|
18
|
+
|
19
|
+
require 'terminal-table'
|
20
|
+
|
21
|
+
To generate a table, provide an array of arrays (which are interpreted as rows):
|
22
|
+
|
23
|
+
rows = []
|
24
|
+
rows << ['One', 1]
|
25
|
+
rows << ['Two', 2]
|
26
|
+
rows << ['Three', 3]
|
27
|
+
table = Terminal::Table.new :rows => rows
|
28
|
+
|
29
|
+
# > puts table
|
30
|
+
#
|
31
|
+
# +-------+---+
|
32
|
+
# | One | 1 |
|
33
|
+
# | Two | 2 |
|
34
|
+
# | Three | 3 |
|
35
|
+
# +-------+---+
|
36
|
+
|
37
|
+
|
38
|
+
The constructor can also be given a block which is either yielded the Table object or instance evaluated:
|
39
|
+
|
40
|
+
table = Terminal::Table.new do |t|
|
41
|
+
t.rows = rows
|
42
|
+
end
|
43
|
+
|
44
|
+
table = Terminal::Table.new do
|
45
|
+
self.rows = rows
|
46
|
+
end
|
47
|
+
|
48
|
+
Adding rows one by one:
|
49
|
+
|
50
|
+
table = Terminal::Table.new do |t|
|
51
|
+
t << ['One', 1]
|
52
|
+
t.add_row ['Two', 2]
|
53
|
+
end
|
54
|
+
|
55
|
+
To add separators between rows:
|
56
|
+
|
57
|
+
table = Terminal::Table.new do |t|
|
58
|
+
t << ['One', 1]
|
59
|
+
t << :separator
|
60
|
+
t.add_row ['Two', 2]
|
61
|
+
t.add_separator
|
62
|
+
t.add_row ['Three', 3]
|
63
|
+
end
|
64
|
+
|
65
|
+
# > puts table
|
66
|
+
#
|
67
|
+
# +-------+---+
|
68
|
+
# | One | 1 |
|
69
|
+
# +-------+---+
|
70
|
+
# | Two | 2 |
|
71
|
+
# +-------+---+
|
72
|
+
# | Three | 3 |
|
73
|
+
# +-------+---+
|
74
|
+
|
75
|
+
Cells can handle multiline content:
|
76
|
+
|
77
|
+
table = Terminal::Table.new do |t|
|
78
|
+
t << ['One', 1]
|
79
|
+
t << :separator
|
80
|
+
t.add_row ["Two\nDouble", 2]
|
81
|
+
t.add_separator
|
82
|
+
t.add_row ['Three', 3]
|
83
|
+
end
|
84
|
+
|
85
|
+
# > puts table
|
86
|
+
#
|
87
|
+
# +--------+---+
|
88
|
+
# | One | 1 |
|
89
|
+
# +--------+---+
|
90
|
+
# | Two | 2 |
|
91
|
+
# | Double | |
|
92
|
+
# +--------+---+
|
93
|
+
# | Three | 3 |
|
94
|
+
# +--------+---+
|
95
|
+
|
96
|
+
=== Head
|
97
|
+
|
98
|
+
To add a head to the table:
|
99
|
+
|
100
|
+
table = Terminal::Table.new :headings => ['Word', 'Number'], :rows => rows
|
101
|
+
|
102
|
+
# > puts table
|
103
|
+
#
|
104
|
+
# +-------+--------+
|
105
|
+
# | Word | Number |
|
106
|
+
# +-------+--------+
|
107
|
+
# | One | 1 |
|
108
|
+
# | Two | 2 |
|
109
|
+
# | Three | 3 |
|
110
|
+
# +-------+--------+
|
111
|
+
|
112
|
+
=== Title
|
113
|
+
|
114
|
+
To add a title to the table:
|
115
|
+
|
116
|
+
table = Terminal::Table.new :title => "Cheatsheet", :headings => ['Word', 'Number'], :rows => rows
|
117
|
+
|
118
|
+
# > puts table
|
119
|
+
#
|
120
|
+
# +------------+--------+
|
121
|
+
# | Cheatsheet |
|
122
|
+
# +------------+--------+
|
123
|
+
# | Word | Number |
|
124
|
+
# +------------+--------+
|
125
|
+
# | One | 1 |
|
126
|
+
# | Two | 2 |
|
127
|
+
# | Three | 3 |
|
128
|
+
# +------------+--------+
|
129
|
+
|
130
|
+
=== Alignment
|
131
|
+
|
132
|
+
To align the second column to the right:
|
133
|
+
|
134
|
+
table.align_column(1, :right)
|
135
|
+
|
136
|
+
# > puts table
|
137
|
+
#
|
138
|
+
# +-------+--------+
|
139
|
+
# | Word | Number |
|
140
|
+
# +-------+--------+
|
141
|
+
# | One | 1 |
|
142
|
+
# | Two | 2 |
|
143
|
+
# | Three | 3 |
|
144
|
+
# +-------+--------+
|
145
|
+
|
146
|
+
To align an individual cell, you specify the cell value in a hash along the alignment:
|
147
|
+
|
148
|
+
table << ["Four", {:value => 4.0, :alignment => :center}]
|
149
|
+
|
150
|
+
# > puts table
|
151
|
+
#
|
152
|
+
# +-------+--------+
|
153
|
+
# | Word | Number |
|
154
|
+
# +-------+--------+
|
155
|
+
# | One | 1 |
|
156
|
+
# | Two | 2 |
|
157
|
+
# | Three | 3 |
|
158
|
+
# | Four | 4.0 |
|
159
|
+
# +-------+--------+
|
160
|
+
|
161
|
+
=== Style
|
162
|
+
|
163
|
+
To specify style options:
|
164
|
+
|
165
|
+
table = Terminal::Table.new :headings => ['Word', 'Number'], :rows => rows, :style => {:width => 80}
|
166
|
+
|
167
|
+
# > puts table
|
168
|
+
#
|
169
|
+
# +--------------------------------------+---------------------------------------+
|
170
|
+
# | Word | Number |
|
171
|
+
# +--------------------------------------+---------------------------------------+
|
172
|
+
# | One | 1 |
|
173
|
+
# | Two | 2 |
|
174
|
+
# | Three | 3 |
|
175
|
+
# +--------------------------------------+---------------------------------------+
|
176
|
+
|
177
|
+
And change styles on the fly:
|
178
|
+
|
179
|
+
table.style = {:width => 40, :padding_left => 3, :border_x => "=", :border_i => "x"}
|
180
|
+
|
181
|
+
# > puts table
|
182
|
+
#
|
183
|
+
# x====================x=================x
|
184
|
+
# | Cheatsheet |
|
185
|
+
# x====================x=================x
|
186
|
+
# | Word | Number |
|
187
|
+
# x====================x=================x
|
188
|
+
# | One | 1 |
|
189
|
+
# | Two | 2 |
|
190
|
+
# | Three | 3 |
|
191
|
+
# x====================x=================x
|
192
|
+
|
193
|
+
To change the default style options:
|
194
|
+
|
195
|
+
Terminal::Style.defaults = {:width => 80}
|
196
|
+
|
197
|
+
All Table objects created afterwards will inherit these defaults.
|
198
|
+
|
199
|
+
=== Constructor options and setter methods
|
200
|
+
|
201
|
+
Valid options for the constructor are :rows, :headings, :style and :title - and all options can also be set on the created table object by their setter method:
|
202
|
+
|
203
|
+
table = Terminal::Table.new
|
204
|
+
table.title = "Cheatsheet"
|
205
|
+
table.headings = ['Word', 'Number']
|
206
|
+
table.rows = rows
|
207
|
+
table.style = {:width => 40}
|
208
|
+
|
209
|
+
== More examples
|
210
|
+
|
211
|
+
For more examples, please see the examples/examples.rb file included in the source distribution.
|
212
|
+
|
213
|
+
== Author
|
214
|
+
|
215
|
+
TJ Holowaychuk <tj@vision-media.ca>
|
216
|
+
|
217
|
+
== License
|
218
|
+
|
219
|
+
(The MIT License)
|
220
|
+
|
221
|
+
Copyright (c) 2008-2009 TJ Holowaychuk <tj@vision-media.ca>
|
222
|
+
|
223
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
224
|
+
a copy of this software and associated documentation files (the
|
225
|
+
'Software'), to deal in the Software without restriction, including
|
226
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
227
|
+
distribute, sublicense, an d/or sell copies of the Software, and to
|
228
|
+
permit persons to whom the Software is furnished to do so, subject to
|
229
|
+
the following conditions:
|
230
|
+
|
231
|
+
The above copyright notice and this permission notice shall be
|
232
|
+
included in all copies or substantial portions of the Software.
|
233
|
+
|
234
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
235
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
236
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
237
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
238
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
239
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
240
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rake'
|
4
|
+
require 'echoe'
|
5
|
+
require './lib/terminal-table.rb'
|
6
|
+
|
7
|
+
Echoe.new("terminal-table", Terminal::Table::VERSION) do |p|
|
8
|
+
p.author = "TJ Holowaychuk"
|
9
|
+
p.email = "tj@vision-media.ca"
|
10
|
+
p.summary = "Simple, feature rich ascii table generation library"
|
11
|
+
p.url = "http://github.com/visionmedia/terminal-table"
|
12
|
+
p.runtime_dependencies = []
|
13
|
+
end
|
14
|
+
|
15
|
+
Dir['tasks/**/*.rake'].sort.each { |lib| load lib }
|