socialcast 0.3.6 → 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
data/CONTRIBUTORS.txt ADDED
@@ -0,0 +1,5 @@
1
+ Ryan Sonnek - Original Author
2
+
3
+ see http://github.com/socialcast/socialcast-command-line/contributors
4
+ for comple list of contributors
5
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2011 Socialcast, Inc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # socialcast-command-line
2
+
3
+ command line interface to the Socialcast API
4
+ http://www.socialcast.com/resources/api.html
5
+
6
+ ## Contributing
7
+
8
+ * Fork the project.
9
+ * Fix the issue
10
+ * Add tests
11
+ * Send me a pull request. Bonus points for topic branches.
12
+
13
+ see CONTRIBUTORS.txt for list of contributors
14
+
15
+ ## Copyright
16
+
17
+ Copyright (c) 2011 Socialcast Inc.
18
+ See LICENSE.txt for details.
data/bin/socialcast CHANGED
@@ -1,79 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'commander/import'
4
- require 'rest_client'
5
- require 'json'
6
- require File.join(File.dirname(__FILE__), '..', 'lib', 'socialcast')
7
- require File.join(File.dirname(__FILE__), '..', 'lib', 'socialcast', 'version')
8
- include Socialcast
9
-
10
- program :version, Socialcast::VERSION
11
- program :description, 'Socialcast API command line interface'
12
-
13
- command :authenticate do |c|
14
- c.syntax = 'socialcast authenticate [options]'
15
- c.summary = 'authenticate your Socialcast credentials'
16
- c.description = 'verify that your credentials are valid'
17
- c.example 'default usage', 'socialcast authenticate -u emily@socialcast.com'
18
- c.option '-u', '--user STRING', String, 'Socialcast account username/email'
19
- c.option '--domain STRING', String, 'Socialcast community domain'
20
- c.action do |args, options|
21
- options.default :domain => 'api.socialcast.com'
22
-
23
- options.user = ask('Socialcast username: ') unless options.user
24
- options.password = password
25
-
26
- say "Authenticating #{options.user}"
27
- url = ['https://', options.domain, '/api/authentication.json'].join
28
- params = {:email => options.user, :password => options.password }
29
- resource = RestClient::Resource.new url
30
- response = resource.post params
31
- puts "API response: #{response.body.to_s}" if options.trace
32
- communities = JSON.parse(response.body.to_s)['communities']
33
- options.domain = communities.detect {|c| c['domain'] == options.domain} ? options.domain : communities.first['domain']
34
-
35
- save_credentials :user => options.user, :password => options.password, :domain => options.domain
36
- say "Authentication successful for #{options.domain}"
37
- end
38
- end
39
-
40
-
41
- command :share do |c|
42
- c.syntax = 'socialcast share <message> [options]'
43
- c.summary = 'share a message'
44
- c.description = 'post a message into your socialcast stream'
45
- c.example 'basic usage', 'socialcast share "some text"'
46
- c.option '--url STRING', String, 'referenced url for the message'
47
- c.option '--attachments FILES', Array, 'list of files to attach to the message'
48
- c.action do |args, options|
49
- options.default :attachments => []
50
-
51
- message = args.first
52
- message ||= $stdin.read_nonblock(100_000) rescue nil
53
-
54
- attachment_ids = []
55
- options.attachments.each do |path|
56
- Dir[File.expand_path(path)].each do |attachment|
57
- attachment_url = ['https://', credentials[:domain], '/api/attachments.json'].join
58
- say "Uploading attachment #{attachment}..."
59
- attachment_uploader = RestClient::Resource.new attachment_url, :user => credentials[:user], :password => credentials[:password]
60
- attachment_uploader.post :attachment => File.new(attachment) do |response, request, result|
61
- if response.code == 201
62
- attachment_ids << JSON.parse(response.body)['attachment']['id']
63
- else
64
- say "Error uploading attachment: #{response.body}"
65
- end
66
- end
67
- end
68
- end
69
-
70
- Socialcast::Message.site = ['https://', credentials[:domain], '/api'].join
71
- Socialcast::Message.user = credentials[:user]
72
- Socialcast::Message.password = credentials[:password]
73
-
74
- Socialcast::Message.create :body => message, :url => options.url, :attachment_ids => attachment_ids
75
-
76
- say "Message has been shared"
77
- end
78
- end
3
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'socialcast', 'cli')
79
4
 
5
+ Socialcast::CLI.start
data/lib/socialcast.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'yaml'
2
2
  require 'fileutils'
3
- require File.join(File.dirname(__FILE__), 'socialcast', 'message')
4
3
 
5
4
  module Socialcast
6
5
  def config_dir
@@ -0,0 +1,67 @@
1
+ require "thor"
2
+ require 'json'
3
+ require 'rest_client'
4
+ require 'highline'
5
+ require 'socialcast'
6
+ require 'socialcast/message'
7
+
8
+ module Socialcast
9
+ class CLI < Thor
10
+ include Thor::Actions
11
+ include Socialcast
12
+ default_task :share
13
+
14
+ desc "authenticate", "Authenticate using your Socialcast credentials"
15
+ method_option :user, :type => :string, :aliases => '-u', :desc => 'email address for the authenticated user'
16
+ method_option :domain, :type => :string, :default => 'api.socialcast.com', :desc => 'socialcast community domain'
17
+ method_option :trace, :type => :boolean, :default => false, :aliases => '-v'
18
+ def authenticate
19
+ user = options[:user] || ask('Socialcast username: ')
20
+ password = HighLine.new.ask("Socialcast password: ") { |q| q.echo = false }
21
+ domain = options[:domain]
22
+
23
+ url = ['https://', domain, '/api/authentication.json'].join
24
+ say "Authenticating #{user} to #{url}"
25
+ params = {:email => user, :password => password }
26
+ resource = RestClient::Resource.new url
27
+ response = resource.post params
28
+ puts "API response: #{response.body.to_s}" if options[:trace]
29
+ communities = JSON.parse(response.body.to_s)['communities']
30
+ domain = communities.detect {|c| c['domain'] == domain} ? domain : communities.first['domain']
31
+
32
+ save_credentials :user => user, :password => password, :domain => domain
33
+ say "Authentication successful for #{domain}"
34
+ end
35
+
36
+ desc "share MESSAGE", "Posts a new message into socialcast"
37
+ method_option :url, :type => :string
38
+ method_option :attachments, :type => :array, :default => []
39
+ def share(message = nil)
40
+ message ||= $stdin.read_nonblock(100_000) rescue nil
41
+
42
+ attachment_ids = []
43
+ options[:attachments].each do |path|
44
+ Dir[File.expand_path(path)].each do |attachment|
45
+ attachment_url = ['https://', credentials[:domain], '/api/attachments.json'].join
46
+ say "Uploading attachment #{attachment}..."
47
+ attachment_uploader = RestClient::Resource.new attachment_url, :user => credentials[:user], :password => credentials[:password]
48
+ attachment_uploader.post :attachment => File.new(attachment) do |response, request, result|
49
+ if response.code == 201
50
+ attachment_ids << JSON.parse(response.body)['attachment']['id']
51
+ else
52
+ say "Error uploading attachment: #{response.body}"
53
+ end
54
+ end
55
+ end
56
+ end
57
+
58
+ Socialcast::Message.site = ['https://', credentials[:domain], '/api'].join
59
+ Socialcast::Message.user = credentials[:user]
60
+ Socialcast::Message.password = credentials[:password]
61
+
62
+ Socialcast::Message.create :body => message, :url => options[:url], :attachment_ids => attachment_ids
63
+
64
+ say "Message has been shared"
65
+ end
66
+ end
67
+ end
@@ -1,3 +1,3 @@
1
1
  module Socialcast
2
- VERSION = "0.3.6"
2
+ VERSION = "1.0.0.beta1"
3
3
  end
data/socialcast.gemspec CHANGED
@@ -8,16 +8,17 @@ Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Ryan Sonnek","Sean Cashin"]
10
10
  s.email = ["ryan@socialcast.com"]
11
- s.homepage = "http://github.com/scashin133/socialcast-command-line"
11
+ s.homepage = "http://github.com/wireframe/socialcast-command-line"
12
12
  s.summary = %q{command line interface to socialcast api}
13
13
  s.description = %q{publish messages to your stream from a command line interface}
14
14
 
15
15
  s.rubyforge_project = "socialcast"
16
16
 
17
17
  s.add_development_dependency "shoulda", ">= 0"
18
- s.add_runtime_dependency 'commander', '>= 4.0'
19
18
  s.add_runtime_dependency 'rest-client', '>= 1.4.0'
20
19
  s.add_runtime_dependency 'json', '>= 1.4.6'
20
+ s.add_runtime_dependency 'thor', '>= 0.14.6'
21
+ s.add_runtime_dependency 'highline', '>= 1.6.2'
21
22
 
22
23
  s.files = `git ls-files`.split("\n")
23
24
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
metadata CHANGED
@@ -1,13 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: socialcast
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
5
- prerelease:
4
+ hash: 62196353
5
+ prerelease: 6
6
6
  segments:
7
+ - 1
7
8
  - 0
8
- - 3
9
- - 6
10
- version: 0.3.6
9
+ - 0
10
+ - beta
11
+ - 1
12
+ version: 1.0.0.beta1
11
13
  platform: ruby
12
14
  authors:
13
15
  - Ryan Sonnek
@@ -16,8 +18,7 @@ autorequire:
16
18
  bindir: bin
17
19
  cert_chain: []
18
20
 
19
- date: 2011-03-23 00:00:00 -07:00
20
- default_executable:
21
+ date: 2011-06-22 00:00:00 Z
21
22
  dependencies:
