buffer 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -0
- data/bin/buffer +19 -4
- data/lib/buffer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d221f19af636e707a8aaa8347c8250c9f82a0f2d
|
4
|
+
data.tar.gz: d5e2cce4e5747447616336dfe57925e3ed01e278
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 644e52c54def7336f7b79cd9391ea759701591e7d2f7cf28f954f2ea8f986077ff6061e90fbea33da52288d3ec7af338d3b39f5d1bcea0ca82a1831a4db98151
|
7
|
+
data.tar.gz: e264fe061fa436d855c20dba0962c1a0876bec71256c8b3f5dec5882678b642c65d218c914a7e86bcd188ed02656d131abb1c118404c56a0842d9c2ec19e260e
|
data/README.md
CHANGED
@@ -51,6 +51,25 @@ export BUFFER_PROFILE_ID="0" # (default of 0)
|
|
51
51
|
* Gather Access Token and place it after the word "access_token"
|
52
52
|
* Set BUFFER_PROFILE_ID="0" if you only have one account to post to. Otherwise it's more complicated ;). Find me on Twitter and I can explain [@_ZPH](https://twitter.com/_ZPH).
|
53
53
|
|
54
|
+
#### Example
|
55
|
+
|
56
|
+
The example below will use your Buffer account and schedule an update to be posted on your connected profiles with the specified IDs.
|
57
|
+
|
58
|
+
```
|
59
|
+
client = Buffer::Client.new(ACCESS_TOKEN)
|
60
|
+
client.create_update(
|
61
|
+
body: {
|
62
|
+
text:
|
63
|
+
"Today's artist spotlight is on #{artist_name}.
|
64
|
+
Check out the track, #{track_title}.",
|
65
|
+
profile_ids: [
|
66
|
+
'...',
|
67
|
+
'...',
|
68
|
+
]
|
69
|
+
},
|
70
|
+
)
|
71
|
+
```
|
72
|
+
|
54
73
|
## TODO:
|
55
74
|
|
56
75
|
* Improve instructions
|
data/bin/buffer
CHANGED
@@ -17,14 +17,29 @@ def gather_message(argv)
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
+
def parse_profile_ids(env = ENV)
|
21
|
+
profile = ENV.fetch('BUFFER_PROFILE_ID', "0")
|
22
|
+
profiles = if profile.include?(",")
|
23
|
+
profile.split(",")
|
24
|
+
else
|
25
|
+
Array(profile)
|
26
|
+
end
|
27
|
+
profiles.map { |i| Integer(i) }
|
28
|
+
end
|
29
|
+
|
20
30
|
def main
|
21
31
|
token = Env.BUFFER_ACCESS_TOKEN
|
22
|
-
profile = Integer(ENV.fetch('BUFFER_PROFILE_ID', "0"))
|
23
|
-
|
24
32
|
message = gather_message(ARGV)
|
25
33
|
client = Buffer::Client.new(token)
|
26
|
-
|
27
|
-
|
34
|
+
all_profiles = client.profiles
|
35
|
+
desired_profiles = parse_profile_ids.map do |i|
|
36
|
+
begin
|
37
|
+
all_profiles[i]["_id"]
|
38
|
+
rescue
|
39
|
+
abort("ERROR: Unable to find all the requested profiles. Profile Index #{i} was the issue.")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
post_args = {text: message, profile_ids: desired_profiles}
|
28
43
|
LOG.info('#main.post_args') { post_args }
|
29
44
|
unless ENV['BUFFER_DEBUG']
|
30
45
|
client.create_update(body: post_args)
|
data/lib/buffer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: buffer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ZPH
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|