graffle 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/History.txt +5 -4
  2. data/Manifest.txt +13 -10
  3. data/Rakefile.hoe +1 -1
  4. data/examples/rails-workflow-test.expected +10 -0
  5. data/examples/rails-workflow-test.graffle/data.plist +1033 -0
  6. data/examples/rails-workflow-test.graffle/image1.png +0 -0
  7. data/examples/rails-workflow-test.graffle/image2.png +0 -0
  8. data/examples/rails-workflow-test.graffle/image3.png +0 -0
  9. data/examples/rails-workflow-test.rb +40 -0
  10. data/graffle.tmproj +431 -2
  11. data/lib/graffle/stereotypes.rb +15 -4
  12. data/lib/graffle/styled-text-reader.rb +3 -0
  13. data/lib/graffle/version.rb +1 -1
  14. data/lib/graphical_tests_for_rails.rb +25 -0
  15. data/lib/graphical_tests_for_rails/interpreters.rb +147 -0
  16. data/lib/graphical_tests_for_rails/orderings.rb +101 -0
  17. data/test/graffle-file-types/opening-tests.rb +0 -1
  18. data/test/graphical_tests_for_rails/graphic-interpreter-tests.rb +131 -0
  19. data/test/graphical_tests_for_rails/in-workflow-order-tests.rb +165 -0
  20. data/test/{grails-tests/commands-from-quoted-args-tests.rb → graphical_tests_for_rails/text-interpreter-tests.rb} +38 -27
  21. data/test/line-graphic-tests.rb +8 -0
  22. data/test/sheet-tests.rb +18 -0
  23. data/test/tests-of-examples/workflow-slowtests.rb +19 -0
  24. metadata +20 -18
  25. data/bin/bin-skeleton +0 -13
  26. data/lib/graffle/lib-skeleton +0 -3
  27. data/lib/grail_test.rb +0 -16
  28. data/lib/grail_test/command-interpreters.rb +0 -78
  29. data/test/grails-tests/destinations-tests.rb +0 -19
  30. data/test/grails-tests/do-nothing-commands-tests.rb +0 -18
  31. data/test/grails-tests/graphic-interpreter-tests.rb +0 -70
  32. data/test/grails-tests/translation-testcase.rb +0 -25
  33. data/test/test-skeleton +0 -19
