gridcli 0.0.4 → 0.0.5
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/TODO +13 -0
- data/gridcli.gemspec +2 -0
- data/lib/gridcli/commands/help.rb +1 -1
- data/lib/gridcli/commands/list.rb +1 -2
- data/lib/gridcli/commands/pprint.rb +19 -0
- data/lib/gridcli/commands/update.rb +6 -1
- data/lib/gridcli/pprinter.rb +48 -0
- data/lib/gridcli/storage/files.rb +2 -2
- data/lib/gridcli/version.rb +1 -1
- data/lib/gridcli.rb +2 -0
- metadata +38 -3
data/TODO
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
grid list friends --of-friends
|
2
|
+
|
3
|
+
pretty print for profiles
|
4
|
+
|
5
|
+
ascii profiles
|
6
|
+
|
7
|
+
circles (or grids?) - with lists stored locally. Format:
|
8
|
+
|
9
|
+
play: [ sally, mary, suzie ]
|
10
|
+
work: [ bob, john ]
|
11
|
+
everyone: [ @work, @play ]
|
12
|
+
|
13
|
+
or something like that..
|
data/gridcli.gemspec
CHANGED
@@ -16,6 +16,8 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.require_paths = ["lib"]
|
17
17
|
s.add_dependency("activeresource", ">= 3.0.10")
|
18
18
|
s.add_dependency("chronic", ">= 0.6.4")
|
19
|
+
s.add_dependency("json", ">= 1.6.1")
|
20
|
+
s.add_dependency("colorize", ">= 0.5.8")
|
19
21
|
s.bindir = "bin"
|
20
22
|
s.executables << "grid"
|
21
23
|
end
|
@@ -13,7 +13,7 @@ module GridCLI
|
|
13
13
|
puts "Usage: grid <cmd>\n\nAvailable commands:\n\n"
|
14
14
|
Runner.commands.each { |klass|
|
15
15
|
inst = klass.new
|
16
|
-
puts "\t#{inst.cmd
|
16
|
+
puts "\t#{inst.cmd.ljust(25) + inst.desc}"
|
17
17
|
}
|
18
18
|
puts "\n\nTo get the options for any individual command, use:"
|
19
19
|
puts "\tgrid help <cmd>\n\n"
|
@@ -9,8 +9,7 @@ module GridCLI
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def run(args)
|
12
|
-
|
13
|
-
type = args.shift
|
12
|
+
type = (args.length > 0) ? args.shift : "all"
|
14
13
|
usage if not [ 'like', 'dislike', 'status', 'message', 'all' ].include? type
|
15
14
|
period = (args.length > 0 and not args.first.start_with? '-') ? args.shift : nil
|
16
15
|
dates = parse_dates period
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module GridCLI
|
2
|
+
class PPrintCommand < BaseCommand
|
3
|
+
def initialize
|
4
|
+
super "pprint", "A program that will pretty print posts/users"
|
5
|
+
end
|
6
|
+
|
7
|
+
def run(args)
|
8
|
+
usage if args.length != 0
|
9
|
+
|
10
|
+
ARGV.clear
|
11
|
+
ARGF.each { |line|
|
12
|
+
puts PrettyPrinter.new(line)
|
13
|
+
puts
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
Runner.register "pprint", PPrintCommand
|
19
|
+
end
|
@@ -29,7 +29,12 @@ module GridCLI
|
|
29
29
|
if posts.length == 0
|
30
30
|
puts "Up to date."
|
31
31
|
else
|
32
|
-
posts.each { |p|
|
32
|
+
posts.each { |p|
|
33
|
+
type = p.known_attributes.first
|
34
|
+
json = p.send(type).to_json(:root => type)
|
35
|
+
puts PrettyPrinter.new(json)
|
36
|
+
puts
|
37
|
+
}
|
33
38
|
@config['last_sha'] = GridCLI.storage.append(posts)
|
34
39
|
@config.save
|
35
40
|
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'colorize'
|
3
|
+
|
4
|
+
module GridCLI
|
5
|
+
class PrettyPrinter
|
6
|
+
def initialize(string)
|
7
|
+
begin
|
8
|
+
j = JSON.parse(string)
|
9
|
+
type = j.keys.first
|
10
|
+
@contents = j[type]
|
11
|
+
@created_at = Time.parse(@contents['created_at']).localtime.to_s
|
12
|
+
@pretty = case type
|
13
|
+
when "message" then pprint_message
|
14
|
+
when "like" then pprint_like
|
15
|
+
when "dislike" then pprint_dislike
|
16
|
+
when "status" then pprint_status
|
17
|
+
else string
|
18
|
+
end
|
19
|
+
rescue JSON::ParserError
|
20
|
+
@pretty = string
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def pprint_like
|
25
|
+
"on #{@created_at} #{@contents['from_username']} liked #{@contents['body']}".green
|
26
|
+
end
|
27
|
+
|
28
|
+
def pprint_dislike
|
29
|
+
"on #{@created_at} #{@contents['from_username']} disliked #{@contents['body']}".red
|
30
|
+
end
|
31
|
+
|
32
|
+
def pprint_status
|
33
|
+
"on #{@created_at} #{@contents['from_username']} was #{@contents['body']}".cyan
|
34
|
+
end
|
35
|
+
|
36
|
+
def pprint_message
|
37
|
+
s = "Message from: ".cyan + @contents['from_username'] + "\n"
|
38
|
+
s+= "Subject: ".cyan + @contents['subject'] + "\n"
|
39
|
+
s+= "Date: ".cyan + @created_at + "\n"
|
40
|
+
s+= "To: ".cyan + @contents['recipients'] + "\n"
|
41
|
+
s+= @contents['body']
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_s
|
45
|
+
@pretty
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -85,13 +85,13 @@ module GridCLI
|
|
85
85
|
|
86
86
|
def search(type, query, start_date, end_date)
|
87
87
|
files(type, start_date, end_date) { |path|
|
88
|
-
system "grep -R \"#{query}\" #{path}"
|
88
|
+
system "grep -R \"#{query}\" #{path} | #{$0} pprint"
|
89
89
|
}
|
90
90
|
end
|
91
91
|
|
92
92
|
def list(type, start_date, end_date)
|
93
93
|
files(type, start_date, end_date) { |path|
|
94
|
-
system "cat #{path}"
|
94
|
+
system "cat #{path} | #{$0} pprint"
|
95
95
|
}
|
96
96
|
end
|
97
97
|
|
data/lib/gridcli/version.rb
CHANGED
data/lib/gridcli.rb
CHANGED
@@ -17,8 +17,10 @@ end
|
|
17
17
|
|
18
18
|
require 'gridcli/version'
|
19
19
|
require 'gridcli/runner'
|
20
|
+
require 'gridcli/pprinter'
|
20
21
|
|
21
22
|
require 'gridcli/commands/base'
|
23
|
+
require 'gridcli/commands/pprint'
|
22
24
|
require 'gridcli/commands/signup'
|
23
25
|
require 'gridcli/commands/help'
|
24
26
|
require 'gridcli/commands/profile'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gridcli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Brian Muller
|
@@ -50,6 +50,38 @@ dependencies:
|
|
50
50
|
version: 0.6.4
|
51
51
|
type: :runtime
|
52
52
|
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: json
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 13
|
62
|
+
segments:
|
63
|
+
- 1
|
64
|
+
- 6
|
65
|
+
- 1
|
66
|
+
version: 1.6.1
|
67
|
+
type: :runtime
|
68
|
+
version_requirements: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: colorize
|
71
|
+
prerelease: false
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 27
|
78
|
+
segments:
|
79
|
+
- 0
|
80
|
+
- 5
|
81
|
+
- 8
|
82
|
+
version: 0.5.8
|
83
|
+
type: :runtime
|
84
|
+
version_requirements: *id004
|
53
85
|
description: "A command line interface to The Grid: Social Networking, Web 0.2"
|
54
86
|
email:
|
55
87
|
- bamuller@gmail.com
|
@@ -66,6 +98,7 @@ files:
|
|
66
98
|
- Gemfile
|
67
99
|
- README.rdoc
|
68
100
|
- Rakefile
|
101
|
+
- TODO
|
69
102
|
- bin/grid
|
70
103
|
- gridcli.gemspec
|
71
104
|
- lib/gridcli.rb
|
@@ -78,12 +111,14 @@ files:
|
|
78
111
|
- lib/gridcli/commands/like.rb
|
79
112
|
- lib/gridcli/commands/list.rb
|
80
113
|
- lib/gridcli/commands/message.rb
|
114
|
+
- lib/gridcli/commands/pprint.rb
|
81
115
|
- lib/gridcli/commands/profile.rb
|
82
116
|
- lib/gridcli/commands/search.rb
|
83
117
|
- lib/gridcli/commands/signup.rb
|
84
118
|
- lib/gridcli/commands/status.rb
|
85
119
|
- lib/gridcli/commands/update.rb
|
86
120
|
- lib/gridcli/config.rb
|
121
|
+
- lib/gridcli/pprinter.rb
|
87
122
|
- lib/gridcli/resources/base.rb
|
88
123
|
- lib/gridcli/resources/blockage.rb
|
89
124
|
- lib/gridcli/resources/friendship.rb
|