copilot 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/lib/copilot.rb CHANGED
@@ -1,9 +1,9 @@
1
- require_relative 'copilot/facade'
2
-
3
- module CoPilot
4
- class << self
5
- def new(email_address, password)
6
- Facade.new email_address, password
7
- end
8
- end
1
+ require_relative 'copilot/facade'
2
+
3
+ module CoPilot
4
+ class << self
5
+ def new(email_address, password)
6
+ Facade.new email_address, password
7
+ end
8
+ end
9
9
  end
File without changes
File without changes
@@ -1,5 +1,5 @@
1
1
  require_relative 'internal/build_table_row'
2
- require_relative 'internal/builds_dashboard'
2
+ require_relative 'internal/builds_page'
3
3
 
4
4
  module CoPilot
5
5
  class BuildsForBundleIdRequest
@@ -10,36 +10,45 @@ module CoPilot
10
10
 
11
11
  def send(bundle_id, options={})
12
12
  @limit = options[:limit]
13
- @builds_dashboard = BuildsDashboard.new @browser, bundle_id
14
- @builds_dashboard.goto
15
- @builds_dashboard.more_builds
13
+ @since = options[:since]
14
+ @builds_page = BuildsPage.new @browser, bundle_id
15
+ @builds_page.goto
16
+ @builds_page.more_builds
16
17
  @builds = []
17
- add_builds
18
+ add_builds_for_each_page
19
+ remove_duplicate_builds
18
20
  strip_excess_builds
19
21
  @builds
20
22
  end
21
23
 
22
24
  private
23
25
 
26
+ def add_builds_for_each_page
27
+ add_builds
28
+ add_builds while @builds_page.next_page && !limit_reached && !age_reached
29
+ end
30
+
24
31
  def add_builds
25
- rows = @builds_dashboard.builds_table_rows
32
+ rows = @builds_page.builds_table_rows
26
33
  @builds += rows.map { |row| BuildTableRow.new(row).to_hash }
27
- return if limit_reached
34
+ end
28
35
 
29
- next_link = @builds_dashboard.next_page_link
30
- return unless next_link
31
- next_link.click
32
- sleep 2
33
- add_builds
36
+ def remove_duplicate_builds
37
+ @builds.uniq! { |b| b[:id] }
34
38
  end
35
39
 
36
40
  def strip_excess_builds
37
41
  @builds = @builds.first @limit if @limit
42
+ @builds.select! { |b| b[:added_date] > @since } if @since
38
43
  end
39
44
 
40
45
  def limit_reached
41
46
  @limit && @builds.length >= @limit
42
47
  end
43
48
 
49
+ def age_reached
50
+ @since && @builds.last[:added_date] > @since
51
+ end
52
+
44
53
  end
45
54
  end
@@ -9,6 +9,7 @@ module CoPilot
9
9
 
10
10
  def send(build_id, options={})
11
11
  @limit = options[:limit]
12
+ @since = options[:since]
12
13
  @feedback = []
13
14
  @feedback_page = FeedbackPage.new @browser, build_id
14
15
  @feedback_page.goto
@@ -21,41 +22,36 @@ module CoPilot
21
22
 
22
23
  def add_feedback_for_each_page
23
24
  add_feedback
24
- while @feedback_page.next_page_link && !limit_reached
25
- @feedback_page.next_page
26
- add_feedback
27
- end
25
+ add_feedback while @feedback_page.next_page && !limit_reached && !age_reached
28
26
  end
29
27
 
30
28
  def add_feedback
31
29
  @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
-
30
+ @feedback_page.each_summary_detail_pair do |summary, detail|
31
+ main_feedback_table = detail.table(class: 'mainfeedback')
40
32
  @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
33
+ user: summary.tds[0].text,
34
+ date: Time.parse(summary.tds[1].text),
35
+ subject: summary.tds[2].text,
36
+ replies: summary.tds[3].text.to_i,
37
+ via: main_feedback_table.ps[0].text,
38
+ message: main_feedback_table.ps[1].text
47
39
  }
48
-
49
40
  end
