site_navigator 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in site_navigator.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 TODO: Write your name
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # SiteNavigator
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'site_navigator'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install site_navigator
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bets ADDED
@@ -0,0 +1,9 @@
1
+
2
+ #!/usr/bin/env ruby
3
+
4
+ require 'bets'
5
+ require 'gtk2'
6
+
7
+ tt = RulesDebuger::BetsGUI.new
8
+
9
+
@@ -0,0 +1,9 @@
1
+
2
+ #!/usr/bin/env ruby
3
+
4
+ require 'gtk2'
5
+ require 'site_navigator.rb'
6
+
7
+ tt = SiteNavigator::Navigator.new
8
+
9
+
data/install.sh ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+ source /home/tuxer/.rvm/scripts/rvm
3
+ rake install
data/lib/install.sh ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+ source /home/dzen79/.rvm/scripts/rvm
3
+ rake install
@@ -0,0 +1,140 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <interface>
3
+ <requires lib="gtk+" version="2.24"/>
4
+ <!-- interface-naming-policy project-wide -->
5
+ <object class="GtkListStore" id="ls_sites"/>
6
+ <object class="GtkWindow" id="wnd_main">
7
+ <property name="can_focus">False</property>
8
+ <property name="border_width">8</property>
9
+ <property name="default_width">300</property>
10
+ <property name="default_height">600</property>
11
+ <property name="type_hint">dialog</property>
12
+ <signal name="destroy" handler="on_wnd_main_destroy" swapped="no"/>
13
+ <signal name="delete-event" handler="on_wnd_main_delete_event" swapped="no"/>
14
+ <child>
15
+ <object class="GtkVBox" id="vbox1">
16
+ <property name="visible">True</property>
17
+ <property name="can_focus">False</property>
18
+ <child>
19
+ <object class="GtkHBox" id="hbox2">
20
+ <property name="visible">True</property>
21
+ <property name="can_focus">False</property>
22
+ <child>
23
+ <object class="GtkLabel" id="label1">
24
+ <property name="visible">True</property>
25
+ <property name="can_focus">False</property>
26
+ <property name="label" translatable="yes">Файл:</property>
27
+ <property name="justify">right</property>
28
+ </object>
29
+ <packing>
30
+ <property name="expand">False</property>
31
+ <property name="fill">True</property>
32
+ <property name="padding">1</property>
33
+ <property name="position">0</property>
34
+ </packing>
35
+ </child>
36
+ <child>
37
+ <object class="GtkFileChooserButton" id="fcb_filename">
38
+ <property name="visible">True</property>
39
+ <property name="can_focus">False</property>
40
+ <property name="border_width">5</property>
41
+ <signal name="file-set" handler="on_fcb_filename_file_set" swapped="no"/>
42
+ </object>
43
+ <packing>
44
+ <property name="expand">True</property>
45
+ <property name="fill">True</property>
46
+ <property name="position">1</property>
47
+ </packing>
48
+ </child>
49
+ </object>
50
+ <packing>
51
+ <property name="expand">False</property>
52
+ <property name="fill">True</property>
53
+ <property name="position">0</property>
54
+ </packing>
55
+ </child>
56
+ <child>
57
+ <object class="GtkLabel" id="lbl_info">
58
+ <property name="visible">True</property>
59
+ <property name="can_focus">False</property>
60
+ <property name="ypad">1</property>
61
+ <property name="label" translatable="yes">Сайты не загружены</property>
62
+ <property name="ellipsize">start</property>
63
+ </object>
64
+ <packing>
65
+ <property name="expand">False</property>
66
+ <property name="fill">True</property>
67
+ <property name="padding">14</property>
68
+ <property name="position">1</property>
69
+ </packing>
70
+ </child>
71
+ <child>
72
+ <object class="GtkHBox" id="hbox1">
73
+ <property name="visible">True</property>
74
+ <property name="can_focus">False</property>
75
+ <child>
76
+ <object class="GtkButton" id="btn_prev">
77
+ <property name="label" translatable="yes">Назад</property>
78
+ <property name="visible">True</property>
79
+ <property name="sensitive">False</property>
80
+ <property name="can_focus">True</property>
81
+ <property name="receives_default">True</property>
82
+ <property name="border_width">5</property>
83
+ <property name="use_action_appearance">False</property>
84
+ <property name="yalign">0.56000000238418579</property>
85
+ <signal name="clicked" handler="on_btn_prev_clicked" swapped="no"/>
86
+ </object>
87
+ <packing>
88
+ <property name="expand">True</property>
89
+ <property name="fill">True</property>
90
+ <property name="position">0</property>
91
+ </packing>
92
+ </child>
93
+ <child>
94
+ <object class="GtkButton" id="btn_next">
95
+ <property name="label" translatable="yes">Вперед</property>
96
+ <property name="visible">True</property>
97
+ <property name="sensitive">False</property>
98
+ <property name="can_focus">True</property>
99
+ <property name="receives_default">True</property>
100
+ <property name="border_width">5</property>
101
+ <property name="use_action_appearance">False</property>
102
+ <signal name="clicked" handler="on_btn_next_clicked" swapped="no"/>
103
+ </object>
104
+ <packing>
105
+ <property name="expand">True</property>
106
+ <property name="fill">True</property>
107
+ <property name="position">1</property>
108
+ </packing>
109
+ </child>
110
+ </object>
111
+ <packing>
112
+ <property name="expand">False</property>
113
+ <property name="fill">True</property>
114
+ <property name="position">2</property>
115
+ </packing>
116
+ </child>
117
+ <child>
118
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
119
+ <property name="visible">True</property>
120
+ <property name="can_focus">True</property>
121
+ <property name="hscrollbar_policy">automatic</property>
122
+ <property name="vscrollbar_policy">automatic</property>
123
+ <child>
124
+ <object class="GtkTreeView" id="trv_sites">
125
+ <property name="visible">True</property>
126
+ <property name="can_focus">True</property>
127
+ <signal name="cursor-changed" handler="on_trv_sites_cursor_changed" swapped="no"/>
128
+ </object>
129
+ </child>
130
+ </object>
131
+ <packing>
132
+ <property name="expand">True</property>
133
+ <property name="fill">True</property>
134
+ <property name="position">3</property>
135
+ </packing>
136
+ </child>
137
+ </object>
138
+ </child>
139
+ </object>
140
+ </interface>
@@ -0,0 +1,131 @@
1
+ # encoding: utf-8
2
+ require "site_navigator/version"
3
+ require "watir-webdriver"
4
+ require "gtk2"
5
+
6
+ module SiteNavigator
7
+ class Navigator
8
+ def initialize
9
+ Gtk.init
10
+ builder = Gtk::Builder.new
11
+ builder.add_from_file(File.join(File.dirname(__FILE__), 'site_navigator.glade'))
12
+ builder.connect_signals {|handler| method(handler) }
13
+
14
+ @options = {}
15
+ begin
16
+ @options = File.open(File.join(File.dirname(__FILE__), "options.dat"), "rb") {|f| Marshal.load(f)}
17
+ rescue Exception => e
18
+ puts e
19
+ end
20
+
21
+ @lbl_info = builder.get_object('lbl_info')
22
+ @fcb_filename = builder.get_object('fcb_filename')
23
+ @btn_prev = builder.get_object('btn_prev')
24
+ @btn_next = builder.get_object('btn_next')
25
+
26
+ @trv_sites = builder.get_object('trv_sites')
27
+ renderer = Gtk::CellRendererText.new
28
+ column = Gtk::TreeViewColumn.new("№", renderer, :text => 0)
29
+ @trv_sites.append_column(column)
30
+ column = Gtk::TreeViewColumn.new("Сайт", renderer, :text => 1)
31
+ @trv_sites.append_column(column)
32
+ @ls_sites = Gtk::ListStore.new(String, String)
33
+ @trv_sites.model = @ls_sites
34
+
35
+ @wnd_main = builder.get_object('wnd_main')
36
+ @wnd_main.keep_above = true
37
+ @wnd_main.show
38
+
39
+ @sites_list = []
40
+ sites_load(@options[:filename]) unless @options[:filename].nil?
41
+
42
+ @trv_sites.set_focus(true)
43
+ Gtk.main
44
+ end
45
+
46
+ def list_fill
47
+ @ls_sites.clear
48
+ @sites_list.each_index do |index|
49
+ item = @ls_sites.append
50
+ item[0] = index.to_s
51
+ item[1] = @sites_list[index]
52
+ @trv_sites.selection.select_iter(item) if index == @options[:num]
53
+ end
54
+ end
55
+
56
+ def sites_load(filename)
57
+ @sites_num = (@options[:num].nil? ? 0 : @options[:num])
58
+ @options[:num] = @sites_num
59
+ @options[:filename] = filename
60
+ @sites_list = File.open(filename, "rb:UTF-8").read.split(/\r\n/)
61
+ @lbl_info.text = "В списке #{@sites_list.length} сайтов. Текущий сайт №#{@sites_num}"
62
+ list_fill
63
+ @btn_prev.sensitive = true
64
+ @btn_next.sensitive = true
65
+ Gtk::main_iteration_do(blocking = false) while Gtk::events_pending?
66
+ @browser = Watir::Browser.new :firefox if @browser.nil?
67
+ @browser.driver.manage.timeouts.implicit_wait = 3
68
+ site_goto
69
+ @trv_sites.set_focus(true)
70
+ Gtk::main_iteration_do(blocking = false) while Gtk::events_pending?
71
+ path, c = @trv_sites.cursor
72
+ @trv_sites.set_cursor path,c,false
73
+ end
74
+
75
+ def on_wnd_main_destroy
76
+ gtk_main_quit
77
+ end
78
+
79
+ def gtk_main_quit
80
+ @browser.close
81
+ Gtk.main_quit()
82
+ end
83
+
84
+ def on_wnd_main_delete_event(widget, event)
85
+ begin
86
+ File.open(File.join(File.dirname(__FILE__), "options.dat"), "wb") {|f| Marshal.dump(@options, f)}
87
+ rescue Exception => e
88
+ puts e
89
+ end
90
+ return false
91
+ end
92
+
93
+ def on_fcb_filename_file_set(widget)
94
+ sites_load(@fcb_filename.filename) unless @fcb_filename.filename.nil?
95
+ end
96
+
97
+ def on_btn_prev_clicked(widget)
98
+ Gtk::main_iteration_do(blocking = false) while Gtk::events_pending?
99
+ path, c = @trv_sites.cursor
100
+ path.prev!
101
+ @trv_sites.set_cursor path,c,false
102
+ end
103
+
104
+ def on_btn_next_clicked(widget)
105
+ Gtk::main_iteration_do(blocking = false) while Gtk::events_pending?
106
+ path, c = @trv_sites.cursor
107
+ path.next!
108
+ @trv_sites.set_cursor path,c,false
109
+ end
110
+
111
+ def on_trv_sites_cursor_changed(widget)
112
+ Gtk::main_iteration_do(blocking = false) while Gtk::events_pending?
113
+ path, c = widget.cursor
114
+ iter = @ls_sites.get_iter(path)
115
+ @sites_num = iter[0].to_i
116
+ @options[:num] = @sites_num
117
+ @lbl_info.text = "В списке #{@sites_list.length} сайтов. Текущий сайт №#{@sites_num}"
118
+ @browser = Watir::Browser.new :firefox if @browser.nil?
119
+ site_goto
120
+ end
121
+
122
+ def site_goto
123
+ begin
124
+ @browser.goto @sites_list[@sites_num]
125
+ rescue Exception => e
126
+ @browser = nil
127
+ puts e
128
+ end
129
+ end
130
+ end
131
+ end
@@ -0,0 +1,3 @@
1
+ module SiteNavigator
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'site_navigator/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "site_navigator"
8
+ gem.version = SiteNavigator::VERSION
9
+ gem.authors = ["Chemeris P.Taras"]
10
+ gem.email = ["chemt79@gmail.com"]
11
+ gem.description = %q{Приблуда для хождения по списку сайтов}
12
+ gem.summary = %q{Навигатор по списку сайтов}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: site_navigator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Chemeris P.Taras
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-16 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Приблуда для хождения по списку сайтов
15
+ email:
16
+ - chemt79@gmail.com
17
+ executables:
18
+ - site_navigator
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - LICENSE.txt
25
+ - README.md
26
+ - Rakefile
27
+ - bets
28
+ - bin/site_navigator
29
+ - install.sh
30
+ - lib/install.sh
31
+ - lib/site_navigator.glade
32
+ - lib/site_navigator.rb
33
+ - lib/site_navigator/version.rb
34
+ - site_navigator.gemspec
35
+ homepage: ''
36
+ licenses: []
37
+ post_install_message:
38
+ rdoc_options: []
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubyforge_project:
55
+ rubygems_version: 1.8.24
56
+ signing_key:
57
+ specification_version: 3
58
+ summary: Навигатор по списку сайтов
59
+ test_files: []