socialcast 1.3.20 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -2
- data/lib/socialcast/command_line/cli.rb +3 -18
- data/lib/socialcast/command_line/ldap_connector.rb +2 -2
- data/lib/socialcast/command_line/message.rb +53 -11
- data/lib/socialcast/command_line/provision_user.rb +2 -1
- data/lib/socialcast/command_line/version.rb +1 -1
- data/socialcast.gemspec +1 -1
- data/spec/socialcast/command_line/cli_spec.rb +33 -0
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5daf2f4603064b636445379dd5f5eea9a13ef62
|
4
|
+
data.tar.gz: b34de952dd00f585bcb512635284cdb1ebb034e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17caa0dc57e586e351fa28a86fa147b483ac8e1cd2dd3696b05462899a53855c95d3af9699d1c10b93071a65bda626782168c9498daa4bde0927674bcc5536bd
|
7
|
+
data.tar.gz: a1ff63c7a1022137a247263278ee356c99149998bad01470df7ec0876a9628cb57ecaac28e9054a5bab92f1f1c5e8245891c11248aabfec4a1e021bd27d7be10
|
data/.travis.yml
CHANGED
@@ -10,20 +10,6 @@ require 'highline'
|
|
10
10
|
require 'logger'
|
11
11
|
require 'fileutils'
|
12
12
|
|
13
|
-
# uncomment to debug HTTP traffic
|
14
|
-
# class ActiveResource::Connection
|
15
|
-
# def configure_http(http)
|
16
|
-
# http = apply_ssl_options(http)
|
17
|
-
# # Net::HTTP timeouts default to 60 seconds.
|
18
|
-
# if @timeout
|
19
|
-
# http.open_timeout = @timeout
|
20
|
-
# http.read_timeout = @timeout
|
21
|
-
# end
|
22
|
-
# http.set_debug_output STDOUT
|
23
|
-
# http
|
24
|
-
# end
|
25
|
-
# end
|
26
|
-
|
27
13
|
module Socialcast
|
28
14
|
module CommandLine
|
29
15
|
class CLI < Thor
|
@@ -109,10 +95,9 @@ module Socialcast
|
|
109
95
|
end
|
110
96
|
end
|
111
97
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
98
|
+
Socialcast::CommandLine::Message.with_debug options[:trace] do
|
99
|
+
Socialcast::CommandLine::Message.create :body => message, :url => options[:url], :message_type => options[:message_type], :attachment_ids => attachment_ids, :group_id => options[:group_id]
|
100
|
+
end
|
116
101
|
say "Message has been shared"
|
117
102
|
end
|
118
103
|
|
@@ -1,17 +1,59 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
ActiveResource::Base.include_root_in_json = true
|
1
|
+
require 'ostruct'
|
2
|
+
require 'json'
|
4
3
|
|
5
4
|
module Socialcast
|
6
5
|
module CommandLine
|
7
|
-
class Message
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
6
|
+
class Message
|
7
|
+
class << self
|
8
|
+
attr_accessor :debug
|
9
|
+
|
10
|
+
def create(attributes = {})
|
11
|
+
options = {
|
12
|
+
:user => user,
|
13
|
+
:password => password,
|
14
|
+
}
|
15
|
+
RestClient.proxy = proxy if proxy
|
16
|
+
resource = RestClient::Resource.new create_url, options
|
17
|
+
attributes_json = { :message => attributes }.to_json
|
18
|
+
response = resource.post attributes_json, :accept => :json, :content_type => :json
|
19
|
+
response_body = response.body.to_s.presence
|
20
|
+
puts "API response: #{response_body}" if debug
|
21
|
+
|
22
|
+
response_data = response_body ? JSON.parse(response_body) : {}
|
23
|
+
OpenStruct.new(response_data['message'] || {})
|
24
|
+
end
|
25
|
+
|
26
|
+
def with_debug(new_value)
|
27
|
+
old_value = debug
|
28
|
+
self.debug = new_value
|
29
|
+
yield
|
30
|
+
ensure
|
31
|
+
self.debug = old_value
|
32
|
+
end
|
33
|
+
|
34
|
+
def site
|
35
|
+
File.join('https://', Socialcast::CommandLine.credentials[:domain], 'api')
|
36
|
+
end
|
37
|
+
|
38
|
+
def proxy
|
39
|
+
Socialcast::CommandLine.credentials[:proxy]
|
40
|
+
end
|
41
|
+
|
42
|
+
def user
|
43
|
+
Socialcast::CommandLine.credentials[:user]
|
44
|
+
end
|
45
|
+
|
46
|
+
def password
|
47
|
+
Socialcast::CommandLine.credentials[:password]
|
48
|
+
end
|
49
|
+
|
50
|
+
def create_url
|
51
|
+
File.join(site, 'messages.json')
|
52
|
+
end
|
53
|
+
|
54
|
+
def configure_from_credentials
|
55
|
+
# backwards-compatibility noop
|
56
|
+
end
|
15
57
|
end
|
16
58
|
end
|
17
59
|
end
|
data/socialcast.gemspec
CHANGED
@@ -20,8 +20,8 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.add_runtime_dependency 'thor', '~> 0.14', '>= 0.14.6'
|
21
21
|
s.add_runtime_dependency 'highline', '~> 1.6', '>= 1.6.2'
|
22
22
|
s.add_runtime_dependency 'socialcast-net-ldap', '~> 0.1', '>= 0.1.6'
|
23
|
-
s.add_runtime_dependency 'activeresource', '>= 4.0'
|
24
23
|
s.add_runtime_dependency 'activesupport', '>= 4.0'
|
24
|
+
s.add_runtime_dependency 'builder', '~> 3.1'
|
25
25
|
s.add_development_dependency 'rspec', '~> 3.3'
|
26
26
|
s.add_development_dependency 'webmock', '~> 1.7', '>= 1.7.7'
|
27
27
|
s.add_development_dependency 'rake', '0.9.2.2'
|
@@ -121,6 +121,39 @@ describe Socialcast::CommandLine::CLI do
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
+
context 'with response data' do
|
125
|
+
before do
|
126
|
+
message_request_data = {
|
127
|
+
'message' => {
|
128
|
+
'body' => 'testing',
|
129
|
+
'url' => nil,
|
130
|
+
'message_type' => nil,
|
131
|
+
'attachment_ids' => [],
|
132
|
+
'group_id' => nil
|
133
|
+
}
|
134
|
+
}
|
135
|
+
message_response_data = {
|
136
|
+
'message' => message_request_data['message'].merge(
|
137
|
+
'id' => 123,
|
138
|
+
'permalink_url' => 'https://test.stagings.socialcast.com/messages/123'
|
139
|
+
)
|
140
|
+
}
|
141
|
+
stub_request(:post, "https://ryan%40socialcast.com:foo@test.staging.socialcast.com/api/messages.json")
|
142
|
+
.with(:body => message_request_data)
|
143
|
+
.with(:headers => {'Accept' => 'application/json'})
|
144
|
+
.to_return(:status => 200, :body => message_response_data.to_json, :headers => {})
|
145
|
+
end
|
146
|
+
it do
|
147
|
+
message_object = nil
|
148
|
+
expect(Socialcast::CommandLine::Message).to receive(:create).and_wrap_original do |method, *args|
|
149
|
+
message_object = method.call(*args)
|
150
|
+
end
|
151
|
+
Socialcast::CommandLine::CLI.start ['share', 'testing']
|
152
|
+
expect(message_object.permalink_url).to eq 'https://test.stagings.socialcast.com/messages/123'
|
153
|
+
expect(message_object['permalink_url']).to eq 'https://test.stagings.socialcast.com/messages/123'
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
124
157
|
context 'with a message_type message' do
|
125
158
|
before do
|
126
159
|
stub_request(:post, "https://ryan%40socialcast.com:foo@test.staging.socialcast.com/api/messages.json").
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: socialcast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Sonnek
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-09-
|
13
|
+
date: 2016-09-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|
@@ -107,7 +107,7 @@ dependencies:
|
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: 0.1.6
|
109
109
|
- !ruby/object:Gem::Dependency
|
110
|
-
name:
|
110
|
+
name: activesupport
|
111
111
|
requirement: !ruby/object:Gem::Requirement
|
112
112
|
requirements:
|
113
113
|
- - ">="
|
@@ -121,19 +121,19 @@ dependencies:
|
|
121
121
|
- !ruby/object:Gem::Version
|
122
122
|
version: '4.0'
|
123
123
|
- !ruby/object:Gem::Dependency
|
124
|
-
name:
|
124
|
+
name: builder
|
125
125
|
requirement: !ruby/object:Gem::Requirement
|
126
126
|
requirements:
|
127
|
-
- - "
|
127
|
+
- - "~>"
|
128
128
|
- !ruby/object:Gem::Version
|
129
|
-
version: '
|
129
|
+
version: '3.1'
|
130
130
|
type: :runtime
|
131
131
|
prerelease: false
|
132
132
|
version_requirements: !ruby/object:Gem::Requirement
|
133
133
|
requirements:
|
134
|
-
- - "
|
134
|
+
- - "~>"
|
135
135
|
- !ruby/object:Gem::Version
|
136
|
-
version: '
|
136
|
+
version: '3.1'
|
137
137
|
- !ruby/object:Gem::Dependency
|
138
138
|
name: rspec
|
139
139
|
requirement: !ruby/object:Gem::Requirement
|