postwill 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +3 -0
- data/.rubocop.yml +22 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +21 -0
- data/PROVIDERS.md +209 -0
- data/README.md +118 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/circle.yml +3 -0
- data/lib/postwill.rb +23 -0
- data/lib/postwill/client.rb +37 -0
- data/lib/postwill/providers/base.rb +19 -0
- data/lib/postwill/providers/facebook.rb +22 -0
- data/lib/postwill/providers/instagram.rb +18 -0
- data/lib/postwill/providers/pinterest.rb +28 -0
- data/lib/postwill/providers/tumblr.rb +40 -0
- data/lib/postwill/providers/twitter.rb +28 -0
- data/lib/postwill/response.rb +10 -0
- data/lib/postwill/settings.rb +10 -0
- data/lib/postwill/version.rb +3 -0
- data/postwill.gemspec +37 -0
- metadata +263 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 30095965154e5dd472ec29cb9233d35358e2611f
|
4
|
+
data.tar.gz: '05809809a66497afaf232de6dbed86438383a5e9'
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 118f092d6e12a6cf437bca64599b2e8a16d15fb4a3561b60163eddbe0a9bb16f55fea390c1f64fccfa557f035d871396b40e7d0e3a3d5b77c3e94c5fafe7c575
|
7
|
+
data.tar.gz: 9b799265920e40539a0fe7b0818d3e6937da532d9031a13d61883f8903b56143a35222ae01adf0d047c9c426f87d4c93e5e0a32fa0119f60f7014bac68b4c749
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
AllCops:
|
2
|
+
DisplayCopNames: true
|
3
|
+
DisplayStyleGuide: true
|
4
|
+
StyleGuideCopsOnly: true
|
5
|
+
TargetRubyVersion: 2.4
|
6
|
+
|
7
|
+
Metrics/LineLength:
|
8
|
+
Max: 120
|
9
|
+
|
10
|
+
Documentation:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
FrozenStringLiteralComment:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Style/FileName:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Metrics/ModuleLength:
|
20
|
+
Exclude:
|
21
|
+
- spec/**/*_spec.rb
|
22
|
+
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Kirill Shevchenko
|
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.
|
data/PROVIDERS.md
ADDED
@@ -0,0 +1,209 @@
|
|
1
|
+
# Twitter
|
2
|
+
|
3
|
+
Based on: [Twitter](https://github.com/sferik/twitter)
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
postwill = Postwill::Client.new(
|
7
|
+
twitter: {
|
8
|
+
access_token: 'access_token',
|
9
|
+
access_token_secret: 'access_token_secret'
|
10
|
+
}
|
11
|
+
)
|
12
|
+
|
13
|
+
postwill.to(:twitter, text: 'text', image: 'image')
|
14
|
+
```
|
15
|
+
|
16
|
+
Success:
|
17
|
+
```ruby
|
18
|
+
{
|
19
|
+
twitter: {
|
20
|
+
status: :ok,
|
21
|
+
response: {} # Response data
|
22
|
+
}
|
23
|
+
}
|
24
|
+
```
|
25
|
+
|
26
|
+
Failure:
|
27
|
+
```ruby
|
28
|
+
{
|
29
|
+
twitter: {
|
30
|
+
status: :error,
|
31
|
+
response: '' # String error message
|
32
|
+
}
|
33
|
+
}
|
34
|
+
```
|
35
|
+
|
36
|
+
Settings:
|
37
|
+
```ruby
|
38
|
+
Postwill::Settings.configure do |config|
|
39
|
+
config.providers.twitter = {
|
40
|
+
consumer_key: 'your_consumer_key',
|
41
|
+
consumer_secret: 'your_consumer_secret'
|
42
|
+
}
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
# Facebook
|
47
|
+
|
48
|
+
Based on: [Koala](https://github.com/arsduo/koala)
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
postwill = Postwill::Client.new(
|
52
|
+
facebook: {
|
53
|
+
access_token: 'access_token'
|
54
|
+
}
|
55
|
+
)
|
56
|
+
|
57
|
+
postwill.to(:facebook, text: 'text', image: 'image')
|
58
|
+
```
|
59
|
+
|
60
|
+
Success:
|
61
|
+
```ruby
|
62
|
+
{
|
63
|
+
facebook: {
|
64
|
+
status: :ok,
|
65
|
+
response: {} # Response data
|
66
|
+
}
|
67
|
+
}
|
68
|
+
```
|
69
|
+
|
70
|
+
Failure:
|
71
|
+
```ruby
|
72
|
+
{
|
73
|
+
facebook: {
|
74
|
+
status: :error,
|
75
|
+
response: '' # String error message
|
76
|
+
}
|
77
|
+
}
|
78
|
+
```
|
79
|
+
|
80
|
+
# Pinterest
|
81
|
+
|
82
|
+
Based on: [PinterestApi](https://github.com/realadeel/pinterest-api)
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
postwill = Postwill::Client.new(
|
86
|
+
pinterest: {
|
87
|
+
access_token: 'access_token'
|
88
|
+
}
|
89
|
+
)
|
90
|
+
|
91
|
+
# Reqired: [board_id image image_url]
|
92
|
+
# Optional: [text link]
|
93
|
+
|
94
|
+
postwill.to(:pinterest, text: 'text', image: 'image', board_id: 'board_id', link: 'link')
|
95
|
+
# OR
|
96
|
+
postwill.to(:pinterest, text: 'text', image_url: 'image_url', board_id: 'board_id', link: 'link')
|
97
|
+
```
|
98
|
+
|
99
|
+
Success:
|
100
|
+
```ruby
|
101
|
+
{
|
102
|
+
pinterest: {
|
103
|
+
status: :ok,
|
104
|
+
response: {
|
105
|
+
'data' => {
|
106
|
+
'url' => 'PIN_LINK',
|
107
|
+
'note' => 'text',
|
108
|
+
'link' => 'LINK',
|
109
|
+
'id' => 'PIN_ID'
|
110
|
+
}
|
111
|
+
}
|
112
|
+
}
|
113
|
+
}
|
114
|
+
```
|
115
|
+
|
116
|
+
Failure:
|
117
|
+
```ruby
|
118
|
+
{
|
119
|
+
pinterest: {
|
120
|
+
status: :error,
|
121
|
+
response: '' # String error message
|
122
|
+
}
|
123
|
+
}
|
124
|
+
```
|
125
|
+
|
126
|
+
# Tumblr
|
127
|
+
|
128
|
+
Based on: [TumblrClient](https://github.com/postwill/tumblr_client)
|
129
|
+
|
130
|
+
```ruby
|
131
|
+
Postwill::Settings.configure do |config|
|
132
|
+
config.providers.tumblr = {
|
133
|
+
consumer_key: 'consumer_key',
|
134
|
+
consumer_secret: 'consumer_secret'
|
135
|
+
}
|
136
|
+
end
|
137
|
+
|
138
|
+
postwill = Postwill::Client.new(
|
139
|
+
tumblr: {
|
140
|
+
access_token: 'access_token',
|
141
|
+
access_token_secret: 'access_token_secret'
|
142
|
+
}
|
143
|
+
)
|
144
|
+
|
145
|
+
# Reqired: [user_nickname text image title]
|
146
|
+
|
147
|
+
postwill.to(:tumblr, text: 'text', image: 'image', user: 'user_nickname')
|
148
|
+
# or
|
149
|
+
postwill.to(:tumblr, text: 'text', title: 'title', user: 'user_nickname')
|
150
|
+
```
|
151
|
+
|
152
|
+
Success:
|
153
|
+
```ruby
|
154
|
+
{
|
155
|
+
tumblr: {
|
156
|
+
status: :ok,
|
157
|
+
response: {
|
158
|
+
{
|
159
|
+
'id' => 'POST_ID'
|
160
|
+
}
|
161
|
+
}
|
162
|
+
}
|
163
|
+
}
|
164
|
+
```
|
165
|
+
|
166
|
+
Failure:
|
167
|
+
```ruby
|
168
|
+
{
|
169
|
+
tumblr: {
|
170
|
+
status: :error,
|
171
|
+
response: '' # String error message
|
172
|
+
}
|
173
|
+
}
|
174
|
+
```
|
175
|
+
|
176
|
+
# Instagram
|
177
|
+
|
178
|
+
Based on: [InstagramUpload](https://github.com/postwill/instagram_upload)
|
179
|
+
|
180
|
+
```ruby
|
181
|
+
postwill = Postwill::Client.new(
|
182
|
+
instagram: {
|
183
|
+
username: 'username',
|
184
|
+
password: 'password'
|
185
|
+
}
|
186
|
+
)
|
187
|
+
|
188
|
+
postwill.to(:instagram, text: 'text', image: 'image')
|
189
|
+
```
|
190
|
+
|
191
|
+
Success:
|
192
|
+
```ruby
|
193
|
+
{
|
194
|
+
instagram: {
|
195
|
+
status: :ok,
|
196
|
+
response: {} # Response data
|
197
|
+
}
|
198
|
+
}
|
199
|
+
```
|
200
|
+
|
201
|
+
Failure:
|
202
|
+
```ruby
|
203
|
+
{
|
204
|
+
instagram: {
|
205
|
+
status: :error,
|
206
|
+
response: '' # String error message
|
207
|
+
}
|
208
|
+
}
|
209
|
+
```
|
data/README.md
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
# Postwill
|
2
|
+
|
3
|
+
Posting to the most popular social media
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'postwill'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install postwill
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
List of available providers is [here](https://github.com/postwill/postwill/blob/master/PROVIDERS.md).
|
24
|
+
|
25
|
+
### Single provider
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
postwill = Postwill::Client.new(
|
29
|
+
twitter: {
|
30
|
+
access_token: 'access_token',
|
31
|
+
access_token_secret: 'access_token_secret'
|
32
|
+
}
|
33
|
+
)
|
34
|
+
|
35
|
+
postwill.to(:twitter, text: 'text', image: 'image')
|
36
|
+
```
|
37
|
+
|
38
|
+
Success:
|
39
|
+
```ruby
|
40
|
+
{
|
41
|
+
twitter: {
|
42
|
+
status: :ok,
|
43
|
+
response: {} # Hash of response data depends on provider
|
44
|
+
}
|
45
|
+
}
|
46
|
+
```
|
47
|
+
|
48
|
+
Failure:
|
49
|
+
```ruby
|
50
|
+
{
|
51
|
+
twitter: {
|
52
|
+
status: :error,
|
53
|
+
response: '' # String error message
|
54
|
+
}
|
55
|
+
}
|
56
|
+
```
|
57
|
+
|
58
|
+
Application credentials
|
59
|
+
|
60
|
+
`config/initializers/postwill.rb`
|
61
|
+
```ruby
|
62
|
+
Postwill::Settings.configure do |config|
|
63
|
+
config.providers.twitter = {
|
64
|
+
consumer_key: 'your_consumer_key',
|
65
|
+
consumer_secret: 'your_consumer_secret'
|
66
|
+
}
|
67
|
+
end
|
68
|
+
```
|
69
|
+
|
70
|
+
### Multiple providers
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
postwill = Postwill::Client.new(
|
74
|
+
twitter: {
|
75
|
+
access_token: 'access_token',
|
76
|
+
access_token_secret: 'access_token_secret'
|
77
|
+
},
|
78
|
+
facebook: {
|
79
|
+
access_token: 'access_token'
|
80
|
+
}
|
81
|
+
)
|
82
|
+
|
83
|
+
postwill.to(%i[twitter facebook], text: 'text', image: 'image')
|
84
|
+
```
|
85
|
+
|
86
|
+
Result:
|
87
|
+
```ruby
|
88
|
+
{
|
89
|
+
twitter: {
|
90
|
+
status: :ok,
|
91
|
+
response: {} # Response data
|
92
|
+
},
|
93
|
+
facebook: {
|
94
|
+
status: :ok,
|
95
|
+
response: {} # Response data
|
96
|
+
}
|
97
|
+
}
|
98
|
+
```
|
99
|
+
|
100
|
+
Application credentials(for providers which need them)
|
101
|
+
|
102
|
+
`config/initializers/postwill.rb`
|
103
|
+
```ruby
|
104
|
+
Postwill::Settings.configure do |config|
|
105
|
+
config.providers.twitter = {
|
106
|
+
consumer_key: 'your_consumer_key',
|
107
|
+
consumer_secret: 'your_consumer_secret'
|
108
|
+
}
|
109
|
+
end
|
110
|
+
```
|
111
|
+
|
112
|
+
## Contributing
|
113
|
+
|
114
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/postwill/postwill.
|
115
|
+
|
116
|
+
## License
|
117
|
+
|
118
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'postwill'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/circle.yml
ADDED
data/lib/postwill.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
require 'pry-byebug'
|
3
|
+
require 'dry-configurable'
|
4
|
+
require 'dry-monads'
|
5
|
+
require 'twitter'
|
6
|
+
require 'koala'
|
7
|
+
require 'pinterest-api'
|
8
|
+
require 'instagram_upload'
|
9
|
+
|
10
|
+
Bundler.require(:default)
|
11
|
+
|
12
|
+
require_relative 'postwill/settings'
|
13
|
+
require_relative 'postwill/providers/base'
|
14
|
+
require_relative 'postwill/providers/twitter'
|
15
|
+
require_relative 'postwill/providers/facebook'
|
16
|
+
require_relative 'postwill/providers/pinterest'
|
17
|
+
require_relative 'postwill/providers/tumblr'
|
18
|
+
require_relative 'postwill/providers/instagram'
|
19
|
+
require_relative 'postwill/response'
|
20
|
+
require_relative 'postwill/client'
|
21
|
+
|
22
|
+
module Postwill
|
23
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Postwill
|
2
|
+
class Client
|
3
|
+
PROVIDERS = %i[twitter facebook pinterest tumblr instagram]
|
4
|
+
|
5
|
+
def initialize(data)
|
6
|
+
instance_providers(data)
|
7
|
+
end
|
8
|
+
|
9
|
+
def to(providers, options = {})
|
10
|
+
availables_providers(providers).each_with_object({}) do |provider, result|
|
11
|
+
provider_service = instance_variable_get("@#{provider}")
|
12
|
+
result[provider] = response(provider_service.call(options))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def availables_providers(*providers)
|
19
|
+
providers.flatten.map { |provider| PROVIDERS.include?(provider) ? provider : nil }.compact
|
20
|
+
end
|
21
|
+
|
22
|
+
def response(result)
|
23
|
+
return Response.call(:ok, result.value) if result.success?
|
24
|
+
Response.call(:error, result.value.message)
|
25
|
+
end
|
26
|
+
|
27
|
+
def instance_providers(data)
|
28
|
+
PROVIDERS.each do |provider|
|
29
|
+
next unless data[provider]
|
30
|
+
|
31
|
+
instance_variable_set("@#{provider}", Object.const_get(['Postwill::Providers::',
|
32
|
+
provider.to_s.capitalize].join)
|
33
|
+
.new(data[provider]))
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Postwill
|
2
|
+
module Providers
|
3
|
+
class Base
|
4
|
+
attr_reader :client
|
5
|
+
|
6
|
+
def call(options = {})
|
7
|
+
Dry::Monads::Right(post(options))
|
8
|
+
rescue Exception => error
|
9
|
+
Dry::Monads::Left(error)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def post(options)
|
15
|
+
raise NotImplementedError
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Postwill
|
2
|
+
module Providers
|
3
|
+
class Facebook < Base
|
4
|
+
def initialize(options)
|
5
|
+
@client ||= ::Koala::Facebook::API.new(options[:access_token])
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def post(options)
|
11
|
+
image = options[:image]
|
12
|
+
text = options[:text]
|
13
|
+
|
14
|
+
if image
|
15
|
+
client.put_picture(image, { message: text })
|
16
|
+
else
|
17
|
+
client.put_connections('me', 'feed', message: text)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Postwill
|
2
|
+
module Providers
|
3
|
+
class Instagram < Base
|
4
|
+
def initialize(options)
|
5
|
+
@client ||= ::InstagramUpload::Client.new(options[:username], options[:password])
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def post(options)
|
11
|
+
image = options[:image]
|
12
|
+
text = options[:text]
|
13
|
+
|
14
|
+
client.upload_photo(image, text)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Postwill
|
2
|
+
module Providers
|
3
|
+
class Pinterest < Base
|
4
|
+
def initialize(options)
|
5
|
+
@client ||= ::Pinterest::Client.new(options[:access_token])
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def post(options)
|
11
|
+
params = {
|
12
|
+
board: options[:board_id],
|
13
|
+
note: options[:text],
|
14
|
+
link: options[:link],
|
15
|
+
image_url: options[:image_url],
|
16
|
+
image: options[:image]
|
17
|
+
}.compact
|
18
|
+
|
19
|
+
response(client.create_pin(params).to_h)
|
20
|
+
end
|
21
|
+
|
22
|
+
def response(result)
|
23
|
+
raise Exception, result['message'] unless result.dig('data', 'id')
|
24
|
+
result
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Postwill
|
2
|
+
module Providers
|
3
|
+
class Tumblr < Base
|
4
|
+
def initialize(options)
|
5
|
+
@client ||= ::Tumblr::Client.new(
|
6
|
+
consumer_key: credentials[:consumer_key],
|
7
|
+
consumer_secret: credentials[:consumer_secret],
|
8
|
+
oauth_token: options[:access_token],
|
9
|
+
oauth_token_secret: options[:access_token_secret]
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def post(options)
|
16
|
+
image = options[:image]
|
17
|
+
text = options[:text]
|
18
|
+
title = options[:title]
|
19
|
+
user = options[:user]
|
20
|
+
|
21
|
+
if image
|
22
|
+
result = client.photo(user, data: [image], caption: text)
|
23
|
+
else
|
24
|
+
result = client.text(user, body: text, title: title)
|
25
|
+
end
|
26
|
+
|
27
|
+
response(result)
|
28
|
+
end
|
29
|
+
|
30
|
+
def credentials
|
31
|
+
Postwill::Settings.config.providers.tumblr
|
32
|
+
end
|
33
|
+
|
34
|
+
def response(result)
|
35
|
+
raise Exception, result['errors'] unless result.dig('id')
|
36
|
+
result
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Postwill
|
2
|
+
module Providers
|
3
|
+
class Twitter < Base
|
4
|
+
def initialize(options)
|
5
|
+
@client ||= ::Twitter::REST::Client.new do |config|
|
6
|
+
config.consumer_key = credentials[:consumer_key]
|
7
|
+
config.consumer_secret = credentials[:consumer_secret]
|
8
|
+
config.access_token = options[:access_token]
|
9
|
+
config.access_token_secret = options[:access_token_secret]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def post(options)
|
16
|
+
image = File.open(options[:image]) if options[:image]
|
17
|
+
text = options[:text]
|
18
|
+
|
19
|
+
response = image ? client.update_with_media(text, image) : client.update(text)
|
20
|
+
response.to_h
|
21
|
+
end
|
22
|
+
|
23
|
+
def credentials
|
24
|
+
Postwill::Settings.config.providers.twitter
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/postwill.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
2
|
+
require 'postwill/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = 'postwill'
|
6
|
+
spec.version = Postwill::VERSION
|
7
|
+
spec.authors = ['Kirill Shevchenko']
|
8
|
+
spec.email = ['hello@kirillshevch.com']
|
9
|
+
|
10
|
+
spec.summary = 'Posting to the most popular social media'
|
11
|
+
spec.description = spec.summary
|
12
|
+
spec.homepage = 'https://github.com/postwill/postwill'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
+
f.match(%r{^(test|spec|features)/})
|
17
|
+
end
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_dependency 'dry-configurable', '~> 0.7'
|
23
|
+
spec.add_dependency 'dry-monads', '~> 0.3.1'
|
24
|
+
spec.add_dependency 'twitter', '~> 6.1.0'
|
25
|
+
spec.add_dependency 'koala', '~> 3.0.0'
|
26
|
+
spec.add_dependency 'pinterest-api', '~> 0.4.0'
|
27
|
+
spec.add_dependency 'instagram_upload', '~> 0.1.2'
|
28
|
+
|
29
|
+
spec.add_development_dependency 'bundler', '~> 1.15'
|
30
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
31
|
+
spec.add_development_dependency 'rspec', '~> 3.6.0'
|
32
|
+
spec.add_development_dependency 'pry-byebug', '~> 3.5.0'
|
33
|
+
spec.add_development_dependency 'rubocop', '~> 0.50.0'
|
34
|
+
spec.add_development_dependency 'vcr', '~> 3.0.3'
|
35
|
+
spec.add_development_dependency 'webmock', '~> 3.0.1'
|
36
|
+
spec.add_development_dependency 'ffaker', '~> 2.7'
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,263 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: postwill
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kirill Shevchenko
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-10-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: dry-configurable
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: dry-monads
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.3.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.3.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: twitter
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 6.1.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 6.1.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: koala
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.0.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.0.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pinterest-api
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.4.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.4.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: instagram_upload
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.1.2
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.1.2
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: bundler
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.15'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.15'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rake
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '10.0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '10.0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rspec
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 3.6.0
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 3.6.0
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: pry-byebug
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 3.5.0
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 3.5.0
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rubocop
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 0.50.0
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 0.50.0
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: vcr
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 3.0.3
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 3.0.3
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: webmock
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: 3.0.1
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: 3.0.1
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: ffaker
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - "~>"
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '2.7'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - "~>"
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '2.7'
|
209
|
+
description: Posting to the most popular social media
|
210
|
+
email:
|
211
|
+
- hello@kirillshevch.com
|
212
|
+
executables: []
|
213
|
+
extensions: []
|
214
|
+
extra_rdoc_files: []
|
215
|
+
files:
|
216
|
+
- ".gitignore"
|
217
|
+
- ".rspec"
|
218
|
+
- ".rubocop.yml"
|
219
|
+
- Gemfile
|
220
|
+
- LICENSE.txt
|
221
|
+
- PROVIDERS.md
|
222
|
+
- README.md
|
223
|
+
- Rakefile
|
224
|
+
- bin/console
|
225
|
+
- bin/setup
|
226
|
+
- circle.yml
|
227
|
+
- lib/postwill.rb
|
228
|
+
- lib/postwill/client.rb
|
229
|
+
- lib/postwill/providers/base.rb
|
230
|
+
- lib/postwill/providers/facebook.rb
|
231
|
+
- lib/postwill/providers/instagram.rb
|
232
|
+
- lib/postwill/providers/pinterest.rb
|
233
|
+
- lib/postwill/providers/tumblr.rb
|
234
|
+
- lib/postwill/providers/twitter.rb
|
235
|
+
- lib/postwill/response.rb
|
236
|
+
- lib/postwill/settings.rb
|
237
|
+
- lib/postwill/version.rb
|
238
|
+
- postwill.gemspec
|
239
|
+
homepage: https://github.com/postwill/postwill
|
240
|
+
licenses:
|
241
|
+
- MIT
|
242
|
+
metadata: {}
|
243
|
+
post_install_message:
|
244
|
+
rdoc_options: []
|
245
|
+
require_paths:
|
246
|
+
- lib
|
247
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
248
|
+
requirements:
|
249
|
+
- - ">="
|
250
|
+
- !ruby/object:Gem::Version
|
251
|
+
version: '0'
|
252
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
253
|
+
requirements:
|
254
|
+
- - ">="
|
255
|
+
- !ruby/object:Gem::Version
|
256
|
+
version: '0'
|
257
|
+
requirements: []
|
258
|
+
rubyforge_project:
|
259
|
+
rubygems_version: 2.5.2
|
260
|
+
signing_key:
|
261
|
+
specification_version: 4
|
262
|
+
summary: Posting to the most popular social media
|
263
|
+
test_files: []
|