rpush_webui 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.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/config/rpush.rb +129 -0
- data/lib/models/notifications.rb +29 -0
- data/lib/public/webui.js +57 -0
- data/lib/rpush_webui.rb +4 -0
- data/lib/rpush_webui/version.rb +3 -0
- data/lib/views/index.slim +6 -0
- data/lib/views/layout.slim +11 -0
- data/lib/webui.rb +18 -0
- data/rpush_webui.gemspec +36 -0
- data/spec/factories/app.rb +7 -0
- data/spec/factories/notification.rb +42 -0
- data/spec/factories/sequences.rb +9 -0
- data/spec/models/notifications_spec.rb +45 -0
- data/spec/spec_helper.rb +26 -0
- data/spec/webui_spec.rb +20 -0
- metadata +252 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fc4a04094fcfebaff4a2cf3d7908945f67abe33a
|
4
|
+
data.tar.gz: 1027940d63d63e43d03f858f1daac773c94ca6ce
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0034d92d68a83c26585c71a8226a26508ecb5aabebb5ffbb390904661718b92b52cc57d5688eefa968b966557dc80c8119357dc1c7e61ad7d7a735fc66514724
|
7
|
+
data.tar.gz: 7ee363cb78f34f20b9105ca8b32bf14f8c1b15b9ad4d7463878a077cfc583b26c62c9a04ea1a97e294c1fb0ee82749cf71a87f8e4e926ffa3e0f70aa3fe67eef
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Nikolay Murzin
|
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,31 @@
|
|
1
|
+
# RpushWebui
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'rpush_webui'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install rpush_webui
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/rpush_webui/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/config/rpush.rb
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
Rpush.configure do |config|
|
2
|
+
|
3
|
+
# Supported clients are :active_record and :redis.
|
4
|
+
config.client = :redis
|
5
|
+
|
6
|
+
# Options passed to Redis.new
|
7
|
+
# config.redis_options = {}
|
8
|
+
|
9
|
+
# Frequency in seconds to check for new notifications.
|
10
|
+
config.push_poll = 2
|
11
|
+
|
12
|
+
# Frequency in seconds to check for feedback
|
13
|
+
config.feedback_poll = 60
|
14
|
+
|
15
|
+
# The maximum number of notifications to load from the store every `push_poll` seconds.
|
16
|
+
# If some notifications are still enqueued internally, Rpush will load the batch_size less
|
17
|
+
# the number enqueued. An exception to this is if the service is able to receive multiple
|
18
|
+
# notification payloads over the connection with a single write, such as APNs.
|
19
|
+
config.batch_size = 100
|
20
|
+
|
21
|
+
# Path to write PID file. Relative to current directory unless absolute.
|
22
|
+
config.pid_file = 'tmp/rpush.pid'
|
23
|
+
|
24
|
+
# Path to log file. Relative to current directory unless absolute.
|
25
|
+
config.log_file = 'log/rpush.log'
|
26
|
+
|
27
|
+
config.log_level = (defined?(Rails) && Rails.logger) ? Rails.logger.level : ::Logger::Severity::INFO
|
28
|
+
|
29
|
+
# Define a custom logger.
|
30
|
+
# config.logger = MyLogger.new
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
Rpush.reflect do |on|
|
35
|
+
|
36
|
+
# Called with a Rpush::Apns::Feedback instance when feedback is received
|
37
|
+
# from the APNs that a notification has failed to be delivered.
|
38
|
+
# Further notifications should not be sent to the device.
|
39
|
+
# on.apns_feedback do |feedback|
|
40
|
+
# end
|
41
|
+
|
42
|
+
# Called when a notification is queued internally for delivery.
|
43
|
+
# The internal queue for each app runner can be inspected:
|
44
|
+
#
|
45
|
+
# Rpush::Daemon::AppRunner.runners.each do |app_id, runner|
|
46
|
+
# runner.app
|
47
|
+
# runner.queue_size
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
# on.notification_enqueued do |notification|
|
51
|
+
# end
|
52
|
+
|
53
|
+
# Called when a notification is successfully delivered.
|
54
|
+
# on.notification_delivered do |notification|
|
55
|
+
# end
|
56
|
+
|
57
|
+
# Called when notification delivery failed.
|
58
|
+
# Call 'error_code' and 'error_description' on the notification for the cause.
|
59
|
+
# on.notification_failed do |notification|
|
60
|
+
# end
|
61
|
+
|
62
|
+
# Called when the notification delivery failed and only the notification ID
|
63
|
+
# is present in memory.
|
64
|
+
# on.notification_id_failed do |app, notification_id, error_code, error_description|
|
65
|
+
# end
|
66
|
+
|
67
|
+
# Called when a notification will be retried at a later date.
|
68
|
+
# Call 'deliver_after' on the notification for the next delivery date
|
69
|
+
# and 'retries' for the number of times this notification has been retried.
|
70
|
+
# on.notification_will_retry do |notification|
|
71
|
+
# end
|
72
|
+
|
73
|
+
# Called when a notification will be retried and only the notification ID
|
74
|
+
# is present in memory.
|
75
|
+
# on.notification_id_will_retry do |app, notification_id, retry_after|
|
76
|
+
# end
|
77
|
+
|
78
|
+
# Called when a TCP connection is lost and will be reconnected.
|
79
|
+
# on.tcp_connection_lost do |app, error|
|
80
|
+
# end
|
81
|
+
|
82
|
+
# Called for each recipient which successfully receives a notification. This
|
83
|
+
# can occur more than once for the same notification when there are multiple
|
84
|
+
# recipients.
|
85
|
+
# on.gcm_delivered_to_recipient do |notification, registration_id|
|
86
|
+
# end
|
87
|
+
|
88
|
+
# Called for each recipient which fails to receive a notification. This
|
89
|
+
# can occur more than once for the same notification when there are multiple
|
90
|
+
# recipients. (do not handle invalid registration IDs here)
|
91
|
+
# on.gcm_failed_to_recipient do |notification, error, registration_id|
|
92
|
+
# end
|
93
|
+
|
94
|
+
# Called when the GCM returns a canonical registration ID.
|
95
|
+
# You will need to replace old_id with canonical_id in your records.
|
96
|
+
# on.gcm_canonical_id do |old_id, canonical_id|
|
97
|
+
# end
|
98
|
+
|
99
|
+
# Called when the GCM returns a failure that indicates an invalid registration id.
|
100
|
+
# You will need to delete the registration_id from your records.
|
101
|
+
# on.gcm_invalid_registration_id do |app, error, registration_id|
|
102
|
+
# end
|
103
|
+
|
104
|
+
# Called when an SSL certificate will expire within 1 month.
|
105
|
+
# Implement on.error to catch errors raised when the certificate expires.
|
106
|
+
# on.ssl_certificate_will_expire do |app, expiration_time|
|
107
|
+
# end
|
108
|
+
|
109
|
+
# Called when an SSL certificate has been revoked.
|
110
|
+
# on.ssl_certificate_revoked do |app, error|
|
111
|
+
# end
|
112
|
+
|
113
|
+
# Called when the ADM returns a canonical registration ID.
|
114
|
+
# You will need to replace old_id with canonical_id in your records.
|
115
|
+
# on.adm_canonical_id do |old_id, canonical_id|
|
116
|
+
# end
|
117
|
+
|
118
|
+
# Called when Failed to deliver to ADM. Check the 'reason' string for further
|
119
|
+
# explanations.
|
120
|
+
#
|
121
|
+
# If the reason is the string 'Unregistered', you should remove
|
122
|
+
# this registration id from your records.
|
123
|
+
# on.adm_failed_to_recipient do |notification, registration_id, reason|
|
124
|
+
# end
|
125
|
+
|
126
|
+
# Called when an exception is raised.
|
127
|
+
# on.error do |error|
|
128
|
+
# end
|
129
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rpush'
|
2
|
+
load 'config/rpush.rb'
|
3
|
+
|
4
|
+
class Hash
|
5
|
+
def map_value
|
6
|
+
self.map { |k,v| {k => yield(v)} }.reduce(:merge)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Notifications
|
11
|
+
|
12
|
+
def initialize(**options)
|
13
|
+
@dt = options[:dt]
|
14
|
+
@start_at = options[:start_at]
|
15
|
+
@finish_at = options[:finish_at]
|
16
|
+
@notifications = Rpush::Notification.all
|
17
|
+
end
|
18
|
+
|
19
|
+
def data
|
20
|
+
fetch = -> a { a['delivered'] ? [true, a['delivered_at']] : [false, a['failed_at']] }
|
21
|
+
@notifications
|
22
|
+
.map(&:attributes)
|
23
|
+
.map(&fetch)
|
24
|
+
.select { |_,d| d.to_i >= @start_at.to_i && d.to_i <= @finish_at.to_i }
|
25
|
+
.group_by { |_,d| (d.to_i - @start_at.to_i) / @dt.to_i }
|
26
|
+
.map_value { |g| {true => 0, false => 0}.merge g.group_by(&:first).map_value(&:size) }
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/lib/public/webui.js
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
// Load the Visualization API and the piechart package.
|
2
|
+
google.load('visualization', '1.0', {'packages':['corechart']});
|
3
|
+
|
4
|
+
// Set a callback to run when the Google Visualization API is loaded.
|
5
|
+
google.setOnLoadCallback(init);
|
6
|
+
|
7
|
+
|
8
|
+
// Callback that creates and populates a data table,
|
9
|
+
// instantiates the pie chart, passes in the data and
|
10
|
+
// draws it.
|
11
|
+
function init() {
|
12
|
+
$('button#plot').click(function() {
|
13
|
+
|
14
|
+
var start_at = $('#start_at').val();
|
15
|
+
var finish_at = $('#finish_at').val();
|
16
|
+
var dt = $('#dt').val();
|
17
|
+
|
18
|
+
var chart_data = [];
|
19
|
+
|
20
|
+
var uri = '/data/' + start_at + '/' + finish_at + '/' + dt;
|
21
|
+
|
22
|
+
$.getJSON(uri, function( data ) {
|
23
|
+
|
24
|
+
$.each( data, function( key, val ) {
|
25
|
+
chart_data.push([parseInt(key),parseInt(val['true']),parseInt(val['false'])]);
|
26
|
+
});
|
27
|
+
|
28
|
+
// Create the data table.
|
29
|
+
var data = google.visualization.arrayToDataTable(
|
30
|
+
[["Time", "Delivered", "Failed"]].concat(chart_data)
|
31
|
+
);
|
32
|
+
|
33
|
+
var view = new google.visualization.DataView(data);
|
34
|
+
view.setColumns([0, 1,
|
35
|
+
{ calc: "stringify",
|
36
|
+
sourceColumn: 1,
|
37
|
+
type: "string",
|
38
|
+
role: "annotation" },
|
39
|
+
2]);
|
40
|
+
|
41
|
+
// Set chart options
|
42
|
+
var options = {
|
43
|
+
width: 600,
|
44
|
+
height: 400,
|
45
|
+
legend: { position: 'top', maxLines: 3 },
|
46
|
+
bar: { groupWidth: '75%' },
|
47
|
+
isStacked: true,
|
48
|
+
};
|
49
|
+
|
50
|
+
// Instantiate and draw our chart, passing in some options.
|
51
|
+
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
|
52
|
+
chart.draw(view, options);
|
53
|
+
});
|
54
|
+
});
|
55
|
+
};
|
56
|
+
|
57
|
+
|
data/lib/rpush_webui.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
doctype html
|
2
|
+
html
|
3
|
+
head
|
4
|
+
meta charset="utf-8"
|
5
|
+
title Rpush WebUI
|
6
|
+
script type="text/javascript" src="https://www.google.com/jsapi"
|
7
|
+
script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
|
8
|
+
script type="text/javascript" src="webui.js"
|
9
|
+
body
|
10
|
+
h1 Rpush WebUI
|
11
|
+
== yield
|
data/lib/webui.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'slim'
|
2
|
+
require 'sinatra'
|
3
|
+
require 'sinatra/json'
|
4
|
+
require_relative 'models/notifications'
|
5
|
+
|
6
|
+
set :port, 8080
|
7
|
+
|
8
|
+
get '/' do
|
9
|
+
slim :index
|
10
|
+
end
|
11
|
+
|
12
|
+
get '/data/:start_at/:finish_at/:to' do
|
13
|
+
start_at = params[:start_at] ? Time.parse(params[:start_at]) : 3.seconds.ago
|
14
|
+
finish_at = params[:finish_at] ? Time.parse(params[:finish_at]) : 0.seconds.ago
|
15
|
+
dt = params[:dt] ? params[:dt].to_i.seconds : 1.second
|
16
|
+
notifications = Notifications.new dt: dt, start_at: start_at, finish_at: finish_at
|
17
|
+
json notifications.data
|
18
|
+
end
|
data/rpush_webui.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rpush_webui/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rpush_webui"
|
8
|
+
spec.version = RpushWebui::VERSION
|
9
|
+
spec.authors = ["Nikolay Murzin"]
|
10
|
+
spec.email = ["murzin.nikolay@gmail.com"]
|
11
|
+
spec.summary = %q{WebUI for Rpush}
|
12
|
+
spec.description = %q{Plots of push notifications.}
|
13
|
+
spec.homepage = "http://github.com/sw1sh/rpush_webui"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.2'
|
25
|
+
spec.add_development_dependency 'rspec-mocks', '~> 3.2'
|
26
|
+
spec.add_development_dependency 'rspec-its', '~> 1.1'
|
27
|
+
spec.add_development_dependency "factory_girl", "~> 4.0"
|
28
|
+
spec.add_development_dependency 'rack-test', '~> 0.6'
|
29
|
+
spec.add_development_dependency 'fakeredis', '~> 0.5'
|
30
|
+
|
31
|
+
spec.add_dependency 'rpush', '~> 2.3'
|
32
|
+
spec.add_dependency 'rpush-redis', '~> 0.4'
|
33
|
+
spec.add_dependency 'sinatra', '~> 1.4'
|
34
|
+
spec.add_dependency 'sinatra-contrib', '~> 1.4'
|
35
|
+
spec.add_dependency 'slim', '~> 3.0'
|
36
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#:id => 4335,
|
2
|
+
# :badge => nil,
|
3
|
+
# :device_token => nil,
|
4
|
+
# :sound => "default",
|
5
|
+
# :alert => nil,
|
6
|
+
# :data => {
|
7
|
+
# "title" => "513 Hi, Test! 1"
|
8
|
+
# },
|
9
|
+
# :expiry => 86400,
|
10
|
+
# :delivered => true,
|
11
|
+
# :delivered_at => Fri, 06 Feb 2015 17:46:55 MSK +03:00,
|
12
|
+
# :failed => false,
|
13
|
+
# :failed_at => nil,
|
14
|
+
# :error_code => nil,
|
15
|
+
# :error_description => nil,
|
16
|
+
# :deliver_after => nil,
|
17
|
+
# :created_at => Fri, 06 Feb 2015 17:46:53 MSK +03:00,
|
18
|
+
# :updated_at => Fri, 06 Feb 2015 17:46:53 MSK +03:00,
|
19
|
+
# :alert_is_json => false,
|
20
|
+
# :type => "Rpush::Client::ActiveRecord::Gcm::Notification",
|
21
|
+
# :collapse_key => nil,
|
22
|
+
# :delay_while_idle => false,
|
23
|
+
# :registration_ids => [
|
24
|
+
# [0] "APA91bFzGijid6cWIHHDxm0EbGWN0JyPh0srCL08v-0lDYbvjIiT3YHzyL-n2PeZpTAYMgfa4GZAeypV2jRetEiUQPpYTPsNgRJMiUqBGmnIcP2WVL2cvudb0CxMfFcCcJBx6_RNOG4XaZEu7zm89WXt3BoRxPyVjw",
|
25
|
+
# [1] "APA91bELbYIiVc6hk2F750HJLOodivg58MfynT0DVxXWLRXuMElZ1qao3380EtSZhBRhAFagw3ECN_NmFpnau3hayCOP8E9urmM_3jB3wzA2Y3xkUrtLMzKduYFgQ89bzPrzqveH6g1GMQCc4QP1L0yfqNbtC8pvNg",
|
26
|
+
# [2] "APA91bHJcJ6NpYxmRR9mjbGxJBv0RecsSgI2deVt3BZDcCXnJKB36Tx3fiNhKrgHPuCXyIpXDAUVMiVhZtaIm76gYpWHhMaKeqaByAhMN7rkRw4BeQODrYiV5GycXokDH9UjmxsfscKKmIM4Trr77req3XWt4Eb_eg"
|
27
|
+
# ],
|
28
|
+
# :app_id => 3,
|
29
|
+
# :retries => 0,
|
30
|
+
# :uri => nil,
|
31
|
+
# :fail_after => nil,
|
32
|
+
# :processing => false,
|
33
|
+
# :priority => nil,
|
34
|
+
# :url_args => nil,
|
35
|
+
# :category => nil
|
36
|
+
FactoryGirl.define do
|
37
|
+
factory :rpush_gcm_notification, class: 'Rpush::Gcm::Notification' do
|
38
|
+
registration_ids { generate :registration_ids }
|
39
|
+
association :app, factory: :rpush_gcm_app
|
40
|
+
data { generate :gcm_data }
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
sequence :registration_ids do |n|
|
3
|
+
["APA91bFzGijid6cWIHHDxm0EbGWN0JyPh0srCL08v-0lDYbvjIiT3YHzyL-n2PeZpTAYMgfa4GZAeypV2jRetEiUQPpYTPsNgRJMiUqBGmnIcP2WVL2cvudb0CxMfFcCcJBx6_RNOG4XaZEu7zm89WXt3BoRxPyVjw"]
|
4
|
+
end
|
5
|
+
|
6
|
+
sequence :gcm_data do |n|
|
7
|
+
{ title: "title_#{n}", text: "text_#{n}" }
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'models/notifications'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Notifications do
|
5
|
+
|
6
|
+
let!(:start_at) { 3.seconds.ago }
|
7
|
+
let!(:finish_at) { start_at + 3.seconds }
|
8
|
+
|
9
|
+
let(:notifications) {
|
10
|
+
[[0, true],
|
11
|
+
[1, true],
|
12
|
+
[1, true],
|
13
|
+
[1, true],
|
14
|
+
[2, true],
|
15
|
+
[2, true],
|
16
|
+
[2, true],
|
17
|
+
[0, false],
|
18
|
+
[1, false],
|
19
|
+
[2, false],
|
20
|
+
[3, false]]
|
21
|
+
}
|
22
|
+
|
23
|
+
before do
|
24
|
+
notifications.each do |seconds, is_delivered|
|
25
|
+
if is_delivered
|
26
|
+
create :rpush_gcm_notification, delivered_at: start_at + seconds,
|
27
|
+
delivered: is_delivered
|
28
|
+
else
|
29
|
+
create :rpush_gcm_notification, failed_at: start_at + seconds,
|
30
|
+
delivered: is_delivered
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
subject { Notifications.new dt: 1.second, start_at: start_at, finish_at: finish_at }
|
36
|
+
|
37
|
+
let(:expected_data) {
|
38
|
+
{ 0 => {true => 1, false => 1}, 1 => {true => 3, false => 1},
|
39
|
+
2 => {true => 3, false => 1}, 3 => {true => 0, false => 1} }
|
40
|
+
}
|
41
|
+
|
42
|
+
its(:data) { is_expected.to eq(expected_data) }
|
43
|
+
|
44
|
+
|
45
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rpush'
|
2
|
+
load 'config/rpush.rb'
|
3
|
+
|
4
|
+
require 'rspec/core'
|
5
|
+
require 'fakeredis'
|
6
|
+
require 'rspec/its'
|
7
|
+
require 'rack/test'
|
8
|
+
require 'factory_girl'
|
9
|
+
|
10
|
+
require 'factories/notification'
|
11
|
+
require 'factories/sequences'
|
12
|
+
require 'factories/app'
|
13
|
+
|
14
|
+
RSpec.configure do |config|
|
15
|
+
config.include FactoryGirl::Syntax::Methods
|
16
|
+
config.include Rack::Test::Methods
|
17
|
+
|
18
|
+
config.after { Redis.new.flushdb }
|
19
|
+
|
20
|
+
config.raise_errors_for_deprecations!
|
21
|
+
|
22
|
+
config.mock_with :rspec
|
23
|
+
|
24
|
+
config.color = true
|
25
|
+
config.order = :random
|
26
|
+
end
|
data/spec/webui_spec.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'webui'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe 'WebUI App' do
|
5
|
+
|
6
|
+
def app
|
7
|
+
Sinatra::Application
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'GET index' do
|
11
|
+
get '/'
|
12
|
+
expect(last_response).to be_ok
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'GET data' do
|
16
|
+
get '/data/2015-02-18,14:00:00/2015-02-18,14:00:10/1'
|
17
|
+
expect(last_response).to be_ok
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,252 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rpush_webui
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nikolay Murzin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-mocks
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.2'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec-its
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.1'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.1'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: factory_girl
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '4.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '4.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rack-test
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.6'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.6'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: fakeredis
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.5'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.5'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rpush
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '2.3'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '2.3'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rpush-redis
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0.4'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0.4'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: sinatra
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '1.4'
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '1.4'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: sinatra-contrib
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '1.4'
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '1.4'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: slim
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '3.0'
|
188
|
+
type: :runtime
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '3.0'
|
195
|
+
description: Plots of push notifications.
|
196
|
+
email:
|
197
|
+
- murzin.nikolay@gmail.com
|
198
|
+
executables: []
|
199
|
+
extensions: []
|
200
|
+
extra_rdoc_files: []
|
201
|
+
files:
|
202
|
+
- ".gitignore"
|
203
|
+
- Gemfile
|
204
|
+
- LICENSE.txt
|
205
|
+
- README.md
|
206
|
+
- Rakefile
|
207
|
+
- config/rpush.rb
|
208
|
+
- lib/models/notifications.rb
|
209
|
+
- lib/public/webui.js
|
210
|
+
- lib/rpush_webui.rb
|
211
|
+
- lib/rpush_webui/version.rb
|
212
|
+
- lib/views/index.slim
|
213
|
+
- lib/views/layout.slim
|
214
|
+
- lib/webui.rb
|
215
|
+
- rpush_webui.gemspec
|
216
|
+
- spec/factories/app.rb
|
217
|
+
- spec/factories/notification.rb
|
218
|
+
- spec/factories/sequences.rb
|
219
|
+
- spec/models/notifications_spec.rb
|
220
|
+
- spec/spec_helper.rb
|
221
|
+
- spec/webui_spec.rb
|
222
|
+
homepage: http://github.com/sw1sh/rpush_webui
|
223
|
+
licenses:
|
224
|
+
- MIT
|
225
|
+
metadata: {}
|
226
|
+
post_install_message:
|
227
|
+
rdoc_options: []
|
228
|
+
require_paths:
|
229
|
+
- lib
|
230
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
231
|
+
requirements:
|
232
|
+
- - ">="
|
233
|
+
- !ruby/object:Gem::Version
|
234
|
+
version: '0'
|
235
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
236
|
+
requirements:
|
237
|
+
- - ">="
|
238
|
+
- !ruby/object:Gem::Version
|
239
|
+
version: '0'
|
240
|
+
requirements: []
|
241
|
+
rubyforge_project:
|
242
|
+
rubygems_version: 2.4.3
|
243
|
+
signing_key:
|
244
|
+
specification_version: 4
|
245
|
+
summary: WebUI for Rpush
|
246
|
+
test_files:
|
247
|
+
- spec/factories/app.rb
|
248
|
+
- spec/factories/notification.rb
|
249
|
+
- spec/factories/sequences.rb
|
250
|
+
- spec/models/notifications_spec.rb
|
251
|
+
- spec/spec_helper.rb
|
252
|
+
- spec/webui_spec.rb
|