simulacrum 0.1.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cane +9 -0
- data/.env.example +2 -0
- data/.gitignore +10 -0
- data/.rspec +3 -0
- data/.rubocop.yml +14 -0
- data/.travis.yml +28 -0
- data/Gemfile +2 -0
- data/README.md +78 -19
- data/Rakefile +20 -0
- data/examples/README.md +3 -0
- data/examples/basic/Gemfile +4 -0
- data/examples/basic/README.md +13 -0
- data/examples/basic/config.ru +3 -0
- data/examples/basic/example_app.rb +7 -0
- data/examples/basic/public/button.html +13 -0
- data/examples/basic/public/index.html +22 -0
- data/examples/basic/public/panel.html +13 -0
- data/examples/basic/public/stylesheets/button.css +15 -0
- data/examples/basic/public/stylesheets/main.css +3 -0
- data/examples/basic/public/stylesheets/normalize.css +425 -0
- data/examples/basic/script/start +4 -0
- data/examples/basic/spec/simulacrum_helper.rb +9 -0
- data/examples/basic/spec/ui/button_spec.rb +10 -0
- data/exe/simulacrum +5 -0
- data/features/command_line/help.feature +8 -0
- data/features/exit_codes/failing.feature +24 -0
- data/features/exit_codes/passing.feature +24 -0
- data/features/exit_codes/pending.feature +22 -0
- data/features/output/candidate.feature +32 -0
- data/features/output/diff.feature +5 -0
- data/features/step_definitions/dummy_steps.rb +15 -0
- data/features/step_definitions/file_steps.rb +19 -0
- data/features/support/env.rb +15 -0
- data/fixtures/a1.png +0 -0
- data/fixtures/app/fixture_app.rb +12 -0
- data/fixtures/app/public/images/a1.png +0 -0
- data/fixtures/app/public/ui_component.html +10 -0
- data/fixtures/app/spec/component_spec.rb +9 -0
- data/fixtures/app/spec/simulacrum_helper.rb +37 -0
- data/fixtures/app/spec/ui/references/ui_component/test_driver/candidate.png +0 -0
- data/fixtures/diff.png +0 -0
- data/lib/simulacrum.rb +74 -15
- data/lib/simulacrum/cli.rb +38 -0
- data/lib/simulacrum/cli/parser.rb +152 -0
- data/lib/simulacrum/comparator.rb +15 -15
- data/lib/simulacrum/component.rb +22 -11
- data/lib/simulacrum/configuration.rb +20 -13
- data/lib/simulacrum/diff.rb +2 -0
- data/lib/simulacrum/diff/rmagick.rb +8 -6
- data/lib/simulacrum/driver.rb +45 -0
- data/lib/simulacrum/matchers.rb +6 -16
- data/lib/simulacrum/methods.rb +1 -0
- data/lib/simulacrum/renderer.rb +23 -8
- data/lib/simulacrum/runner.rb +44 -0
- data/lib/simulacrum/version.rb +2 -1
- data/rubocop-todo.yml +29 -0
- data/script/bootstrap +3 -0
- data/script/quality +7 -0
- data/script/spec +10 -0
- data/simulacrum.gemspec +52 -0
- data/spec/lib/simulacrum/cli/parser_spec.rb +113 -0
- data/spec/lib/simulacrum/cli_spec.rb +18 -0
- data/spec/lib/simulacrum/comparator_spec.rb +75 -0
- data/spec/lib/simulacrum/component_spec.rb +208 -0
- data/spec/lib/simulacrum/driver/local_spec.rb +11 -0
- data/spec/lib/simulacrum/version_spec.rb +12 -0
- data/spec/lib/simulacrum_spec.rb +53 -0
- data/spec/spec_helper.rb +13 -8
- data/spec/use_codeclimate.rb +3 -0
- data/spec/use_simplecov.rb +5 -12
- metadata +217 -32
- data/lib/simulacrum/diff/pdiff.rb +0 -47
- data/spec/fixtures/a.png +0 -0
- data/spec/fixtures/a2.png +0 -0
- data/spec/use_coveralls.rb +0 -2
@@ -1,47 +0,0 @@
|
|
1
|
-
# require 'chunky_png'
|
2
|
-
# require_relative '../diff'
|
3
|
-
|
4
|
-
# module Simulacrum
|
5
|
-
# class Pdiff < Simulacrum::Diff
|
6
|
-
# include ChunkyPNG::Color
|
7
|
-
|
8
|
-
# def compare
|
9
|
-
# a_image = ChunkyPNG::Image.from_file(@a_path)
|
10
|
-
# b_image = ChunkyPNG::Image.from_file(@b_path)
|
11
|
-
# end
|
12
|
-
# end
|
13
|
-
# end
|
14
|
-
|
15
|
-
# require 'chunky_png'
|
16
|
-
# include ChunkyPNG::Color
|
17
|
-
|
18
|
-
|
19
|
-
# images = [
|
20
|
-
# ChunkyPNG::Image.from_file('1.png'),
|
21
|
-
# ChunkyPNG::Image.from_file('2.png')
|
22
|
-
# ]
|
23
|
-
|
24
|
-
# output = ChunkyPNG::Image.new(images.first.width, images.last.width, WHITE)
|
25
|
-
|
26
|
-
# diff = []
|
27
|
-
|
28
|
-
# images.first.height.times do |y|
|
29
|
-
# images.first.row(y).each_with_index do |pixel, x|
|
30
|
-
# unless pixel == images.last[x,y]
|
31
|
-
# score = Math.sqrt(
|
32
|
-
# (r(images.last[x,y]) - r(pixel)) ** 2 +
|
33
|
-
# (g(images.last[x,y]) - g(pixel)) ** 2 +
|
34
|
-
# (b(images.last[x,y]) - b(pixel)) ** 2
|
35
|
-
# ) / Math.sqrt(MAX ** 2 * 3)
|
36
|
-
|
37
|
-
# output[x,y] = grayscale(MAX - (score * MAX).round)
|
38
|
-
# diff << score
|
39
|
-
# end
|
40
|
-
# end
|
41
|
-
# end
|
42
|
-
|
43
|
-
# puts "pixels (total): #{images.first.pixels.length}"
|
44
|
-
# puts "pixels changed: #{diff.length}"
|
45
|
-
# puts "image changed (%): #{(diff.inject {|sum, value| sum + value} / images.first.pixels.length) * 100}%"
|
46
|
-
|
47
|
-
# output.save('diff.png')
|
data/spec/fixtures/a.png
DELETED
Binary file
|
data/spec/fixtures/a2.png
DELETED
Binary file
|
data/spec/use_coveralls.rb
DELETED