22
23
  - !ruby/object:Gem::Dependency
23
24
  name: shoulda
@@ -34,40 +35,57 @@ dependencies:
34
35
  type: :development
35
36
  version_requirements: *id001
36
37
  - !ruby/object:Gem::Dependency
37
- name: commander
38
+ name: rest-client
38
39
  prerelease: false
39
40
  requirement: &id002 !ruby/object:Gem::Requirement
40
41
  none: false
41
42
  requirements:
42
43
  - - ">="
43
44
  - !ruby/object:Gem::Version
44
- hash: 27
45
+ hash: 7
45
46
  segments:
47
+ - 1
46
48
  - 4
47
49
  - 0
48
- version: "4.0"
50
+ version: 1.4.0
49
51
  type: :runtime
50
52
  version_requirements: *id002
51
53
  - !ruby/object:Gem::Dependency
52
- name: rest-client
54
+ name: json
53
55
  prerelease: false
54
56
  requirement: &id003 !ruby/object:Gem::Requirement
55
57
  none: false
56
58
  requirements:
57
59
  - - ">="
58
60
  - !ruby/object:Gem::Version
59
- hash: 7
61
+ hash: 11
60
62
  segments:
61
63
  - 1
62
64
  - 4
63
- - 0
64
- version: 1.4.0
65
+ - 6
66
+ version: 1.4.6
65
67
  type: :runtime
66
68
  version_requirements: *id003
67
69
  - !ruby/object:Gem::Dependency
68
- name: json
70
+ name: thor
69
71
  prerelease: false
70
72
  requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 43
78
+ segments:
79
+ - 0
80
+ - 14
81
+ - 6
82
+ version: 0.14.6
83
+ type: :runtime
84
+ version_requirements: *id004
85
+ - !ruby/object:Gem::Dependency
86
+ name: highline
87
+ prerelease: false
88
+ requirement: &id005 !ruby/object:Gem::Requirement
71
89
  none: false
72
90
  requirements:
73
91
  - - ">="
@@ -75,11 +93,11 @@ dependencies:
75
93
  hash: 11
76
94
  segments:
77
95
  - 1
78
- - 4
79
96
  - 6
80
- version: 1.4.6
97
+ - 2
98
+ version: 1.6.2
81
99
  type: :runtime
82
- version_requirements: *id004
100
+ version_requirements: *id005
83
101
  description: publish messages to your stream from a command line interface
84
102
  email:
85
103
  - ryan@socialcast.com
@@ -92,20 +110,21 @@ extra_rdoc_files: []
92
110
  files:
93
111
  - .document
94
112
  - .gitignore
113
+ - CONTRIBUTORS.txt
95
114
  - Gemfile
96
- - LICENSE
97
- - README.rdoc
115
+ - LICENSE.txt
116
+ - README.md
98
117
  - Rakefile
99
118
  - bin/socialcast
100
119
  - lib/socialcast.rb
120
+ - lib/socialcast/cli.rb
101
121
  - lib/socialcast/message.rb
102
122
  - lib/socialcast/version.rb
103
123
  - socialcast.gemspec
104
124
  - test/commander_helper.rb
105
125
  - test/helper.rb
106
126
  - test/test_socialcast.rb
107
- has_rdoc: true
108
- homepage: http://github.com/scashin133/socialcast-command-line
127
+ homepage: http://github.com/wireframe/socialcast-command-line
109
128
  licenses: []
110
129
 
111
130
  post_install_message:
@@ -125,16 +144,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
144
  required_rubygems_version: !ruby/object:Gem::Requirement
126
145
  none: false
127
146
  requirements:
128
- - - ">="
147
+ - - ">"
129
148
  - !ruby/object:Gem::Version
130
- hash: 3
149
+ hash: 25
131
150
  segments:
132
- - 0
133
- version: "0"
151
+ - 1
152
+ - 3
153
+ - 1
154
+ version: 1.3.1
134
155
  requirements: []
135
156
 
136
157
  rubyforge_project: socialcast
137
- rubygems_version: 1.6.1
158
+ rubygems_version: 1.8.1
138
159
  signing_key:
139
160
  specification_version: 3
140
161
  summary: command line interface to socialcast api
data/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2009 Ryan Sonnek
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.rdoc DELETED
@@ -1,17 +0,0 @@
1
- = socialcast_cli
2
-
3
- Description goes here.
4
-
5
- == Note on Patches/Pull Requests
6
-
7
- * Fork the project.
8
- * Make your feature addition or bug fix.
9
- * Add tests for it. This is important so I don't break it in a
10
- future version unintentionally.
11
- * Commit, do not mess with rakefile, version, or history.
12
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
- * Send me a pull request. Bonus points for topic branches.
14
-
15
- == Copyright
16
-
17
- Copyright (c) 2010 Ryan Sonnek. See LICENSE for details.