Skip to content

Commit

Permalink
Merge pull request #7 from nacyot/metalbird
Browse files Browse the repository at this point in the history
Metalbird
  • Loading branch information
nacyot committed Sep 19, 2015
2 parents 064faec + ce60c6d commit c0a936a
Show file tree
Hide file tree
Showing 27 changed files with 174 additions and 137 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
@@ -1,10 +1,10 @@
language: ruby
sudo: false
rvm:
- 1.9.3
- 2.2.1
- 2.2.3
env:
global:
- secure: "GsTst74irWe77XI+VJtJQKJjpc6Nz9z0CAEVcDglsNOJg//Enq2nyNeTkGexdge0AEa0u0kmYXFsWUrBteq0EBBGbZTl1XdMf1KW0CL8ni6i2AreaKkuV4e1aM/aXOD6lXycyzW/xaSo+9jvQyy2fF6mgs/pNNizFIz8Ja52iQY="
- SERVER_ENV=CI
- SERVER_ENV=CI
- secure: MqtV3eeHuUjIjncqAcSydfsofkM3bpSj0pcajw4L321qh8Wag1RIhqw+DqNLQALhgHFPv/B540AAJxxG1Y5exT8GfB98ZjIKwCa7Fpt8xZjh0bRHnzbmJSkWjhldRplAHUYuHTjOAq04/l13O0+1tw50CGjVQHjJdaS/2q2cihk=
script:
- bundle exec rspec
116 changes: 60 additions & 56 deletions Gemfile.lock
@@ -1,136 +1,139 @@
PATH
remote: .
specs:
post_publisher (0.0.1)
metalbird (0.0.1)
oauth (~> 0.4)
tumblr_client (~> 0.8)
twitter (~> 5)

