babot 0.2.1 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b6b19753e0a50827eb7d2423bd654a7bcecceae
4
- data.tar.gz: 5dc21ac5617ba8b07f4e1bf413d21f995b6702be
3
+ metadata.gz: 0355f66292997601578a1c85085cdfdbe71b2bd8
4
+ data.tar.gz: 062379bb8322b364e28e88ec7598e7559d95be41
5
5
  SHA512:
6
- metadata.gz: 81c1c0a8d7fd364e5a8e0a1ab1e6c5a53f2754f4aebe69f8997d6b3c65187dfe6ee25a0daad046d30458ad457b2a57bfdf85649fc0447e2134d9d6ff58dfff16
7
- data.tar.gz: 3be4b33f9fdf2a47e06f6749b68bc8ec39c0fb2499282e719b9516c26da8913f2eb12e7df322f35f43572231664a1ee26d4f17e43974fb8119fddbe0143d2d46
6
+ metadata.gz: dc51c5e669487b96c0bd2277138811f44cc172860fdd003e2a85d95a5d4872a027dfb4102bb205526206e6ea21c9400029fb58cc574f62a913b8af05ee3cc991
7
+ data.tar.gz: 550574a9c78c429755ffba815d449c36fd0754894cec238d5d02084d0fba3100efd62abffe96e18d1276aa24b405e89fabe05b4c29ea5ea6652247edc02e972e
data/Gemfile.lock CHANGED
@@ -1,14 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- babot (0.2.1)
4
+ babot (0.3.0)
5
5
  activesupport
6
6
  boson
7
- capistrano
8
- capistrano-af83
9
- git
10
- rake
11
- rvm-capistrano
12
7
  twitter
13
8
  whenever
14
9
 
@@ -21,58 +16,16 @@ GEM
21
16
  multi_json (~> 1.3)
22
17
  thread_safe (~> 0.1)
23
18
  tzinfo (~> 0.3.37)
24
- addressable (2.3.5)
25
19
  atomic (1.1.12)
26
20
  boson (1.2.4)
27
- capistrano (2.15.5)
28
- highline
29
- net-scp (>= 1.0.0)
30
- net-sftp (>= 2.0.0)
31
- net-ssh (>= 2.0.14)
32
- net-ssh-gateway (>= 1.1.0)
33
- capistrano-af83 (0.4.2)
34
- capistrano (~> 2.14)
35
- capistrano-custom-maintenance (~> 0.1.0)
36
- capistrano-notification (~> 0.1)
37
- shout-bot (= 0.0.4)
38
- sushi (~> 0.0.2)
39
- capistrano-custom-maintenance (0.1.0)
40
- capistrano
41
- capistrano-file-resources (>= 0.1.1)
42
- json
43
- mime-types
44
- capistrano-file-resources (0.1.1)
45
- capistrano
46
- mime-types
47
- capistrano-notification (0.1.1)
48
- capistrano
49
- shout-bot
50
- validatable
51
21
  chronic (0.9.1)
52
22
  faraday (0.8.8)
53
23
  multipart-post (~> 1.2.0)
54
- git (1.2.5)
55
- highline (1.6.19)
56
24
  i18n (0.6.4)
57
- json (1.8.0)
58
- mime-types (1.23)
59
25
  minitest (4.7.5)
60
26
  multi_json (1.7.8)
61
27
  multipart-post (1.2.0)
62
- net-scp (1.1.2)
63
- net-ssh (>= 2.6.5)
64
- net-sftp (2.1.2)
65
- net-ssh (>= 2.6.5)
66
- net-ssh (2.6.8)
67
- net-ssh-gateway (1.2.0)
68
- net-ssh (>= 2.6.5)
69
- rake (10.1.0)
70
- rvm-capistrano (1.4.3)
71
- capistrano (>= 2.15.4)
72
- shout-bot (0.0.4)
73
- addressable
74
28
  simple_oauth (0.2.0)
75
- sushi (0.0.2)
76
29
  thread_safe (0.1.2)
77
30
  atomic
78
31
  twitter (4.8.1)
@@ -80,7 +33,6 @@ GEM
80
33
  multi_json (~> 1.0)
81
34
  simple_oauth (~> 0.2)
82
35
  tzinfo (0.3.37)
83
- validatable (1.6.7)
84
36
  whenever (0.8.4)
85
37
  activesupport (>= 2.3.4)
86
38
  chronic (>= 0.6.3)
data/README.md CHANGED
@@ -1,17 +1,26 @@
1
1
  Babot helps you manage your Twitter bots.
2
2
 
