autoup 0.9.1 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ef0d9fc11e7ec074f78ddb895ac7bd3850e28ef
4
- data.tar.gz: 089d9af43dcc8ca78b2d3562bee712124c7fe0cc
3
+ metadata.gz: 541337e58e6ed6810efd1becb84c0e7c217050c4
4
+ data.tar.gz: eaebb087b762611d769419ae1c5e602af3d9d9cb
5
5
  SHA512:
6
- metadata.gz: 0a4ffaf74f0719fc1497eb2c1980a9574422aa0c353576ee25f809aea8f43c18e2ff06d693e361ba067af1c13b01b4cbd771aa5e31904a7d14e206e460e477cf
7
- data.tar.gz: 805f66cd7f2cec8017327540f1c6cde4f9e41a5b716c78b8d2fccb5b7d5824382cc244f302cd810f3d5fedc31e6d3911eef5848b5d04ddf853e50b590a6b6b3e
6
+ metadata.gz: a030ebaf9fee2e05e2c166c6c3005aabc960276947ce739cc144ea78ef7fe810f9f09670a7eb6fadc4fd97e16b654a63d4ba35bf8417e39db61b67e7e2303497
7
+ data.tar.gz: ef93ef9f4d747b652d130ec6867ae1aa1511c7a5ef6f7a8a18762f2bd9497d9f5b91dac487214c3594741932b95201b1f098dfd458a6ad3b93fc70ef708c8820
data/autoup.gemspec CHANGED
@@ -1,13 +1,13 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'autoup'
3
- s.version = '0.9.1'
4
- s.license = 'Apache-2.0'
3
+ s.version = '0.9.3'
5
4
  s.summary = 'Selenium robot for auto-bumping vBulletin posts'
6
5
  s.description = "Logs in onto vBulletin forum boards, finds all user's threads and bumps all the posts"
6
+ s.homepage = 'https://github.com/chillum/autoup'
7
+ s.license = 'Apache-2.0'
7
8
  s.author = 'Vasily Korytov'
8
9
  s.email = 'vasily.korytov@yahoo.com'
9
10
  s.files = ['LICENSE.txt', 'README.md', 'examples/autoup.yml', 'autoup.gemspec', 'lib/autoup.rb']
10
11
  s.executables << 'autoup'
11
- s.homepage = 'https://github.com/chillum/autoup'
12
12
  s.add_dependency 'selenium-webdriver', '~> 2.43'
13
13
  end
data/bin/autoup CHANGED
@@ -1,5 +1,5 @@
1
1
  #! /usr/bin/env ruby
2
- #
2
+
3
3
  # Copyright 2014 Vasily Korytov
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
data/examples/autoup.yml CHANGED
@@ -1,18 +1,24 @@
1
- # autoup config
2
- # one or more `forum` entries with all fields are required
3
- # example settings for English and Russian vB installations
1
+ # autoup config: ~/.config/autoup.yml
2
+ # include one or more `forum` items
4
3
 
4
+ # minimal setup
5
+ - forum: 'http://localhost/forum-en/'
6
+ user: 'username'
7
+ pass: 'password'
8
+
9
+ # defaults expanded
5
10
  - forum: 'http://localhost/forum-en/'
6
11
  user: 'username'
7
12
  pass: 'password'
8
13
  find: 'Find all threads started by'
9
14
  stats: 'Show All Statistics'
10
15
  up: 'Bump the thread!'
16
+ timeout: 5
11
17
 
18
+ # Russian board example
12
19
  - forum: 'http://localhost/forum-ru/'
13
20
  user: 'username'
14
21
  pass: 'password'
15
22
  find: 'Найти все темы, созданные'
16
23
  stats: 'Показать всю статистику'
17
24
  up: 'Поднять тему!'
18
- timeout: 10 # this is a slow server. timeout defaults to 5
data/lib/autoup.rb CHANGED
@@ -25,22 +25,53 @@ require 'yaml'
25
25
  class AutoUp
26
26
  # Launches AutoUp (specify the config file to override the default)
27
27
  def initialize(yml = File.expand_path('~/.config/autoup.yml'))
28
- config = YAML.load_file yml
29
- config.each do |cfg|
28
+ begin
29
+ config = YAML.load_file(yml)
30
+ rescue Errno::ENOENT
31
+ puts('ERROR: no configuration file at `~/.config/autoup.yml`. Example:')
32
+ puts('https://github.com/chillum/autoup/blob/master/examples/autoup.yml')
33
+ return
34
+ end
35
+ config.each { |cfg|
36
+ # Required settings
37
+ unless cfg['forum']
38
+ puts('ERROR: `forum` attribute is required')
39
+ next
40
+ end
41
+ unless cfg['user']
42
+ puts('ERROR: `user` attribute is required')
43
+ next
44
+ end
45
+ unless cfg['pass']
46
+ puts('ERROR: `pass` attribute is required')
47
+ next
48
+ end
49
+ # Optional settings
50
+ cfg['timeout'] ||= 5
51
+ cfg['find'] ||= 'Find all threads started by'
52
+ cfg['stats'] ||= 'Show All Statistics'
53
+ cfg['up'] ||= 'Bump the thread!'
54
+
30
55
  web = Selenium::WebDriver.for :firefox
31
56
  begin
32
- web.manage.timeouts.implicit_wait = cfg['timeout'] || 5
33
- web.get cfg['forum']
57
+ web.manage.timeouts.implicit_wait = cfg['timeout']
58
+ web.get(cfg['forum'])
59
+
60
+ begin
61
+ web.find_element(:name, 'vb_login_username').send_keys(cfg['user'])
62
+ rescue Selenium::WebDriver::Error::NoSuchElementError
63
+ puts("ERROR: unable to load #{cfg['forum']} (does not load or does not contain vb_login_username)")
64
+ next
65
+ end
34
66
 
35
- web.find_element(:name, 'vb_login_username').send_keys(cfg['user'])
36
67
  login = web.find_element(:name, 'vb_login_password')
37
- login.send_keys cfg['pass']
68
+ login.send_keys(cfg['pass'])
38
69
  login.submit
39
70
 
40
71
  begin
41
72
  web.find_element(:link, cfg['user']).click
42
73
  rescue Selenium::WebDriver::Error::NoSuchElementError
43
- puts "ERROR: unable to login as #{cfg['user']} on #{cfg['forum']}"
74
+ puts("ERROR: unable to login as #{cfg['user']} on #{cfg['forum']}")
44
75
  next
45
76
  end
46
77
 
@@ -48,22 +79,22 @@ class AutoUp
48
79
  web.find_element(:link, "#{cfg['find']} #{cfg['user']}").click
49
80
 
50
81
  links = []
51
- web.find_elements(:css, 'a[id ^= "thread_title_"]').each do |link|
82
+ web.find_elements(:css, 'a[id ^= "thread_title_"]').each { |link|
52
83
  links.push link.attribute('href')
53
- end
84
+ }
54
85
 
55
- links.each do |link|
56
- web.get link
86
+ links.each { |link|
87
+ web.get(link)
57
88
  begin
58
89
  web.find_element(:css, "input[value = '#{cfg['up']}']").click
59
- puts "UP: #{link}"
90
+ puts("UP: #{link}")
60
91
  rescue Selenium::WebDriver::Error::NoSuchElementError
61
- puts "SKIP: #{link}"
92
+ puts("SKIP: #{link}")
62
93
  end
63
- end
94
+ }
64
95
  ensure
65
96
  web.quit
66
97
  end
67
- end
98
+ }
68
99
  end
69
100
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autoup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vasily Korytov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-04 00:00:00.000000000 Z
11
+ date: 2014-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver