dailyrep 1.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 +7 -0
- data/.gitignore +21 -0
- data/README.md +17 -0
- data/Rakefile +8 -0
- data/bin/dailyrep +42 -0
- data/config/.gitkeep +0 -0
- data/config/config_template.json +57 -0
- data/config/index_template.html +189 -0
- data/dailyrep.gemspec +27 -0
- data/lib/dailyrep/AppContainer.rb +25 -0
- data/lib/dailyrep/Changable.rb +20 -0
- data/lib/dailyrep/Dbops.rb +28 -0
- data/lib/dailyrep/IBrowser.rb +77 -0
- data/lib/dailyrep/IndexWriter.rb +55 -0
- data/lib/dailyrep/Loadconfig.rb +135 -0
- data/lib/dailyrep/Notificator.rb +23 -0
- data/lib/dailyrep/Trackable.rb +14 -0
- data/lib/dailyrep/entities/Doujob.rb +83 -0
- data/lib/dailyrep/entities/Kinozal.rb +87 -0
- data/lib/dailyrep/entities/Micex.rb +66 -0
- data/lib/dailyrep/entities/Minfin.rb +69 -0
- data/lib/dailyrep/entities/Yanoil.rb +67 -0
- data/lib/dailyrep/version.rb +3 -0
- data/test/dailyrep/Doujob_test.rb +22 -0
- data/test/dailyrep/IBrowser_test.rb +46 -0
- data/test/dailyrep/Kinozal_test.rb +23 -0
- data/test/dailyrep/Micex_test.rb +27 -0
- data/test/dailyrep/Minfin_test.rb +23 -0
- data/test/dailyrep/Yanoil_test.rb +21 -0
- data/test/test_helper.rb +37 -0
- metadata +176 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e5aabaa849a78b02083adc92b191856b2bf181ce
|
4
|
+
data.tar.gz: b6de563b3d158016848d724bb2f3cb0e5e35b1a5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 100ca07e97d514fe1e99ac7ae11c0ef8ca81806747c170b770adc79df78e8a6e9a991b574b845af891a8d6317cf3c3aacec0dc007e799384217aa7b19a947896
|
7
|
+
data.tar.gz: 5c9c4a4bc461672499a24a40d83b00afdec6d840f93082ddc2a334888eaf4bfdc53c2b8d7fad6e082eb9ed996bc087b8c7ea58cab884b88e33a58b22396b8834
|
data/.gitignore
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
log
|
2
|
+
db/
|
3
|
+
|
4
|
+
.idea/
|
5
|
+
config/index.html
|
6
|
+
config/config.json
|
7
|
+
|
8
|
+
# cache files for sublime text
|
9
|
+
*.tmlanguage.cache
|
10
|
+
*.tmPreferences.cache
|
11
|
+
*.stTheme.cache
|
12
|
+
|
13
|
+
# workspace files are user-specific
|
14
|
+
*.sublime-workspace
|
15
|
+
|
16
|
+
# project files should be checked into the repository, unless a significant
|
17
|
+
# proportion of contributors will probably not be using SublimeText
|
18
|
+
*.sublime-project
|
19
|
+
|
20
|
+
# sftp configuration file
|
21
|
+
sftp-config.json
|
data/README.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
This is Ruby App collects the information you need (currency, new torrents, etc) from various web sites.
|
2
|
+
|
3
|
+
Main features:
|
4
|
+
- local SQlite3 database to store history info
|
5
|
+
- devices notification over PushBullet service
|
6
|
+
- recent information visualization via html
|
7
|
+
- flexible configuration using json file
|
8
|
+
|
9
|
+
Currently available web site notificattions:
|
10
|
+
- http://minfin.com.ua - UAH/USD currency
|
11
|
+
- http://micex.ru/ - RUB/USD currency
|
12
|
+
- http://dou.ua/ - new IT job opportunities
|
13
|
+
- http://kinozal.tv/ - new movies available on torrent
|
14
|
+
- http://news.yandex.ru/ - Breny Oil rate
|
15
|
+
|
16
|
+
As the example (app reloads index.html file that is shared thought Google Drive):
|
17
|
+
www.googledrive.com/host/0Byb1mtPn4ZEAVm9zTUJQbHM2U0U
|
data/Rakefile
ADDED
data/bin/dailyrep
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
p "Daily rep stared at #{Time.now}"
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'active_record'
|
6
|
+
require 'json'
|
7
|
+
require 'hashdiff'
|
8
|
+
|
9
|
+
Dir.chdir(File.expand_path(File.dirname(__FILE__)))
|
10
|
+
|
11
|
+
CONFIG_FILE = '../config/config.json'
|
12
|
+
if not File.exist?(CONFIG_FILE) then
|
13
|
+
p "Please create config.json file \n For more info: https://github.com/yurii-kurylenko/DailyRep"
|
14
|
+
abort "config.json is missing"
|
15
|
+
end
|
16
|
+
|
17
|
+
DATABASE = '../db/db.sql3' #sets production/development database
|
18
|
+
|
19
|
+
require_relative '../lib/dailyrep/Loadconfig.rb'
|
20
|
+
# require_relative '../lib/dailyrep/IBrowser'
|
21
|
+
# require_relative '../lib/dailyrep/Micex'
|
22
|
+
# require_relative '../lib/dailyrep/IndexWriter'
|
23
|
+
# require_relative '../lib/dailyrep/Doujob'
|
24
|
+
# require_relative '../lib/dailyrep/Kinozal'
|
25
|
+
# require_relative '../lib/dailyrep/Yanoil'
|
26
|
+
# require_relative '../lib/dailyrep/Minfin'
|
27
|
+
|
28
|
+
require_relative '../lib/dailyrep/AppContainer'
|
29
|
+
|
30
|
+
|
31
|
+
#creating tracking objects container
|
32
|
+
@app_container = DailyRep::AppContainer.new
|
33
|
+
#create index writer object
|
34
|
+
@app_container.start!
|
35
|
+
#tracking objects preparing
|
36
|
+
@app_container.write_html
|
37
|
+
#starts
|
38
|
+
@app_container.start!
|
39
|
+
#write html changes to index.html
|
40
|
+
|
41
|
+
|
42
|
+
p "Finished at #{Time.now}!. Has been ran for #{(Time.now - DailyRep::START_TIME).round(2)} seconds"
|
data/config/.gitkeep
ADDED
File without changes
|
@@ -0,0 +1,57 @@
|
|
1
|
+
{
|
2
|
+
"Vesrion": "1.1.0",
|
3
|
+
"Push clients":{
|
4
|
+
// In this line you should add your app token from pushbullet service
|
5
|
+
"username": "user token"
|
6
|
+
},
|
7
|
+
"Raise errors": "true",
|
8
|
+
"Push title": "DailyRep notification",
|
9
|
+
"Index path": "./index.html",
|
10
|
+
"app_cycle": {
|
11
|
+
"write_to_db": "true",
|
12
|
+
"notify": "false",
|
13
|
+
"web_reload": "true",
|
14
|
+
"write_html": "true"
|
15
|
+
},
|
16
|
+
"Entities": {
|
17
|
+
"micex": {
|
18
|
+
"source": "http://www.micex.ru/issrpc/marketdata/currency/selt/daily/short/result.json?boardid=CETS&secid=USD000UTSTOM",
|
19
|
+
"enabled": "true",
|
20
|
+
"time frame": "0..23",
|
21
|
+
"delta": "3"
|
22
|
+
},
|
23
|
+
"doujob": {
|
24
|
+
"source": "http://jobs.dou.ua/vacancies/?search=",
|
25
|
+
"enabled": "true",
|
26
|
+
"time frame": "0..23",
|
27
|
+
"searchStr": [
|
28
|
+
"Ruby"
|
29
|
+
]
|
30
|
+
},
|
31
|
+
"kinozal": {
|
32
|
+
"source": "http://kinozal.tv/browse.php?s=",
|
33
|
+
"enabled": "true",
|
34
|
+
"time frame": "0..23",
|
35
|
+
"filters": "&g=0&c=0&v=3&d=0&w=0&t=0&f=0",
|
36
|
+
"searchStr": [
|
37
|
+
"Hobbit Battle",
|
38
|
+
"Interstellar",
|
39
|
+
"Seventh Son",
|
40
|
+
"Paddington",
|
41
|
+
"American Sniper"
|
42
|
+
]
|
43
|
+
},
|
44
|
+
"yanoil": {
|
45
|
+
"source": "http://news.yandex.ru/quotes/1006.html",
|
46
|
+
"enabled": "true",
|
47
|
+
"time frame": "0..23",
|
48
|
+
"delta": "0.05"
|
49
|
+
},
|
50
|
+
"minfin": {
|
51
|
+
"source": "http://minfin.com.ua/currency/mb/",
|
52
|
+
"enabled": "true",
|
53
|
+
"time frame": "0..23",
|
54
|
+
"delta": "2"
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}
|
@@ -0,0 +1,189 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
|
5
|
+
<title>
|
6
|
+
Daily Report
|
7
|
+
</title>
|
8
|
+
<style type="text/css">
|
9
|
+
.content {
|
10
|
+
margin-top: 5em;
|
11
|
+
margin-left: 2em;
|
12
|
+
margin-right: 2em;
|
13
|
+
}
|
14
|
+
a span {
|
15
|
+
font-weight: bold;
|
16
|
+
}
|
17
|
+
</style>
|
18
|
+
</head>
|
19
|
+
<body>
|
20
|
+
<header class="navbar navbar-inverse navbar-fixed-top bs-docs-nav" role="banner">
|
21
|
+
<div class="container">
|
22
|
+
<div class="navbar-header">
|
23
|
+
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".bs-navbar-collapse">
|
24
|
+
<span class="sr-only">Toggle navigation</span>
|
25
|
+
<span class="icon-bar"></span>
|
26
|
+
<span class="icon-bar"></span>
|
27
|
+
<span class="icon-bar"></span>
|
28
|
+
</button>
|
29
|
+
<a href="./" class="navbar-brand">Daily Report</a>
|
30
|
+
</div>
|
31
|
+
<nav class="collapse navbar-collapse bs-navbar-collapse" role="navigation">
|
32
|
+
<ul class="nav navbar-nav">
|
33
|
+
<li>
|
34
|
+
<a href="#">Last refresh:
|
35
|
+
<span class="badge" id="refresh">2015-01-25 12:54:07 +0200</span>
|
36
|
+
</a>
|
37
|
+
</li>
|
38
|
+
<li>
|
39
|
+
<a href="#">App version:
|
40
|
+
<span id="vesrion">1.0.0</span>
|
41
|
+
</a>
|
42
|
+
</li>
|
43
|
+
<li>
|
44
|
+
<a href="#"> Written by Yurii Kurylenko</a>
|
45
|
+
</li>
|
46
|
+
</ul>
|
47
|
+
</nav>
|
48
|
+
</div>
|
49
|
+
</header>
|
50
|
+
<div class="content">
|
51
|
+
<div class="row">
|
52
|
+
<div class="col-md-6">
|
53
|
+
<div class="row">
|
54
|
+
<div class="col-md-6">
|
55
|
+
<div class="panel panel-primary">
|
56
|
+
<div class="panel-heading">
|
57
|
+
<h3 class="panel-title">Micex USD/RUB rate</h3>
|
58
|
+
</div>
|
59
|
+
<div class="panel-body">
|
60
|
+
<div class="list-group">
|
61
|
+
<a class="list-group-item" href="#">
|
62
|
+
Current value:
|
63
|
+
<span id="micex_last">64.1605</span>
|
64
|
+
</a>
|
65
|
+
<a class="list-group-item" href="#">
|
66
|
+
Open value:
|
67
|
+
<span id="micex_open">63.7515</span>
|
68
|
+
</a>
|
69
|
+
<a class="list-group-item" href="#">
|
70
|
+
Delta percent:
|
71
|
+
<span id="micex_delta" class="val_color">0.64</span>
|
72
|
+
</a>
|
73
|
+
</div>
|
74
|
+
</div>
|
75
|
+
<div class="panel-footer">
|
76
|
+
<div>
|
77
|
+
Refreshed: <span class="badge" id="micex_refresh">2015-01-25 12:54:05 +0200</span>
|
78
|
+
</div>
|
79
|
+
<div>
|
80
|
+
Last notified:<span class="badge" id="micex_notif">2015-01-13 16:00:26 +0200</span>
|
81
|
+
</div>
|
82
|
+
</div>
|
83
|
+
</div>
|
84
|
+
</div>
|
85
|
+
<div class="col-md-6">
|
86
|
+
<div class="panel panel-primary">
|
87
|
+
<div class="panel-heading">
|
88
|
+
<h3 class="panel-title">Minfin UAH/USD rate</h3>
|
89
|
+
</div>
|
90
|
+
<div class="panel-body">
|
91
|
+
<div class="list-group">
|
92
|
+
<a class="list-group-item" href="#">
|
93
|
+
Current value:
|
94
|
+
<span id="minfin_current">20.8500</span>
|
95
|
+
</a>
|
96
|
+
<a class="list-group-item" href="#">
|
97
|
+
Delta percent:
|
98
|
+
<span id="minfin_delta" class="val_color">0.0</span>
|
99
|
+
</a>
|
100
|
+
</div>
|
101
|
+
</div>
|
102
|
+
<div class="panel-footer">
|
103
|
+
<div>
|
104
|
+
Refreshed: <span class="badge" id="minfin_refresh">2015-01-25 12:54:05 +0200</span>
|
105
|
+
</div>
|
106
|
+
</div>
|
107
|
+
</div>
|
108
|
+
</div>
|
109
|
+
</div>
|
110
|
+
<div class="row">
|
111
|
+
<div class="col-md-6">
|
112
|
+
<div class="panel panel-primary">
|
113
|
+
<div class="panel-heading">
|
114
|
+
<h3 class="panel-title">Brent oil rate</h3>
|
115
|
+
</div>
|
116
|
+
<div class="panel-body">
|
117
|
+
<div class="list-group">
|
118
|
+
<a class="list-group-item" href="#">
|
119
|
+
Current value:
|
120
|
+
<span id="yanoil_current">48.55</span>
|
121
|
+
</a>
|
122
|
+
<a class="list-group-item" href="#">
|
123
|
+
Delta percent:
|
124
|
+
<span id="yanoil_delta" class="val_color">-0.27</span>
|
125
|
+
</a>
|
126
|
+
</div>
|
127
|
+
</div>
|
128
|
+
<div class="panel-footer">
|
129
|
+
<div>
|
130
|
+
Refreshed: <span class="badge" id="yanoil_refresh">2015-01-25 12:54:05 +0200</span>
|
131
|
+
</div>
|
132
|
+
</div>
|
133
|
+
</div>
|
134
|
+
</div>
|
135
|
+
</div>
|
136
|
+
</div>
|
137
|
+
<div class="col-md-3">
|
138
|
+
<div class="panel panel-primary">
|
139
|
+
<div class="panel-heading">
|
140
|
+
<h3 class="panel-title">New Movies</h3>
|
141
|
+
</div>
|
142
|
+
<div id="kinozal" class="panel-body">
|
143
|
+
<div class="list-group"></div>
|
144
|
+
</div>
|
145
|
+
<div class="panel-footer">
|
146
|
+
<div>
|
147
|
+
Refreshed: <span class="badge" id="kinozal_refresh">2015-01-25 12:54:06 +0200</span>
|
148
|
+
</div>
|
149
|
+
</div>
|
150
|
+
</div>
|
151
|
+
</div>
|
152
|
+
<div class="col-md-3">
|
153
|
+
<div class="panel panel-primary">
|
154
|
+
<div class="panel-heading">
|
155
|
+
<h3 class="panel-title">Dou vacancies</h3>
|
156
|
+
</div>
|
157
|
+
<div id="doujobs" class="panel-body">
|
158
|
+
<div class="list-group"></div>
|
159
|
+
</div>
|
160
|
+
<div class="panel-footer">
|
161
|
+
<div>
|
162
|
+
Refreshed:
|
163
|
+
<span id="doujob_refresh" class="badge">2015-01-25 12:54:07 +0200</span>
|
164
|
+
</div>
|
165
|
+
</div>
|
166
|
+
</div>
|
167
|
+
</div>
|
168
|
+
</div>
|
169
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
|
170
|
+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
|
171
|
+
<script>
|
172
|
+
(function() {
|
173
|
+
return $(".list-group-item .val_color").each((function(_this) {
|
174
|
+
return function(index, element) {
|
175
|
+
var float, str;
|
176
|
+
str = $(element).text();
|
177
|
+
float = parseFloat(str);
|
178
|
+
if (float > 0) {
|
179
|
+
return $(element).css("color", "green");
|
180
|
+
} else {
|
181
|
+
return $(element).css("color", "red");
|
182
|
+
}
|
183
|
+
};
|
184
|
+
})(this));
|
185
|
+
})();
|
186
|
+
</script>
|
187
|
+
</div>
|
188
|
+
</body>
|
189
|
+
</html>
|
data/dailyrep.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
require "dailyrep/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'dailyrep'
|
7
|
+
s.licenses = ['MIT']
|
8
|
+
s.version = DailyRep::VERSION
|
9
|
+
s.summary = "Ruby app that provides values checking on particular websites and performs notification"
|
10
|
+
s.description = File.read(File.join(File.dirname(__FILE__), 'README.md'))
|
11
|
+
s.authors = "Yurii Kurylenko"
|
12
|
+
s.email = "yuriy.kurilenko7@gmail.com"
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test}/*`.split("\n")
|
16
|
+
s.executables = ['dailyrep']
|
17
|
+
|
18
|
+
s.add_dependency "hashdiff", ">= 0.0.2"
|
19
|
+
s.add_dependency "activerecord"
|
20
|
+
s.add_dependency "sqlite3"
|
21
|
+
s.add_dependency "rake"
|
22
|
+
s.add_dependency "nokogiri"
|
23
|
+
s.add_dependency "washbullet"
|
24
|
+
|
25
|
+
|
26
|
+
s.required_ruby_version = '>=2.0'
|
27
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative 'IBrowser'
|
2
|
+
Dir["../lib/dailyrep/entities/*.rb"].each {|file|require file }
|
3
|
+
|
4
|
+
module DailyRep
|
5
|
+
class AppContainer
|
6
|
+
def initialize
|
7
|
+
@track_array = []
|
8
|
+
Configer.enabled_entities.each { |entity|
|
9
|
+
@track_array.concat(DailyRep::Entities::const_get(entity.capitalize).create)
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
def start!
|
15
|
+
#all objects running
|
16
|
+
@track_array.each { |obj|
|
17
|
+
obj.run
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def write_html
|
22
|
+
IBrowser.write_html if Configer.is_phase_enabled? "write_html"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module DailyRep
|
2
|
+
module Changable
|
3
|
+
def track_change value, delta
|
4
|
+
value = value.to_f
|
5
|
+
delta = delta.to_f
|
6
|
+
push = 0
|
7
|
+
if value.abs > delta then
|
8
|
+
a_r_out = self.check_history_notif(self.entity.to_s, :delta.to_s)
|
9
|
+
if a_r_out.nil? then
|
10
|
+
push = 1
|
11
|
+
else
|
12
|
+
if (a_r_out.to_f - value).abs > delta.to_i then
|
13
|
+
push = 1
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
return push
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module DailyRep
|
2
|
+
module Dbops
|
3
|
+
def check_history_notif entity, parameter, timescope=(Time.now - 6.hour)
|
4
|
+
sql = History.select("val").where(entity: entity, parameter: parameter, notified: 'Y').where('created_at > ?', timescope).order('id desc').first
|
5
|
+
if !sql.nil? then
|
6
|
+
sql.val
|
7
|
+
else
|
8
|
+
nil
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def check_row_exists entity, parameter, val, timescope=(Time.now - 99.years)
|
13
|
+
count = History.where(entity: entity, parameter: parameter, val: val).where('created_at > ?', timescope).count
|
14
|
+
if count == 0 then false else true end
|
15
|
+
end
|
16
|
+
|
17
|
+
def write_hist entity, parameter, val, notified=0
|
18
|
+
case notified
|
19
|
+
when 1 then
|
20
|
+
notified = 'Y'
|
21
|
+
else
|
22
|
+
notified = 'N'
|
23
|
+
end
|
24
|
+
History.create(entity: entity, parameter: parameter, val: val, notified: notified)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|