3
- The file `~/.babot/config` contains, for each bot, the git
4
- repository and the API keys.
3
+ ```
4
+ gem install babot
5
+ ```
5
6
 
6
- A bot is a git repository containing :
7
+ ```
8
+ Usage: babot [OPTIONS] COMMAND [ARGS]
7
9
 
8
- - a Gemfile
9
- - a lib directory with a [name_of_the_bot].rb file
10
+ Available commands:
11
+ add Add bot [name] from [repository]
12
+ call Call bot [name]
13
+ configure Configure bot [name]
14
+ delete Delete bot [name]
15
+ dry Call bot [name] without update
16
+ dump Dump bots and configuration in tar file
17
+ help Displays help for a command
18
+ install Install from tar file [path]
19
+ list List bots
20
+ push Push to remote server [remote]
21
+ schedule Update crontab
22
+ update Update bot [name]
10
23
 
11
- Look at https://github.com/phorque/twitter-test-bot for a simple bot
12
- example.
13
-
14
- A bot inherit from the Babot::Bot class and must implement a `when`
15
- method returning a 'cron-style' time. When the time is reached the
16
- `call` method will be called and its result will be posted to
17
- Twitter.
24
+ Options:
25
+ -h, --help Displays this help message
26
+ ```
data/babot.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'babot'
3
- s.version = '0.2.1'
3
+ s.version = '0.3.0'
4
4
  s.date = '2013-09-08'
5
5
  s.summary = "Babot"
6
6
  s.description = "A simple tool to manage Twitter bots"
@@ -12,14 +12,9 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.require_path = 'lib'
14
14
  s.add_dependency "twitter"
15
- s.add_dependency "git"
16
15
  s.add_dependency "activesupport"
17
16
  s.add_dependency "whenever"
18
- s.add_dependency "rake"
19
17
  s.add_dependency "boson"
20
- s.add_dependency "capistrano"
21
- s.add_dependency "capistrano-af83"
22
- s.add_dependency "rvm-capistrano"
23
18
 
24
19
  s.executables = ['babot']
25
20
  end
data/bin/babot CHANGED
@@ -49,6 +49,21 @@ class BabotRunner < Boson::Runner
49
49
  def list
50
50
  puts Babot.list
51
51
  end
52
+
53
+ desc "Dump bots and configuration in tar file"
54
+ def dump
55
+ Babot.dump
56
+ end
57
+
58
+ desc "Install from tar file [path]"
59
+ def install(path)
60
+ Babot.install path
61
+ end
62
+
63
+ desc "Push to remote server [remote]"
64
+ def push(remote)
65
+ Babot.push remote
66
+ end
52
67
  end
53
68
 
54
69
  BabotRunner.start
data/lib/babot.rb CHANGED
@@ -13,31 +13,29 @@ class Babot
13
13
  class << self
14
14
 
15
15
  def update(name)
16
- git = Git.open(root.join("bots", name), :log => Logger.new(STDOUT))
17
- git.fetch "origin"
18
- git.merge "origin", "master"
19
- system "cd #{root.join('bots', name)} && bundle install"
16
+ run "cd '#{root.join('bots', name)}' && git pull --rebase origin master"
17
+ run "cd '#{root.join('bots', name)}' && bundle install"
20
18
  end
21
19
 
22
20
  def schedule
23
- cron = File.open root.join("schedule.rb"), "w"
24
- list.map { |name| instanciate(name) }.each do |bot|
25
- cron.puts <<-eos
21
+ Tempfile.open('schedule') do |cron|
22
+ cron.puts(list.map { |name| instanciate(name) }.map do |bot|
23
+ <<-eos
26
24
  every '#{bot.when}' do
27
25
  command 'cd #{root.join('bots', bot.name)} && bundle exec babot call #{bot.name}'
28
26
  end
29
27
  eos
28
+ end)
29
+ cron.flush
30
+ run "whenever -w -f '#{cron.path}'"
30
31
  end
31
- cron.close
32
-
33
- Whenever::CommandLine.execute(file: cron.path, write: true)
34
32
  end
35
33
 
36
34
  def add(name, repository)
37
35
  if repository =~ /\//
38
- FileUtils.ln_s repository, root.join("bots", name)
36
+ run "ln -s '#{repository}' '#{root.join("bots", name)}'"
39
37
  else
40
- Git.clone repository, root.join("bots", name)
38
+ run "git clone '#{repository}' '#{root.join("bots", name)}'"
41
39
  end
42
40
  File.open(root.join("config", name).to_s, 'w') do |config|