50
41
  end
51
42
 
52
43
  def strip_excess_feedback
53
- @feedback = @feedback.first @limit if @limit
54
- end
44
+ @feedback = @feedback.first @limit if @limit
45
+ @feedback.select! { |f| f[:date] > @since } if @since
46
+ end
47
+
48
+ def limit_reached
49
+ @limit && @feedback.length >= @limit
50
+ end
55
51
 
56
- def limit_reached
57
- @limit && @feedback.length >= @limit
58
- end
52
+ def age_reached
53
+ @since && @feedback.last[:date] > @since
54
+ end
59
55
 
60
56
  def b
61
57
  @browser
@@ -1,61 +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
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
61
  end
@@ -1,5 +1,5 @@
1
1
  module CoPilot
2
- class BuildsDashboard
2
+ class BuildsPage
3
3
 
4
4
  def initialize(browser, bundle_id)
5
5
  @browser = browser
@@ -22,13 +22,11 @@ module CoPilot
22
22
  builds_table.trs(id: /\/dashboard\/builds\/report\/\d+\//)
23
23
  end
24
24
 
25
- def next_page_link
26
- builds_table.as(title: 'Next Page')[0]
27
- end
28
-
29
25
  def next_page
30
26
  link = next_page_link
31
- link.click if link
27
+ return false unless link
28
+ link.click
29
+ true
32
30
  end
33
31
 
34
32
  def more_builds_link
@@ -37,11 +35,18 @@ module CoPilot
37
35
 
38
36
  def more_builds
39
37
  link = more_builds_link
40
- link.click if link
38
+ return unless link
39
+ link.click
40
+ sleep 2
41
41
  end
42
42
 
43
43
  private
44
44
 
45
+ def next_page_link
46
+ links = builds_table.as(title: 'Next Page')
47
+ links.length == 1 ? links[0] : nil
48
+ end
49
+
45
50
  def header_divs
46
51
  @header_divs ||= b.divs(class: 'section-header-build')
47
52
  end
@@ -15,24 +15,30 @@ module CoPilot
15
15
  sleep 1
16
16
  end
17
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
18
+ def each_summary_detail_pair
19
+ summary_rows.to_a.each_index { |i| yield [summary_rows[i], detail_rows[i]] }
22
20
  end
23
21
 
22
+ def next_page
23
+ link = next_page_link
24
+ return false unless link
25
+ link.click
26
+ true
27
+ end
28
+
29
+ private
30
+
24
31
  def next_page_link
25
32
  links = b.as(title: 'Next Page')
26
33
  links.length == 1 ? links[0] : nil
27
34
  end
28
35
 
29
- def next_page
30
- link = next_page_link
31
- link.click if link
36
+ def summary_detail_row_pairs
37
+ pairs = []
38
+ summary_rows.to_a.each_index { |i| pairs << [summary_rows[i], detail_rows[i]] }
39
+ pairs
32
40
  end
33
41
 
34
- private
35
-
36
42
  def summary_rows
37
43
  feedback_table.trs(class: 'rowexpand')
38
44
  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.5
4
+ version: 0.0.6
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-05 00:00:00.000000000 Z
12
+ date: 2013-03-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: watir-webdriver
16
- requirement: &70136296097120 !ruby/object:Gem::Requirement
16
+ requirement: &70099948187940 !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: *70136296097120
24
+ version_requirements: *70099948187940
25
25
  description:
26
26
  email: matthew-github@matthewriley.name
27
27
  executables: []
@@ -32,7 +32,7 @@ files:
32
32
  - lib/copilot/requests/builds_for_bundle_id_request.rb
33
33
  - lib/copilot/requests/feedback_for_build_id_request.rb
34
34
  - lib/copilot/requests/internal/build_table_row.rb
35
- - lib/copilot/requests/internal/builds_dashboard.rb
35
+ - lib/copilot/requests/internal/builds_page.rb
36
36
  - lib/copilot/requests/internal/feedback_page.rb
37
37
  - lib/copilot/requests.rb
38
38
  - lib/copilot.rb