middleman-blog-twitter 0.0.4 → 0.1.0

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: 7c13fde00ac6c65f959d060ba450bb21afb7b15c
4
- data.tar.gz: a9ee92d122b3e74182f719437ddb3de23f349199
3
+ metadata.gz: e437ed54417bb11aa5f6072dc2df3627ac07720e
4
+ data.tar.gz: ad4878e17d27e850fe001034f95bb67c1d192fda
5
5
  SHA512:
6
- metadata.gz: fec4f045d539910e0fb213fee619e19095f0088c2d427717946869a8a7cbbfecaf0a0c79c7d58fe38dbeed1b48ab672fc85cc3054677b87a8e718791b9ffe15a
7
- data.tar.gz: 9417559963fe0e2b00d2c789b3f4827cc1740a4d378d907c907dad49b452dfecad857902d1d8af1b6b64461f3fda7611007a93a658860cd98d2d6a7d8b6cac61
6
+ metadata.gz: febf73d247cd1e0014b2cfda4a8eb2cf87b75f4b119d502042379f74688799cd2efa9c9076fba2dce6ed7d0e3de8fbecf0301630312028f2ca0264fdd8e1ffc3
7
+ data.tar.gz: 548862886f676458b7a76f3bdd273791f487d89b7f1caefb0e7bd36e12a7f920ed28c1cecd5e31f250cda5be513632fe63a31ce64096c7f55b50b4961eaeaaf8
data/README.md CHANGED
@@ -43,6 +43,7 @@ activate :blog_twitter do |twitter|
43
43
  twitter.access_token_secret = 'YOUR ACCESS TOKEN SECRET'
44
44
  twitter.hostname = 'http://example.com' # your blog hostname
45
45
  twitter.template_path = 'tweet_template.txt.erb'
46
+ twitter.tweet_if_new = true # If true, tweet if date of latest article is within 1 day. If false, tweet anyway. (Default: true)
46
47
  end
47
48
  ```
48
49
 
@@ -1,7 +1,7 @@
1
1
  module Middleman
2
2
  module Blog
3
3
  module Twitter
4
- VERSION = "0.0.4"
4
+ VERSION = "0.1.0"
5
5
  end
6
6
  end
7
7
  end
@@ -2,6 +2,8 @@ require 'middleman/blog/twitter/version'
2
2
  require 'middleman-blog-twitter'
3
3
  require 'middleman-blog-twitter/extension'
4
4
  require 'twitter'
5
+ require 'active_support'
6
+ require 'active_support/core_ext'
5
7
 
6
8
  module Middleman
7
9
  module Blog
@@ -14,8 +16,9 @@ module Middleman
14
16
 
15
17
  blog_extension = @app.extensions[:blog].values.first
16
18
  latest_article = blog_extension.data.articles.select{ |a| a.published? }.first
17
- hostname = settings.hostname
19
+ return unless should_tweet(latest_article)
18
20
 
21
+ hostname = settings.hostname
19
22
  erb = ERB.new(read_template)
20
23
  tweet = erb.result(binding)
21
24
  client.update(tweet)
@@ -44,6 +47,11 @@ module Middleman
44
47
  file = File.open(settings.template_path, 'r')
45
48
  file.read
46
49
  end
50
+
51
+ def should_tweet(latest_article)
52
+ true unless settings.tweet_if_new
53
+ (latest_article.date >= DateTime.now.ago(1.day)) && latest_article.published?
54
+ end
47
55
  end
48
56
  end
49
57
  end
@@ -10,6 +10,7 @@ module Middleman
10
10
  option :access_token_secret, nil, 'Twitter access token secret'
11
11
  option :hostname, nil, 'Your site hostname'
12
12
  option :template_path, 'tweet_template.txt.erb', 'Tweet template path'
13
+ option :tweet_if_new, true, 'Tweet if latest article written in a day'
13
14
 
14
15
  attr_reader :options
15
16
 
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_runtime_dependency('middleman-blog', '~> 4.0.1')
24
24
  spec.add_runtime_dependency('twitter', '~> 5.13')
25
25
  spec.add_runtime_dependency('thor', ['>= 0.17.0', '< 2.0'])
26
+ spec.add_runtime_dependency('activesupport', '~>4.2')
26
27
 
27
28
  spec.add_development_dependency('bundler', '~> 1.5')
28
29
  spec.add_development_dependency('rake')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-blog-twitter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
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-12 00:00:00.000000000 Z
11
+ date: 2016-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: middleman-core
@@ -86,6 +86,20 @@ dependencies:
86
86
  - - "<"
87
87
  - !ruby/object:Gem::Version
88
88
  version: '2.0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: activesupport
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '4.2'
96
+ type: :runtime
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '4.2'
89
103
  - !ruby/object:Gem::Dependency
90
104
  name: bundler
91
105
  requirement: !ruby/object:Gem::Requirement
@@ -228,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
242
  version: '0'
229
243
  requirements: []
230
244
  rubyforge_project:
231
- rubygems_version: 2.6.4
245
+ rubygems_version: 2.5.1
232
246
  signing_key:
233
247
  specification_version: 4
234
248
  summary: Tweet about the articles on Middleman blog