crashlytics-crawler 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 63d344dc70c62ae6460f0b7e138120f2b031b885
4
+ data.tar.gz: bca0efea7f1c7233779490e456b0f5faf4439e6c
5
+ SHA512:
6
+ metadata.gz: 1afcb46da66e8dcec0123dce2301dde7dfa35348469dd4445e1d1c4b78f8108f3c8d78361d913cfab02e8cab59b1386adcf59a87bad20507956b28d36eaaf6e6
7
+ data.tar.gz: 8a17c7caf3d54d167080b7daaf93e39eeba7b23d4902c53bd18dec221ea0a7ef7b606d8abc2e5e52a408b88a1505a57e985c9d6055a692ac6cdfaace42554900
@@ -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,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Maiz Lulkin
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.
@@ -0,0 +1,31 @@
1
+ # Crashlytics
2
+
3
+ A (crappy) crawler to collect Crashlytics statistics.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'crashlytics'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install crashlytics
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+ Crashlytics.run "USER", "PASSWORD"
23
+ ```
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it
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 new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "crashlytics-crawler"
7
+ spec.version = '0.0.1'
8
+ spec.authors = ["Maiz Lulkin"]
9
+ spec.email = ["maiz@lulk.in"]
10
+ spec.description = %q{A crappy crawler for crashlytics}
11
+ spec.summary = %q{A crappy crawler for crashlytics}
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.3"
21
+
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec", "~>2.14"
24
+ spec.add_development_dependency "timecop"
25
+ spec.add_development_dependency "watir"
26
+
27
+ spec.add_dependency "capybara"
28
+ spec.add_dependency "poltergeist"
29
+ spec.add_dependency "hpricot"
30
+ end
@@ -0,0 +1,9 @@
1
+ module Crashlytics
2
+ def self.run email, password
3
+ Runner.new(email, password).run
4
+ end
5
+ end
6
+
7
+ require_relative 'crashlytics/parser'
8
+ require_relative 'crashlytics/runner'
9
+ require_relative 'crashlytics/crawler'
@@ -0,0 +1,31 @@
1
+ require 'watir'
2
+
3
+ module Crashlytics
4
+
5
+ class InvalidCredentials < StandardError
6
+ end
7
+
8
+ Crawler = Struct.new(:email, :password) do
9
+
10
+ LOGIN_URL = "https://www.crashlytics.com/login"
11
+
12
+ def statistics_page
13
+ login
14
+ browser.goto 'https://www.crashlytics.com/seeking-alpha/ios/apps/com.seekingalpha.ipadportfolio/issues?build=all&status=open&event_type=all&time=last-twenty-four-hours'
15
+ browser.html
16
+ end
17
+
18
+ private
19
+
20
+ def login
21
+ browser.goto LOGIN_URL
22
+ browser.text_field(id: 'form-email').set email
23
+ browser.text_field(id: 'form-password').set password
24
+ browser.button(id: 'sign_in_email').click
25
+ end
26
+
27
+ def browser
28
+ @browser ||= Watir::Browser.new :chrome
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,21 @@
1
+ require 'hpricot'
2
+
3
+ module Crashlytics
4
+
5
+ Parser = Struct.new :html do
6
+ def statistics
7
+ {
8
+ issues: doc.search('.summary-issues .value').text.to_i,
9
+ crashes: doc.search('.crashes-events .value').text.to_i,
10
+ users_affected: doc.search('.crashes-users-affected .value').text.to_i
11
+ }
12
+ end
13
+
14
+ private
15
+
16
+ def doc
17
+ @doc ||= Hpricot(html)
18
+ end
19
+ end
20
+
21
+ end
@@ -0,0 +1,19 @@
1
+ module Crashlytics
2
+
3
+ Runner = Struct.new :user_name, :password do
4
+ def run
5
+ parser.statistics
6
+ end
7
+
8
+ private
9
+
10
+ def parser
11
+ Parser.new(crawler.statistics_page)
12
+ end
13
+
14
+ def crawler
15
+ Crawler.new user_name, password
16
+ end
17
+ end
18
+
19
+ end
data/run.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'hpricot'
2
+ require 'pry'
3
+ require_relative 'lib/crashlytics'
4
+
5
+ # Usage:
6
+ #
7
+ # ruby run.rb USER PASS
8
+
9
+ Crashlytics.run *ARGV
@@ -0,0 +1,20 @@
1
+ require_relative 'spec_helper'
2
+
3
+ include Crashlytics
4
+
5
+ describe Crawler, vcr: true do
6
+ describe "#statistics_page" do
7
+ context 'given valid auth data' do
8
+ subject(:crawler) do
9
+ raise "You should set credentials in your ENV to run this test" unless ENV['CRASHLYTICS_EMAIL']
10
+ Crawler.new ENV['CRASHLYTICS_EMAIL'], ENV['CRASHLYTICS_PASSWORD']
11
+ end
12
+
13
+ it 'gets transaction table from online bank' do
14
+ title = (Hpricot(crawler.statistics_page) % 'title').inner_text
15
+ expect(title).to eq("Crashlytics")
16
+ end
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,23 @@
1
+ <div class="r_metrics"><div class="i_metrics segment row"><div class="columns large-2 small-2 summary-issues">
2
+ <div class="inline-block">
3
+ <div class="stat"><div class="ellipsis value">27</div><div class="name uppercase">
4
+ <div class="ellipsis">issues</div>
5
+ </div></div>
6
+ </div>
7
+ </div>
8
+ <div class="columns flex-box flex-column large-4 small-4 summary-events">
9
+ <div class="flex-grow-1 row">
10
+ <div class="column crashes-events large-6">
11
+ <div class="stat"><div class="ellipsis value">222</div><div class="name uppercase">
12
+ <div class="ellipsis">crashes</div>
13
+ </div></div>
14
+ <div class="crashes icon"></div>
15
+ </div>
16
+ <div class="column crashes-users-affected large-6">
17
+ <div class="stat"><div class="ellipsis value">187</div><div class="name uppercase">
18
+ <div class="ellipsis">users affected</div>
19
+ </div></div>
20
+ </div>
21
+ </div>
22
+ </div>
23
+ <div class="columns large-6 series small-6"><svg width="100%" height="100%"><g transform="translate(30, 10)"><g class="x axis" transform="translate(0, 92)"><g class="tick" transform="translate(17,0)" style="opacity: 1;"><line y2="0" x2="0"></line><text y="5" x="0" dy=".71em" style="text-anchor: middle;">03:00PM</text></g><g class="tick" transform="translate(120,0)" style="opacity: 1;"><line y2="0" x2="0"></line><text y="5" x="0" dy=".71em" style="text-anchor: middle;">09:00PM</text></g><g class="tick" transform="translate(222,0)" style="opacity: 1;"><line y2="0" x2="0"></line><text y="5" x="0" dy=".71em" style="text-anchor: middle;">03:00AM</text></g><g class="tick" transform="translate(325,0)" style="opacity: 1;"><line y2="0" x2="0"></line><text y="5" x="0" dy=".71em" style="text-anchor: middle;">09:00AM</text></g><path class="domain" d="M0,0V0H409.92V0"></path></g><g class="y axis"><g class="tick" transform="translate(0,92)" style="opacity: 1;"><line x2="0" y2="0"></line><text x="-3" y="0" dy=".32em" style="text-anchor: end;">0</text></g><g class="tick" transform="translate(0,75.27272727272728)" style="opacity: 1;"><line x2="0" y2="0"></line><text x="-3" y="0" dy=".32em" style="text-anchor: end;">5</text></g><g class="tick" transform="translate(0,58.54545454545455)" style="opacity: 1;"><line x2="0" y2="0"></line><text x="-3" y="0" dy=".32em" style="text-anchor: end;">10</text></g><g class="tick" transform="translate(0,41.81818181818182)" style="opacity: 1;"><line x2="0" y2="0"></line><text x="-3" y="0" dy=".32em" style="text-anchor: end;">15</text></g><g class="tick" transform="translate(0,25.090909090909093)" style="opacity: 1;"><line x2="0" y2="0"></line><text x="-3" y="0" dy=".32em" style="text-anchor: end;">20</text></g><g class="tick" transform="translate(0,8.36363636363636)" style="opacity: 1;"><line x2="0" y2="0"></line><text x="-3" y="0" dy=".32em" style="text-anchor: end;">25</text></g><path class="domain" d="M0,0H0V92H0"></path></g><g class="ticks" transform="translate(0, 0"><line x1="0" x2="427" y1="92" y2="92"></line><line x1="0" x2="427" y1="75.27272727272728" y2="75.27272727272728"></line><line x1="0" x2="427" y1="58.54545454545455" y2="58.54545454545455"></line><line x1="0" x2="427" y1="41.81818181818182" y2="41.81818181818182"></line><line x1="0" x2="427" y1="25.090909090909093" y2="25.090909090909093"></line><line x1="0" x2="427" y1="8.36363636363636" y2="8.36363636363636"></line></g><g class="layer fill-teal"><rect width="16.9" height="46.83636363636363" x="0" y="45.16363636363637" stroke="#FFF"></rect><rect width="16.9" height="33.45454545454545" x="17" y="58.54545454545455" stroke="#FFF"></rect><rect width="16.9" height="26.763636363636365" x="34" y="65.23636363636363" stroke="#FFF"></rect><rect width="16.9" height="40.14545454545454" x="51" y="51.85454545454546" stroke="#FFF"></rect><rect width="16.9" height="36.8" x="68" y="55.2" stroke="#FFF"></rect><rect width="16.9" height="20.072727272727263" x="85" y="71.92727272727274" stroke="#FFF"></rect><rect width="16.9" height="30.10909090909091" x="102" y="61.89090909090909" stroke="#FFF"></rect><rect width="16.9" height="36.8" x="120" y="55.2" stroke="#FFF"></rect><rect width="16.9" height="20.072727272727263" x="137" y="71.92727272727274" stroke="#FFF"></rect><rect width="16.9" height="30.10909090909091" x="154" y="61.89090909090909" stroke="#FFF"></rect><rect width="16.9" height="40.14545454545454" x="171" y="51.85454545454546" stroke="#FFF"></rect><rect width="16.9" height="33.45454545454545" x="188" y="58.54545454545455" stroke="#FFF"></rect><rect width="16.9" height="13.381818181818176" x="205" y="78.61818181818182" stroke="#FFF"></rect><rect w="222" y="81.96363636363637" stroke="#FFF"></rect><rect width="16.9" height="13.381818181818176" x="239" y="78.61818181818182" stroke=="16.9" height="13.381818181818176" x="273" y="78.28" stroke="#FFF"></rect><rect width="16.9" height="6.690909090909088" x="325" y="85.30909090909091" stroke="#FFF"></rect><rect width="16.9" height="3.3454527272724" x="359" y="38.472727272727276" stroke="#FFF"><rect width="16.9" height="43.49090909090909" x="410" y="48.50909090909091" >
@@ -0,0 +1,25 @@
1
+ require_relative 'spec_helper'
2
+
3
+ include Crashlytics
4
+
5
+ describe Parser do
6
+ let(:html) { File.read(Dir.pwd + "/spec/fixtures/issues.html") }
7
+
8
+ subject(:parser) do
9
+ Parser.new(html)
10
+ end
11
+
12
+ let(:expected_statistics) do
13
+ {
14
+ issues: 27,
15
+ crashes: 222,
16
+ users_affected: 187
17
+ }
18
+ end
19
+
20
+ describe "#statistics" do
21
+ it "should return statistics" do
22
+ expect(parser.statistics).to eq(expected_statistics)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,19 @@
1
+ require_relative 'spec_helper'
2
+
3
+ include Crashlytics
4
+
5
+ describe Runner do
6
+ let(:html) { File.read(Dir.pwd + "/spec/fixtures/issues.html") }
7
+
8
+ subject(:runner) do
9
+ Runner.new 'email', 'pass'
10
+ end
11
+
12
+ describe "#run" do
13
+ it 'gets from the crawler' do
14
+ allow_any_instance_of(Crawler).to receive(:statistics_page).and_return(html)
15
+ runner.run
16
+ end
17
+ end
18
+
19
+ end
@@ -0,0 +1,6 @@
1
+ $:.unshift File.expand_path("../../lib/crashlytics", __FILE__)
2
+
3
+ require 'bundler/setup'
4
+ require 'hpricot'
5
+ require 'timecop'
6
+ require 'crashlytics'
metadata ADDED
@@ -0,0 +1,177 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: crashlytics-crawler
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Maiz Lulkin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-15 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.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '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: '2.14'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '2.14'
55
+ - !ruby/object:Gem::Dependency
56
+ name: timecop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: watir
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: capybara
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: poltergeist
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: hpricot
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: A crappy crawler for crashlytics
126
+ email:
127
+ - maiz@lulk.in
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - .gitignore
133
+ - Gemfile
134
+ - LICENSE.txt
135
+ - README.md
136
+ - Rakefile
137
+ - crashlytics-crawler.gemspec
138
+ - lib/crashlytics.rb
139
+ - lib/crashlytics/crawler.rb
140
+ - lib/crashlytics/parser.rb
141
+ - lib/crashlytics/runner.rb
142
+ - run.rb
143
+ - spec/crawler_spec.rb
144
+ - spec/fixtures/issues.html
145
+ - spec/parser_spec.rb
146
+ - spec/runner_spec.rb
147
+ - spec/spec_helper.rb
148
+ homepage: ''
149
+ licenses:
150
+ - MIT
151
+ metadata: {}
152
+ post_install_message:
153
+ rdoc_options: []
154
+ require_paths:
155
+ - lib
156
+ required_ruby_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - '>='
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ requirements: []
167
+ rubyforge_project:
168
+ rubygems_version: 2.0.6
169
+ signing_key:
170
+ specification_version: 4
171
+ summary: A crappy crawler for crashlytics
172
+ test_files:
173
+ - spec/crawler_spec.rb
174
+ - spec/fixtures/issues.html
175
+ - spec/parser_spec.rb
176
+ - spec/runner_spec.rb
177
+ - spec/spec_helper.rb