qrush-beardo 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.
- data/README.textile +24 -0
- data/Rakefile +30 -0
- data/TODO +21 -0
- data/VERSION.yml +4 -0
- data/bin/bd +24 -0
- data/bin/coop +4 -0
- data/lib/beardo.rb +40 -0
- data/spec/beardo_spec.rb +96 -0
- data/spec/executable_spec.rb +44 -0
- data/spec/spec_helper.rb +9 -0
- metadata +74 -0
data/README.textile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
h1. beardo
|
2
|
+
|
3
|
+
"Co-ops are run by dirty hippies; dirty hippies have beards; therefore, this app is called beardo."
|
4
|
+
|
5
|
+
h2. No, seriously.
|
6
|
+
|
7
|
+
This is a command line interface for "Co-op":http://coopapp.com, since some of us are too cool to use the web interface.
|
8
|
+
It started as a "boston.rb":http://bostonrb.org hackfest project, so blame the pizza and beer if there's bugs.
|
9
|
+
|
10
|
+
h2. Wait, what?
|
11
|
+
|
12
|
+
It uses "rest-client":http://github.com/adamwiggins/rest-client as a wrapper around the "Co-op API":http://coopapp.com/api.
|
13
|
+
|
14
|
+
h2. Do I need a beard, too?
|
15
|
+
|
16
|
+
No, you don't. All you need is a @.beardorc@ in your @HOME@ directory, with the following info (in YAML format):
|
17
|
+
|
18
|
+
<pre>
|
19
|
+
email: dirty@hippie.com
|
20
|
+
password: drumcircle
|
21
|
+
group: 422
|
22
|
+
</pre>
|
23
|
+
|
24
|
+
Then, run @coop "your-message-here"@ and your status on Co-op should be updated.
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'spec/rake/spectask'
|
4
|
+
|
5
|
+
desc "Run all specs"
|
6
|
+
Spec::Rake::SpecTask.new('spec') do |t|
|
7
|
+
t.spec_opts = ['--colour']
|
8
|
+
t.spec_files = FileList['spec/*_spec.rb']
|
9
|
+
end
|
10
|
+
|
11
|
+
begin
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |s|
|
14
|
+
s.name = "beardo"
|
15
|
+
s.summary = "A command line client for Harvest Co-op"
|
16
|
+
s.email = "nick@quaran.to"
|
17
|
+
s.homepage = "http://github.com/qrush/beardo"
|
18
|
+
s.description = "Communicate with co-workers through the best interface available: your terminal"
|
19
|
+
s.authors = ["Nick Quaranto", "Mike Burns"]
|
20
|
+
s.add_dependency('adamwiggins-rest-client', '>= 0.9.2')
|
21
|
+
s.executables = ["bd", "coop"]
|
22
|
+
s.files = FileList["[A-Z]*", "{bin,lib,spec}/**/*"]
|
23
|
+
end
|
24
|
+
rescue LoadError
|
25
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
task :default => :spec
|
30
|
+
|
data/TODO
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
With config file:
|
2
|
+
[ ] I post my status to Co-op when I run beardo status with a status
|
3
|
+
[ ] I see the status ID when I run beardo status with a status
|
4
|
+
[ ] I am prompted for my email, password, and groups with my existing
|
5
|
+
email and groups as the default when I run beardo init.
|
6
|
+
[ ] With too flexible permissions I am prompted to change the
|
7
|
+
permissions when I run beardo init.
|
8
|
+
[ ] With too few permission I am prompted to change the permissions
|
9
|
+
when I run beardo init.
|
10
|
+
[ ] I run beardo status with a status then beardo undo to remove that status.
|
11
|
+
|
12
|
+
Without config file:
|
13
|
+
[ ] I am prompted for my email, password, and groups then my status is
|
14
|
+
posted to Co-op when I run beardo status with a status.
|
15
|
+
[ ] I am shown all commands when I run beardo help.
|
16
|
+
[ ] I am prompted for my email, password, and groups when I run beardo init.
|
17
|
+
|
18
|
+
Random:
|
19
|
+
[ ] I am shown help text when I run beardo status without a status.
|
20
|
+
|
21
|
+
|
data/VERSION.yml
ADDED
data/bin/bd
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
4
|
+
require 'beardo'
|
5
|
+
|
6
|
+
help = <<HELP
|
7
|
+
Beardo is a simple command line interface to Co-op (http://coopapp.com)
|
8
|
+
|
9
|
+
Basic command line usage:
|
10
|
+
bd "your status message"
|
11
|
+
HELP
|
12
|
+
|
13
|
+
status = ""
|
14
|
+
|
15
|
+
opts = OptionParser.new do |parser|
|
16
|
+
parser.banner = help
|
17
|
+
parser.on("--status", "Set your co-op status") do |s|
|
18
|
+
status = ARGV.first
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
opts.parse!
|
23
|
+
|
24
|
+
Beardo.run(status)
|
data/bin/coop
ADDED
data/lib/beardo.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'yaml'
|
3
|
+
require 'rest_client'
|
4
|
+
require 'optparse'
|
5
|
+
|
6
|
+
class Beardo
|
7
|
+
attr_accessor :group, :email, :password
|
8
|
+
|
9
|
+
def initialize(config)
|
10
|
+
self.group = config['group']
|
11
|
+
self.email = config['email']
|
12
|
+
self.password = config['password']
|
13
|
+
end
|
14
|
+
|
15
|
+
def post(message)
|
16
|
+
resource = RestClient::Resource.new("http://coopapp.com", {
|
17
|
+
:user => self.email, :password => self.password
|
18
|
+
})
|
19
|
+
resource["groups/#{self.group}/statuses"].post("<status>#{message}</status>", :content_type => 'application/xml')
|
20
|
+
end
|
21
|
+
|
22
|
+
class << self
|
23
|
+
def config_path
|
24
|
+
ENV['HOME']
|
25
|
+
end
|
26
|
+
|
27
|
+
def config_file
|
28
|
+
File.join(config_path, '.beardorc')
|
29
|
+
end
|
30
|
+
|
31
|
+
def run(message)
|
32
|
+
beardo = Beardo.new(read_config)
|
33
|
+
beardo.post(message)
|
34
|
+
end
|
35
|
+
|
36
|
+
def read_config
|
37
|
+
YAML.load_file(config_file)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/spec/beardo_spec.rb
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
3
|
+
require 'beardo'
|
4
|
+
|
5
|
+
def create_config
|
6
|
+
@config = { 'email' => 'ralph@robotsinc.com',
|
7
|
+
'password' => 'robot',
|
8
|
+
'group' => 1337 }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "beardo command line interface" do
|
12
|
+
describe "running from the executable" do
|
13
|
+
before do
|
14
|
+
create_config
|
15
|
+
@beardo = Object.new
|
16
|
+
stub(Beardo).new { @beardo }
|
17
|
+
stub(Beardo).read_config { @config }
|
18
|
+
stub(@beardo).post { true }
|
19
|
+
@rest_client = Object.new
|
20
|
+
stub(RestClient::Resource).new { @rest_client }
|
21
|
+
stub(@rest_client).post { true }
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should read in configuration options" do
|
25
|
+
mock(Beardo).read_config { @config }
|
26
|
+
Beardo.run('')
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should create a new instance of a Beardo on .run" do
|
30
|
+
mock(Beardo).new(@config) { @beardo }
|
31
|
+
Beardo.run('')
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should post to coop on .run" do
|
35
|
+
@beardo = Object.new
|
36
|
+
mock(@beardo).post('work sucks') { true }
|
37
|
+
Beardo.run('work sucks')
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should default to the home directory for config_path" do
|
43
|
+
Beardo.config_path.should == ENV['HOME']
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should default to .beardorc for config_file" do
|
47
|
+
Beardo.config_file.should =~ /.beardorc$/
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should read config from YAML" do
|
51
|
+
@config_file = "file"
|
52
|
+
stub(Beardo).config_file { @config_file }
|
53
|
+
mock(YAML).load_file(@config_file)
|
54
|
+
Beardo.read_config
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "temporary directory exists" do
|
58
|
+
before do
|
59
|
+
@config_path = File.join('/', 'tmp', 'beardo')
|
60
|
+
begin
|
61
|
+
stub(Beardo).config_path { @config_path }
|
62
|
+
stub(Beardo).config_file { File.join(@config_path, '.beardorc') }
|
63
|
+
Dir.mkdir(@config_path)
|
64
|
+
rescue Errno::EEXIST
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should produce correct configs when send .read_config" do
|
69
|
+
File.open(Beardo.config_file, 'w') do |f|
|
70
|
+
f.puts(@config.to_yaml)
|
71
|
+
end
|
72
|
+
Beardo.read_config.should == @config
|
73
|
+
end
|
74
|
+
|
75
|
+
after do
|
76
|
+
FileUtils.rm_rf(@config_path)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "instance methods" do
|
82
|
+
before do
|
83
|
+
create_config
|
84
|
+
@rest_client = Object.new
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should send the message to Coop on #post" do
|
88
|
+
mock(@rest_client)["groups/#{@config['group']}/statuses"].stub!.post("<status>f this</status>", :content_type => "application/xml")
|
89
|
+
mock(RestClient::Resource).
|
90
|
+
new("http://coopapp.com",
|
91
|
+
{:user => @config['email'],
|
92
|
+
:password => @config['password']}) { @rest_client }
|
93
|
+
@beardo = Beardo.new(@config)
|
94
|
+
@beardo.post('f this')
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'bin')
|
3
|
+
|
4
|
+
describe "the beardo executable" do
|
5
|
+
before do
|
6
|
+
ARGV.clear
|
7
|
+
stub(Beardo).run("") { true }
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should take in some arguments" do
|
11
|
+
mock(Beardo).run("") { true }
|
12
|
+
load "bd"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should parse options with optparse" do
|
16
|
+
@args = []
|
17
|
+
@opts = Object.new
|
18
|
+
stub(OptionParser).new { @opts }
|
19
|
+
mock(@opts).parse! { true }
|
20
|
+
load "bd"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should parse --status properly" do
|
24
|
+
@status = "work sucks"
|
25
|
+
ARGV << "--status"
|
26
|
+
ARGV << @status
|
27
|
+
mock(Beardo).run(@status) { true }
|
28
|
+
load "bd"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "the coop executable" do
|
33
|
+
before do
|
34
|
+
ARGV.clear
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should pipe requests into bd" do
|
38
|
+
@status = "makin' some copies"
|
39
|
+
ARGV << @status
|
40
|
+
mock(Beardo).run(@status)
|
41
|
+
load "coop"
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: qrush-beardo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nick Quaranto
|
8
|
+
- Mike Burns
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2009-04-08 00:00:00 -07:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: adamwiggins-rest-client
|
18
|
+
type: :runtime
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.9.2
|
25
|
+
version:
|
26
|
+
description: "Communicate with co-workers through the best interface available: your terminal"
|
27
|
+
email: nick@quaran.to
|
28
|
+
executables:
|
29
|
+
- bd
|
30
|
+
- coop
|
31
|
+
extensions: []
|
32
|
+
|
33
|
+
extra_rdoc_files:
|
34
|
+
- README.textile
|
35
|
+
files:
|
36
|
+
- Rakefile
|
37
|
+
- README.textile
|
38
|
+
- TODO
|
39
|
+
- VERSION.yml
|
40
|
+
- bin/bd
|
41
|
+
- bin/coop
|
42
|
+
- lib/beardo.rb
|
43
|
+
- spec/beardo_spec.rb
|
44
|
+
- spec/executable_spec.rb
|
45
|
+
- spec/spec_helper.rb
|
46
|
+
has_rdoc: true
|
47
|
+
homepage: http://github.com/qrush/beardo
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options:
|
50
|
+
- --inline-source
|
51
|
+
- --charset=UTF-8
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: "0"
|
59
|
+
version:
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "0"
|
65
|
+
version:
|
66
|
+
requirements: []
|
67
|
+
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 1.2.0
|
70
|
+
signing_key:
|
71
|
+
specification_version: 2
|
72
|
+
summary: A command line client for Harvest Co-op
|
73
|
+
test_files: []
|
74
|
+
|