43
41
  config.write({ 'consumer_key' => "",
@@ -48,12 +46,11 @@ class Babot
48
46
  end
49
47
 
50
48
  def delete(name)
51
- FileUtils.rm_rf root.join("bots", name)
52
- FileUtils.rm_f root.join("config", name)
49
+ run "rm -rf #{root.join('bots', name)} #{root.join('config', name)}"
53
50
  end
54
51
 
55
52
  def configure(name)
56
- system "#{ENV['EDITOR'] || 'nano'} #{root.join("config", name).to_s}"
53
+ run "#{ENV['EDITOR'] || 'nano'} #{root.join("config", name).to_s}"
57
54
  end
58
55
 
59
56
  def call(name)
@@ -68,6 +65,18 @@ class Babot
68
65
  instanciate(name).call
69
66
  end
70
67
 
68
+ def dump
69
+ run "cd ~ && tar --exclude=.git -cf '#{Dir.pwd}/babot-#{Time.now.to_i}.tar' .babot"
70
+ end
71
+
72
+ def install(dump)
73
+ run "cd ~ && rm -rf '.babot' && tar -xf '#{Dir.pwd}/#{dump}'"
74
+ end
75
+
76
+ def push(remote)
77
+ run "scp -qr '#{root}' '#{remote}:~/.' && ssh '#{remote}' 'babot schedule'"
78
+ end
79
+
71
80
  def instanciate(name)
72
81
  require Babot.root.join("bots", name, 'lib', name)
73
82
 
@@ -80,6 +89,11 @@ class Babot
80
89
  def root
81
90
  Pathname.new(ENV["HOME"]).join ".babot"
82
91
  end
92
+
93
+ def run(command)
94
+ puts command
95
+ system command
96
+ end
83
97
  end
84
98
 
85
99
  attr_accessor :name
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.2.1
4
+ version: 0.3.0
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: git
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: activesupport
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,20 +52,6 @@ dependencies:
66
52
  - - '>='
67
53
  - !ruby/object:Gem::Version
68
54
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: rake
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - '>='
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - '>='
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
55
  - !ruby/object:Gem::Dependency
84
56
  name: boson
85
57
  requirement: !ruby/object:Gem::Requirement
@@ -94,48 +66,6 @@ dependencies:
94
66
  - - '>='
95
67
  - !ruby/object:Gem::Version
96
68
  version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: capistrano
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - '>='
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - '>='
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: capistrano-af83
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - '>='
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :runtime
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - '>='
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: rvm-capistrano
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - '>='
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :runtime
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - '>='
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
69
  description: A simple tool to manage Twitter bots
140
70
  email: goya.victor@gmail.com
141
71
  executables:
@@ -144,15 +74,11 @@ extensions: []
144
74
  extra_rdoc_files: []
145
75
  files:
146
76
  - .gitignore
147
- - Capfile
148
77
  - Gemfile
149
78
  - Gemfile.lock
150
79
  - README.md
151
80
  - babot.gemspec
152
81
  - bin/babot
153
- - config/boot.rb
154
- - config/deploy.rb
155
- - config/deploy/production.rb
156
82
  - lib/babot.rb
157
83
  homepage: https://github.com/phorque/babot
158
84
  licenses:
data/Capfile DELETED
@@ -1,4 +0,0 @@
1
- load 'deploy'
2
- # Uncomment if you are using Rails' asset pipeline
3
- # load 'deploy/assets'
4
- load 'config/deploy' # remove this line to skip loading any of the default tasks
data/config/boot.rb DELETED
@@ -1,3 +0,0 @@
1
-
2
-
3
- require './lib/babot'
data/config/deploy.rb DELETED
@@ -1,19 +0,0 @@
1
- set :application, "babot"
2
- set :user, "babot"
3
- set :appname, user
4
-
5
- require "rvm/capistrano"
6
-
7
- set :rvm_ruby_string, "2.0.0"
8
-
9
- require "capistrano/af83"
10
-
11
- set :repository, "git@github.com:phorque/babot.git"
12
- set :scm, :git
13
-
14
- after 'deploy:restart' do
15
- config ||= "config/gaston/bots.yml"
16
- upload config, "#{current_path}/config/gaston/bots.yml"
17
-
18
- run "cd #{current_path} && bundle exec rake bots:update && bundle exec whenever -f bots/schedule.rb -w"
19
- end
@@ -1,5 +0,0 @@
1
- set :branch, :master
2
- set :application, "babot.server"
3
- set :deploy_to, "/home/babot"
4
- set :default_environment, { 'RAILS_ENV' => 'production' }
5
- server "#{user}@#{application}", :app, :primary => true