copilot 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,28 +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
1
+ require 'watir-webdriver'
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 builds_for_bundle_id(bundle_id, options={})
13
+ BuildsForBundleIdRequest.new(browser).send bundle_id, options
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
28
  end
@@ -0,0 +1,45 @@
1
+ require_relative 'internal/build_table_row'
2
+ require_relative 'internal/builds_dashboard'
3
+
4
+ module CoPilot
5
+ class BuildsForBundleIdRequest
6
+
7
+ def initialize(browser)
8
+ @browser = browser
9
+ end
10
+
11
+ def send(bundle_id, options={})
12
+ @limit = options[:limit]
13
+ @builds_dashboard = BuildsDashboard.new @browser, bundle_id
14
+ @builds_dashboard.goto
15
+ @builds_dashboard.more_builds
16
+ @builds = []
17
+ add_builds
18
+ strip_excess_builds
19
+ @builds
20
+ end
21
+
22
+ private
23
+
24
+ def add_builds
25
+ rows = @builds_dashboard.builds_table_rows
26
+ @builds += rows.map { |row| BuildTableRow.new(row).to_hash }
27
+ return if limit_reached
28
+
29
+ next_link = @builds_dashboard.next_page_link
30
+ return unless next_link
31
+ next_link.click
32
+ sleep 2
33
+ add_builds
34
+ end
35
+
36
+ def strip_excess_builds
37
+ @builds = @builds.first @limit if @limit
38
+ end
39
+
40
+ def limit_reached
41
+ @limit && @builds.length >= @limit
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,58 @@
1
+ module CoPilot
2
+ class BuildsDashboard
3
+
4
+ def initialize(browser, bundle_id)
5
+ @browser = browser
6
+ @bundle_id = bundle_id
7
+ end
8
+
9
+ def goto
10
+ b.goto 'https://www.testflightapp.com/dashboard/builds'
11
+ end
12
+
13
+ def header_div
14
+ @header_div ||= header_divs[bundle_index]
15
+ end
16
+
17
+ def builds_table
18
+ @builds_table ||= header_div.parent.tables[bundle_index]
19
+ end
20
+
21
+ def builds_table_rows
22
+ builds_table.trs(id: /\/dashboard\/builds\/report\/\d+\//)
23
+ end
24
+
25
+ def next_page_link
26
+ builds_table.as(title: 'Next Page')[0]
27
+ end
28
+
29
+ def next_page
30
+ link = next_page_link
31
+ link.click if link
32
+ end
33
+
34
+ def more_builds_link
35
+ builds_table.as(text: 'more')[0]
36
+ end
37
+
38
+ def more_builds
39
+ link = more_builds_link
40
+ link.click if link
41
+ end
42
+
43
+ private
44
+
45
+ def header_divs
46
+ @header_divs ||= b.divs(class: 'section-header-build')
47
+ end
48
+
49
+ def bundle_index
50
+ @bundle_index ||= header_divs.to_a.index { |div| div.li.text == @bundle_id }
51
+ end
52
+
53
+ def b
54
+ @browser
55
+ end
56
+
57
+ end
58
+ end
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.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,8 +12,8 @@ cert_chain: []
12
12
  date: 2013-03-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: watir
16
- requirement: !ruby/object:Gem::Requirement
15
+ name: watir-webdriver
16
+ requirement: &70218836405640 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,12 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
24
+ version_requirements: *70218836405640
30
25
  description:
31
26
  email: matthew-github@matthewriley.name
32
27
  executables: []
@@ -34,9 +29,9 @@ extensions: []
34
29
  extra_rdoc_files: []
35
30
  files:
36
31
  - lib/copilot/facade.rb
37
- - lib/copilot/requests/app_with_bundle_id_request.rb
38
- - lib/copilot/requests/internal/build_table.rb
32
+ - lib/copilot/requests/builds_for_bundle_id_request.rb
39
33
  - lib/copilot/requests/internal/build_table_row.rb
34
+ - lib/copilot/requests/internal/builds_dashboard.rb
40
35
  - lib/copilot/requests.rb
41
36
  - lib/copilot.rb
42
37
  homepage: http://rubygems.org/gems/copilot
@@ -59,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
54
  version: '0'
60
55
  requirements: []
61
56
  rubyforge_project:
62
- rubygems_version: 1.8.24
57
+ rubygems_version: 1.8.15
63
58
  signing_key:
64
59
  specification_version: 3
65
60
  summary: CoPilot is a Ruby Gem that provides a rudimentary API for TestFlight using
@@ -1,44 +0,0 @@
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
@@ -1,28 +0,0 @@
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