bets 0.0.1 → 0.0.2
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.
- data/bin/bets +9 -0
- data/lib/bets/version.rb +1 -1
- data/lib/bets.rb +28 -70
- metadata +1 -1
data/bin/bets
CHANGED
data/lib/bets/version.rb
CHANGED
data/lib/bets.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require "rubygems"
|
3
4
|
require "bets/version"
|
4
5
|
require 'watir-webdriver'
|
5
6
|
|
6
|
-
|
7
|
+
require 'betlinks'
|
7
8
|
module Bets
|
8
9
|
class Parse
|
9
10
|
def initialize
|
@@ -15,6 +16,7 @@ module Bets
|
|
15
16
|
|
16
17
|
class Processor
|
17
18
|
private
|
19
|
+
include Betlinks
|
18
20
|
def initialize
|
19
21
|
@names = {}
|
20
22
|
@conditions = {}
|
@@ -55,41 +57,18 @@ module Bets
|
|
55
57
|
'Б2\_коэф' => '$b2_coef',
|
56
58
|
'Б2\_вид\_спорта' => '$b2_kind',
|
57
59
|
'Б2\_ссылка' => '$b2_link',
|
58
|
-
'ПЕЧАТЬ ' => 'puts '
|
60
|
+
'ПЕЧАТЬ ' => 'puts ',
|
61
|
+
'ВЫХОД' => 'exit',
|
62
|
+
'ИСТИНА' => 'true',
|
63
|
+
'ЛОЖЬ' => 'false'
|
59
64
|
}
|
65
|
+
instance_eval "betlinks_init"
|
60
66
|
end
|
61
67
|
|
62
|
-
|
63
|
-
data = File.open("data.txt", "r").read
|
64
|
-
forks = data.split(/^\=.*?\n/)
|
65
|
-
@records = []
|
66
|
-
|
67
|
-
forks.each do |f|
|
68
|
-
next if f.strip.empty?
|
69
|
-
@records << {
|
70
|
-
game: "'#{f.scan(/\d{2}\:\d{2}\.\ (.*?)\:/).flatten(1)[0]}'",
|
71
|
-
percent: f.scan(/\:\ (.*?)\%/).flatten(1)[0].gsub(',','.'),
|
72
|
-
date: "'#{f.scan(/(\d{1,2}[^.].*?)\ в\ \d{2}\:\d{2}/).flatten(1)[0]}'",
|
73
|
-
time: "'#{f.scan(/в\ (\d{2}\:\d{2})/).flatten(1)[0]}'",
|
74
|
-
b1_name: "'#{f.scan(/^1\.\ (.*?);\ /).flatten(1)[0]}'",
|
75
|
-
b1_type: "'#{f.scan(/^1\..*?ставка\ (.*?)\;/).flatten(1)[0]}'",
|
76
|
-
b1_coef: f.scan(/^1\..*?коэф\.\ (.*?)\(/).flatten(1)[0].gsub(',','.'),
|
77
|
-
b1_kind: "'#{f.scan(/^1\..*\((.*?)\/\//).flatten(1)[0]}'",
|
78
|
-
b1_game: "'#{f.scan(/^1\..*?\/\/\ (.*?)\)/).flatten(1)[0]}'",
|
79
|
-
b1_link: "'#{f.scan(/^1\..*\n(http.*?)$/).flatten(1)[0]}'",
|
80
|
-
b2_name: "'#{f.scan(/^2\.\ (.*?);\ /).flatten(1)[0]}'",
|
81
|
-
b2_type: "'#{f.scan(/^2\..*?ставка\ (.*?)\;/).flatten(1)[0]}'",
|
82
|
-
b2_coef: f.scan(/^2\..*?коэф\.\ (.*?)\(/).flatten(1)[0].gsub(',','.'),
|
83
|
-
b2_kind: "'#{f.scan(/^2\..*\((.*?)\/\//).flatten(1)[0]}'",
|
84
|
-
b2_game: "'#{f.scan(/^2\..*?\/\/\ (.*?)\)/).flatten(1)[0]}'",
|
85
|
-
b2_link: "'#{f.scan(/^2\..*\n(http.*?)$/).flatten(1)[0]}'"
|
86
|
-
}
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
68
|
+
|
90
69
|
def translator
|
91
70
|
# Чтение исходного кода
|
92
|
-
text = File.open(
|
71
|
+
text = File.open(ARGV[0], "r").read
|
93
72
|
# Удаление комментариев
|
94
73
|
text.gsub!(/\-\-.*\n/,'')
|
95
74
|
# Разделение на слова
|
@@ -133,55 +112,34 @@ module Bets
|
|
133
112
|
end
|
134
113
|
end
|
135
114
|
end
|
136
|
-
|
137
|
-
def exec
|
138
|
-
@records.each do |r|
|
139
|
-
@binds.each do |b|
|
140
|
-
variables = r.map { |k,v| "$" + k.to_s + "=" + v.to_s + ";" }.flatten(1).join
|
141
115
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
@ff.goto(str)
|
146
|
-
end
|
147
|
-
|
148
|
-
def ff_click(str)
|
149
|
-
eval "@ff.wait_until{@ff.\#{str}.exists?};@ff.\#{str}.click"
|
150
|
-
end
|
116
|
+
def ff_goto(str)
|
117
|
+
@ff.goto(str)
|
118
|
+
end
|
151
119
|
|
152
|
-
|
153
|
-
|
154
|
-
|
120
|
+
def ff_click(str)
|
121
|
+
eval "@ff.wait_until{@ff.#{str}.exists?};@ff.#{str}.click"
|
122
|
+
end
|
155
123
|
|
156
|
-
|
157
|
-
|
158
|
-
|
124
|
+
def ff_set(str, value)
|
125
|
+
eval "@ff.wait_until{@ff.#{str}.exists?};@ff.#{str}.set(#{value})"
|
126
|
+
end
|
159
127
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
eval text
|
169
|
-
end
|
170
|
-
return
|
128
|
+
def ff_get(str, name)
|
129
|
+
eval "@ff.wait_until{@ff.#{str}.exists?};@ff.#{str}.#{name}"
|
130
|
+
end
|
131
|
+
|
132
|
+
def exec
|
133
|
+
@binds.each do |b|
|
134
|
+
text = "результат = FALSE; #{@names[b[0]]} if результат then #{@names[b[1]]} end;"
|
135
|
+
instance_eval text
|
171
136
|
end
|
172
137
|
end
|
173
138
|
public
|
174
139
|
def run
|
175
140
|
translator
|
176
|
-
|
177
|
-
exec
|
141
|
+
loop { exec }
|
178
142
|
end
|
179
143
|
end
|
180
144
|
# Your code goes here...
|
181
145
|
end
|
182
|
-
|
183
|
-
processor = Bets::Processor.new
|
184
|
-
processor.run
|
185
|
-
|
186
|
-
#bets = Bets::Parse.new()
|
187
|
-
#bets.parse
|