glyptic_gifs 0.0.4
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 +7 -0
- data/lib/glyptic_gifs.rb +101 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e25fd51d54e8f6eeb848337434e8692bc26e4f58
|
4
|
+
data.tar.gz: d975e785fb48d8770aadd31c7e302a1a9af0de8f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 862715a1f2a983dbcd7847bdb0a43e06cd47555cd0b6ea0fbb9812a03482d6c92ac60961b77e9866a1711f7cf7dcca82c6f608165944f7d10a89abe3c0804a7a
|
7
|
+
data.tar.gz: 816acd9e72a50c2612137ea5ac7b6318f0c79d5dc5f65f8c09da9d9e2f7fc4d3b0b949b799b8a24102dde52fa384864aa5c4bd86425541effa22e22e1c500df8
|
data/lib/glyptic_gifs.rb
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'rmagick'
|
2
|
+
require 'cucumber'
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
##
|
6
|
+
#
|
7
|
+
# Main class of Glyptic Gifs
|
8
|
+
#
|
9
|
+
|
10
|
+
# = Setting up your project
|
11
|
+
#
|
12
|
+
# = Example
|
13
|
+
#
|
14
|
+
# create_gif(sceanrio, './myproj/gifs', './myproj/pngs', @browser :watir)
|
15
|
+
class GlypticGifs
|
16
|
+
@@scenario_index = 0
|
17
|
+
|
18
|
+
##
|
19
|
+
# This methods takes all of the png files from the parameter png_folder
|
20
|
+
# and stitches them together into a gif file abd saves it to the gif_location
|
21
|
+
#
|
22
|
+
|
23
|
+
def create_gif(scenario, gif_location, png_folder, driver, driver_type)
|
24
|
+
take_gif_frame(driver, driver_type, png_folder) if(scenario.failed?)
|
25
|
+
# iOS takes 10 seconds to save an image.
|
26
|
+
sleep 10
|
27
|
+
dir_contents = Dir.glob("#{png_folder}/*.png").sort
|
28
|
+
image_list = ImageList.new
|
29
|
+
img_index = 0
|
30
|
+
num_of_images = dir_contents.size
|
31
|
+
scenario_index = get_correct_scenario_index(scenario)
|
32
|
+
scenario_array = scenario.feature.feature_elements[scenario_index.to_i].send(:raw_steps).to_a
|
33
|
+
|
34
|
+
# Add the step description in red or green text to each image frame
|
35
|
+
dir_contents.each do |file_name|
|
36
|
+
step_name = scenario_array[img_index].name.to_s
|
37
|
+
if (scenario.failed? && (num_of_images - 1 == img_index))
|
38
|
+
add_text(file_name, "#{img_index+1}: #{step_name}", 'red')
|
39
|
+
else
|
40
|
+
add_text(file_name, "#{img_index+1}: #{step_name}", 'green')
|
41
|
+
end
|
42
|
+
image = Image.read("#{file_name}").first
|
43
|
+
image_list << image
|
44
|
+
img_index = img_index + 1
|
45
|
+
end
|
46
|
+
image_list.delay = 300
|
47
|
+
image_list.write(gif_location)
|
48
|
+
end
|
49
|
+
|
50
|
+
##
|
51
|
+
# Takes a screenshot and saves it as a single frame for the gif
|
52
|
+
# in the png_folder location
|
53
|
+
#
|
54
|
+
def take_gif_frame(driver, driver_type, png_folder)
|
55
|
+
sleep 2
|
56
|
+
@@scenario_index = 0 if @@scenario_index == nil
|
57
|
+
screenshot_name = "%03d" % @@scenario_index
|
58
|
+
screenshot_location = "#{png_folder}/#{screenshot_name}.png"
|
59
|
+
if(driver_type == :watir)
|
60
|
+
driver.screenshot.save screenshot_location
|
61
|
+
elsif(driver_type == :appium)
|
62
|
+
driver.screenshot(screenshot_location)
|
63
|
+
end
|
64
|
+
@@scenario_index = @@scenario_index + 1
|
65
|
+
end
|
66
|
+
|
67
|
+
##
|
68
|
+
# Helper method to get the correct text to add to the png file
|
69
|
+
#
|
70
|
+
def get_correct_scenario_index(scenario)
|
71
|
+
expected_name = scenario.name
|
72
|
+
number_of_sceanrios = scenario.feature.feature_elements.size
|
73
|
+
found = false
|
74
|
+
current_iteration = 0
|
75
|
+
while(!found && number_of_sceanrios > current_iteration) do
|
76
|
+
if expected_name == scenario.feature.feature_elements[current_iteration].name
|
77
|
+
found = true
|
78
|
+
else
|
79
|
+
current_iteration = current_iteration + 1
|
80
|
+
end
|
81
|
+
end
|
82
|
+
current_iteration
|
83
|
+
end
|
84
|
+
|
85
|
+
##
|
86
|
+
# Adds given text to image
|
87
|
+
#
|
88
|
+
def add_text(image_location, text, color)
|
89
|
+
img = Magick::Image.read(image_location).first
|
90
|
+
text_layer = Magick::Draw.new
|
91
|
+
text_layer.font = 'Helvetica'
|
92
|
+
text_layer.pointsize = 20
|
93
|
+
text_layer.font_weight = 800
|
94
|
+
text_layer.fill = 'black'
|
95
|
+
text_layer.gravity = Magick::NorthWestGravity
|
96
|
+
text_layer.annotate(img, 0, 0, 1, 0, text)
|
97
|
+
text_layer.fill = color
|
98
|
+
text_layer.annotate(img, 0, 0, 0, 0, text)
|
99
|
+
img.write(image_location)
|
100
|
+
end
|
101
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: glyptic_gifs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jared Sheffer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rmagick
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.15.4
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.15.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: cucumber
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 2.0.0
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '2.0'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2.0.0
|
47
|
+
description: "Glyptic Gifs - A gem which assists in the creation of gifs for cucumber
|
48
|
+
projects\n "
|
49
|
+
email: magus.chef@gmail.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- lib/glyptic_gifs.rb
|
55
|
+
homepage: http://rubygems.org/gems/glyptic_gifs
|
56
|
+
licenses:
|
57
|
+
- MIT
|
58
|
+
metadata: {}
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 2.4.5
|
76
|
+
signing_key:
|
77
|
+
specification_version: 4
|
78
|
+
summary: Gif Creating Library
|
79
|
+
test_files: []
|
80
|
+
has_rdoc:
|