middleman-blog-twitter 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: 528c7faf540636e1fce4ab158b84f5b9d4362199
4
- data.tar.gz: 1d429602817704ca6f81142998daf6a1779101f0
3
+ metadata.gz: 7c13fde00ac6c65f959d060ba450bb21afb7b15c
4
+ data.tar.gz: a9ee92d122b3e74182f719437ddb3de23f349199
5
5
  SHA512:
6
- metadata.gz: 5826b8913a10b3a86efe4af9debffef184647336caf72ac9b0e8fe3b00fe3b0b94dd7b0e715b332c991df6598771f9387a5f623bcbd487104f62f1b4fe1e54f7
7
- data.tar.gz: 1df4977f880099bbad87daf2d46e20d7fbdaf9a834dcc345ce14172a06771348e35395468d09b638528ed89847560fd71cd047014b1d55483d836056098cd68a
6
+ metadata.gz: fec4f045d539910e0fb213fee619e19095f0088c2d427717946869a8a7cbbfecaf0a0c79c7d58fe38dbeed1b48ab672fc85cc3054677b87a8e718791b9ffe15a
7
+ data.tar.gz: 9417559963fe0e2b00d2c789b3f4827cc1740a4d378d907c907dad49b452dfecad857902d1d8af1b6b64461f3fda7611007a93a658860cd98d2d6a7d8b6cac61
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in middleman-blog-twitter.gemspec
4
4
  gemspec
5
+
6
+ gem 'middleman-blog'
data/Rakefile CHANGED
@@ -1,6 +1,14 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
3
 
4
- RSpec::Core::RakeTask.new(:spec)
4
+ require 'cucumber/rake/task'
5
5
 
6
- task :default => :spec
6
+ Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
7
+ t.cucumber_opts = '--color --tags ~@wip --strict'
8
+ end
9
+
10
+ require 'rake/clean'
11
+
12
+ task test: ['cucumber']
13
+
14
+ task default: :test
data/config.rb ADDED
@@ -0,0 +1,3 @@
1
+ # For test run
2
+ activate :blog
3
+ activate :blog_twitter
@@ -0,0 +1,4 @@
1
+ PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
2
+ require 'middleman-core'
3
+ require 'middleman-core/step_definitions'
4
+ require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-blog-twitter')
@@ -0,0 +1,8 @@
1
+ require 'middleman-core'
2
+ require 'middleman-blog-twitter/commands'
3
+ require 'middleman/blog/twitter'
4
+
5
+ Middleman::Extensions.register :blog_twitter do
6
+ require "middleman-blog-twitter/extension"
7
+ ::Middleman::Blog::TwitterExtension
8
+ end
@@ -0,0 +1,35 @@
1
+ require 'middleman-cli'
2
+ require 'middleman-blog/uri_templates'
3
+
4
+ module Middleman
5
+ module Cli
6
+ class Twitter < ::Thor::Group
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
+ def tweet
19
+ env = options[:environment].to_s.to_sym
20
+ verbose = options[:verbose] ? 0 : 1
21
+ instrument = options[:instrument]
22
+
23
+ ::Middleman::Blog::Twitter.app = ::Middleman::Application.new do
24
+ config[:mode] = :build
25
+ config[:environment] = env
26
+ ::Middleman::Logger.singleton(verbose, instrument)
27
+ end
28
+
29
+ ::Middleman::Blog::Twitter.tweet
30
+ end
31
+ end
32
+
33
+ Base.register(Middleman::Cli::Twitter, 'tweet', 'tweet [options]', 'Tweet latest article')
34
+ end
35
+ end
@@ -0,0 +1,23 @@
1
+ require 'middleman-core'
2
+ require 'middleman/blog/twitter'
3
+
4
+ module Middleman
5
+ module Blog
6
+ class TwitterExtension < ::Middleman::Extension
7
+ option :consumer_key, nil, 'Twitter consumer key'
8
+ option :consumer_secret, nil, 'Twitter consumer secret'
9
+ option :access_token, nil, 'Twitter access token'
10
+ option :access_token_secret, nil, 'Twitter access token secret'
11
+ option :hostname, nil, 'Your site hostname'
12
+ option :template_path, 'tweet_template.txt.erb', 'Tweet template path'
13
+
14
+ attr_reader :options
15
+
16
+ def initialize(app, options_hash={}, &block)
17
+ super
18
+
19
+ @options = options
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,27 +1,50 @@
1
- require "middleman/blog/twitter/version"
2
- require "middleman/blog/twitter/cli"
3
- require "middleman/blog/twitter/settings"
1
+ require 'middleman/blog/twitter/version'
2
+ require 'middleman-blog-twitter'
3
+ require 'middleman-blog-twitter/extension'
4
+ require 'twitter'
4
5
 
5
6
  module Middleman
6
7
  module Blog
7
8
  module Twitter
8
9
  class << self
9
- attr_accessor :settings
10
+ attr_reader :app
10
11
 
11
- def registered(app, options_hash = {}, &block)
12
- settings = Settings.new
13
- yield settings if block_given?
14
- @settings = settings
12
+ def tweet
13
+ @app ||= ::Middleman::Application.new
14
+
15
+ blog_extension = @app.extensions[:blog].values.first
16
+ latest_article = blog_extension.data.articles.select{ |a| a.published? }.first
17
+ hostname = settings.hostname
18
+
19
+ erb = ERB.new(read_template)
20
+ tweet = erb.result(binding)
21
+ client.update(tweet)
22
+ end
23
+
24
+ def app=(app)
25
+ @app = app
15
26
  end
16
27
 
