babot 0.1.2 → 0.1.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 +4 -4
- data/Gemfile.lock +7 -9
- data/README.md +1 -1
- data/babot.gemspec +4 -2
- data/bin/babot +48 -0
- data/config/boot.rb +1 -11
- data/lib/babot.rb +93 -1
- metadata +9 -11
- data/Rakefile +0 -5
- data/config/gaston/bots.yml.sample +0 -8
- data/lib/bot.rb +0 -53
- data/lib/tasks/bots.rake +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb8a45434ea899ca641bf88e57fd8234f5c099f8
|
4
|
+
data.tar.gz: fc78fb184612d1662a6874f036a54539bb6ec24c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7017c77bf5c724288ff87bae98191f668a756e0148dcd7b88b5f65556690cbdacbace9ca4297e34e77e89e5e7ca0da1d745d74c34cb7bde2f7ce49d37a596f4
|
7
|
+
data.tar.gz: c220fc560c8faf77d4f744716f37cc8f04abc8826b71f727b84a322c7723b74ff642029d0ded1b1c184fc8e364385b804049b4367ced4d95d5aa389055684612
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
babot (0.1.
|
4
|
+
babot (0.1.3)
|
5
5
|
activesupport
|
6
|
+
boson
|
6
7
|
capistrano
|
7
8
|
capistrano-af83
|
8
|
-
gaston
|
9
9
|
git
|
10
10
|
rake
|
11
11
|
rvm-capistrano
|
@@ -22,7 +22,8 @@ GEM
|
|
22
22
|
thread_safe (~> 0.1)
|
23
23
|
tzinfo (~> 0.3.37)
|
24
24
|
addressable (2.3.5)
|
25
|
-
atomic (1.1.
|
25
|
+
atomic (1.1.12)
|
26
|
+
boson (1.2.4)
|
26
27
|
capistrano (2.15.5)
|
27
28
|
highline
|
28
29
|
net-scp (>= 1.0.0)
|
@@ -50,12 +51,9 @@ GEM
|
|
50
51
|
chronic (0.9.1)
|
51
52
|
faraday (0.8.8)
|
52
53
|
multipart-post (~> 1.2.0)
|
53
|
-
gaston (0.4.1)
|
54
|
-
inflecto
|
55
54
|
git (1.2.5)
|
56
55
|
highline (1.6.19)
|
57
56
|
i18n (0.6.4)
|
58
|
-
inflecto (0.0.2)
|
59
57
|
json (1.8.0)
|
60
58
|
mime-types (1.23)
|
61
59
|
minitest (4.7.5)
|
@@ -69,13 +67,13 @@ GEM
|
|
69
67
|
net-ssh-gateway (1.2.0)
|
70
68
|
net-ssh (>= 2.6.5)
|
71
69
|
rake (10.1.0)
|
72
|
-
rvm-capistrano (1.4.
|
73
|
-
capistrano (>= 2.
|
70
|
+
rvm-capistrano (1.4.3)
|
71
|
+
capistrano (>= 2.15.4)
|
74
72
|
shout-bot (0.0.4)
|
75
73
|
addressable
|
76
74
|
simple_oauth (0.2.0)
|
77
75
|
sushi (0.0.2)
|
78
|
-
thread_safe (0.1.
|
76
|
+
thread_safe (0.1.2)
|
79
77
|
atomic
|
80
78
|
twitter (4.8.1)
|
81
79
|
faraday (~> 0.8, < 0.10)
|
data/README.md
CHANGED
data/babot.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'babot'
|
3
|
-
s.version = '0.1.
|
3
|
+
s.version = '0.1.5'
|
4
4
|
s.date = '2013-09-08'
|
5
5
|
s.summary = "Babot"
|
6
6
|
s.description = "A simple tool to manage Twitter bots"
|
@@ -12,12 +12,14 @@ Gem::Specification.new do |s|
|
|
12
12
|
|
13
13
|
s.require_path = 'lib'
|
14
14
|
s.add_dependency "twitter"
|
15
|
-
s.add_dependency "gaston"
|
16
15
|
s.add_dependency "git"
|
17
16
|
s.add_dependency "activesupport"
|
18
17
|
s.add_dependency "whenever"
|
19
18
|
s.add_dependency "rake"
|
19
|
+
s.add_dependency "boson"
|
20
20
|
s.add_dependency "capistrano"
|
21
21
|
s.add_dependency "capistrano-af83"
|
22
22
|
s.add_dependency "rvm-capistrano"
|
23
|
+
|
24
|
+
s.executables = ['babot']
|
23
25
|
end
|
data/bin/babot
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'boson/runner'
|
4
|
+
require 'pathname'
|
5
|
+
|
6
|
+
$:.unshift File.expand_path("../../lib", __FILE__)
|
7
|
+
require 'babot'
|
8
|
+
|
9
|
+
class BabotRunner < Boson::Runner
|
10
|
+
desc "Update bots"
|
11
|
+
def update
|
12
|
+
Babot.update
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Update crontab"
|
16
|
+
def schedule
|
17
|
+
Babot.schedule
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "Call bot [name]"
|
21
|
+
def call(name)
|
22
|
+
Babot.call name
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Call bot [name] without update"
|
26
|
+
def dry(name)
|
27
|
+
puts Babot.dry(name)
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "Add bot [name] from [repository]"
|
31
|
+
def add(name, repository)
|
32
|
+
Babot.add name, repository
|
33
|
+
Babot.configure name
|
34
|
+
Babot.update
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "Delete bot [name]"
|
38
|
+
def delete(name)
|
39
|
+
Babot.delete name
|
40
|
+
end
|
41
|
+
|
42
|
+
desc "Configure bot [name]"
|
43
|
+
def configure(name)
|
44
|
+
Babot.configure name
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
BabotRunner.start
|
data/config/boot.rb
CHANGED
@@ -1,13 +1,3 @@
|
|
1
|
-
require 'gaston'
|
2
|
-
require 'fileutils'
|
3
|
-
require 'git'
|
4
|
-
require 'twitter'
|
5
|
-
require 'active_support/core_ext/string/inflections'
|
6
1
|
|
7
|
-
Gaston.configure do |gaston|
|
8
|
-
gaston.env = ENV["RACK_ENV"] || "development"
|
9
|
-
gaston.files = Dir["./config/gaston/**/*.yml"]
|
10
|
-
end
|
11
2
|
|
12
|
-
require '
|
13
|
-
require 'bots/twitter_bot'
|
3
|
+
require './lib/babot'
|
data/lib/babot.rb
CHANGED
@@ -1 +1,93 @@
|
|
1
|
-
require '
|
1
|
+
require 'fileutils'
|
2
|
+
require 'git'
|
3
|
+
require 'twitter'
|
4
|
+
require 'pathname'
|
5
|
+
require 'yaml'
|
6
|
+
require 'tempfile'
|
7
|
+
require 'active_support/core_ext/string/inflections'
|
8
|
+
|
9
|
+
class Babot
|
10
|
+
|
11
|
+
class << self
|
12
|
+
|
13
|
+
def update
|
14
|
+
Dir["#{bots_root}/*"].each do |repository|
|
15
|
+
Git.open(repository).pull
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def schedule
|
20
|
+
File.open(root.join("schedule.rb"), "w") do |schedule|
|
21
|
+
@@config['bots'].map do |name, options|
|
22
|
+
bot = instanciate name, options
|
23
|
+
schedule.puts <<-eos
|
24
|
+
every '#{bot.when}' do
|
25
|
+
rake 'bots:call[#{name}]'
|
26
|
+
end
|
27
|
+
eos
|
28
|
+
end
|
29
|
+
Whenever::CommandLine.execute(file: schedule.path, write: true)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def add(name, repository)
|
34
|
+
Git.clone repository, bot_root(name)
|
35
|
+
File.open(root.join("config", name).to_s, 'w') do |config|
|
36
|
+
config.write({ 'consumer_key' => "",
|
37
|
+
'consumer_secret' => "",
|
38
|
+
'oauth_token' => "",
|
39
|
+
'oauth_token_secret' => "" }.to_yaml)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def delete(name)
|
44
|
+
FileUtils.rm_rf bot_root(name)
|
45
|
+
FileUtils.rm_f config_root.join(name)
|
46
|
+
end
|
47
|
+
|
48
|
+
def configure(name)
|
49
|
+
system "#{ENV['EDITOR'] || 'nano'} #{root.join("config", name).to_s}"
|
50
|
+
end
|
51
|
+
|
52
|
+
def call(name)
|
53
|
+
Twitter.update dry(name)
|
54
|
+
end
|
55
|
+
|
56
|
+
def dry(name)
|
57
|
+
instanciate(name, YAML.load_file(config_root.join name)).call
|
58
|
+
end
|
59
|
+
|
60
|
+
def instanciate(name, config)
|
61
|
+
require Babot.bot_root(name).join('lib', name)
|
62
|
+
|
63
|
+
Babot::const_get(name.camelize).new(name)
|
64
|
+
rescue StandardError, ScriptError => error
|
65
|
+
puts error, error.backtrace
|
66
|
+
end
|
67
|
+
|
68
|
+
def root
|
69
|
+
Pathname.new(ENV["HOME"]).join ".babot"
|
70
|
+
end
|
71
|
+
|
72
|
+
def bots_root
|
73
|
+
root.join("bots")
|
74
|
+
end
|
75
|
+
|
76
|
+
def config_root
|
77
|
+
root.join("config")
|
78
|
+
end
|
79
|
+
|
80
|
+
def bot_root(name)
|
81
|
+
bots_root.join name
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def initialize(options)
|
86
|
+
Twitter.configure do |config|
|
87
|
+
config.consumer_key = options['consumer_key']
|
88
|
+
config.consumer_secret = options['consumer_secret']
|
89
|
+
config.oauth_token = options['oauth_token']
|
90
|
+
config.oauth_token_secret = options['oauth_token_secret']
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: babot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Goya
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: git
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '>='
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: activesupport
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - '>='
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: whenever
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - '>='
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - '>='
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: boson
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - '>='
|
@@ -138,7 +138,8 @@ dependencies:
|
|
138
138
|
version: '0'
|
139
139
|
description: A simple tool to manage Twitter bots
|
140
140
|
email: goya.victor@gmail.com
|
141
|
-
executables:
|
141
|
+
executables:
|
142
|
+
- babot
|
142
143
|
extensions: []
|
143
144
|
extra_rdoc_files: []
|
144
145
|
files:
|
@@ -147,15 +148,12 @@ files:
|
|
147
148
|
- Gemfile
|
148
149
|
- Gemfile.lock
|
149
150
|
- README.md
|
150
|
-
- Rakefile
|
151
151
|
- babot.gemspec
|
152
|
+
- bin/babot
|
152
153
|
- config/boot.rb
|
153
154
|
- config/deploy.rb
|
154
155
|
- config/deploy/production.rb
|
155
|
-
- config/gaston/bots.yml.sample
|
156
156
|
- lib/babot.rb
|
157
|
-
- lib/bot.rb
|
158
|
-
- lib/tasks/bots.rake
|
159
157
|
homepage: https://github.com/phorque/babot
|
160
158
|
licenses:
|
161
159
|
- MIT
|
data/Rakefile
DELETED
data/lib/bot.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
module Babot
|
2
|
-
class Bot
|
3
|
-
attr_accessor :name, :repository
|
4
|
-
|
5
|
-
def Bot.instanciate(name, options)
|
6
|
-
require "./#{Babot::Bot.path(name)}"
|
7
|
-
|
8
|
-
Babot::const_get(name.camelize).new(name, options)
|
9
|
-
rescue StandardError, ScriptError => error
|
10
|
-
puts error, error.backtrace
|
11
|
-
end
|
12
|
-
|
13
|
-
def Bot.update(name, options)
|
14
|
-
unless File.exists? root(name)
|
15
|
-
clone name, options[:repository]
|
16
|
-
end
|
17
|
-
Bot.instanciate(name, options).pull!
|
18
|
-
end
|
19
|
-
|
20
|
-
def Bot.clone(name, repository)
|
21
|
-
Git.clone repository, Pathname.new("bots").join(name)
|
22
|
-
end
|
23
|
-
|
24
|
-
def Bot.root(name)
|
25
|
-
Pathname.new("bots").join name
|
26
|
-
end
|
27
|
-
|
28
|
-
def Bot.path(name)
|
29
|
-
Bot.root(name).join "lib", name
|
30
|
-
end
|
31
|
-
|
32
|
-
def initialize(name, options)
|
33
|
-
@name = name
|
34
|
-
end
|
35
|
-
|
36
|
-
def pull!
|
37
|
-
git.pull
|
38
|
-
end
|
39
|
-
|
40
|
-
protected
|
41
|
-
def root
|
42
|
-
Bot.root name
|
43
|
-
end
|
44
|
-
|
45
|
-
def path
|
46
|
-
Bot.path name
|
47
|
-
end
|
48
|
-
|
49
|
-
def git
|
50
|
-
@git ||= Git.open(root)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
data/lib/tasks/bots.rake
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require './config/boot'
|
2
|
-
|
3
|
-
namespace :bots do
|
4
|
-
desc "update bots code and schedule"
|
5
|
-
task update: [:update_code, :schedule]
|
6
|
-
|
7
|
-
desc "update bots code"
|
8
|
-
task :update_code do |t, args|
|
9
|
-
Gaston.bots.map do |name, options|
|
10
|
-
Babot::Bot.update name, options
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
desc "update bots schedule"
|
15
|
-
task :schedule do |t, args|
|
16
|
-
schedule = File.open("bots/schedule.rb", "w")
|
17
|
-
Gaston.bots.map do |name, options|
|
18
|
-
bot = Babot::Bot.instanciate name, options
|
19
|
-
schedule.puts <<-eos
|
20
|
-
every '#{bot.when}' do
|
21
|
-
rake 'bots:call[#{name}]'
|
22
|
-
end
|
23
|
-
eos
|
24
|
-
end
|
25
|
-
schedule.close
|
26
|
-
end
|
27
|
-
|
28
|
-
desc "call the bot"
|
29
|
-
task :call, :name do |t, args|
|
30
|
-
options = Gaston.bots[args[:name]]
|
31
|
-
Twitter.configure do |config|
|
32
|
-
config.consumer_key = options.consumer_key
|
33
|
-
config.consumer_secret = options.consumer_secret
|
34
|
-
config.oauth_token = options.oauth_token
|
35
|
-
config.oauth_token_secret = options.oauth_token_secret
|
36
|
-
end
|
37
|
-
Babot::Bot.instanciate(args[:name], options).call.tap do |tweet|
|
38
|
-
Twitter.update tweet
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|