babot 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -2
- data/babot.gemspec +1 -2
- data/bin/babot +4 -10
- data/lib/babot.rb +26 -54
- metadata +1 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d30a84bef581bba5e575f75254eddf1fa28dca37
|
4
|
+
data.tar.gz: c9450ed722b8fcc6add142a6207ff9c95f2048df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3226467734a2827f618b9a074d70f0f3aa23191478755631f82733800b83275832ce3e7da4ddedad54bd1f14c25359236ee4f950bdc04fa3d0aa0ab34eed01d
|
7
|
+
data.tar.gz: 257cb4fffdd5c6eeb5df4d671ebff99b1ac859a39f46b16575a4af5ad52384514a8fa551f80320362557566359d60b6cf7cd464365abf9b7df8a7dd48ccc90c7
|
data/Gemfile.lock
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.3.
|
3
|
+
s.version = '0.3.1'
|
4
4
|
s.date = '2013-09-08'
|
5
5
|
s.summary = "Babot"
|
6
6
|
s.description = "A simple tool to manage Twitter bots"
|
@@ -12,7 +12,6 @@ Gem::Specification.new do |s|
|
|
12
12
|
|
13
13
|
s.require_path = 'lib'
|
14
14
|
s.add_dependency "twitter"
|
15
|
-
s.add_dependency "activesupport"
|
16
15
|
s.add_dependency "whenever"
|
17
16
|
s.add_dependency "boson"
|
18
17
|
|
data/bin/babot
CHANGED
@@ -5,8 +5,7 @@ require 'boson/runner'
|
|
5
5
|
$:.unshift File.expand_path("../../lib", __FILE__)
|
6
6
|
require 'babot'
|
7
7
|
|
8
|
-
FileUtils.mkdir_p
|
9
|
-
Babot.root.join("bots")]
|
8
|
+
FileUtils.mkdir_p Babot.root
|
10
9
|
|
11
10
|
class BabotRunner < Boson::Runner
|
12
11
|
desc "Update bot [name]"
|
@@ -19,14 +18,9 @@ class BabotRunner < Boson::Runner
|
|
19
18
|
Babot.schedule
|
20
19
|
end
|
21
20
|
|
22
|
-
desc "
|
23
|
-
def
|
24
|
-
Babot.
|
25
|
-
end
|
26
|
-
|
27
|
-
desc "Call bot [name] without update"
|
28
|
-
def dry(name)
|
29
|
-
puts Babot.dry(name)
|
21
|
+
desc "Run bot [name]"
|
22
|
+
def run(name)
|
23
|
+
Babot.run name
|
30
24
|
end
|
31
25
|
|
32
26
|
desc "Add bot [name] from [repository]"
|
data/lib/babot.rb
CHANGED
@@ -1,43 +1,29 @@
|
|
1
1
|
require 'fileutils'
|
2
|
-
require 'git'
|
3
2
|
require 'twitter'
|
4
3
|
require 'pathname'
|
5
4
|
require 'yaml'
|
6
|
-
require 'tempfile'
|
7
|
-
require 'whenever'
|
8
|
-
require 'active_support/core_ext/string/inflections'
|
9
|
-
require 'bundler/cli'
|
10
5
|
|
11
6
|
class Babot
|
12
7
|
|
13
8
|
class << self
|
14
9
|
|
15
10
|
def update(name)
|
16
|
-
|
17
|
-
run "cd '#{root.join('bots', name)}' && bundle install"
|
11
|
+
cmd "cd '#{root.join(name)}' && git pull --rebase origin master && bundle install"
|
18
12
|
end
|
19
13
|
|
20
14
|
def schedule
|
21
|
-
|
22
|
-
|
23
|
-
<<-eos
|
24
|
-
every '#{bot.when}' do
|
25
|
-
command 'cd #{root.join('bots', bot.name)} && bundle exec babot call #{bot.name}'
|
26
|
-
end
|
27
|
-
eos
|
28
|
-
end)
|
29
|
-
cron.flush
|
30
|
-
run "whenever -w -f '#{cron.path}'"
|
15
|
+
list.each do |name|
|
16
|
+
cmd "whenever -i #{name} -f #{root.join(name, 'config', 'schedule.rb')}"
|
31
17
|
end
|
32
18
|
end
|
33
19
|
|
34
20
|
def add(name, repository)
|
35
|
-
if repository =~
|
36
|
-
|
21
|
+
if repository =~ /^\//
|
22
|
+
cmd "ln -s '#{repository}' '#{root.join(name)}'"
|
37
23
|
else
|
38
|
-
|
24
|
+
cmd "git clone '#{repository}' '#{root.join(name)}'"
|
39
25
|
end
|
40
|
-
File.open(root.join("config",
|
26
|
+
File.open(root.join(name, "config", "credentials.yml").to_s, 'w') do |config|
|
41
27
|
config.write({ 'consumer_key' => "",
|
42
28
|
'consumer_secret' => "",
|
43
29
|
'oauth_token' => "",
|
@@ -46,66 +32,52 @@ class Babot
|
|
46
32
|
end
|
47
33
|
|
48
34
|
def delete(name)
|
49
|
-
|
35
|
+
cmd "rm -rf '#{root.join(name)}' '#{root.join(name, 'config', 'credentials.yml')}'"
|
50
36
|
end
|
51
37
|
|
52
38
|
def configure(name)
|
53
|
-
|
39
|
+
cmd "#{ENV['EDITOR'] || 'nano'} '#{root.join(name, "config", 'credentials.yml')}'"
|
54
40
|
end
|
55
41
|
|
56
|
-
def
|
57
|
-
|
58
|
-
end
|
42
|
+
def run(name)
|
43
|
+
options = YAML::load_file root.join(name, "config", 'credentials.yml')
|
59
44
|
|
60
|
-
|
61
|
-
|
45
|
+
Twitter.configure do |config|
|
46
|
+
config.consumer_key = options['consumer_key']
|
47
|
+
config.consumer_secret = options['consumer_secret']
|
48
|
+
config.oauth_token = options['oauth_token']
|
49
|
+
config.oauth_token_secret = options['oauth_token_secret']
|
50
|
+
end
|
51
|
+
load Babot.root.join(name, 'babot.run').to_s
|
62
52
|
end
|
63
53
|
|
64
|
-
def
|
65
|
-
|
54
|
+
def list
|
55
|
+
Dir.entries(root).reject { |name| name =~ /^\./ }
|
66
56
|
end
|
67
57
|
|
68
58
|
def dump
|
69
|
-
|
59
|
+
cmd "cd ~ && tar --exclude=.git -cf '#{Dir.pwd}/babot-#{Time.now.to_i}.tar' .babot"
|
70
60
|
end
|
71
61
|
|
72
62
|
def install(dump)
|
73
|
-
|
63
|
+
cmd "cd ~ && rm -rf '.babot' && tar -xf '#{Dir.pwd}/#{dump}'"
|
74
64
|
end
|
75
65
|
|
76
66
|
def push(remote)
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
def instanciate(name)
|
81
|
-
require Babot.root.join("bots", name, 'lib', name)
|
82
|
-
|
83
|
-
options = YAML.load_file(root.join("config", name))
|
84
|
-
Babot::const_get(name.camelize).new(name, options)
|
85
|
-
rescue StandardError, ScriptError => error
|
86
|
-
puts error, error.backtrace
|
67
|
+
cmd "scp -qr '#{root}' '#{remote}:~/.' && ssh '#{remote}' 'babot schedule'"
|
87
68
|
end
|
88
69
|
|
89
70
|
def root
|
90
71
|
Pathname.new(ENV["HOME"]).join ".babot"
|
91
72
|
end
|
92
73
|
|
93
|
-
def
|
74
|
+
def cmd(command)
|
94
75
|
puts command
|
95
76
|
system command
|
96
77
|
end
|
97
|
-
end
|
98
|
-
|
99
|
-
attr_accessor :name
|
100
|
-
|
101
|
-
def initialize(name, options)
|
102
|
-
@name = name
|
103
78
|
|
104
|
-
|
105
|
-
|
106
|
-
config.consumer_secret = options['consumer_secret']
|
107
|
-
config.oauth_token = options['oauth_token']
|
108
|
-
config.oauth_token_secret = options['oauth_token_secret']
|
79
|
+
def run!
|
80
|
+
Twitter.update new.call
|
109
81
|
end
|
110
82
|
end
|
111
83
|
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.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Goya
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: activesupport
|
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'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: whenever
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|