social_cleaner 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +19 -0
- data/Rakefile +1 -0
- data/lib/social_cleaner.rb +0 -5
- data/lib/social_cleaner/twitr.rb +38 -64
- data/lib/social_cleaner/version.rb +3 -0
- data/social_cleaner.gemspec +26 -0
- metadata +80 -67
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 23f47ebec3840e96094d085251c99e697ac3fa2a
|
4
|
+
data.tar.gz: a34f4fa1a2033132f4de85d588c6ca30e0ce31b8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9e77c70a3f9635c792da22e026467eec4d948a9834482b0b475cc1dfbe61eeb859f459bbc6a337fd60fd784dd7f7f2dbca60b5e9d04064fb82a00e7a45bdab32
|
7
|
+
data.tar.gz: cfec480947ab08c9246e1c44e616eaa0b849fe15dea7e59e8e8ead4fd49b5ec7f5f68b93bc736a4c1e53bc64712bd898204b22a712953f9e122159d1f33246bc
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Michaël Rigart
|
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,19 @@
|
|
1
|
+
README (draft)
|
2
|
+
======
|
3
|
+
|
4
|
+
install the gem:
|
5
|
+
|
6
|
+
gem install social_cleaner
|
7
|
+
|
8
|
+
Then make a ruby script:
|
9
|
+
|
10
|
+
#!/usr/bin/ruby
|
11
|
+
#
|
12
|
+
# Get requires out of the way
|
13
|
+
require 'social_cleaner'
|
14
|
+
|
15
|
+
cleaner = SocialCleaner::Twitr.new(consumer_token, consumer_secret, access_token, access_secret, delete_after_days)
|
16
|
+
cleaner.delete_messages
|
17
|
+
|
18
|
+
|
19
|
+
Save the file, make it executeable and run like ./script.rb or put it in a cronjob
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/lib/social_cleaner.rb
CHANGED
data/lib/social_cleaner/twitr.rb
CHANGED
@@ -1,79 +1,53 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class Twitr
|
4
|
-
|
5
|
-
# parameters
|
6
|
-
attr_accessor :consumer_token, :consumer_secret, :access_token, :access_secret, :delete_after_days
|
7
|
-
|
8
|
-
# client object
|
9
|
-
attr_accessor :client
|
1
|
+
require 'twitter'
|
2
|
+
require 'time'
|
10
3
|
|
11
|
-
|
12
|
-
attr_accessor :expire_ids, :expire_before
|
13
|
-
|
14
|
-
|
15
|
-
def initialize(consumer_token, consumer_secret, access_token, access_secret, delete_after_days)
|
16
|
-
self.consumer_token = consumer_token
|
17
|
-
self.consumer_secret = consumer_secret
|
18
|
-
self.access_token = access_token
|
19
|
-
self.access_secret = access_secret
|
20
|
-
self.delete_after_days = delete_after_days
|
21
|
-
self.expire_ids = []
|
22
|
-
end
|
4
|
+
module SocialCleaner
|
23
5
|
|
6
|
+
class Twitr
|
24
7
|
|
25
|
-
|
26
|
-
# Let's get a Twitter Client created
|
27
|
-
oauth = Twitter::OAuth.new(self.consumer_token, self.consumer_secret)
|
28
|
-
oauth.authorize_from_access(self.access_token, self.access_secret)
|
8
|
+
attr_accessor :consumer_token, :consumer_secret, :access_token, :access_secret, :delete_after_days
|
29
9
|
|
30
|
-
|
31
|
-
|
10
|
+
def initialize(consumer_token, consumer_secret, access_token, access_secret, delete_after_days)
|
11
|
+
self.consumer_token = consumer_token
|
12
|
+
self.consumer_secret = consumer_secret
|
13
|
+
self.access_token = access_token
|
14
|
+
self.access_secret = access_secret
|
15
|
+
self.delete_after_days = delete_after_days
|
16
|
+
end
|
32
17
|
|
18
|
+
def delete_messages
|
19
|
+
Twitter.configure do |config|
|
20
|
+
config.consumer_key = consumer_token
|
21
|
+
config.consumer_secret = consumer_secret
|
22
|
+
config.oauth_token = access_token
|
23
|
+
config.oauth_token_secret = access_secret
|
24
|
+
end
|
33
25
|
|
34
|
-
|
35
|
-
|
36
|
-
if Time.parse(status["created_at"]) < self.expire_before
|
37
|
-
$stderr.puts "Queueing tweet delete status ID #{status["id"]} created at #{status["created_at"]} (#{status["text"]})."
|
38
|
-
$stdout.puts "#{status["id"]}\t\t#{status["created_at"]}\t\t#{status["text"]}"
|
39
|
-
self.expire_ids.push(status["id"])
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
26
|
+
expire_before = Time.now - (delete_after_days * 60 * 60 * 24)
|
27
|
+
expire_ids = []
|
43
28
|
|
29
|
+
puts "Expiring all Twitter updates prior to #{expire_before.to_s}."
|
44
30
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
31
|
+
Twitter.user_timeline(count: 200).each do |status|
|
32
|
+
if status[:created_at] < expire_before
|
33
|
+
puts "Queueing delete status ID #{status[:id]} created at #{status[:created_at]} (#{status[:text]})."
|
34
|
+
expire_ids.push(status[:id])
|
50
35
|
end
|
36
|
+
end
|
51
37
|
|
38
|
+
# Now we'll sort the array, this will have the affect of putting the oldest items first in
|
39
|
+
# the list to be deleted.
|
40
|
+
expire_ids.sort!
|
52
41
|
|
53
|
-
|
54
|
-
# Create client object
|
55
|
-
create_client
|
56
|
-
|
57
|
-
# Expire deadline
|
58
|
-
self.expire_before = Time.now - (self.delete_after_days.to_i * 60 * 60 * 24)
|
59
|
-
|
60
|
-
$stderr.puts "Expiring all Twitter updates prior to #{self.expire_before.to_s}."
|
61
|
-
|
62
|
-
# Iterate through timeline
|
63
|
-
# The old tweet id's don't contain a timestamp. maybe implement this for later?
|
64
|
-
add_tweets_to_queue(self.client.user_timeline)
|
65
|
-
add_tweets_to_queue(self.client.retweeted_by_me)
|
42
|
+
puts "Deleting #{expire_ids.length} tweets."
|
66
43
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
# Now let's delete the stuff
|
74
|
-
# Note: the delete method is not rate limited.
|
75
|
-
delete_tweets
|
76
|
-
end
|
44
|
+
# Now let's delete the stuff
|
45
|
+
# Note: the delete method is not rate limited.
|
46
|
+
expire_ids.each do |delete_status|
|
47
|
+
puts "Deleting #{delete_status}..."
|
48
|
+
Twitter.status_destroy(delete_status)
|
49
|
+
end
|
77
50
|
end
|
51
|
+
end
|
78
52
|
end
|
79
53
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'social_cleaner/version'
|
5
|
+
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'social_cleaner'
|
9
|
+
spec.version = SocialCleaner::VERSION
|
10
|
+
spec.authors = %w(Michaël Rigart)
|
11
|
+
spec.email = %w(michael@netronix.be)
|
12
|
+
spec.summary = 'Clean social media messages'
|
13
|
+
spec.description = 'Clean all messages from social media'
|
14
|
+
spec.homepage = 'http://www.michaelrigart.be/'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($/)
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |file| File.basename(file) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = %w(lib)
|
21
|
+
|
22
|
+
spec.add_dependency 'twitter', '>= 4.8'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
25
|
+
spec.add_development_dependency 'rake'
|
26
|
+
end
|
metadata
CHANGED
@@ -1,84 +1,97 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: social_cleaner
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease: false
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 4
|
10
|
-
version: 0.0.4
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
13
|
-
-
|
6
|
+
authors:
|
7
|
+
- Michaël
|
8
|
+
- Rigart
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-07-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: twitter
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 35
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
- 9
|
33
|
-
- 12
|
34
|
-
version: 0.9.12
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '4.8'
|
35
21
|
type: :runtime
|
36
|
-
|
37
|
-
|
38
|
-
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '4.8'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.3'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.3'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
description: Clean all messages from social media
|
57
|
+
email:
|
58
|
+
- michael@netronix.be
|
39
59
|
executables: []
|
40
|
-
|
41
60
|
extensions: []
|
42
|
-
|
43
|
-
|
44
|
-
-
|
45
|
-
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
46
66
|
- README
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
47
69
|
- lib/social_cleaner.rb
|
48
70
|
- lib/social_cleaner/twitr.rb
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
71
|
+
- lib/social_cleaner/version.rb
|
72
|
+
- social_cleaner.gemspec
|
73
|
+
homepage: http://www.michaelrigart.be/
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
53
77
|
post_install_message:
|
54
|
-
rdoc_options:
|
55
|
-
|
56
|
-
require_paths:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
57
80
|
- lib
|
58
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
none: false
|
69
|
-
requirements:
|
70
|
-
- - ">="
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
hash: 3
|
73
|
-
segments:
|
74
|
-
- 0
|
75
|
-
version: "0"
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
76
91
|
requirements: []
|
77
|
-
|
78
|
-
|
79
|
-
rubygems_version: 1.3.7
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.0.2
|
80
94
|
signing_key:
|
81
|
-
specification_version:
|
82
|
-
summary:
|
95
|
+
specification_version: 4
|
96
|
+
summary: Clean social media messages
|
83
97
|
test_files: []
|
84
|
-
|