17
- def twitter_settings
18
- @settings
28
+ private
29
+
30
+ def settings
31
+ @app.extensions[:blog_twitter].options
32
+ end
33
+
34
+ def client
35
+ ::Twitter::REST::Client.new do |config|
36
+ config.consumer_key = settings.consumer_key
37
+ config.consumer_secret = settings.consumer_secret
38
+ config.access_token = settings.access_token
39
+ config.access_token_secret = settings.access_token_secret
40
+ end
41
+ end
42
+
43
+ def read_template
44
+ file = File.open(settings.template_path, 'r')
45
+ file.read
19
46
  end
20
47
  end
21
48
  end
22
49
  end
23
50
  end
24
-
25
- ::Middleman::Extensions.register(:blog_twitter) do
26
- ::Middleman::Blog::Twitter
27
- end
@@ -1,7 +1,7 @@
1
1
  module Middleman
2
2
  module Blog
3
3
  module Twitter
4
- VERSION = "0.0.3"
4
+ VERSION = "0.0.4"
5
5
  end
6
6
  end
7
7
  end
@@ -13,16 +13,22 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = 'https://github.com/mizoguche/middleman-blog-twitter'
14
14
  spec.license = 'MIT'
15
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)/})
16
+ spec.files = `git ls-files`.split("\n")
17
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency 'middleman-blog', '~> 4.0.1'
22
- spec.add_dependency 'twitter', '~> 5.13'
23
- spec.add_dependency 'thor', ['>= 0.17.0', '< 2.0']
21
+ spec.add_runtime_dependency('middleman-core', ['>= 4.1.9'])
22
+ spec.add_runtime_dependency('middleman-cli')
23
+ spec.add_runtime_dependency('middleman-blog', '~> 4.0.1')
24
+ spec.add_runtime_dependency('twitter', '~> 5.13')
25
+ spec.add_runtime_dependency('thor', ['>= 0.17.0', '< 2.0'])
24
26
 
25
- spec.add_development_dependency 'bundler', '~> 1.5'
26
- spec.add_development_dependency 'rake'
27
- spec.add_development_dependency 'rspec'
27
+ spec.add_development_dependency('bundler', '~> 1.5')
28
+ spec.add_development_dependency('rake')
29
+ spec.add_development_dependency('rspec')
30
+ spec.add_development_dependency('cucumber')
31
+ spec.add_development_dependency('aruba')
32
+ spec.add_development_dependency('rdoc')
33
+ spec.add_development_dependency('yard')
28
34
  end
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-blog-twitter
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
  - Michiaki Mizoguchi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-10 00:00:00.000000000 Z
11
+ date: 2016-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: middleman-core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 4.1.9
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 4.1.9
27
+ - !ruby/object:Gem::Dependency
28
+ name: middleman-cli
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: middleman-blog
15
43
  requirement: !ruby/object:Gem::Requirement
@@ -100,6 +128,62 @@ dependencies:
100
128
  - - ">="
101
129
  - !ruby/object:Gem::Version
102
130
  version: '0'
131
+ - !ruby/object:Gem::Dependency
132
+ name: cucumber
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ - !ruby/object:Gem::Dependency
146
+ name: aruba
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ - !ruby/object:Gem::Dependency
160
+ name: rdoc
161
+ requirement: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ - !ruby/object:Gem::Dependency
174
+ name: yard
175
+ requirement: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ type: :development
181
+ prerelease: false
182
+ version_requirements: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
103
187
  description: Tweet about the articles on Middleman blog
104
188
  email:
105
189
  - michiaki.mizoguchi@gmail.com
@@ -114,10 +198,12 @@ files:
114
198
  - LICENSE.txt
115
199
  - README.md
116
200
  - Rakefile
201
+ - config.rb
202
+ - features/support/env.rb
203
+ - lib/middleman-blog-twitter.rb
204
+ - lib/middleman-blog-twitter/commands.rb
205
+ - lib/middleman-blog-twitter/extension.rb
117
206
  - lib/middleman/blog/twitter.rb
118
- - lib/middleman/blog/twitter/cli.rb
119
- - lib/middleman/blog/twitter/settings.rb
120
- - lib/middleman/blog/twitter/updater.rb
121
207
  - lib/middleman/blog/twitter/version.rb
122
208
  - middleman-blog-twitter.gemspec
123
209
  - spec/middleman/blog/twitter_spec.rb
@@ -142,10 +228,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
228
  version: '0'
143
229
  requirements: []
144
230
  rubyforge_project:
145
- rubygems_version: 2.4.5
231
+ rubygems_version: 2.6.4
146
232
  signing_key:
147
233
  specification_version: 4
148
234
  summary: Tweet about the articles on Middleman blog
149
235
  test_files:
236
+ - features/support/env.rb
150
237
  - spec/middleman/blog/twitter_spec.rb
151
238
  - spec/spec_helper.rb
@@ -1,30 +0,0 @@
1
- require 'middleman/blog/twitter/updater'
2
- require 'middleman-blog/uri_templates'
3
- require 'thor'
4
-
5
- module Middleman
6
- module Cli
7
- class Twitter < ::Thor
8
- include Thor::Actions
9
- include Middleman::Blog::UriTemplates
10
-
11
- check_unknown_options!
12
-
13
- namespace :tweet
14
-
15
- def self.exit_on_failure?
16
- true
17
- end
18
-
19
- desc "tweet", "Tweets about your blog articles."
20
- def tweet
21
- shared_instance = ::Middleman::Application.server.inst
22
- blog_inst = shared_instance.blog
23
- latest_article = blog_inst.articles[0]
24
-
25
- updater = ::Middleman::Blog::Twitter::Updater.new(::Middleman::Blog::Twitter.twitter_settings)
26
- updater.tweet(latest_article)
27
- end
28
- end
29
- end
30
- end
@@ -1,17 +0,0 @@
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
@@ -1,34 +0,0 @@
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