GEM
remote: https://rubygems.org/
specs:
addressable (2.3.7)
ast (2.0.0)
astrolabe (1.3.0)
parser (>= 2.2.0.pre.3, < 3.0)
addressable (2.3.8)
ast (2.1.0)
astrolabe (1.3.1)
parser (~> 2.2)
buftok (0.2.0)
celluloid (0.16.0)
timers (~> 4.0.0)
coderay (1.1.0)
coveralls (0.7.11)
multi_json (~> 1.10)
coveralls (0.8.2)
json (~> 1.8)
rest-client (>= 1.6.8, < 2)
simplecov (~> 0.9.1)
simplecov (~> 0.10.0)
term-ansicolor (~> 1.3)
thor (~> 0.19.1)
diff-lcs (1.2.5)
docile (1.1.5)
equalizer (0.0.9)
domain_name (0.5.24)
unf (>= 0.0.5, < 1.0.0)
dotenv (2.0.2)
equalizer (0.0.10)
faraday (0.9.1)
multipart-post (>= 1.2, < 3)
faraday_middleware (0.9.1)
faraday_middleware (0.9.2)
faraday (>= 0.7.4, < 0.10)
ffi (1.9.6)
ffi (1.9.10)
formatador (0.2.5)
guard (2.12.4)
guard (2.13.0)
formatador (>= 0.2.4)
listen (~> 2.7)
listen (>= 2.7, <= 4.0)
lumberjack (~> 1.0)
nenv (~> 0.1)
notiffany (~> 0.0)
pry (>= 0.9.12)
shellany (~> 0.0)
thor (>= 0.18.1)
guard-compat (1.2.1)
guard-rspec (4.5.0)
guard-rspec (4.6.4)
guard (~> 2.1)
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
hitimes (1.2.2)
http (0.6.3)
http (0.9.6)
addressable (~> 2.3)
http-cookie (~> 1.0)
http-form_data (~> 1.0.1)
http_parser.rb (~> 0.6.0)
http-cookie (1.0.2)
domain_name (~> 0.5)
http-form_data (1.0.1)
http_parser.rb (0.6.0)
json (1.8.2)
listen (2.8.5)
celluloid (>= 0.15.2)
json (1.8.3)
listen (3.0.3)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
lumberjack (1.0.9)
memoizable (0.4.2)
thread_safe (~> 0.3, >= 0.3.1)
method_source (0.8.2)
mime-types (2.4.3)
multi_json (1.10.1)
mime-types (2.6.2)
multipart-post (2.0.0)
naught (1.0.0)
naught (1.1.0)
nenv (0.2.0)
netrc (0.10.3)
notiffany (0.0.6)
notiffany (0.0.8)
nenv (~> 0.1)
shellany (~> 0.0)
oauth (0.4.7)
parser (2.2.0.3)
parser (2.2.2.6)
ast (>= 1.1, < 3.0)
powerpack (0.1.0)
powerpack (0.1.1)
pry (0.10.1)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rainbow (2.0.0)
rb-fsevent (0.9.4)
rb-fsevent (0.9.6)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
rest-client (1.7.3)
rest-client (1.8.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
rspec (3.2.0)
rspec-core (~> 3.2.0)
rspec-expectations (~> 3.2.0)
rspec-mocks (~> 3.2.0)
rspec-core (3.2.1)
rspec-support (~> 3.2.0)
rspec-expectations (3.2.0)
rspec (3.3.0)
rspec-core (~> 3.3.0)
rspec-expectations (~> 3.3.0)
rspec-mocks (~> 3.3.0)
rspec-core (3.3.2)
rspec-support (~> 3.3.0)
rspec-expectations (3.3.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.2.0)
rspec-mocks (3.2.1)
rspec-support (~> 3.3.0)
rspec-mocks (3.3.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.2.0)
rspec-support (3.2.2)
rubocop (0.29.1)
rspec-support (~> 3.3.0)
rspec-support (3.3.0)
rubocop (0.34.1)
astrolabe (~> 1.3)
parser (>= 2.2.0.1, < 3.0)
parser (>= 2.2.2.5, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.4)
ruby-progressbar (1.7.1)
ruby-progressbar (1.7.5)
shellany (0.0.1)
simple_oauth (0.3.1)
simplecov (0.9.2)
simplecov (0.10.0)
docile (~> 1.1.0)
multi_json (~> 1.0)
simplecov-html (~> 0.9.0)
simplecov-html (0.9.0)
json (~> 1.8)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
slop (3.6.0)
term-ansicolor (1.3.0)
term-ansicolor (1.3.2)
tins (~> 1.0)
thor (0.19.1)
thread_safe (0.3.4)
timers (4.0.1)
hitimes
tins (1.3.4)
thread_safe (0.3.5)
tins (1.6.0)
tumblr_client (0.8.5)
faraday (~> 0.9.0)
faraday_middleware (~> 0.9.0)
json
mime-types
oauth
simple_oauth
twitter (5.14.0)
twitter (5.15.0)
addressable (~> 2.3)
buftok (~> 0.2.0)
equalizer (~> 0.0.9)
equalizer (= 0.0.10)
faraday (~> 0.9.0)
http (~> 0.6.0)
http (>= 0.4, < 0.10)
http_parser.rb (~> 0.6.0)
json (~> 1.8)
memoizable (~> 0.4.0)
Expand All @@ -147,9 +150,10 @@ PLATFORMS

DEPENDENCIES
coveralls
dotenv
guard
guard-rspec
post_publisher!
metalbird!
rspec
rubocop
twitter-text
55 changes: 44 additions & 11 deletions README.md
@@ -1,24 +1,57 @@
# Post Publisher Gem
# Metalbird - Library for Publishing posts

[![Build Status](https://travis-ci.org/remotty/post_publisher.svg)](https://travis-ci.org/remotty/post_publisher)
[![Coverage Status](https://coveralls.io/repos/remotty/post_publisher/badge.svg)](https://coveralls.io/r/remotty/post_publisher)
[![Code Climate](https://codeclimate.com/github/remotty/post_publisher/badges/gpa.svg)](https://codeclimate.com/github/remotty/post_publisher)
[![Inline docs](http://inch-ci.org/github/remotty/post_publisher.svg?branch=master)](http://inch-ci.org/github/remotty/post_publisher)
[![Dependency Status](https://gemnasium.com/remotty/post_publisher.svg)](https://gemnasium.com/remotty/post_publisher)
[![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://www.rubydoc.info/github/remotty/post_publisher/master)
[![Build Status](https://travis-ci.org/hubtee/metalbird.svg)](https://travis-ci.org/hubtee/metalbird)
[![Coverage Status](https://coveralls.io/repos/hubtee/metalbird/badge.svg)](https://coveralls.io/r/hubtee/metalbird)
[![Code Climate](https://codeclimate.com/github/hubtee/metalbird/badges/gpa.svg)](https://codeclimate.com/github/hubtee/metalbird)
[![Inline docs](http://inch-ci.org/github/hubtee/metalbird.svg?branch=master)](http://inch-ci.org/github/hubtee/metalbird)
[![Dependency Status](https://gemnasium.com/hubtee/metalbird.svg)](https://gemnasium.com/hubtee/metalbird)
[![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://www.rubydoc.info/github/hubtee/metalbird/master)

## Install

```
# gem install post_publisher
```sh
$ gem install metalbird
```

```
gem 'post_publisher'
```ruby
gem 'metalbird'
```

## Usage

### Twitter

```ruby
require 'metalbird'

opts = {}
opts[:consumer_key] = ENV['TWITTER_CONSUMER_KEY']
opts[:consumer_secret] = ENV['TWITTER_CONSUMER_SECRET']
opts[:access_token] = ENV['ACCESS_TOKEN']
opts[:access_token_secret] = ENV['ACCESS_TOKEN_SECRET']

auth = Metalbird::Twitter::Authentication.new(opts)
publisher = Metalbird::Twitter::Publisher.new(auth)

# Post tweet
args = Metalbird::Twitter::PublishArgs.new(tweet: 'Hello, World')
publisher.publish(args)

# Post tweet with images
data = {
tweet: 'Hello, image',
images: [File.open('./images/image.jpg')]
}
args = Metalbird::Twitter::PublishArgs.new(data)
publisher.publish(args)

# Retweet
args = Metalbird::Twitter::RetweetArgs.new(tweet_id: 645198939356983296)
publisher.publish(args)
```

### Tumblr

## Support

### Web Service
Expand Down
2 changes: 1 addition & 1 deletion bin/auth_twitter.rb
Expand Up @@ -2,4 +2,4 @@

require './bin/authenticator'

PostPublisher::Authenticator::Twitter.authenticate
Metalbird::Authenticator::Twitter.authenticate
8 changes: 4 additions & 4 deletions bin/post_tweet.rb
@@ -1,4 +1,4 @@
require './lib/post_publisher'
require './lib/metalbird'
require 'pp'

Dotenv::Railtie.load
Expand All @@ -9,8 +9,8 @@
opts[:access_token] = ENV['ACCESS_TOKEN']
opts[:access_token_secret] = ENV['ACCESS_TOKEN_SECRET']

auth = PostPublisher::Twitter::Authentication.new(opts)
publisher = PostPublisher::Twitter::Publisher.new(auth)
auth = Metalbird::Twitter::Authentication.new(opts)
publisher = Metalbird::Twitter::Publisher.new(auth)

args = PostPublisher::Twitter::PublishArgs.new(tweet: 'Hello, World')
args = Metalbird::Twitter::PublishArgs.new(tweet: 'Hello, World')
pp publisher.publish(args)
10 changes: 10 additions & 0 deletions lib/metalbird.rb
@@ -0,0 +1,10 @@
require 'logger'

$LOAD_PATH.unshift File.dirname(__FILE__)

module Metalbird
autoload :Twitter, 'metalbird/twitter'
autoload :Tumblr, 'metalbird/tumblr'

Logger = ::Logger.new(STDOUT)
end
@@ -1,7 +1,7 @@
# See http://d.hatena.ne.jp/riocampos+tech/20130615/p1
require 'oauth'

module PostPublisher
module Metalbird
module Twitter
class CliTools
@consumer_key = ''
Expand Down
6 changes: 6 additions & 0 deletions lib/metalbird/tumblr.rb
@@ -0,0 +1,6 @@
module Metalbird
module Tumblr
autoload :Authentication, 'metalbird/tumblr/authentication'
autoload :Publisher, 'metalbird/tumblr/publisher'
end
end
@@ -1,6 +1,6 @@
require 'tumblr_client'

module PostPublisher
module Metalbird
module Tumblr
class Authentication
attr_reader :client
Expand Down
@@ -1,4 +1,4 @@
module PostPublisher
module Metalbird
module Tumblr
class Publisher
def initialize(auth)
Expand Down
8 changes: 8 additions & 0 deletions lib/metalbird/twitter.rb
@@ -0,0 +1,8 @@
module Metalbird
module Twitter
autoload :Authentication, 'metalbird/twitter/authentication'
autoload :Publisher, 'metalbird/twitter/publisher'
autoload :PublishArgs, 'metalbird/twitter/publish_args'
autoload :RetweetArgs, 'metalbird/twitter/retweet_args'
end
end
@@ -1,6 +1,6 @@
require 'twitter'

module PostPublisher
module Metalbird
module Twitter
class Authentication
attr_reader :client
Expand Down
@@ -1,7 +1,7 @@
require 'twitter-text'
require 'uri'

module PostPublisher
module Metalbird
module Twitter
class PublishArgs
MAX_TWEET_LENGTH = 140
Expand Down

0 comments on commit c0a936a

Please sign in to comment.