dieselup 1.0.1 → 2.0.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 +13 -5
- data/.travis.yml +2 -2
- data/README.md +10 -2
- data/dieselup.gemspec +2 -1
- data/lib/dieselup.rb +3 -0
- data/lib/dieselup/base.rb +42 -18
- data/lib/dieselup/url.rb +0 -2
- data/lib/dieselup/version.rb +1 -1
- data/spec/dieselup_spec.rb +5 -15
- metadata +35 -21
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MTgwYjliMTgxNTFjNmVmYWYwZmM2YjA4Y2VjYWEyNDExNTNjMjg0Yw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
M2YwMmU2YjEwM2MwNmVjYzg2NjVmNWQ5Y2U5NTBhYjFmYmI3MjE1Mw==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MmVlYWRhYTcxYTVkZjgwYTJhNzZiZjU3NDUxYWQ5YWQ2MTJiYWUyMGZmZGMz
|
10
|
+
OWUyMWFmNzcwMGM5NTgwNzVlYmVkY2YzMTliMGY3YjdmMWU0YTY2YjNmNTk0
|
11
|
+
Yjk0Mjk4OTI2ODRlMmE5YzFlYTdmMDBhNDY1YWM4MDZiNDQ0ZDI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YzhiM2VhNzg0MWFjYjQwNDMzZmUyZTVjYTk2M2I3YjM1Y2NiNDMyN2MyOGIz
|
14
|
+
ZjFiNGZkNTBiMzkwMjY5YmI4NzNlYTIxNWUwZTY0YWMyZjBjMDhjNGI3M2Jk
|
15
|
+
ZmQyYWNkNTg2OTc5YWYzMzkxZWQ3ODhlNTE0OWFjYThjNmM5Zjc=
|
data/.travis.yml
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
3
|
- 1.9.3
|
4
|
-
- 2.0
|
4
|
+
- 2.0
|
5
5
|
- 2.1
|
6
|
-
- 2.2
|
6
|
+
- 2.2
|
7
7
|
env:
|
8
8
|
global:
|
9
9
|
- secure: AtVYNnfo2JaqXAe/xXwzCzgJIvWF5D5CiEeu4nhT9fA9HHuxUUyL4SEoMXcdmfdm/ECUucj0LL/Feu7J6GAwDaetLlNqb3zj27CLk89cbAuBoGmU/y4LqALflRm2s7CMNTry13V/uo/gXtdAXN56lEj0+V7OJVrDLtz6OHryvFKjClSJmsyeDmFOLDHpQ+ISnhEFfZ4dZ6GRlPuVs0Gr5GdKL9QFg8WtWZhpacLT87IHyoxVXiOX8x0Egcrgc2UxhJLZ9VHb5du7kUJ384Y3Y8bUVCaIgiU6iV5MMzfga0G7ueE3hNCXVzWSlHoUxuzNtb4sVaw08qperPvMne4uYuE/wZAMNBuby9wmdLs/Sy2pfAP7aLyECHRldvjcxntZbpAoeZ6lZcCchV6opXqKuKNLAdr71kE248Jucl6c2SRNoVS1uAewB+ie+jmHn1Dt0Eg2Ux3jS3ccidzKJ8qf9nPouLSj0OXcl8ijdgEFohEiGfNxW/C/5TEUGCf+5r/TRfthDpwlQtufxEkVjhiO4q7DUVwTkf7sNiONBkOLx0VvMgNMU0fzWofCwaOqLcRjaQiUnAsenSDhjEtpCOn47i+joXeFLNzLtFLilmWyYse78pAtfhhlFbx2+rf95k1+krYrOHe+7yICYdg8kK5Gss1xfo79a/+0kP/DgwvRfeg=
|
data/README.md
CHANGED
@@ -31,15 +31,23 @@ $ USERNAME=your-username PASSWORD=your-password dieselup <your-topic-ID>
|
|
31
31
|
Cron task example:
|
32
32
|
|
33
33
|
```shell
|
34
|
-
|
34
|
+
USERNAME=your-username
|
35
|
+
PASSWORD=your-password
|
36
|
+
...
|
37
|
+
*/1 * * * * dieselup <your-topic-ID> > /dev/null 2>&1
|
35
38
|
```
|
36
39
|
|
37
40
|
That's it!
|
38
41
|
|
42
|
+
Like PHP?
|
43
|
+
---------
|
44
|
+
|
45
|
+
Sweet. Check out [PHP dieselup](https://github.com/xcopy/dieselup)
|
46
|
+
|
39
47
|
Contributing
|
40
48
|
------------
|
41
49
|
|
42
|
-
1. Fork it
|
50
|
+
1. Fork it
|
43
51
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
44
52
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
45
53
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/dieselup.gemspec
CHANGED
@@ -27,5 +27,6 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_development_dependency 'rspec', '~> 3.4'
|
28
28
|
|
29
29
|
spec.add_runtime_dependency 'activesupport', '~> 4.2'
|
30
|
-
spec.add_runtime_dependency 'nokogiri', '
|
30
|
+
spec.add_runtime_dependency 'nokogiri', '1.6'
|
31
|
+
spec.add_runtime_dependency 'rainbow', '~> 2.1'
|
31
32
|
end
|
data/lib/dieselup.rb
CHANGED
data/lib/dieselup/base.rb
CHANGED
@@ -7,20 +7,38 @@ module Dieselup
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def up!
|
10
|
-
|
11
|
-
|
10
|
+
begin
|
11
|
+
login
|
12
|
+
post
|
13
|
+
rescue => e
|
14
|
+
log(e.message, nil, :red)
|
15
|
+
end
|
12
16
|
end
|
13
17
|
|
14
18
|
def login
|
19
|
+
log('Checking access', :yellow)
|
20
|
+
|
15
21
|
response = request(Dieselup::Url::BASE)
|
16
22
|
document = Nokogiri::HTML(response.body)
|
17
23
|
|
18
|
-
if document.css('
|
19
|
-
|
20
|
-
|
24
|
+
if document.css('a#user_link').empty?
|
25
|
+
log('Logging in', :yellow)
|
26
|
+
|
27
|
+
url = Dieselup::Url.get(app: 'core', module: 'global', section: 'login', do: 'process')
|
28
|
+
|
29
|
+
params = {
|
30
|
+
auth_key: '880ea6a14ea49e853634fbdc5015a024',
|
31
|
+
referer: Dieselup::Url::BASE,
|
32
|
+
ips_username: ENV['USERNAME'],
|
33
|
+
ips_password: ENV['PASSWORD'],
|
34
|
+
rememberMe: 1
|
35
|
+
}
|
36
|
+
|
21
37
|
response = request(url, 'POST', params)
|
22
38
|
end
|
23
39
|
|
40
|
+
log('Logged in', :green)
|
41
|
+
|
24
42
|
response
|
25
43
|
end
|
26
44
|
|
@@ -30,25 +48,31 @@ module Dieselup
|
|
30
48
|
response = request(Dieselup::Url.get(showtopic: ARGV.first))
|
31
49
|
document = Nokogiri::HTML(response.body)
|
32
50
|
|
33
|
-
delete_links = document.css('
|
34
|
-
link[:href]
|
51
|
+
delete_links = document.css('a.delete_post').map { |link|
|
52
|
+
link[:href]
|
35
53
|
}
|
36
54
|
|
37
55
|
if delete_links.any?
|
56
|
+
log('Deleting last UP', :yellow)
|
57
|
+
|
38
58
|
request(delete_links.last)
|
39
59
|
end
|
40
60
|
|
41
61
|
params = {Post: 'UP'}
|
42
62
|
|
43
|
-
hidden_inputs = document.css('//form[@
|
63
|
+
hidden_inputs = document.css('//form[@id="ips_fastReplyForm"]/input[@type*="hidden"]')
|
44
64
|
hidden_inputs.each do |input|
|
45
65
|
params[input[:name]] = input[:value]
|
46
66
|
end
|
47
67
|
|
68
|
+
log('Posting new UP', :green)
|
69
|
+
|
48
70
|
request(Dieselup::Url::BASE, 'POST', params)
|
49
71
|
end
|
50
72
|
|
51
73
|
def request(url, method = 'GET', params = {})
|
74
|
+
puts Rainbow("#{method} #{url}").color(:silver).bright
|
75
|
+
|
52
76
|
uri = URI(url)
|
53
77
|
|
54
78
|
http = Net::HTTP.new(uri.host, uri.port)
|
@@ -68,11 +92,11 @@ module Dieselup
|
|
68
92
|
|
69
93
|
response = http.request(request)
|
70
94
|
|
95
|
+
=begin
|
71
96
|
document = Nokogiri::HTML(response.body)
|
72
|
-
|
73
97
|
errors = document.xpath('//div[@class="errorwrap"]/p')
|
74
|
-
|
75
98
|
raise StandardError, errors.first.text if errors.any?
|
99
|
+
=end
|
76
100
|
|
77
101
|
cookies = response.get_fields('set-cookie')
|
78
102
|
cookies.each do |cookie|
|
@@ -82,16 +106,16 @@ module Dieselup
|
|
82
106
|
response
|
83
107
|
end
|
84
108
|
|
85
|
-
|
86
|
-
|
87
|
-
uri = URI.parse(url)
|
109
|
+
def log(message, *colors)
|
110
|
+
color, background, bright = colors
|
88
111
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
112
|
+
rainbow = Rainbow(message.to_s).color(color.try(:to_sym) || :white)
|
113
|
+
|
114
|
+
if background
|
115
|
+
rainbow = rainbow.background(background.to_sym)
|
93
116
|
end
|
117
|
+
|
118
|
+
puts rainbow
|
94
119
|
end
|
95
|
-
=end
|
96
120
|
end
|
97
121
|
end
|
data/lib/dieselup/url.rb
CHANGED
data/lib/dieselup/version.rb
CHANGED
data/spec/dieselup_spec.rb
CHANGED
@@ -30,27 +30,17 @@ describe Dieselup do
|
|
30
30
|
it 'should login successfully' do
|
31
31
|
response = @base.login
|
32
32
|
document = Nokogiri::HTML(response.body)
|
33
|
-
|
34
|
-
expect(response.code).to eq '200'
|
35
|
-
expect(document.at("p:contains(#{ENV['USERNAME']})")).to_not be_nil
|
33
|
+
expect(document.at("a:contains(#{ENV['USERNAME']})")).to_not be_nil
|
36
34
|
end
|
37
35
|
|
38
|
-
it 'should send GET request and get
|
36
|
+
it 'should send GET request and get HTTP response with status 200 OK' do
|
39
37
|
response = @base.request(Dieselup::Url::BASE)
|
40
|
-
document = Nokogiri::HTML(response.body)
|
41
|
-
|
42
38
|
expect(response.code).to eq '200'
|
43
|
-
expect(document.at("a:contains(#{ENV['USERNAME']})")).to_not be_nil
|
44
39
|
end
|
45
40
|
|
46
|
-
it 'should
|
47
|
-
@base.
|
48
|
-
|
49
|
-
ARGV.clear
|
50
|
-
|
51
|
-
expect { @base.request(Dieselup::Url.get(showtopic: 1)) }.to raise_error(StandardError)
|
52
|
-
expect { @base.post }.to raise_error(ArgumentError)
|
53
|
-
expect { @base.login }.to raise_error(StandardError)
|
41
|
+
it 'should send GET request and get HTTP response with status 404 Not Found' do
|
42
|
+
response = @base.request(Dieselup::Url.get(showtopic: 1))
|
43
|
+
expect(response.code).to eq '404'
|
54
44
|
end
|
55
45
|
end
|
56
46
|
end
|
metadata
CHANGED
@@ -1,99 +1,113 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dieselup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kairat Jenishev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.7'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: dotenv
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '2.1'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '3.4'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.4'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: activesupport
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ~>
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '4.2'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '4.2'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: nokogiri
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - '='
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '1.6'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - '='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '1.6'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rainbow
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.1'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.1'
|
97
111
|
description: Lift up your topic to the top in Diesel Forum
|
98
112
|
email: kairat.jenishev@gmail.com
|
99
113
|
executables:
|
@@ -101,10 +115,10 @@ executables:
|
|
101
115
|
extensions: []
|
102
116
|
extra_rdoc_files: []
|
103
117
|
files:
|
104
|
-
-
|
105
|
-
-
|
106
|
-
-
|
107
|
-
-
|
118
|
+
- .env.dist
|
119
|
+
- .gitignore
|
120
|
+
- .rspec
|
121
|
+
- .travis.yml
|
108
122
|
- Gemfile
|
109
123
|
- LICENSE.txt
|
110
124
|
- README.md
|
@@ -129,17 +143,17 @@ require_paths:
|
|
129
143
|
- lib
|
130
144
|
required_ruby_version: !ruby/object:Gem::Requirement
|
131
145
|
requirements:
|
132
|
-
- -
|
146
|
+
- - ! '>='
|
133
147
|
- !ruby/object:Gem::Version
|
134
148
|
version: 1.9.3
|
135
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
150
|
requirements:
|
137
|
-
- -
|
151
|
+
- - ! '>='
|
138
152
|
- !ruby/object:Gem::Version
|
139
153
|
version: '0'
|
140
154
|
requirements: []
|
141
155
|
rubyforge_project:
|
142
|
-
rubygems_version: 2.4.
|
156
|
+
rubygems_version: 2.4.3
|
143
157
|
signing_key:
|
144
158
|
specification_version: 4
|
145
159
|
summary: DieselUp!
|