Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

post-into-group #11

Merged
merged 2 commits into from

2 participants

@wireframe

add group_id cli param to allow posting message into specific group

@vanm

Looks good to me @wireframe!

@wireframe wireframe merged commit bf3f181 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 27, 2012
  1. add group_id cli param to post message into a group

    Ryan Sonnek authored
  2. add test for group_id param

    Ryan Sonnek authored
This page is out of date. Refresh to see the latest.
View
18 lib/socialcast/cli.rb
@@ -13,6 +13,20 @@
require 'builder'
require 'net/ldap'
+# uncomment to debug HTTP traffic
+# class ActiveResource::Connection
+# def configure_http(http)
+# http = apply_ssl_options(http)
+# # Net::HTTP timeouts default to 60 seconds.
+# if @timeout
+# http.open_timeout = @timeout
+# http.read_timeout = @timeout
+# end
+# http.set_debug_output STDOUT
+# http
+# end
+# end
+
module Socialcast
class CLI < Thor
include Thor::Actions
@@ -49,6 +63,7 @@ def authenticate
method_option :url, :type => :string, :desc => '(optional) url to associate to the message'
method_option :message_type, :type => :string, :desc => '(optional) force an alternate message_type'
method_option :attachments, :type => :array, :default => []
+ method_option :group_id, :type => :numeric, :desc => "(optional) ID of group to post into"
def share(message = nil)
message ||= $stdin.read_nonblock(100_000) rescue nil
@@ -67,8 +82,9 @@ def share(message = nil)
end
end
+ ActiveResource::Base.logger = Logger.new(STDOUT) if options[:trace]
Socialcast::Message.configure_from_credentials
- Socialcast::Message.create :body => message, :url => options[:url], :message_type => options[:message_type], :attachment_ids => attachment_ids
+ Socialcast::Message.create :body => message, :url => options[:url], :message_type => options[:message_type], :attachment_ids => attachment_ids, :group_id => options[:group_id]
say "Message has been shared"
end
View
2  lib/socialcast/version.rb
@@ -1,3 +1,3 @@
module Socialcast
- VERSION = "1.1.1"
+ VERSION = "1.1.2"
end
View
13 spec/cli_spec.rb
@@ -32,6 +32,19 @@
# See expectations
end
end
+ context 'with a group_id param' do
+ before do
+ Socialcast.stub(:credentials).and_return(YAML.load_file(File.join(File.dirname(__FILE__), 'fixtures', 'credentials.yml')))
+ stub_request(:post, "https://ryan%40socialcast.com:foo@test.staging.socialcast.com/api/messages.json").
+ with(:body => /group\_id\"\:123/).
+ to_return(:status => 200, :body => "", :headers => {})
+
+ Socialcast::CLI.start ['share', 'hi', '--group_id=123']
+ end
+ it 'should send a POST with group_id param == 123' do
+ # See expectations
+ end
+ end
context "with a proxy" do
before do
Socialcast.stub(:credentials).and_return(YAML.load_file(File.join(File.dirname(__FILE__), 'fixtures', 'credentials_with_proxy.yml')))
Something went wrong with that request. Please try again.