middleman-blog-twitter 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6d60e04881eade8bb8741f19caf87851d809c4e3
4
+ data.tar.gz: 4e84713496c9ba406147c33ed693477a6c3f0a2b
5
+ SHA512:
6
+ metadata.gz: d104f960086ba133af315c3b74b8cc42a1695ff59a109bd784327d1ffe0745bf43bf5cc77972b09d5c11677f1ce61b123d026d96fd0a04e96e45041baa618728
7
+ data.tar.gz: 82c1a9d0eb54f93eeb38f648bad6fa336430adc13a688c33b3f0fd312d51938caac608053d38798002b859d49f681b122c3f6daeb844cda8a1fc9c53f910e529
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in middleman-blog-twitter.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Michiaki Mizoguchi
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # Middleman::Blog::Twitter
2
+
3
+ Tweet about the latest article on Middleman blog.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'middleman-blog-twitter'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install middleman-blog-twitter
18
+
19
+ ## Usage
20
+ ### 1. Settings(Tweet text template)
21
+ Create ERB for tweet text(ex. `tweet_template.txt.erb`).
22
+
23
+ ```ruby
24
+ Blog updated: <%= latest_article.title %> <%= hostname %><%= latest_article.url %>
25
+ ```
26
+
27
+ #### Available variables
28
+
29
+ |name|value|
30
+ |---|---|
31
+ |latest_article|[Middleman::Sitemap::Resource](http://www.rubydoc.info/github/middleman/middleman/Middleman/Sitemap/Resource) included [Middleman::Blog::BlogArticle](http://www.rubydoc.info/github/middleman/middleman-blog/master/Middleman/Blog/BlogArticle) object of the latest blog article|
32
+ |hostname|Your blog hostname(set in the next section)|
33
+
34
+
35
+ ### 2. Settings(Tokens, hostname, and template path)
36
+ On `config.rb`
37
+
38
+ ```ruby
39
+ activate :blog_twitter do |twitter|
40
+ twitter.consumer_key = 'YOUR CONSUMER KEY'
41
+ twitter.consumer_secret = 'YOUR CONSUMER SECRET'
42
+ twitter.access_token = 'YOUR ACCESS TOKEN'
43
+ twitter.access_token_secret = 'YOUR ACCESS TOKEN SECRET'
44
+ twitter.hostname = 'http://example.com' # your blog hostname
45
+ twitter.template_path = 'tweet_template.txt.erb'
46
+ end
47
+ ```
48
+
49
+ ### 3. Execute command
50
+ ```sh
51
+ $ middleman tweet
52
+ ```
53
+
54
+ then
55
+
56
+ > Blog updated: \<latest article title\> \<latest article url\>
57
+
58
+ ## Contributing
59
+
60
+ 1. Fork it ( http://github.com/<my-github-username>/middleman-blog-twitter/fork )
61
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
62
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
63
+ 4. Push to the branch (`git push origin my-new-feature`)
64
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,27 @@
1
+ require "middleman/blog/twitter/version"
2
+ require "middleman/blog/twitter/cli"
3
+ require "middleman/blog/twitter/settings"
4
+
5
+ module Middleman
6
+ module Blog
7
+ module Twitter
8
+ class << self
9
+ attr_accessor :settings
10
+
11
+ def registered(app, options_hash = {}, &block)
12
+ settings = Settings.new
13
+ yield settings if block_given?
14
+ @settings = settings
15
+ end
16
+
17
+ def twitter_settings
18
+ @settings
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ ::Middleman::Extensions.register(:blog_twitter) do
26
+ ::Middleman::Blog::Twitter
27
+ end
@@ -0,0 +1,29 @@
1
+ require 'middleman-core/cli'
2
+ require "middleman/blog/twitter/updater"
3
+
4
+ module Middleman
5
+ module Cli
6
+ class Twitter < Thor
7
+ include Thor::Actions
8
+ include Middleman::Blog::UriTemplates
9
+
10
+ check_unknown_options!
11
+
12
+ namespace :tweet
13
+
14
+ def self.exit_on_failure?
15
+ true
16
+ end
17
+
18
+ desc "tweet", "Tweets about your blog articles."
19
+ def tweet
20
+ shared_instance = ::Middleman::Application.server.inst
21
+ blog_inst = shared_instance.blog
22
+ latest_article = blog_inst.articles[0]
23
+
24
+ updater = ::Middleman::Blog::Twitter::Updater.new(::Middleman::Blog::Twitter.twitter_settings)
25
+ updater.tweet(latest_article)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,17 @@
1
+ module Middleman
2
+ module Blog
3
+ module Twitter
4
+ class Settings
5
+ OPTIONS = [
6
+ :access_token,
7
+ :access_token_secret,
8
+ :consumer_key,
9
+ :consumer_secret,
10
+ :hostname,
11
+ :template_path
12
+ ]
13
+ attr_accessor *OPTIONS
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,34 @@
1
+ require 'twitter'
2
+ require 'erb'
3
+
4
+ module Middleman
5
+ module Blog
6
+ module Twitter
7
+ class Updater
8
+ def initialize(settings)
9
+ @settings = settings
10
+ @client = ::Twitter::REST::Client.new do |config|
11
+ config.consumer_key = settings.consumer_key
12
+ config.consumer_secret = settings.consumer_secret
13
+ config.access_token = settings.access_token
14
+ config.access_token_secret = settings.access_token_secret
15
+ end
16
+ end
17
+
18
+ def tweet(latest_article)
19
+ hostname = @settings.hostname
20
+
21
+ erb = ERB.new(read_template)
22
+ tweet = erb.result(binding)
23
+
24
+ @client.update(tweet)
25
+ end
26
+
27
+ def read_template
28
+ file = File.open(@settings.template_path, 'r')
29
+ file.read
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,7 @@
1
+ module Middleman
2
+ module Blog
3
+ module Twitter
4
+ VERSION = "0.0.2"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'middleman/blog/twitter/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "middleman-blog-twitter"
8
+ spec.version = Middleman::Blog::Twitter::VERSION
9
+ spec.authors = ["Michiaki Mizoguchi"]
10
+ spec.email = ["michiaki.mizoguchi@gmail.com"]
11
+ spec.summary = %q{Tweet about the articles on Middleman blog}
12
+ spec.description = %q{Tweet about the articles on Middleman blog}
13
+ spec.homepage = "https://github.com/mizoguche/middleman-blog-twitter"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "middleman-blog", "~> 3.5"
22
+ spec.add_runtime_dependency "twitter", "~> 5.13"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.5"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "rspec"
27
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Middleman::Blog::Twitter do
4
+ it 'should have a version number' do
5
+ Middleman::Blog::Twitter::VERSION.should_not be_nil
6
+ end
7
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'middleman/blog/twitter'
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: middleman-blog-twitter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Michiaki Mizoguchi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: middleman-blog
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: twitter
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.13'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5.13'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Tweet about the articles on Middleman blog
84
+ email:
85
+ - michiaki.mizoguchi@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - lib/middleman/blog/twitter.rb
98
+ - lib/middleman/blog/twitter/cli.rb
99
+ - lib/middleman/blog/twitter/settings.rb
100
+ - lib/middleman/blog/twitter/updater.rb
101
+ - lib/middleman/blog/twitter/version.rb
102
+ - middleman-blog-twitter.gemspec
103
+ - spec/middleman/blog/twitter_spec.rb
104
+ - spec/spec_helper.rb
105
+ homepage: https://github.com/mizoguche/middleman-blog-twitter
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.4.5
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: Tweet about the articles on Middleman blog
129
+ test_files:
130
+ - spec/middleman/blog/twitter_spec.rb
131
+ - spec/spec_helper.rb
132
+ has_rdoc: