babot 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3226bcc0c6179090a2d08c01eb73527266ff6889
4
+ data.tar.gz: 15d7aca71a1a15c60ccf1987732123facb85b5ed
5
+ SHA512:
6
+ metadata.gz: e8e68a57d90d88667c3e62edfb1da9560511557e4d41a921a0a9107ea8dd4266b39f62eea161275284cf6240662804e07c83f7470d683926aa0c676afada48c3
7
+ data.tar.gz: 260a7daa80fa106d4195ebd2484075cd6fb26535419d1fb6ef4783df009aa8c53193dd44725b27dba1901626f1b7070d8e462a47a859c7ac5f9a4d8bbb3f4901
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ bots
2
+ config/gaston/bots.yml
data/Capfile ADDED
@@ -0,0 +1,4 @@
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/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,94 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ babot (0.1.0)
5
+ activesupport
6
+ capistrano
7
+ capistrano-af83
8
+ gaston
9
+ git
10
+ rake
11
+ rvm-capistrano
12
+ twitter
13
+ whenever
14
+
15
+ GEM
16
+ remote: http://rubygems.org/
17
+ specs:
18
+ activesupport (4.0.0)
19
+ i18n (~> 0.6, >= 0.6.4)
20
+ minitest (~> 4.2)
21
+ multi_json (~> 1.3)
22
+ thread_safe (~> 0.1)
23
+ tzinfo (~> 0.3.37)
24
+ addressable (2.3.5)
25
+ atomic (1.1.10)
26
+ capistrano (2.15.5)
27
+ highline
28
+ net-scp (>= 1.0.0)
29
+ net-sftp (>= 2.0.0)
30
+ net-ssh (>= 2.0.14)
31
+ net-ssh-gateway (>= 1.1.0)
32
+ capistrano-af83 (0.4.2)
33
+ capistrano (~> 2.14)
34
+ capistrano-custom-maintenance (~> 0.1.0)
35
+ capistrano-notification (~> 0.1)
36
+ shout-bot (= 0.0.4)
37
+ sushi (~> 0.0.2)
38
+ capistrano-custom-maintenance (0.1.0)
39
+ capistrano
40
+ capistrano-file-resources (>= 0.1.1)
41
+ json
42
+ mime-types
43
+ capistrano-file-resources (0.1.1)
44
+ capistrano
45
+ mime-types
46
+ capistrano-notification (0.1.1)
47
+ capistrano
48
+ shout-bot
49
+ validatable
50
+ chronic (0.9.1)
51
+ faraday (0.8.8)
52
+ multipart-post (~> 1.2.0)
53
+ gaston (0.4.1)
54
+ inflecto
55
+ git (1.2.5)
56
+ highline (1.6.19)
57
+ i18n (0.6.4)
58
+ inflecto (0.0.2)
59
+ json (1.8.0)
60
+ mime-types (1.23)
61
+ minitest (4.7.5)
62
+ multi_json (1.7.8)
63
+ multipart-post (1.2.0)
64
+ net-scp (1.1.2)
65
+ net-ssh (>= 2.6.5)
66
+ net-sftp (2.1.2)
67
+ net-ssh (>= 2.6.5)
68
+ net-ssh (2.6.8)
69
+ net-ssh-gateway (1.2.0)
70
+ net-ssh (>= 2.6.5)
71
+ rake (10.1.0)
72
+ rvm-capistrano (1.4.1)
73
+ capistrano (>= 2.0.0)
74
+ shout-bot (0.0.4)
75
+ addressable
76
+ simple_oauth (0.2.0)
77
+ sushi (0.0.2)
78
+ thread_safe (0.1.0)
79
+ atomic
80
+ twitter (4.8.1)
81
+ faraday (~> 0.8, < 0.10)
82
+ multi_json (~> 1.0)
83
+ simple_oauth (~> 0.2)
84
+ tzinfo (0.3.37)
85
+ validatable (1.6.7)
86
+ whenever (0.8.4)
87
+ activesupport (>= 2.3.4)
88
+ chronic (>= 0.6.3)
89
+
90
+ PLATFORMS
91
+ ruby
92
+
93
+ DEPENDENCIES
94
+ babot!
data/README.md ADDED
@@ -0,0 +1,17 @@
1
+ Babot helps you manage your Twitter bots.
2
+
3
+ The file `config/gaston/bots.yml` contains, for each bot, the git
4
+ repository and the API keys.
5
+
6
+ A bot is a git repository containing :
7
+
8
+ - a Gemfile
9
+ - a lib directory with a [name_of_the_bot].rb file
10
+
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.
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ $:.unshift File.expand_path('../lib', __FILE__)
2
+
3
+ Dir["./lib/tasks/*.rake"].each do |file|
4
+ import file
5
+ end
data/config/boot.rb ADDED
@@ -0,0 +1,13 @@
1
+ require 'gaston'
2
+ require 'fileutils'
3
+ require 'git'
4
+ require 'twitter'
5
+ require 'active_support/core_ext/string/inflections'
6
+
7
+ Gaston.configure do |gaston|
8
+ gaston.env = ENV["RACK_ENV"] || "development"
9
+ gaston.files = Dir["./config/gaston/**/*.yml"]
10
+ end
11
+
12
+ require 'bot'
13
+ require 'bots/twitter_bot'
data/config/deploy.rb ADDED
@@ -0,0 +1,19 @@
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
@@ -0,0 +1,5 @@
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
@@ -0,0 +1,8 @@
1
+ :gaston:
2
+ bots:
3
+ test:
4
+ :repository: git@github.com:phorque/twitter-test-bot.git
5
+ :consumer_key: lol
6
+ :consumer_secret: lol
7
+ :oauth_token: lol
8
+ :oauth_token_secret: lol
data/lib/bot.rb ADDED
@@ -0,0 +1,53 @@
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
@@ -0,0 +1,41 @@
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
metadata ADDED
@@ -0,0 +1,181 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: babot
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Victor Goya
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: twitter
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: gaston
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
+ - !ruby/object:Gem::Dependency
42
+ name: git
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activesupport
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: whenever
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
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ 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
+ description: A simple tool to manage Twitter bots
140
+ email: goya.victor@gmail.com
141
+ executables: []
142
+ extensions: []
143
+ extra_rdoc_files: []
144
+ files:
145
+ - .gitignore
146
+ - Capfile
147
+ - Gemfile
148
+ - Gemfile.lock
149
+ - README.md
150
+ - Rakefile
151
+ - config/boot.rb
152
+ - config/deploy.rb
153
+ - config/deploy/production.rb
154
+ - config/gaston/bots.yml.sample
155
+ - lib/bot.rb
156
+ - lib/tasks/bots.rake
157
+ homepage: https://github.com/phorque/babot
158
+ licenses:
159
+ - MIT
160
+ metadata: {}
161
+ post_install_message:
162
+ rdoc_options: []
163
+ require_paths:
164
+ - lib
165
+ required_ruby_version: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - '>='
168
+ - !ruby/object:Gem::Version
169
+ version: '0'
170
+ required_rubygems_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - '>='
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ requirements: []
176
+ rubyforge_project:
177
+ rubygems_version: 2.0.0
178
+ signing_key:
179
+ specification_version: 4
180
+ summary: Babot
181
+ test_files: []