bets 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/bin/bets +9 -0
  2. data/lib/bets/version.rb +1 -1
  3. data/lib/bets.rb +28 -70
  4. metadata +1 -1
data/bin/bets CHANGED
@@ -0,0 +1,9 @@
1
+
2
+ #!/usr/bin/env ruby
3
+
4
+ require 'bets'
5
+
6
+ processor = Bets::Processor.new
7
+ processor.run
8
+
9
+
data/lib/bets/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bets
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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
- def read_data
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("./examples/test.rules", "r").read
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
- text = <<EOF
143
- #{variables}
144
- def ff_goto(str)
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
- def ff_set(str, value)
153
- eval "@ff.wait_until{@ff.\#{str}.exists?};@ff.\#{str}.set(\#{value})"
154
- end
120
+ def ff_click(str)
121
+ eval "@ff.wait_until{@ff.#{str}.exists?};@ff.#{str}.click"
122
+ end
155
123
 
156
- def ff_get(str, name)
157
- eval "@ff.wait_until{@ff.\#{str}.exists?};@ff.\#{str}.\#{name}"
158
- end
124
+ def ff_set(str, value)
125
+ eval "@ff.wait_until{@ff.#{str}.exists?};@ff.#{str}.set(#{value})"
126
+ end
159
127
 
160
- результат = FALSE;
161
- begin
162
- #{@names[b[0]]}
163
- end
164
- if результат
165
- #{@names[b[1]]}
166
- end
167
- EOF
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
- read_data
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: