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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c720c5f920f5d215ecdd86fbbb24bce689ea3825
4
- data.tar.gz: 71289210d6c274b805d4304e1d5dd2f355e8e1a8
3
+ metadata.gz: 9c37d99d456c1e05e2cd448103b3752b56714b0e
4
+ data.tar.gz: 09fbe3cc3a1ddc935a7ce5e0698132569b5c91bf
5
5
  SHA512:
6
- metadata.gz: aaed1ab1510883a3a6f445ddc462149fabe62b127dbbc5669cf415ff4481a363dba383ecd58075a47d7cba400c3e01ddbedb7734e27d8329f005ddd57148a633
7
- data.tar.gz: 734284b3a82d83637008294000eb7db93015af984911d7b498a7799947f9bb7d15450636a2d7daa40e5ffa215da73fb12d0005b5e6ca66a724de87f13997ecd1
6
+ metadata.gz: 299b2b1a5989dad8d98547a91948f7344e7035bb205052af01c5cfbb2caf2435a4c7892fd434308c78b0db910475c686f78e2de310390ddd04b612a238583fcb
7
+ data.tar.gz: db78b98a6845febd2b830973053031366a32cc436f2437f2840dff1caac7ac799e45c0eacfca63266f7eb662c4ddae3cda16b7fd28ad14e397eeb12a92ad1903
data/.gitignore CHANGED
@@ -19,3 +19,4 @@ notes.txt
19
19
  .DS_STORE
20
20
  spec/fixtures/updates_by_profile_id_sent.txt
21
21
  utility.rb
22
+ tags
data/.rubocop.yml ADDED
@@ -0,0 +1,18 @@
1
+ Encoding:
2
+ Enabled: true
3
+
4
+ LineLength:
5
+ Enabled: true
6
+ Max: 79
7
+
8
+ StringLiterals:
9
+ Enabled: false
10
+
11
+ AllCops:
12
+ # Includes:
13
+ Excludes:
14
+ - spec/**
15
+ - bin/**
16
+ - utility.rb
17
+ - Rakefile
18
+ - tmp/*
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-buffer) or use the single API key given when registering your own Buffer Dev credentials.
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
- def self.encode(arg)
4
- raise_error_for_incorrect_input(arg)
5
- arg = arg[:schedules] if arg.respond_to?(:keys)
6
- output = []
7
- arg.each_with_index do |item, index|
8
- process_schedule(output, item, index)
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
- private
12
+ private
14
13
 
15
- def self.raise_error_for_incorrect_input(arg)
16
- unless arg.kind_of?(Hash) || arg.kind_of?(Array)
17
- raise ArgumentError, "Input must be/inherit from Hash or Array"
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
- def self.process_schedule(output, item, index)
22
- uri = Addressable::URI.new
23
- uri.query_values = item
24
- pairs = uri.query.split("&").map do |pair|
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
@@ -1,3 +1,3 @@
1
1
  module Buff
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -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/4eb8565e0acb04bb82000004.json?access_token=some_token").
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.3
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-05-26 00:00:00.000000000 Z
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