copilot 0.0.1 → 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.
@@ -0,0 +1,28 @@
1
+ require 'watir'
2
+ require_relative 'requests'
3
+
4
+ module CoPilot
5
+ class Facade
6
+
7
+ def initialize(email_address, password)
8
+ @email_address = email_address
9
+ @password = password
10
+ end
11
+
12
+ def app_with_bundle_id(bundle_id)
13
+ AppWithBundleIdRequest.new(browser).send(bundle_id)
14
+ end
15
+
16
+ private
17
+
18
+ def browser
19
+ b = Watir::Browser.new
20
+ b.goto 'https://www.testflightapp.com/login'
21
+ b.text_field(name: 'username').set @email_address
22
+ b.text_field(name: 'password').set @password
23
+ b.button(value: /Go/).click
24
+ b
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,44 @@
1
+ require_relative 'internal/build_table'
2
+
3
+ module CoPilot
4
+ class AppWithBundleIdRequest
5
+
6
+ def initialize(browser)
7
+ @browser = browser
8
+ end
9
+
10
+ def send(bundle_id)
11
+ b.goto 'https://www.testflightapp.com/dashboard/builds'
12
+ header_divs = b.divs(class: 'section-header-build')
13
+ header_div_index = header_divs.to_a.index { |div| bundle_id(div) == bundle_id }
14
+ header_div = header_divs[header_div_index]
15
+ build_table = header_div.parent.tables[header_div_index]
16
+ build_table.a(text: 'more').click
17
+ build_app header_div, build_table
18
+ end
19
+
20
+ private
21
+
22
+ def build_app(header_div, build_table)
23
+ app = {
24
+ bundle_id: bundle_id(header_div),
25
+ builds: []
26
+ }
27
+ bt = BuildTable.new build_table
28
+ app[:builds] = bt.builds
29
+ app
30
+ end
31
+
32
+ def bundle_id(section_build_header_div)
33
+ section_build_header_div.li.text
34
+ end
35
+
36
+ def b
37
+ @browser
38
+ end
39
+
40
+ end
41
+
42
+
43
+
44
+ end
@@ -0,0 +1,28 @@
1
+ require_relative 'build_table_row'
2
+
3
+ module CoPilot
4
+ class BuildTable
5
+
6
+ def initialize(table)
7
+ @table = table
8
+ @builds = []
9
+ end
10
+
11
+ def builds
12
+ trs = @table.trs(id: /\/dashboard\/builds\/report\/\d+\//)
13
+ @builds += trs.map { |tr| BuildTableRow.new(tr).to_hash }
14
+
15
+ next_links = @table.as(title: 'Next Page')
16
+ next_link = next_links.length == 1 ? next_links[0] : nil
17
+
18
+ return @builds unless next_link
19
+
20
+ next_link.click
21
+ sleep 2
22
+ builds
23
+ end
24
+
25
+
26
+
27
+ end
28
+ end
@@ -0,0 +1,61 @@
1
+ require 'time'
2
+
3
+ module CoPilot
4
+ class BuildTableRow
5
+
6
+ def initialize(tr)
7
+ @tr = tr
8
+ end
9
+
10
+ def build_id
11
+ @tr.id.split('/').last
12
+ end
13
+
14
+ def version
15
+ @tr[1].text
16
+ end
17
+
18
+ def added_date
19
+ Time.parse @tr[2].text
20
+ end
21
+
22
+ def built_for
23
+ @tr[3].text
24
+ end
25
+
26
+ def size
27
+ @tr[4].text
28
+ end
29
+
30
+ def sdk
31
+ @tr[5].text
32
+ end
33
+
34
+ def crashes
35
+ @tr[6].text.to_i
36
+ end
37
+
38
+ def feedback
39
+ @tr[7].text.to_i
40
+ end
41
+
42
+ def installs
43
+ @tr[8].text.to_i
44
+ end
45
+
46
+ def to_hash
47
+ {
48
+ id: build_id,
49
+ version: version,
50
+ added_date: added_date,
51
+ built_for: built_for,
52
+ size: size,
53
+ sdk: sdk,
54
+ crashes: crashes,
55
+ feedback: feedback,
56
+ installs: installs
57
+ }
58
+ end
59
+
60
+ end
61
+ end
@@ -0,0 +1 @@
1
+ Dir[File.expand_path(File.dirname(__FILE__) + '/requests/**/*_request.rb')].each { |f| require f }
data/lib/copilot.rb ADDED
@@ -0,0 +1 @@
1
+ require_relative 'copilot/facade'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: copilot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ cert_chain: []
12
12
  date: 2013-03-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: rake
15
+ name: watir
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
@@ -27,12 +27,18 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
- description: None yet.
30
+ description:
31
31
  email: matthew-github@matthewriley.name
32
32
  executables: []
33
33
  extensions: []
34
34
  extra_rdoc_files: []
35
- files: []
35
+ files:
36
+ - lib/copilot/facade.rb
37
+ - lib/copilot/requests/app_with_bundle_id_request.rb
38
+ - lib/copilot/requests/internal/build_table.rb
39
+ - lib/copilot/requests/internal/build_table_row.rb
40
+ - lib/copilot/requests.rb
41
+ - lib/copilot.rb
36
42
  homepage: http://rubygems.org/gems/copilot
37
43
  licenses: []
38
44
  post_install_message:
@@ -56,5 +62,6 @@ rubyforge_project:
56
62
  rubygems_version: 1.8.24
57
63
  signing_key:
58
64
  specification_version: 3
59
- summary: None yet.
65
+ summary: CoPilot is a Ruby Gem that provides a rudimentary API for TestFlight using
66
+ browser automation.
60
67
  test_files: []