integration-diff 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02c429447679f324211bb8fc6dd8f6b0ededa462
4
- data.tar.gz: fa9acec0cc1f55ad7e5b258f9453dc9be7c7cb71
3
+ metadata.gz: 56099739623d94131dbb655d6f2a6fcc3b7ba644
4
+ data.tar.gz: a9a405856011a2e5d4750d127fc5302de202a768
5
5
  SHA512:
6
- metadata.gz: 661bed2fff8991b58d100142a892fb43ce917acf08d5f195e0170cc6f223551f4caccde8cac0c57d693539a1c990608fb1b354dcc8ad4428e95aa198b11fe588
7
- data.tar.gz: 8b13946dc473347a79d3af43a46e86a17beedee68279cd48886fa5b447adb4484eaeff7944eaa8f2b4512f0ed9862333d3df7f1a71dc8c481c058f8e766c3d37
6
+ metadata.gz: 34385079e07bedca35e2d84bc0457707ff769eb471c8182546869d19590b224bef20be92e1cfc5dc5dc1e46c571d87542d469a95922e6a99bc5765bd8e8d7445
7
+ data.tar.gz: f96ad96632e09ddca7597a81347cd9f37ee4222f5be9ea228331a2c9a079c2249079e1a49bd2dc41ee1f0e3e7c255d2264806f2fc52e12f70b9662120e259bcf
data/Readme.md CHANGED
@@ -10,9 +10,9 @@ gem 'integration-diff'
10
10
 
11
11
  ### Configuration
12
12
 
13
- Include `integration-diff-rails` in your rspec `spec_helper` and configure 6 variables
14
- which will be used while taking screenshots. Make sure that `enable_service` is set to
15
- to true if images need to be uploaded.
13
+ Include `integration-diff` in your rspec `spec_helper` and configure 6 variables
14
+ which will be used while taking screenshots. Make sure that `enable_service` is
15
+ set to true if images need to be uploaded.
16
16
 
17
17
  **NOTE:** Make sure that that project exists in service with `project_name`. Also
18
18
  api key can be obtained by loggin into service and visiting `/api_key`.
@@ -0,0 +1,55 @@
1
+ module IntegrationDiff
2
+ class RunDetails
3
+ class Jenkins
4
+ def branch
5
+ ENV.fetch('GIT_BRANCH').split('/').last
6
+ end
7
+
8
+ def author
9
+ 'Jenkins'.freeze
10
+ end
11
+ end
12
+
13
+ class Travis
14
+ def branch
15
+ ENV.fetch('TRAVIS_BRANCH')
16
+ end
17
+
18
+ def author
19
+ 'Travis'.freeze
20
+ end
21
+ end
22
+
23
+ class GitRepo
24
+ def branch
25
+ `git rev-parse --abbrev-ref HEAD`.strip
26
+ end
27
+
28
+ def author
29
+ `git config user.name`.strip
30
+ end
31
+ end
32
+
33
+ class Default
34
+ def branch
35
+ 'HEAD'.freeze
36
+ end
37
+
38
+ def author
39
+ 'None'.freeze
40
+ end
41
+ end
42
+
43
+ def details
44
+ if !!ENV['JENKINS_HOME']
45
+ Jenkins.new
46
+ elsif !!ENV['TRAVIS']
47
+ Travis.new
48
+ elsif system('git branch')
49
+ GitRepo.new
50
+ else
51
+ Default.new
52
+ end
53
+ end
54
+ end
55
+ end
@@ -1,11 +1,12 @@
1
1
  require 'time'
2
2
  require 'json'
3
+ require 'integration_diff/run_details'
3
4
 
4
5
  module IntegrationDiff
5
6
  class Runner
6
7
  include Capybara::DSL
7
8
 
8
- DIR = 'tmp/idff_images'
9
+ DIR = 'tmp/idiff_images'.freeze
9
10
 
10
11
  def self.instance
11
12
  @runner ||= Runner.new(IntegrationDiff.base_uri,
@@ -17,6 +18,8 @@ module IntegrationDiff
17
18
  @base_uri = base_uri
18
19
  @project_name = project_name
19
20
  @javascript_driver = javascript_driver
21
+
22
+ Dir.mkdir('tmp') unless Dir.exist?('tmp')
20
23
  Dir.mkdir(DIR) unless Dir.exist?(DIR)
21
24
  end
22
25
 
@@ -35,7 +38,7 @@ module IntegrationDiff
35
38
  upload_image(identifier)
36
39
  end
37
40
 
38
- finalize_run if @run_id
41
+ complete_run if @run_id
39
42
  rescue StandardError => e
40
43
  IntegrationDiff.logger.fatal e.message
41
44
  raise e
@@ -52,10 +55,9 @@ module IntegrationDiff
52
55
  def draft_run
53
56
  run_name = @project_name + "-" + Time.now.iso8601
54
57
 
55
- # will have to make it configurable. ie, read from env.
56
- # https://github.com/code-mancers/integration-diff.rb/pull/4#discussion-diff-42290464
57
- branch = `git rev-parse --abbrev-ref HEAD`.strip
58
- author = `git config user.name`.strip
58
+ details = IntegrationDiff::RunDetails.new.details
59
+ branch = details.branch
60
+ author = details.author
59
61
  project = IntegrationDiff.project_name
60
62
 
61
63
  response = connection.post('/api/v1/runs',
@@ -66,17 +68,18 @@ module IntegrationDiff
66
68
  end
67
69
 
68
70
  def upload_image(identifier)
71
+ IntegrationDiff.logger.fatal "uploading #{identifier}"
69
72
  image_io = Faraday::UploadIO.new(image_file(identifier), 'image/png')
70
73
  connection.post("/api/v1/runs/#{@run_id}/run_images",
71
74
  identifier: identifier, image: image_io)
72
75
  end
73
76
 
74
- def finalize_run
75
- connection.put("/api/v1/runs/#{@run_id}/status", status: "finalized")
77
+ def complete_run
78
+ connection.put("/api/v1/runs/#{@run_id}/status", status: "completed")
76
79
  end
77
80
 
78
81
  def image_file(identifier)
79
- "#{DIR}/#{identifier}.png"
82
+ "#{Dir.pwd}/#{DIR}/#{identifier}.png"
80
83
  end
81
84
 
82
85
  def connection
@@ -1,3 +1,3 @@
1
1
  module IntegrationDiff
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: integration-diff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuva
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-26 00:00:00.000000000 Z
11
+ date: 2016-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -38,6 +38,7 @@ files:
38
38
  - lib/integration_diff.rb
39
39
  - lib/integration_diff/dsl.rb
40
40
  - lib/integration_diff/dummy_runner.rb
41
+ - lib/integration_diff/run_details.rb
41
42
  - lib/integration_diff/runner.rb
42
43
  - lib/integration_diff/version.rb
43
44
  homepage: http://diff.codemancers.com