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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f08d885b3a563e4c3ef173a3e6569f178b45a2b5
4
- data.tar.gz: a25e5aa969cf05a408b0f027ef104f8da2272f40
3
+ metadata.gz: a5daf2f4603064b636445379dd5f5eea9a13ef62
4
+ data.tar.gz: b34de952dd00f585bcb512635284cdb1ebb034e7
5
5
  SHA512:
6
- metadata.gz: 744f8760336434d4eea9ef24cd998d72cd98ad2f1714920148c9d4fffaa1bec11a07f94ee2fc96e0beb500a7dbf9631ea867958b21a6b1d21cbf48aa54dab4ea
7
- data.tar.gz: ae0f636a53218ffaea87557dd2dbb07d1888004364e8ebdb1403504de3c22b428364696caf48762783bc972843650e34eece032f1681bf3a7ef3ed544fdfc42c
6
+ metadata.gz: 17caa0dc57e586e351fa28a86fa147b483ac8e1cd2dd3696b05462899a53855c95d3af9699d1c10b93071a65bda626782168c9498daa4bde0927674bcc5536bd
7
+ data.tar.gz: a1ff63c7a1022137a247263278ee356c99149998bad01470df7ec0876a9628cb57ecaac28e9054a5bab92f1f1c5e8245891c11248aabfec4a1e021bd27d7be10
@@ -1,6 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
4
- - 2.1.6
5
3
  - 2.2.4
6
4
  - 2.3.1
@@ -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
- ActiveResource::Base.logger = Logger.new(STDOUT) if options[:trace]
113
- Socialcast::CommandLine::Message.configure_from_credentials
114
- Socialcast::CommandLine::Message.create :body => message, :url => options[:url], :message_type => options[:message_type], :attachment_ids => attachment_ids, :group_id => options[:group_id]
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,6 +1,6 @@
1
1
  require 'net/ldap'
2
- require 'active_support/core_ext/object/blank'
3
- require 'active_support/core_ext/array/wrap'
2
+ require 'active_support'
3
+ require 'active_support/core_ext'
4
4
 
5
5
  module Socialcast
6
6
  module CommandLine
@@ -1,17 +1,59 @@
1
- require 'active_resource'
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 < ActiveResource::Base
8
- headers['Accept'] = 'application/json'
9
-
10
- def self.configure_from_credentials
11
- Socialcast::CommandLine::Message.site = ['https://', Socialcast::CommandLine.credentials[:domain], '/api'].join
12
- Socialcast::CommandLine::Message.proxy = Socialcast::CommandLine.credentials[:proxy] if Socialcast::CommandLine.credentials[:proxy]
13
- Socialcast::CommandLine::Message.user = Socialcast::CommandLine.credentials[:user]
14
- Socialcast::CommandLine::Message.password = Socialcast::CommandLine.credentials[:password]
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
@@ -2,7 +2,8 @@ require 'zlib'
2
2
  require 'builder'
3
3
  require 'set'
4
4
  require 'fileutils'
5
- require 'active_support/core_ext/string/strip'
5
+ require 'active_support'
6
+ require 'active_support/core_ext'
6
7
 
7
8
  module Socialcast
8
9
  module CommandLine
@@ -1,5 +1,5 @@
1
1
  module Socialcast
2
2
  module CommandLine
3
- VERSION = '1.3.20'
3
+ VERSION = '1.4.0'
4
4
  end
5
5
  end
@@ -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.3.20
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-08 00:00:00.000000000 Z
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: activeresource
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: activesupport
124
+ name: builder
125
125
  requirement: !ruby/object:Gem::Requirement
126
126
  requirements:
127
- - - ">="
127
+ - - "~>"
128
128
  - !ruby/object:Gem::Version
129
- version: '4.0'
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: '4.0'
136
+ version: '3.1'
137
137
  - !ruby/object:Gem::Dependency
138
138
  name: rspec
139
139
  requirement: !ruby/object:Gem::Requirement