twitter2vk_reposter 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/ChangeLog +4 -0
  2. data/bin/twitter2vk_reposter +17 -12
  3. metadata +17 -4
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.3.4 (Харчо)
2
+ * Increase max length of VK status for new API.
3
+ * Don’t raise error, when Twitter is over capacity.
4
+
1
5
  == 0.3.4 (Борщ)
2
6
  * Fix for statuses with <, > and &.
3
7
 
@@ -4,7 +4,6 @@
4
4
  $KCODE = 'u'
5
5
 
6
6
  require 'rubygems'
7
- require 'json'
8
7
  require 'active_support'
9
8
  require 'rvk'
10
9
  require 'twitter_oauth'
@@ -62,8 +61,10 @@ def trim_text(text, length)
62
61
  end
63
62
  end
64
63
 
64
+ VK_MAX_STATUS = 255
65
+
65
66
  def format_status(status, config)
66
- last = trim_text(format_text(status, config['last']), 159)
67
+ last = trim_text(format_text(status, config['last']), VK_MAX_STATUS)
67
68
 
68
69
  if status.has_key?('retweeted_status')
69
70
  text = format_text(status['retweeted_status'], config['retweet'])
@@ -77,7 +78,7 @@ def format_status(status, config)
77
78
  text.gsub!(replace[0], replace[1])
78
79
  end
79
80
 
80
- trim_text(text, 160 - last.length).to_s + last.to_s
81
+ trim_text(text, VK_MAX_STATUS - last.length).to_s + last.to_s
81
82
  end
82
83
 
83
84
  default = {
@@ -99,16 +100,20 @@ last_message = if File.exists? config['last_message']
99
100
  end
100
101
  last_message = nil unless last_message =~ /^\d/
101
102
 
102
- twitter = TwitterOAuth::Client.new(:consumer_key => 'lGdk5MXwNqFyQ6glsog0g',
103
- :consumer_secret => 'jHfpLGY11clNSh9M0Fqnjl7fzqeHwrKSWTBo4i8TUcE',
104
- :token => config['twitter_token'], :secret => config['twitter_secret'])
105
- if last_message
106
- query = { :since_id => last_message }
107
- else
108
- query = { :count => 1 }
103
+ begin
104
+ twitter = TwitterOAuth::Client.new(:consumer_key => 'lGdk5MXwNqFyQ6glsog0g',
105
+ :consumer_secret => 'jHfpLGY11clNSh9M0Fqnjl7fzqeHwrKSWTBo4i8TUcE',
106
+ :token => config['twitter_token'], :secret => config['twitter_secret'])
107
+ if last_message
108
+ query = { :since_id => last_message }
109
+ else
110
+ query = { :count => 1 }
111
+ end
112
+ statuses = twitter.user_timeline(query) + twitter.retweeted_by_me(query)
113
+ statuses.sort! { |a, b| a['id'] <=> b['id'] }
114
+ rescue JSON::ParserError => e
115
+ exit 1
109
116
  end
110
- statuses = twitter.user_timeline(query) + twitter.retweeted_by_me(query)
111
- statuses.sort! { |a, b| a['id'] <=> b['id'] }
112
117
 
113
118
  statuses = [statuses.last] unless last_message
114
119
 
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitter2vk_reposter
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 25
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 3
8
- - 4
9
- version: 0.3.4
9
+ - 5
10
+ version: 0.3.5
10
11
  platform: ruby
11
12
  authors:
12
13
  - Andrey "A.I." Sitnik
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-05-09 00:00:00 +04:00
18
+ date: 2010-09-02 00:00:00 +04:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: activesupport
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 3
27
30
  segments:
28
31
  - 0
29
32
  version: "0"
@@ -33,9 +36,11 @@ dependencies:
33
36
  name: json
34
37
  prerelease: false
35
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
36
40
  requirements:
37
41
  - - ">="
38
42
  - !ruby/object:Gem::Version
43
+ hash: 3
39
44
  segments:
40
45
  - 0
41
46
  version: "0"
@@ -45,9 +50,11 @@ dependencies:
45
50
  name: rvk
46
51
  prerelease: false
47
52
  requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
48
54
  requirements:
49
55
  - - ">="
50
56
  - !ruby/object:Gem::Version
57
+ hash: 3
51
58
  segments:
52
59
  - 0
53
60
  version: "0"
@@ -57,9 +64,11 @@ dependencies:
57
64
  name: twitter_oauth
58
65
  prerelease: false
59
66
  requirement: &id004 !ruby/object:Gem::Requirement
67
+ none: false
60
68
  requirements:
61
69
  - - ">="
62
70
  - !ruby/object:Gem::Version
71
+ hash: 3
63
72
  segments:
64
73
  - 0
65
74
  version: "0"
@@ -88,23 +97,27 @@ rdoc_options: []
88
97
  require_paths:
89
98
  - ""
90
99
  required_ruby_version: !ruby/object:Gem::Requirement
100
+ none: false
91
101
  requirements:
92
102
  - - ">="
93
103
  - !ruby/object:Gem::Version
104
+ hash: 3
94
105
  segments:
95
106
  - 0
96
107
  version: "0"
97
108
  required_rubygems_version: !ruby/object:Gem::Requirement
109
+ none: false
98
110
  requirements:
99
111
  - - ">="
100
112
  - !ruby/object:Gem::Version
113
+ hash: 3
101
114
  segments:
102
115
  - 0
103
116
  version: "0"
104
117
  requirements: []
105
118
 
106
119
  rubyforge_project: twitter2vk
107
- rubygems_version: 1.3.6
120
+ rubygems_version: 1.3.7
108
121
  signing_key:
109
122
  specification_version: 3
110
123
  summary: "Atomatic repost Twitter statuses to VK (\xD0\x92 \xD0\x9A\xD0\xBE\xD0\xBD\xD1\x82\xD0\xB0\xD0\xBA\xD1\x82\xD0\xB5)."