copilot 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,21 +7,30 @@ module CoPilot
7
7
  def initialize(email_address, password)
8
8
  @email_address = email_address
9
9
  @password = password
10
+ @browser = Watir::Browser.new
11
+ login
10
12
  end
11
13
 
12
14
  def builds_for_bundle_id(bundle_id, options={})
13
- BuildsForBundleIdRequest.new(browser).send bundle_id, options
15
+ BuildsForBundleIdRequest.new(b).send bundle_id, options
14
16
  end
15
17
 
16
- private
18
+ def feedback_for_build_id(build_id, options={})
19
+ FeedbackForBuildIdRequest.new(b).send build_id, options
20
+ end
17
21
 
18
- def browser
19
- b = Watir::Browser.new
22
+ def login
20
23
  b.goto 'https://www.testflightapp.com/login'
21
24
  b.text_field(name: 'username').set @email_address
22
25
  b.text_field(name: 'password').set @password
23
26
  b.button(value: /Go/).click
24
- b
27
+ login if b.url.start_with? 'https://www.testflightapp.com/login'
28
+ end
29
+
30
+ private
31
+
32
+ def b
33
+ @browser
25
34
  end
26
35
 
27
36
  end
@@ -0,0 +1,65 @@
1
+ require_relative 'internal/feedback_page'
2
+
3
+ module CoPilot
4
+ class FeedbackForBuildIdRequest
5
+
6
+ def initialize(browser)
7
+ @browser = browser
8
+ end
9
+
10
+ def send(build_id, options={})
11
+ @limit = options[:limit]
12
+ @feedback = []
13
+ @feedback_page = FeedbackPage.new @browser, build_id
14
+ @feedback_page.goto
15
+ add_feedback_for_each_page
16
+ strip_excess_feedback
17
+ @feedback
18
+ end
19
+
20
+ private
21
+
22
+ def add_feedback_for_each_page
23
+ add_feedback
24
+ while @feedback_page.next_page_link && !limit_reached
25
+ @feedback_page.next_page
26
+ add_feedback
27
+ end
28
+ end
29
+
30
+ def add_feedback
31
+ @feedback_page.expand_details
32
+
33
+ @feedback_page.summary_detail_row_pairs.each do |pair|
34
+ summary_tr = pair[0]
35
+ detail_tr = pair[1]
36
+
37
+ main_feedback_table = detail_tr.table(class: 'mainfeedback')
38
+ td = main_feedback_table.tbody.tr.td
39
+
40
+ @feedback << {
41
+ user: summary_tr.tds[0].text,
42
+ date: Time.parse(summary_tr.tds[1].text),
43
+ subject: summary_tr.tds[2].text,
44
+ replies: summary_tr.tds[3].text.to_i,
45
+ via: td.ps[0].text,
46
+ message: td.ps[1].text
47
+ }
48
+
49
+ end
50
+ end
51
+
52
+ def strip_excess_feedback
53
+ @feedback = @feedback.first @limit if @limit
54
+ end
55
+
56
+ def limit_reached
57
+ @limit && @feedback.length >= @limit
58
+ end
59
+
60
+ def b
61
+ @browser
62
+ end
63
+
64
+ end
65
+ end
@@ -0,0 +1,53 @@
1
+ module CoPilot
2
+ class FeedbackPage
3
+
4
+ def initialize(browser, build_id)
5
+ @browser = browser
6
+ @build_id = build_id
7
+ end
8
+
9
+ def goto
10
+ b.goto "https://www.testflightapp.com/dashboard/builds/feedback/#{@build_id}"
11
+ end
12
+
13
+ def expand_details
14
+ summary_rows.each { |tr| tr.click }
15
+ sleep 1
16
+ end
17
+
18
+ def summary_detail_row_pairs
19
+ pairs = []
20
+ summary_rows.to_a.each_index { |i| pairs << [summary_rows[i], detail_rows[i]] }
21
+ pairs
22
+ end
23
+
24
+ def next_page_link
25
+ links = b.as(title: 'Next Page')
26
+ links.length == 1 ? links[0] : nil
27
+ end
28
+
29
+ def next_page
30
+ link = next_page_link
31
+ link.click if link
32
+ end
33
+
34
+ private
35
+
36
+ def summary_rows
37
+ feedback_table.trs(class: 'rowexpand')
38
+ end
39
+
40
+ def detail_rows
41
+ feedback_table.trs(class: 'rowdetail')
42
+ end
43
+
44
+ def feedback_table
45
+ b.table(id: 'feedbacktable')
46
+ end
47
+
48
+ def b
49
+ @browser
50
+ end
51
+
52
+ end
53
+ 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.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-04 00:00:00.000000000 Z
12
+ date: 2013-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: watir-webdriver
16
- requirement: &70218836405640 !ruby/object:Gem::Requirement
16
+ requirement: &70136296097120 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70218836405640
24
+ version_requirements: *70136296097120
25
25
  description:
26
26
  email: matthew-github@matthewriley.name
27
27
  executables: []
@@ -30,8 +30,10 @@ extra_rdoc_files: []
30
30
  files:
31
31
  - lib/copilot/facade.rb
32
32
  - lib/copilot/requests/builds_for_bundle_id_request.rb
33
+ - lib/copilot/requests/feedback_for_build_id_request.rb
33
34
  - lib/copilot/requests/internal/build_table_row.rb
34
35
  - lib/copilot/requests/internal/builds_dashboard.rb
36
+ - lib/copilot/requests/internal/feedback_page.rb
35
37
  - lib/copilot/requests.rb
36
38
  - lib/copilot.rb
37
39
  homepage: http://rubygems.org/gems/copilot