buff 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +18 -0
- data/README.md +1 -2
- data/bin/buff +13 -0
- data/lib/buff/encode.rb +22 -20
- data/lib/buff/version.rb +1 -1
- data/spec/lib/buff/update_spec.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c37d99d456c1e05e2cd448103b3752b56714b0e
|
4
|
+
data.tar.gz: 09fbe3cc3a1ddc935a7ce5e0698132569b5c91bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 299b2b1a5989dad8d98547a91948f7344e7035bb205052af01c5cfbb2caf2435a4c7892fd434308c78b0db910475c686f78e2de310390ddd04b612a238583fcb
|
7
|
+
data.tar.gz: db78b98a6845febd2b830973053031366a32cc436f2437f2840dff1caac7ac799e45c0eacfca63266f7eb662c4ddae3cda16b7fd28ad14e397eeb12a92ad1903
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
data/README.md
CHANGED
@@ -27,9 +27,8 @@ Or install RubyGems version, which will receive more attention to stability:
|
|
27
27
|
|
28
28
|
## Usage
|
29
29
|
|
30
|
-
* Note that some of the optional params are not implemented!
|
31
30
|
* All methods are tested with Rspec and WebMock. Most methods do not have integration tests that reach out to the live Buffer API servers. Proceed with caution until Buff reaches v0.1.0 and submit issues on Github Issues tab.
|
32
|
-
* Authentication is not included in this gem (Try OAuth-
|
31
|
+
* Authentication is not included in this gem (Try OAuth-buffer2) or use the single API key given when registering your own Buffer Dev credentials.
|
33
32
|
* For convenience load credentials into `~/.bufferapprc` in the following layout. This allows the `ACCESS_TOKEN` to be loaded into `Buff::ACCESS_TOKEN`:
|
34
33
|
|
35
34
|
|
data/bin/buff
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__), '..', 'lib')
|
4
|
+
|
5
|
+
require 'buff'
|
6
|
+
|
7
|
+
_, _, access_token, profile_id = File.open(File.expand_path '~/.bufferapprc').readlines.map(&:chomp)
|
8
|
+
|
9
|
+
client = Buff::Client.new(access_token)
|
10
|
+
id = client.profiles[profile_id.to_i].id
|
11
|
+
|
12
|
+
response = client.create_update(body: {text: ARGV.join(" "), profile_ids: [ id ] } )
|
13
|
+
puts response if ENV['BUFF_DEBUG']
|
data/lib/buff/encode.rb
CHANGED
@@ -1,31 +1,33 @@
|
|
1
1
|
module Buff
|
2
2
|
class Encode
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
class << self
|
4
|
+
def encode(arg)
|
5
|
+
raise_error_for_incorrect_input(arg)
|
6
|
+
arg = arg[:schedules] if arg.respond_to?(:keys)
|
7
|
+
arg.map.with_index do |item, index|
|
8
|
+
process_schedule(item, index)
|
9
|
+
end.join("&")
|
9
10
|
end
|
10
|
-
output.join("&")
|
11
|
-
end
|
12
11
|
|
13
|
-
|
12
|
+
private
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
def raise_error_for_incorrect_input(arg)
|
15
|
+
unless arg.kind_of?(Hash) || arg.kind_of?(Array)
|
16
|
+
raise ArgumentError, "Input must be/inherit from Hash or Array"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def process_schedule(item, index)
|
21
|
+
pairs_for(item).map do |key, value|
|
22
|
+
"schedules[#{index}][#{key}][]=#{value}"
|
23
|
+
end.join("&")
|
18
24
|
end
|
19
|
-
end
|
20
25
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
key , value = pair.split("=")
|
26
|
-
"schedules[#{index}][#{key}][]=#{value}"
|
26
|
+
def pairs_for(item)
|
27
|
+
uri = Addressable::URI.new
|
28
|
+
uri.query_values = item
|
29
|
+
uri.query.split("&").map {|p| p.split("=")}
|
27
30
|
end
|
28
|
-
output << pairs.join("&")
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
data/lib/buff/version.rb
CHANGED
@@ -9,7 +9,7 @@ describe Buff::Client do
|
|
9
9
|
describe "#update_by_id" do
|
10
10
|
|
11
11
|
before do
|
12
|
-
stub_request(:get, "https://api.bufferapp.com/1/updates
|
12
|
+
stub_request(:get, "https://api.bufferapp.com/1/updates/#{ id }.json?access_token=some_token").
|
13
13
|
to_return(fixture("update_by_id.txt"))
|
14
14
|
end
|
15
15
|
it "fails without an id" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: buff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ZPH
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -209,11 +209,13 @@ dependencies:
|
|
209
209
|
description: Buff is an API Wrapper Gem for Bufferapp.com's API
|
210
210
|
email:
|
211
211
|
- Zander@civet.ws
|
212
|
-
executables:
|
212
|
+
executables:
|
213
|
+
- buff
|
213
214
|
extensions: []
|
214
215
|
extra_rdoc_files: []
|
215
216
|
files:
|
216
217
|
- .gitignore
|
218
|
+
- .rubocop.yml
|
217
219
|
- .ruby-version
|
218
220
|
- .travis.yml
|
219
221
|
- API_COVERAGE.md
|
@@ -222,6 +224,7 @@ files:
|
|
222
224
|
- LICENSE.txt
|
223
225
|
- README.md
|
224
226
|
- Rakefile
|
227
|
+
- bin/buff
|
225
228
|
- buff.gemspec
|
226
229
|
- lib/buff.rb
|
227
230
|
- lib/buff/client.rb
|