usaidwat 0.0.10 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -3
- data/Gemfile +1 -1
- data/LICENSE.txt +20 -0
- data/README.md +29 -0
- data/Rakefile +5 -0
- data/bin/usaidwat +1 -55
- data/features/browse.feature +1003 -0
- data/features/fixtures/comments.json +1 -0
- data/features/help.feature +20 -0
- data/features/server/reddit.rb +12 -0
- data/features/step_definitions/reddit_steps.rb +3 -0
- data/features/support/aruba.rb +1 -0
- data/lib/usaidwat/application.rb +77 -0
- data/lib/usaidwat/client.rb +28 -0
- data/lib/usaidwat/formatter.rb +33 -0
- data/lib/usaidwat/version.rb +1 -1
- data/lib/usaidwat.rb +4 -7
- data/spec/spec_helper.rb +2 -0
- data/spec/usaidwat/client_spec.rb +46 -0
- data/spec/usaidwat/formatter_spec.rb +45 -0
- data/usaidwat.gemspec +22 -19
- metadata +86 -20
- data/README.textile +0 -51
- data/lib/usaidwat/reddit.rb +0 -136
- data/lib/usaidwat/utils.rb +0 -31
- data/spec/utils_spec.rb +0 -9
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Michael Dippery
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Usaidwat
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'usaidwat'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install usaidwat
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
CHANGED
data/bin/usaidwat
CHANGED
@@ -1,59 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'usaidwat'
|
4
|
-
require 'usaidwat/utils'
|
5
|
-
require 'rainbow'
|
6
4
|
|
7
|
-
|
8
|
-
def die(code=1, stream=STDERR)
|
9
|
-
stream.puts "Usage: #{File.basename $0} <user> [<subreddit>]"
|
10
|
-
exit code
|
11
|
-
end
|
12
|
-
|
13
|
-
die if ARGV.length < 1 or ARGV.length > 2
|
14
|
-
|
15
|
-
die(0, STDOUT) if ARGV.first == '--help' || ARGV.first == '-h'
|
16
|
-
|
17
|
-
if ARGV.first == '--version' or ARGV.first == '-V'
|
18
|
-
puts "usaidwat v#{USaidWat::VERSION}"
|
19
|
-
exit 0
|
20
|
-
end
|
21
|
-
|
22
|
-
reddit_user = USaidWat::RedditUser.new ARGV.shift
|
23
|
-
if ARGV.length == 0
|
24
|
-
comments = reddit_user.retrieve_comments
|
25
|
-
exit 2 unless comments
|
26
|
-
max_key = comments.longest_subreddit.length
|
27
|
-
comments.each { |c| printf "%-*s %s\n", max_key, c.first, c.last }
|
28
|
-
else
|
29
|
-
if ARGV[0] == '--all'
|
30
|
-
comments = reddit_user.retrieve_comments
|
31
|
-
comments.each do |record|
|
32
|
-
subreddit = record[0]
|
33
|
-
comments = reddit_user.comments_for_subreddit subreddit
|
34
|
-
run_pager
|
35
|
-
is_first = true
|
36
|
-
comments.each do |c|
|
37
|
-
puts unless is_first
|
38
|
-
puts subreddit.foreground(:green).bright
|
39
|
-
puts c
|
40
|
-
is_first = false
|
41
|
-
end
|
42
|
-
end
|
43
|
-
else
|
44
|
-
subreddit = ARGV.shift
|
45
|
-
comments = reddit_user.comments_for_subreddit subreddit
|
46
|
-
unless comments
|
47
|
-
puts "No comments by #{reddit_user.username} for #{subreddit}."
|
48
|
-
exit 0
|
49
|
-
end
|
50
|
-
run_pager
|
51
|
-
is_first = true
|
52
|
-
comments.each do |c|
|
53
|
-
puts unless is_first
|
54
|
-
puts subreddit.foreground(:green).bright
|
55
|
-
puts c
|
56
|
-
is_first = false
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
5
|
+
USaidWat.application.run(ARGV)
|