status_page_ruby 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +25 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +10 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +61 -0
- data/README.md +53 -0
- data/bin/status-page +6 -0
- data/lib/status_page_ruby.rb +20 -0
- data/lib/status_page_ruby/pages/base.rb +52 -0
- data/lib/status_page_ruby/pages/bitbucket.rb +14 -0
- data/lib/status_page_ruby/pages/cloudflare.rb +29 -0
- data/lib/status_page_ruby/pages/github.rb +19 -0
- data/lib/status_page_ruby/pages/rubygems.rb +14 -0
- data/lib/status_page_ruby/repositories/status.rb +40 -0
- data/lib/status_page_ruby/services/backup_data.rb +15 -0
- data/lib/status_page_ruby/services/build_history_table.rb +32 -0
- data/lib/status_page_ruby/services/build_log_table.rb +14 -0
- data/lib/status_page_ruby/services/build_stats_table.rb +79 -0
- data/lib/status_page_ruby/services/pull_statuses.rb +44 -0
- data/lib/status_page_ruby/services/restore_data.rb +15 -0
- data/lib/status_page_ruby/status.rb +36 -0
- data/lib/status_page_ruby/storage.rb +55 -0
- data/lib/status_page_ruby/version.rb +3 -0
- data/lib/status_page_ruby_cli.rb +76 -0
- data/spec/lib/status_page_ruby/pages/bitbucket_spec.rb +39 -0
- data/spec/lib/status_page_ruby/pages/cloudflare_spec.rb +64 -0
- data/spec/lib/status_page_ruby/pages/github_spec.rb +57 -0
- data/spec/lib/status_page_ruby/pages/rubygems_spec.rb +39 -0
- data/spec/lib/status_page_ruby/repositories/status_spec.rb +124 -0
- data/spec/lib/status_page_ruby/services/backup_data_spec.rb +13 -0
- data/spec/lib/status_page_ruby/services/build_history_table_spec.rb +71 -0
- data/spec/lib/status_page_ruby/services/build_log_table_spec.rb +43 -0
- data/spec/lib/status_page_ruby/services/build_stats_table_spec.rb +72 -0
- data/spec/lib/status_page_ruby/services/pull_statuses_spec.rb +30 -0
- data/spec/lib/status_page_ruby/services/restore_data_spec.rb +13 -0
- data/spec/lib/status_page_ruby/status_spec.rb +65 -0
- data/spec/lib/status_page_ruby/storage_spec.rb +134 -0
- data/spec/spec_helper.rb +15 -0
- data/status_page_ruby.gemspec +22 -0
- metadata +139 -0
@@ -0,0 +1,134 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe StatusPageRuby::Storage do
|
4
|
+
describe '.new' do
|
5
|
+
subject { described_class.new(data_file_path) }
|
6
|
+
let(:data_file_path) { double(to_s: double) }
|
7
|
+
|
8
|
+
before do
|
9
|
+
allow(File).to receive(:file?).with(data_file_path.to_s) { is_file }
|
10
|
+
allow(File).to receive(:readable?).with(data_file_path.to_s) { is_readable }
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'when file valid' do
|
14
|
+
let(:is_file) { true }
|
15
|
+
let(:is_readable) { true }
|
16
|
+
|
17
|
+
it { expect(subject.data_file_path).to eq(data_file_path) }
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'when file invalid' do
|
21
|
+
let(:is_file) { false }
|
22
|
+
let(:is_readable) { false }
|
23
|
+
|
24
|
+
it { expect { subject }.to raise_exception(ArgumentError, 'Invalid file given.') }
|
25
|
+
|
26
|
+
context 'when file is not file' do
|
27
|
+
let(:is_readable) { true }
|
28
|
+
|
29
|
+
it { expect { subject }.to raise_exception(ArgumentError, 'Invalid file given.') }
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'when file is not readable' do
|
33
|
+
let(:is_file) { true }
|
34
|
+
|
35
|
+
it { expect { subject }.to raise_exception(ArgumentError, 'Invalid file given.') }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#include?' do
|
41
|
+
let(:data_file_path) { Tempfile.new('data_file_path').path }
|
42
|
+
|
43
|
+
before { File.write(data_file_path, "a,a,a\n1,1,1\n,,\n") }
|
44
|
+
|
45
|
+
[
|
46
|
+
[%w[a a a], true],
|
47
|
+
[%w[1 1 1], true],
|
48
|
+
[[1, 1, 1], false],
|
49
|
+
[['', '', ''], false],
|
50
|
+
[[nil, nil, nil], true]
|
51
|
+
].each do |record, result|
|
52
|
+
context "when record: #{record.inspect}" do
|
53
|
+
subject { described_class.new(data_file_path).include?(record) }
|
54
|
+
|
55
|
+
it { is_expected.to eq(result) }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#write' do
|
61
|
+
let(:data_file_path) { Tempfile.new('data_file_path').path }
|
62
|
+
|
63
|
+
before { File.write(data_file_path, "a,a,a\n") }
|
64
|
+
|
65
|
+
[
|
66
|
+
[[nil, nil, nil], "a,a,a\n,,\n"],
|
67
|
+
[['', '', ''], "a,a,a\n\"\",\"\",\"\"\n"],
|
68
|
+
[[1, 2, 3], "a,a,a\n1,2,3\n"],
|
69
|
+
[['Github', 'up', 1_539_506_590], "a,a,a\nGithub,up,1539506590\n"]
|
70
|
+
].each do |record, result|
|
71
|
+
context "when record: #{record.inspect}" do
|
72
|
+
it do
|
73
|
+
described_class.new(data_file_path).write(record)
|
74
|
+
expect(File.read(data_file_path)).to eq(result)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe '#merge' do
|
81
|
+
let(:data_file_path) { Tempfile.new('data_file_path').path }
|
82
|
+
|
83
|
+
before { File.write(data_file_path, "a,a,a\n") }
|
84
|
+
|
85
|
+
[
|
86
|
+
[[%w[a a a], %w[b b b]], "a,a,a\nb,b,b\n"],
|
87
|
+
[[%w[b b b]], "a,a,a\nb,b,b\n"],
|
88
|
+
[[%w[a a a]], "a,a,a\n"]
|
89
|
+
].each do |records, result|
|
90
|
+
context "when records: #{records.inspect}" do
|
91
|
+
it do
|
92
|
+
described_class.new(data_file_path).merge(records)
|
93
|
+
expect(File.read(data_file_path)).to eq(result)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#copy' do
|
100
|
+
let(:data_file_path) { Tempfile.new('data_file_path').path }
|
101
|
+
let(:target_file_path) { Tempfile.new('data_file_path').path }
|
102
|
+
|
103
|
+
before { File.write(data_file_path, "a,a,a\nb,b,b\nc,c,c\n") }
|
104
|
+
|
105
|
+
it do
|
106
|
+
described_class.new(data_file_path).copy(target_file_path)
|
107
|
+
expect(File.read(target_file_path)).to eq("a,a,a\nb,b,b\nc,c,c\n")
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe '#restore' do
|
112
|
+
let(:data_file_path) { Tempfile.new('data_file_path').path }
|
113
|
+
let(:new_file_path) { Tempfile.new('new_file_path').path }
|
114
|
+
|
115
|
+
[
|
116
|
+
%W[a,a,a\nc,c,c\n a,a,a\nb,b,b\n a,a,a\nb,b,b\nc,c,c\n],
|
117
|
+
%W[a,a,a\nc,c,c\n a,a,a\n a,a,a\nc,c,c\n],
|
118
|
+
%W[a,a,a\nc,c,c\n a,a,a\n a,a,a\nc,c,c\n],
|
119
|
+
%W[a,a,a\nc,c,c\n a,a,a\nc,c,c\n a,a,a\nc,c,c\n]
|
120
|
+
].each do |data_file_content, new_file_content, result|
|
121
|
+
context do
|
122
|
+
before do
|
123
|
+
File.write(data_file_path, data_file_content)
|
124
|
+
File.write(new_file_path, new_file_content)
|
125
|
+
end
|
126
|
+
|
127
|
+
it do
|
128
|
+
described_class.new(data_file_path).restore(new_file_path)
|
129
|
+
expect(File.read(data_file_path)).to eq(result)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
require 'tempfile'
|
5
|
+
require 'timecop'
|
6
|
+
|
7
|
+
require 'status_page_ruby'
|
8
|
+
require 'status_page_ruby_cli'
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.disable_monkey_patching!
|
12
|
+
config.after do
|
13
|
+
Timecop.return
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.expand_path('lib/status_page_ruby/version', __dir__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.name = 'status_page_ruby'
|
5
|
+
gem.version = StatusPageRuby::VERSION
|
6
|
+
gem.date = '2018-10-14'
|
7
|
+
gem.summary = 'Status page commandline tool.'
|
8
|
+
gem.description = 'Status page tool parses, stores and report statuses of web services.'
|
9
|
+
gem.authors = ['Konstantin Lynda']
|
10
|
+
gem.email = 'knlynda@gmail.com'
|
11
|
+
gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
|
12
|
+
gem.test_files = gem.files.grep(%r{^spec/})
|
13
|
+
gem.require_paths = ['lib']
|
14
|
+
gem.bindir = 'bin'
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
16
|
+
gem.homepage = 'http://rubygems.org/gems/status_page_ruby'
|
17
|
+
gem.license = 'MIT'
|
18
|
+
|
19
|
+
gem.add_runtime_dependency 'nokogiri', '1.8.5'
|
20
|
+
gem.add_runtime_dependency 'terminal-table', '1.8.0'
|
21
|
+
gem.add_runtime_dependency 'thor', '0.20.0'
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: status_page_ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Konstantin Lynda
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-10-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nokogiri
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.8.5
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.8.5
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: terminal-table
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.8.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.8.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.20.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.20.0
|
55
|
+
description: Status page tool parses, stores and report statuses of web services.
|
56
|
+
email: knlynda@gmail.com
|
57
|
+
executables:
|
58
|
+
- status-page
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".circleci/config.yml"
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rubocop.yml"
|
65
|
+
- Gemfile
|
66
|
+
- Gemfile.lock
|
67
|
+
- README.md
|
68
|
+
- bin/status-page
|
69
|
+
- lib/status_page_ruby.rb
|
70
|
+
- lib/status_page_ruby/pages/base.rb
|
71
|
+
- lib/status_page_ruby/pages/bitbucket.rb
|
72
|
+
- lib/status_page_ruby/pages/cloudflare.rb
|
73
|
+
- lib/status_page_ruby/pages/github.rb
|
74
|
+
- lib/status_page_ruby/pages/rubygems.rb
|
75
|
+
- lib/status_page_ruby/repositories/status.rb
|
76
|
+
- lib/status_page_ruby/services/backup_data.rb
|
77
|
+
- lib/status_page_ruby/services/build_history_table.rb
|
78
|
+
- lib/status_page_ruby/services/build_log_table.rb
|
79
|
+
- lib/status_page_ruby/services/build_stats_table.rb
|
80
|
+
- lib/status_page_ruby/services/pull_statuses.rb
|
81
|
+
- lib/status_page_ruby/services/restore_data.rb
|
82
|
+
- lib/status_page_ruby/status.rb
|
83
|
+
- lib/status_page_ruby/storage.rb
|
84
|
+
- lib/status_page_ruby/version.rb
|
85
|
+
- lib/status_page_ruby_cli.rb
|
86
|
+
- spec/lib/status_page_ruby/pages/bitbucket_spec.rb
|
87
|
+
- spec/lib/status_page_ruby/pages/cloudflare_spec.rb
|
88
|
+
- spec/lib/status_page_ruby/pages/github_spec.rb
|
89
|
+
- spec/lib/status_page_ruby/pages/rubygems_spec.rb
|
90
|
+
- spec/lib/status_page_ruby/repositories/status_spec.rb
|
91
|
+
- spec/lib/status_page_ruby/services/backup_data_spec.rb
|
92
|
+
- spec/lib/status_page_ruby/services/build_history_table_spec.rb
|
93
|
+
- spec/lib/status_page_ruby/services/build_log_table_spec.rb
|
94
|
+
- spec/lib/status_page_ruby/services/build_stats_table_spec.rb
|
95
|
+
- spec/lib/status_page_ruby/services/pull_statuses_spec.rb
|
96
|
+
- spec/lib/status_page_ruby/services/restore_data_spec.rb
|
97
|
+
- spec/lib/status_page_ruby/status_spec.rb
|
98
|
+
- spec/lib/status_page_ruby/storage_spec.rb
|
99
|
+
- spec/spec_helper.rb
|
100
|
+
- status_page_ruby.gemspec
|
101
|
+
homepage: http://rubygems.org/gems/status_page_ruby
|
102
|
+
licenses:
|
103
|
+
- MIT
|
104
|
+
metadata: {}
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options: []
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
requirements: []
|
120
|
+
rubyforge_project:
|
121
|
+
rubygems_version: 2.6.11
|
122
|
+
signing_key:
|
123
|
+
specification_version: 4
|
124
|
+
summary: Status page commandline tool.
|
125
|
+
test_files:
|
126
|
+
- spec/lib/status_page_ruby/pages/bitbucket_spec.rb
|
127
|
+
- spec/lib/status_page_ruby/pages/cloudflare_spec.rb
|
128
|
+
- spec/lib/status_page_ruby/pages/github_spec.rb
|
129
|
+
- spec/lib/status_page_ruby/pages/rubygems_spec.rb
|
130
|
+
- spec/lib/status_page_ruby/repositories/status_spec.rb
|
131
|
+
- spec/lib/status_page_ruby/services/backup_data_spec.rb
|
132
|
+
- spec/lib/status_page_ruby/services/build_history_table_spec.rb
|
133
|
+
- spec/lib/status_page_ruby/services/build_log_table_spec.rb
|
134
|
+
- spec/lib/status_page_ruby/services/build_stats_table_spec.rb
|
135
|
+
- spec/lib/status_page_ruby/services/pull_statuses_spec.rb
|
136
|
+
- spec/lib/status_page_ruby/services/restore_data_spec.rb
|
137
|
+
- spec/lib/status_page_ruby/status_spec.rb
|
138
|
+
- spec/lib/status_page_ruby/storage_spec.rb
|
139
|
+
- spec/spec_helper.rb
|