@@ -0,0 +1,165 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Created by Brian Marick on 2007-07-11.
4
+ # Copyright (c) 2007. All rights reserved.
5
+
6
+ require 'test/unit'
7
+ require 's4t-utils'
8
+ include S4tUtils
9
+
10
+ require "../set-standalone-test-paths.rb" unless $started_from_rakefile
11
+
12
+ require 'extensions/string'
13
+ require 'graphical_tests_for_rails/orderings.rb'
14
+
15
+ class TestWorkflowOrder < Test::Unit::TestCase
16
+ include Graffle::Builders
17
+ include GraphicalTestsForRails
18
+
19
+ def test_workflow_order_finds_highest_first
20
+ s = sheet {
21
+ with line_graphic {
22
+ graffle_id_is 2
23
+ points_at [10, 10], [11, 11]
24
+ }
25
+ with line_graphic {
26
+ graffle_id_is 1
27
+ points_at [1, 1], [100, 100]
28
+ }
29
+ }
30
+
31
+ graphics = InWorkflowOrder.new(s).graphics
32
+ assert_equal([1, 2], graphics.collect { |g| g.graffle_id })
33
+ end
34
+
35
+ def test_workflow_order_finds_shaped_graphics_too
36
+ s = sheet {
37
+ with line_graphic {
38
+ graffle_id_is 2
39
+ points_at [10, 10], [1000, 1000]
40
+ }
41
+ with shaped_graphic {
42
+ graffle_id_is 1
43
+ bounded_by 5, 5, 100, 100
44
+ }
45
+ }
46
+
47
+ graphics = InWorkflowOrder.new(s).graphics
48
+ assert_equal([1, 2], graphics.collect { |g| g.graffle_id })
49
+ end
50
+
51
+ def test_it_is_the_origin_that_matters
52
+ s = sheet {
53
+ with shaped_graphic {
54
+ graffle_id_is 1
55
+ bounded_by 5, 5, 100, 100
56
+ }
57
+ with line_graphic {
58
+ graffle_id_is 2
59
+ # Note that line extends above shape.
60
+ points_at [10, 10], [1, 1]
61
+ }
62
+ }
63
+ graphics = InWorkflowOrder.new(s).graphics
64
+ assert_equal([1, 2], graphics.collect { |g| g.graffle_id })
65
+ end
66
+
67
+ def test_workflow_order_ignores_labels
68
+ s = sheet {
69
+ with line_label {
70
+ graffle_id_is 222
71
+ bounded_by 1, 1, 1, 1
72
+ for_line 1
73
+ }
74
+ with line_graphic {
75
+ graffle_id_is 1
76
+ points_at [10, 10], [1, 1]
77
+ }
78
+ }
79
+ graphics = InWorkflowOrder.new(s).graphics
80
+ assert_equal([1], graphics.collect { |g| g.graffle_id })
81
+ end
82
+
83
+ def test_workflows_break_order_by_following_lines
84
+
85
+ # Id is the order in which they are linked together.
86
+ # That is NOT the vertical order on the page.
87
+ s = sheet {
88
+ with line_graphic {
89
+ graffle_id_is 3
90
+ points_at [40, 40], [20, 20] # fourth highest
91
+ go_from 2
92
+ go_to 4
93
+ }
94
+ with shaped_graphic {
95
+ graffle_id_is 2
96
+ bounded_by 30, 30, 20, 20 # third highest
97
+ }
98
+ with shaped_graphic {
99
+ graffle_id_is 4
100
+ bounded_by 20, 20, 10, 10 # second highest
101
+ }
102
+ with line_graphic {
103
+ graffle_id_is 1
104
+ points_at [10, 10], [30, 30] # highest
105
+ go_to 2
106
+ }
107
+
108
+ }
109
+ graphics = InWorkflowOrder.new(s).graphics
110
+ assert_equal([1, 2, 3, 4], graphics.collect { |g| g.graffle_id })
111
+ end
112
+
113
+
114
+ def test_large_example_of_disconnected_workflows
115
+
116
+ # Id is the order in which they are linked together.
117
+ # That is NOT the vertical order on the page.
118
+ s = sheet {
119
+
120
+ # Third workflow - starts with shaped graphic, ends with line
121
+ with line_graphic {
122
+ graffle_id_is 7
123
+ points_at [12, 12], [200, 200]
124
+ go_from 6
125
+ }
126
+ with shaped_graphic {
127
+ graffle_id_is 6
128
+ bounded_by 11, 11, 2, 2 # third highest
129
+ }
130
+
131
+ # Second workflow - a single element
132
+ with shaped_graphic {
133
+ graffle_id_is 5
134
+ bounded_by 11, 10, 20, 20 # second highest
135
+ }
136
+
137
+ # First workflow
138
+ with line_graphic {
139
+ graffle_id_is 3
140
+ points_at [40, 40], [20, 20]
141
+ go_from 2
142
+ go_to 4
143
+ }
144
+ with shaped_graphic {
145
+ graffle_id_is 2
146
+ bounded_by 30, 30, 20, 20
147
+ }
148
+ with shaped_graphic {
149
+ graffle_id_is 4
150
+ bounded_by 20, 20, 10, 10
151
+ }
152
+ with line_graphic {
153
+ graffle_id_is 1
154
+ points_at [10, 10], [30, 30] # highest
155
+ go_to 2
156
+ }
157
+
158
+ }
159
+ graphics = InWorkflowOrder.new(s).graphics
160
+ assert_equal((1..7).to_a, graphics.collect { |g| g.graffle_id })
161
+ end
162
+
163
+
164
+
165
+ end
@@ -1,40 +1,29 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
- # Created by Brian Marick on 2007-07-06.
3
+ # Created by Brian Marick on 2007-07-11.
4
4
  # Copyright (c) 2007. All rights reserved.
5
5
 
6
6
  require "../set-standalone-test-paths.rb" unless $started_from_rakefile
7
- require 'test/grails-tests/translation-testcase'
8
7
 
9
- class TestCommandsFromQuotedArgs < TranslationTestCase
8
+ require 'test/unit'
9
+ require 's4t-utils'
10
+ include S4tUtils
10
11
 
11
-
12
- # TODO: put this somewhere right.
13
- PLAIN = ['John follows "sign up" link',
14
- 'he logs in with "john", password "fred", and auth key "foo".',
15
- 'plain command with trailing period',
16
- 'Plain command - (upper case and special chars)'
17
- ]
18
-
19
- # TODO: put this somewhere right.
20
- RTF = %Q{
21
- | {\\rtf1\\mac\\ansicpg10000\\cocoartf824\\cocoasubrtf420
22
- | {\\fonttbl\\f0\\fswiss\\fcharset77 Helvetica;}
23
- | {\\colortbl;\\red255\\green255\\blue255;}
24
- | \\pard\\tx560\\tx1120\\tx1680\\tx2240\\tx2800\\tx3360\\tx3920\\tx4480\\tx5040\\tx5600\\tx6160\\tx6720\\qc\\pardirnatural
25
- |
26
- | \\f0\\fs24 \\cf0 #{PLAIN[0]}\\
27
- | #{PLAIN[1]}\\
28
- | #{PLAIN[2]}\\
29
- | #{PLAIN[3]}}}.trim('|')
12
+ require 'extensions/string'
13
+ require 'graphical_tests_for_rails'
30
14
 
31
15
 
32
- def setup
33
- @interpreter = CommandsWithQuotedArgs.new
16
+ class TestProductionOfMessages < Test::Unit::TestCase
17
+ include GraphicalTestsForRails
18
+
19
+ def assert_translation(expected, original)
20
+ actual = @interpreter.produce_method_call(original)
21
+ assert_equal(expected, actual)
34
22
  end
35
23
 
36
- def test_translation
37
- # Underscoring
24
+ def test_messages_whose_arguments_come_from_quoted_text
25
+ @interpreter = ArgsFromQuotedText.new
26
+
38
27
  assert_translation(['token'], "token")
39
28
  assert_translation(['underscore_separated_tokens'],
40
29
  'underscore separated tokens'
@@ -82,5 +71,27 @@ class TestCommandsFromQuotedArgs < TranslationTestCase
82
71
  assert_translation(["while_a_messages_quotes_are_stripped", "an argument's are retained"],
83
72
  %q{while a message's quotes are stripped, "an argument's are retained"}
84
73
  )
74
+
75
+ assert_translation(["capitals_are_lowercased_throughout"],
76
+ %q{Capitals are lowercased THROUGHOUT})
77
+ end
78
+
79
+ def test_messages_created_from_page_names
80
+ @interpreter = TextIsNameOfPage.new('assert_on_page')
81
+ assert_translation(['assert_on_page', "markup"],
82
+ "MARKUP")
83
+
84
+ assert_translation(['assert_on_page', "outside-spaces"],
85
+ " outside-spaces ")
86
+
87
+ # TODO: don't know what makes sense for interior spaces or
88
+ # non-\w characters.
89
+
90
+ end
91
+
92
+
93
+ def test_ineffectual_interpreters_produce_messages_that_do_nothing
94
+ @interpreter = Ineffectual.new
95
+ assert_translation([:object_id], "MARKUP")
85
96
  end
86
- end
97
+ end
@@ -109,6 +109,14 @@ class TestLineGraphics < Test::Unit::TestCase
109
109
  s.graphics[1].graphics[1].from)
110
110
  end
111
111
 
112
+ def test_lines_need_not_be_connected_to_anything
113
+ s = sheet { with line_graphic }
114
+ line = s.graphics[0]
115
+
116
+ assert_equal(nil, line.to)
117
+ assert_equal(nil, line.from)
118
+ end
119
+
112
120
  LINE_LABEL_TEXT = "
113
121
  | {\\rtf1\\mac\\ansicpg10000\\cocoartf824\\cocoasubrtf420
114
122
  | {\\fonttbl\\f0\\fswiss\\fcharset77 Helvetica;}
@@ -31,6 +31,24 @@ class TestSheets < Test::Unit::TestCase
31
31
  sheet { with abstract, line, shaped }.graphics)
32
32
  end
33
33
 
34
+ def test_sheet_can_omit_labels_when_returning_graphics
35
+ s = sheet {
36
+ with shaped_graphic {
37
+ graffle_id_is 33
38
+ }
39
+ with line_label {
40
+ for_line 1
41
+ graffle_id_is 3
42
+ }
43
+ with line_graphic {
44
+ graffle_id_is 1
45
+ }
46
+ }
47
+
48
+ graphics = s.graphics_without_labels
49
+ assert_equal([33, 1], graphics.collect { |g| g.graffle_id })
50
+ end
51
+
34
52
 
35
53
  def test_sheet_elements_know_parent
36
54
  abstract = abstract_graphic
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Created by Brian Marick on 2007-07-11.
4
+ # Copyright (c) 2007. All rights reserved.
5
+
6
+ require "../set-standalone-test-paths.rb" unless $started_from_rakefile
7
+ require "test/unit"
8
+ require 's4t-utils'
9
+
10
+
11
+ class TestThatExamplesWork < Test::Unit::TestCase
12
+ In_examples = "cd #{PACKAGE_ROOT}/examples;"
13
+ def test_all
14
+ system "#{In_examples} ruby rails-workflow-test.rb > rails-workflow-test.actual 2>&1"
15
+ system("#{In_examples} diff rails-workflow-test.{e*,a*}")
16
+ assert_equal(0, $?)
17
+ system "#{In_examples} rm rails-workflow-test.actual" if $? == 0
18
+ end
19
+ end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: graffle
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.7
7
- date: 2007-07-11 00:00:00 -05:00
6
+ version: 0.1.8
7
+ date: 2007-07-13 00:00:00 -05:00
8
8
  summary: Working with OmniGraffle documents, including support for Rails integration tests.
9
9
  require_paths:
10
10
  - lib
@@ -35,18 +35,23 @@ files:
35
35
  - README.txt
36
36
  - Rakefile
37
37
  - Rakefile.hoe
38
- - bin/bin-skeleton
38
+ - examples/rails-workflow-test.expected
39
+ - examples/rails-workflow-test.graffle/data.plist
40
+ - examples/rails-workflow-test.graffle/image1.png
41
+ - examples/rails-workflow-test.graffle/image2.png
42
+ - examples/rails-workflow-test.graffle/image3.png
43
+ - examples/rails-workflow-test.rb
39
44
  - graffle.tmproj
40
45
  - lib/graffle.rb
41
46
  - lib/graffle/.document
42
- - lib/graffle/lib-skeleton
43
47
  - lib/graffle/nodoc/hacks.rb
44
48
  - lib/graffle/point.rb
45
49
  - lib/graffle/stereotypes.rb
46
50
  - lib/graffle/styled-text-reader.rb
47
51
  - lib/graffle/version.rb
48
- - lib/grail_test.rb
49
- - lib/grail_test/command-interpreters.rb
52
+ - lib/graphical_tests_for_rails.rb
53
+ - lib/graphical_tests_for_rails/interpreters.rb
54
+ - lib/graphical_tests_for_rails/orderings.rb
50
55
  - setup.rb
51
56
  - test/abstract-graphic-tests.rb
52
57
  - test/array-and-hash-stereotyping-tests.rb
@@ -58,11 +63,9 @@ files:
58
63
  - test/graffle-file-types/multiple-canvases.graffle
59
64
  - test/graffle-file-types/opening-tests.rb
60
65
  - test/graffle-file-types/two-boxes-and-a-line.graffle
61
- - test/grails-tests/commands-from-quoted-args-tests.rb
62
- - test/grails-tests/destinations-tests.rb
63
- - test/grails-tests/do-nothing-commands-tests.rb
64
- - test/grails-tests/graphic-interpreter-tests.rb
65
- - test/grails-tests/translation-testcase.rb
66
+ - test/graphical_tests_for_rails/graphic-interpreter-tests.rb
67
+ - test/graphical_tests_for_rails/in-workflow-order-tests.rb
68
+ - test/graphical_tests_for_rails/text-interpreter-tests.rb
66
69
  - test/group-tests.rb
67
70
  - test/hacks-tests.rb
68
71
  - test/line-graphic-tests.rb
@@ -71,7 +74,7 @@ files:
71
74
  - test/shaped-graphic-tests.rb
72
75
  - test/sheet-tests.rb
73
76
  - test/styled-text-reader-tests.rb
74
- - test/test-skeleton
77
+ - test/tests-of-examples/workflow-slowtests.rb
75
78
  - test/text-tests.rb
76
79
  - test/util.rb
77
80
  test_files:
@@ -87,10 +90,9 @@ test_files:
87
90
  - test/styled-text-reader-tests.rb
88
91
  - test/text-tests.rb
89
92
  - test/graffle-file-types/opening-tests.rb
90
- - test/grails-tests/commands-from-quoted-args-tests.rb
91
- - test/grails-tests/destinations-tests.rb
92
- - test/grails-tests/do-nothing-commands-tests.rb
93
- - test/grails-tests/graphic-interpreter-tests.rb
93
+ - test/graphical_tests_for_rails/graphic-interpreter-tests.rb
94
+ - test/graphical_tests_for_rails/in-workflow-order-tests.rb
95
+ - test/graphical_tests_for_rails/text-interpreter-tests.rb
94
96
  rdoc_options:
95
97
  - --main
96
98
  - README.txt
@@ -99,8 +101,8 @@ extra_rdoc_files:
99
101
  - LICENSE.txt
100
102
  - Manifest.txt
101
103
  - README.txt
102
- executables:
103
- - bin-skeleton
104
+ executables: []
105
+
104
106
  extensions: []
105
107
 
106
108
  requirements: []
@@ -1,13 +0,0 @@
1
- #! /opt/local/bin/ruby
2
-
3
- require 's4t-utils'
4
- include S4tUtils
5
-
6
- require 'graffle'
7
- include Graffle
8
-
9
- if $0 == __FILE__
10
- with_pleasant_exceptions do
11
- # Your program here.
12
- end
13
- end
@@ -1,3 +0,0 @@
1
- module Graffle
2
- # Your code here
3
- end
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # Created by Brian Marick on 2007-07-10.
4
- # Copyright (c) 2007. All rights reserved.
5
-
6
-
7
-
8
- require 'graffle'
9
- require 'grail_test/command-interpreters'
10
-
11
- # See README.txt[link:files/README_txt.html]
12
- module GrailTest
13
-
14
- end
15
-
16
- GrailTests=GrailTest # Be tolerant of typos
@@ -1,78 +0,0 @@
1
- require 'enumerator'
2
-
3
- module GrailTest
4
-
5
- class GraphicInterpreter
6
-
7
- def initialize(graphics, hash = {})
8
- @graphics = graphics
9
- @line_label_strategy =
10
- hash['interpret line labels as'] || DoNothingCommands
11
- @shaped_graphic_text_strategy =
12
- hash['interpret shaped graphic text as'] || DoNothingCommands
13
- end
14
-
15
- def run_against(target)
16
- @target = target
17
- @graphics.each do |g|
18
- case g.stereotype.basename
19
- when "ShapedGraphic"
20
- process_commands(@shaped_graphic_text_strategy.new,
21
- g.content.as_lines)
22
- when "LineGraphic"
23
- process_commands(@line_label_strategy.new,
24
- g.label_lines)
25
- end
26
- end
27
- end
28
-
29
- private
30
-
31
- def process_commands(command_maker, command_lines)
32
- command_lines.each do |line|
33
- info = command_maker.produce_method_call(line)
34
- @target.send(*info)
35
- end
36
- end
37
- end
38
-
39
-
40
- class CommandsWithQuotedArgs
41
-
42
- def produce_method_call(string)
43
- quote_marker = '%<<<==-'
44
-
45
- string = string.gsub(/(\w)'(\w)/, "#{quote_marker}\\1\\2#{quote_marker}")
46
- tokens = string.split(/['"],?/, allow_trailing_null_fields = -1)
47
- message = tokens[0].strip
48
- args = tokens[1..-1]
49
-
50
-
51
- message.gsub!(/#{quote_marker}(.)(.)#{quote_marker}/, "\\1\\2")
52
- message.gsub!(/\s+/,'_')
53
- message.gsub!(/-/, '_')
54
- message.gsub!(/\W/, '')
55
-
56
-
57
- args = args.enum_slice(2).collect { |e| e[0] }
58
- args = args.collect do | arg |
59
- arg.gsub(/#{quote_marker}(.)(.)#{quote_marker}/, "\\1'\\2")
60
- end
61
-
62
- [message] + args
63
- end
64
- end
65
-
66
- class Destinations
67
- def produce_method_call(string)
68
- ['assert_on_page', string.downcase]
69
- end
70
- end
71
-
72
- class DoNothingCommands
73
- def produce_method_call(string)
74
- [:object_id] # no_op
75
- end
76
- end
77
- end
78
-