talk 2.0.1 → 2.0.2

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.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -0
  3. data/.travis.yml +6 -0
  4. data/Gemfile +10 -0
  5. data/README.md +6 -0
  6. data/Rakefile +9 -0
  7. data/features/class-field.feature +226 -0
  8. data/features/class.feature +95 -0
  9. data/features/enumeration-constant.feature +76 -0
  10. data/features/enumeration.feature +35 -0
  11. data/features/glossary-term.feature +46 -0
  12. data/features/glossary.feature +35 -0
  13. data/features/step_definitions/class-field.rb +74 -0
  14. data/features/step_definitions/class.rb +50 -0
  15. data/features/step_definitions/enumeration-constant.rb +42 -0
  16. data/features/step_definitions/enumeration.rb +29 -0
  17. data/features/step_definitions/glossary-term.rb +31 -0
  18. data/features/step_definitions/glossary.rb +23 -0
  19. data/features/support/env.rb +261 -0
  20. data/lib/context.rb +282 -0
  21. data/lib/context_class.rb +224 -0
  22. data/lib/contexts/README.md +274 -0
  23. data/lib/contexts/base.rb +6 -0
  24. data/lib/contexts/boolean.rb +5 -0
  25. data/lib/contexts/class.rb +11 -0
  26. data/lib/contexts/constant.rb +5 -0
  27. data/lib/contexts/enumeration.rb +20 -0
  28. data/lib/contexts/field.rb +47 -0
  29. data/lib/contexts/glossary.rb +7 -0
  30. data/lib/contexts/inherits.rb +3 -0
  31. data/lib/contexts/map.rb +7 -0
  32. data/lib/contexts/meta.rb +2 -0
  33. data/lib/contexts/method.rb +15 -0
  34. data/lib/contexts/numeric.rb +5 -0
  35. data/lib/contexts/protocol.rb +8 -0
  36. data/lib/contexts/reference.rb +6 -0
  37. data/lib/contexts/string.rb +5 -0
  38. data/lib/contexts/target.rb +11 -0
  39. data/lib/contexts/term.rb +11 -0
  40. data/lib/languages/java/java.rb +145 -0
  41. data/lib/languages/java/templates/class.java.erb +22 -0
  42. data/lib/languages/java/templates/enumeration.java.erb +10 -0
  43. data/lib/languages/java/templates/glossary.java.erb +8 -0
  44. data/lib/languages/language.rb +172 -0
  45. data/lib/languages/objc/objc.rb +162 -0
  46. data/lib/languages/objc/templates/TalkClasses.h.erb +3 -0
  47. data/lib/languages/objc/templates/TalkClassesForward.h.erb +2 -0
  48. data/lib/languages/objc/templates/TalkConstants.h.erb +22 -0
  49. data/lib/languages/objc/templates/TalkObjectList.h.erb +4 -0
  50. data/lib/languages/objc/templates/class.h.erb +21 -0
  51. data/lib/languages/objc/templates/class.m.erb +43 -0
  52. data/lib/parse_error.rb +4 -0
  53. data/lib/parser.rb +119 -0
  54. data/lib/registry.rb +151 -0
  55. data/lib/talk.rb +5 -0
  56. data/talk.gemspec +18 -0
  57. metadata +71 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d7fc025a61346588f9645f6ecd1bb9450f092bf1
4
- data.tar.gz: f6e49406e45c550e9a4492936af318650133be43
3
+ metadata.gz: d526ec8ff5dcfbc0df84597b909908878533ff1c
4
+ data.tar.gz: 0e3149f3d0ec39651885ac9b8423b0f1d31b75fa
5
5
  SHA512:
6
- metadata.gz: f3e3c0f6acff21efb2bbe29249489b7db50183ba5745cbccf5a6cc4c9f62b79576796942451784ae8c083e6017764a4281806f2b4172a2e0cf2b459dad3ac1a9
7
- data.tar.gz: 5dc5c0994dba93d32f4699ec1e5c14935e6babd945cd09b093e5205ac233a45e7b20410ee31f926801c0802ad285f254cf652561fa8db9f5a8c3a2c9d1dba6e5
6
+ metadata.gz: 85f753134c46ee61b44350daf3c81a5b080c2eea7612647cfb0cc6d6e7f7ec01d77408757bfa8fe687edd00c1d47fc05b4ef91e7cfdf0e627c86477ab0b0ab54
7
+ data.tar.gz: bfa8165d934932f43af1867bdcd99a0374a74beb77b86d644c27fbc69fe780da5bae33f833024fba385c9f984a61b4b82cd2dc97f3b0f7f363bf3fc5f5948350
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ Gemfile.lock
3
+ .bundle
4
+
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.2"
4
+ - "1.9.3"
5
+ - "2.0.0"
6
+ - jruby-19mode
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'trollop'
4
+ gem 'json'
5
+
6
+ group :test do
7
+ gem 'cucumber'
8
+ gem 'rspec'
9
+ gem 'rake'
10
+ end
@@ -0,0 +1,6 @@
1
+ talk
2
+ ====
3
+
4
+ Compile-to-source protocol contract specification language
5
+
6
+ [![Build Status](https://travis-ci.org/jonasacres/talk.png?branch=master)](https://travis-ci.org/jonasacres/talk)
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'cucumber'
3
+ require 'cucumber/rake/task'
4
+
5
+ Cucumber::Rake::Task.new(:features) do |t|
6
+ t.cucumber_opts = "features --format pretty"
7
+ end
8
+
9
+ task :default => :features
@@ -0,0 +1,226 @@
1
+ Feature: @class -> @field
2
+ Scenario Outline: Define a field
3
+ Given I have defined a valid class
4
+ And I give it a field named <name> of type <type> and description <description>
5
+ When I get the result hash
6
+ Then the field <name> should have type <type> and description <description>
7
+
8
+ Examples:
9
+ | name | type | description |
10
+ | foobar8 | int8 | I am an 8-bit integer |
11
+ | foobarU16 | uint16 | I am a 16-bit unsigned integer |
12
+
13
+ Scenario Outline: Define a field with implicit description
14
+ Given I have defined a valid class
15
+ And I give it a field named <name> of type <type> and implicit description <description>
16
+ When I get the result hash
17
+ Then the field <name> should have type <type> and description <description>
18
+
19
+ Examples:
20
+ | name | type | description |
21
+ | foobar8 | int8 | I am an 8-bit integer |
22
+ | foobarU16 | uint16 | I am a 16-bit unsigned integer |
23
+
24
+ Scenario Outline: Define a field with a valid primitive type
25
+ Given I have defined a valid class
26
+ And I give it a valid field named foobar of type <type>
27
+ When I get the result hash
28
+ Then the field foobar should have type <type>
29
+
30
+ Examples:
31
+ | type |
32
+ | uint8 |
33
+ | uint16 |
34
+ | uint32 |
35
+ | uint64 |
36
+ | int8 |
37
+ | int16 |
38
+ | int32 |
39
+ | int64 |
40
+ | string |
41
+ | object |
42
+ | talkobject |
43
+ | real |
44
+ | bool |
45
+
46
+ Scenario Outline: Define a field with an invalid type
47
+ Given I have defined a valid class
48
+ And I give it a valid field named foobar of type <type>
49
+ When I get the result hash
50
+ Then there should be a parse error
51
+
52
+ Examples:
53
+ | type |
54
+ | Lies |
55
+ | IAmTheDevil |
56
+ | LookMaNoParse |
57
+
58
+ Scenario Outline: Define a field with a sibling class
59
+ Given I have defined a valid class named <sibling>
60
+ And I have defined a valid class
61
+ And I give it a valid field named foobar of type <sibling>
62
+ When I get the result hash
63
+ Then the field foobar should have type <sibling>
64
+
65
+ Examples:
66
+ | sibling |
67
+ | Brother |
68
+ | Sister |
69
+ | GenderNeutralSibling |
70
+
71
+ Scenario Outline: Define a field with a sibling class referenced by abbreviation
72
+ Given I have defined a valid class named <sibling>
73
+ And I have defined a valid class
74
+ And I give it a valid field named foobar of type <abbrev>
75
+ When I get the result hash
76
+ Then the field foobar should have type <sibling>
77
+
78
+ Examples:
79
+ | sibling | abbrev |
80
+ | com.example.Sibling | Sibling |
81
+ | com.example.Sibling | example.Sibling |
82
+ | com.example.Sibling | com.example.Sibling |
83
+
84
+ Scenario: Define a field that refers to its container class
85
+ Given I have defined a valid class named Container
86
+ And I give it a valid field named foobar of type Container
87
+ When I get the result hash
88
+ Then the field foobar should have type Container
89
+
90
+ Scenario Outline: Define a field with an @see class
91
+ Given I have defined a valid class named <other>
92
+ And I have defined a valid class
93
+ And I give it a valid field named foobar
94
+ And I give foobar @see class <other>
95
+ When I get the result hash
96
+ Then the field foobar should have an @see class <other>
97
+
98
+ Examples:
99
+ | other |
100
+ | AClass |
101
+ | CoolClass |
102
+ | LameClass |
103
+
104
+ Scenario: Define a field with an @see class that doesn't exist
105
+ Given I have defined a valid class
106
+ And I give it a valid field named foobar
107
+ And I give foobar @see class DoesntExist
108
+ When I get the result hash
109
+ Then there should be a parse error
110
+
111
+ Scenario Outline: Define a field with an @see glossary
112
+ Given I have defined a valid glossary named <other>
113
+ And I have defined a valid class
114
+ And I give it a valid field named foobar
115
+ And I give foobar @see glossary <other>
116
+ When I get the result hash
117
+ Then the field foobar should have an @see glossary <other>
118
+
119
+ Examples:
120
+ | other |
121
+ | BestBabyNamesFor2014 |
122
+ | LexiconOfCthulhu |
123
+ | AdorableAnimals |
124
+
125
+ Scenario: Define a field with an @see glossary that doesn't exist
126
+ Given I have defined a valid class
127
+ And I give it a valid field named foobar
128
+ And I give foobar @see glossary DoesntExist
129
+ When I get the result hash
130
+ Then there should be a parse error
131
+
132
+ Scenario Outline: Define a field with an @see enumeration
133
+ Given I have defined a valid enumeration named <other>
134
+ And I have defined a valid class
135
+ And I give it a valid field named foobar
136
+ And I give foobar @see enumeration <other>
137
+ When I get the result hash
138
+ Then the field foobar should have an @see enumeration <other>
139
+
140
+ Examples:
141
+ | other |
142
+ | BestBabyNamesFor2014 |
143
+ | LexiconOfCthulhu |
144
+ | AdorableAnimals |
145
+
146
+ Scenario Outline: Define a field with an @see enum
147
+ Given I have defined a valid enumeration named <other>
148
+ And I have defined a valid class
149
+ And I give it a valid field named foobar
150
+ And I give foobar @see enum <other>
151
+ When I get the result hash
152
+ Then the field foobar should have an @see enumeration <other>
153
+
154
+ Examples:
155
+ | other |
156
+ | HowILoveThee |
157
+ | MarksEvilBitmasks |
158
+ | WaysToLeaveYourLover |
159
+
160
+ Scenario: Define a field with an @see enumeration that doesn't exist
161
+ Given I have defined a valid class
162
+ And I give it a valid field named foobar
163
+ And I give foobar @see enumeration DoesntExist
164
+ When I get the result hash
165
+ Then there should be a parse error
166
+
167
+ Scenario Outline: Define a field with @caveats
168
+ Given I have defined a valid class
169
+ And I give it a valid field named foobar
170
+ And I give foobar @caveat <message_1>
171
+ And I give foobar @caveat <message_2>
172
+ When I get the result hash
173
+ Then the field foobar should have a @caveat <message_1>
174
+ And the field foobar should have a @caveat <message_2>
175
+
176
+ Examples:
177
+ | message_1 | message_2 |
178
+ | This field is pure evil | May contain null, as well as fatal amounts of arsenic |
179
+ | Field might be garbage | Field might also have the information you need to survive |
180
+
181
+ Scenario Outline: Define a field as @deprecated
182
+ Given I have defined a valid class
183
+ And I give it a valid field named foobar
184
+ And I give foobar @deprecated <message>
185
+ When I get the result hash
186
+ Then the field foobar should have @deprecated <message>
187
+
188
+ Examples:
189
+ | message |
190
+ | It wasn't working out |
191
+ | It's not the field, it's us |
192
+ | We still want to be friends with this field and hope it moves on to other classes that will love it for who it is |
193
+
194
+ Scenario: Define a field as @deprecated twice
195
+ Given I have defined a valid class
196
+ And I give it a valid field named foobar
197
+ And I give foobar @deprecated once
198
+ And I give foobar @deprecated again
199
+ When I get the result hash
200
+ Then there should be a parse error
201
+
202
+ Scenario Outline: Define a field with an @version
203
+ Given I have defined a valid class
204
+ And I give it a valid field named foobar
205
+ And I give foobar @version <version>
206
+ When I get the result hash
207
+ Then the field foobar should have @version <version>
208
+
209
+ Examples:
210
+ | version |
211
+ | 1 |
212
+ | 3.0 |
213
+ | sheepishly stroked lion |
214
+
215
+ Scenario Outline: Define a field with two @version tags
216
+ Given I have defined a valid class
217
+ And I give it a valid field named foobar
218
+ And I give foobar @version <version_1>
219
+ And I give foobar @version <version_2>
220
+ When I get the result hash
221
+ Then there should be a parse error
222
+
223
+ Examples:
224
+ | version_1 | version_2 |
225
+ | 1.0 | 1.0 |
226
+ | 1.0 | 2.0 |
@@ -0,0 +1,95 @@
1
+ Feature: @class
2
+ Scenario Outline: Define a class with an explicit @description
3
+ Given I have defined a class named <name>
4
+ And I have given <description> as a @description
5
+ When I get the result hash
6
+ Then there should be a class named <name>
7
+ And it should have description <description>
8
+
9
+ Examples:
10
+ | name | description |
11
+ | Lumberjack | I am a lumberjack, and I am acceptable |
12
+ | com.example.JavaClass | I have a hierarchical name |
13
+
14
+ Scenario Outline: Define a class with an implicit @description
15
+ Given I have defined a class named <name>
16
+ And I have given <description> as an implied description
17
+ When I get the result hash
18
+ Then there should be a class named <name>
19
+ And it should have description <description>
20
+
21
+ Examples:
22
+ | name | description |
23
+ | Lumberjack | I am a lumberjack, and I am acceptable |
24
+ | com.example.JavaClass | I have a hierarchical name |
25
+
26
+ Scenario: Define a class without a description
27
+ Given I have defined a class named NoDescriptionClsas
28
+ But I don't give a description
29
+ When I get the result hash
30
+ Then there should be a parse error
31
+
32
+ Scenario: Define a class with a duplicate name
33
+ Given I have defined a class named DuplicateClass
34
+ And I have given it some random bullshit as a @description
35
+ And I define another class also named DuplicateClass
36
+ When I get the result hash
37
+ Then there should be a parse error
38
+
39
+ Scenario Outline: Define a class with @inherits
40
+ Given I have defined a valid class named <base>
41
+ And I have defined a valid class named ChildClass
42
+ And I give it @inherits <base>
43
+ When I get the result hash
44
+ Then the class ChildClass should have @inherits <base>
45
+
46
+ Examples:
47
+ | base |
48
+ | BaseClass |
49
+ | YourDaddy |
50
+
51
+ Scenario Outline: Define a class that @inherits from an undefined class
52
+ Given I have defined a valid class named ChildClass
53
+ And I give it @inherits <base>
54
+ When I get the result hash
55
+ Then there should be a parse error
56
+
57
+ Examples:
58
+ | base |
59
+ | DoesntExist |
60
+ | uint16 |
61
+ | string |
62
+ | talkobject |
63
+
64
+ Scenario Outline: Define a class that @inherits twice
65
+ Given I have defined a valid class named BaseClass1
66
+ And I have defined a valid class named BaseClass2
67
+ And I have defined a valid class named ChildClass
68
+ And I give it @inherits <base_1>
69
+ And I give it @inherits <base_2>
70
+ When I get the result hash
71
+ Then there should be a parse error
72
+
73
+ Examples:
74
+ | base_1 | base_2 |
75
+ | BaseClass1 | BaseClass1 |
76
+ | BaseClass1 | BaseClass2 |
77
+
78
+ Scenario Outline: Define a class that sets @implement
79
+ Given I have defined a valid class named NoImplementClass
80
+ And I give it @implement <implement>
81
+ When I get the result hash
82
+ Then the class NoImplementClass should have @implement <value>
83
+
84
+ Examples:
85
+ | implement | value |
86
+ | 0 | false |
87
+ | off | false |
88
+ | false | false |
89
+ | no | false |
90
+ | NO | false |
91
+ | False | false |
92
+ | 1 | true |
93
+ | on | true |
94
+ | true | true |
95
+ | yes | true |
@@ -0,0 +1,76 @@
1
+ Feature: @enumeration -> @constant
2
+
3
+ Scenario Outline: Define a constant
4
+ Given I have defined a valid enumeration named <enumeration>
5
+ And I define a constant named <constant> with value <value> and description <description>
6
+ When I get the result hash
7
+ Then the enumeration <enumeration> should contain a constant named <constant>
8
+ And the constant <constant> of enumeration <enumeration> should have value <value>
9
+ And the constant <constant> of enumeration <enumeration> should have description <description>
10
+
11
+ Examples:
12
+ | enumeration | constant | value | description |
13
+ | AnEnumeration | AConstant | 1 | A description |
14
+ | AnotherEnumeration | AnotherConstant | 4 | Another description |
15
+
16
+ Scenario Outline: Define multiple constants
17
+ Given I have defined a valid enumeration named <enumeration>
18
+ And I define a constant named <constant_1> with value <value_1> and description <description_1>
19
+ And I define a constant named <constant_2> with value <value_2> and description <description_2>
20
+ When I get the result hash
21
+ Then the enumeration <enumeration> should contain a constant named <constant_1>
22
+ And the constant <constant_1> of enumeration <enumeration> should have value <value_1>
23
+ And the constant <constant_1> of enumeration <enumeration> should have description <description_1>
24
+ And the enumeration <enumeration> should contain a constant named <constant_2>
25
+ And the constant <constant_2> of enumeration <enumeration> should have value <value_2>
26
+ And the constant <constant_2> of enumeration <enumeration> should have description <description_2>
27
+
28
+ Examples:
29
+ | enumeration | constant_1 | value_1 | description_1 | constant_2 | value_2 | description_2 |
30
+ | AnEnumeration | Constant1 | 1 | A Description | Constant2 | 2 | Another Description |
31
+ | AnotherEnumeration | ConstantA | 2 | A Description | ConstantB | 1 | Another Description |
32
+ | AThirdEnumeration | ConstantOne | 2 | Numeral two | ConstantTwo | 2 | Ordinal two |
33
+
34
+ Scenario: Define constants with implied values
35
+ Given I have defined a valid enumeration named AnEnumeration
36
+ And I define a valid constant named Constant0
37
+ And I define a valid constant named Constant1
38
+ And I define a valid constant named Constant2
39
+ When I get the result hash
40
+ Then the constant Constant0 of enumeration AnEnumeration should have value 0
41
+ Then the constant Constant1 of enumeration AnEnumeration should have value 1
42
+ Then the constant Constant2 of enumeration AnEnumeration should have value 2
43
+
44
+
45
+ Scenario Outline: Define constants with mixed explicit and implied values
46
+ Given I have defined a valid enumeration named AnEnumeration
47
+ And I define a valid constant named Constant1 with value <value1>
48
+ And I define a valid constant named Constant2
49
+ And I define a valid constant named Constant3
50
+ And I define a valid constant named Constant4 with value <value4>
51
+ And I define a valid constant named Constant5
52
+ When I get the result hash
53
+ Then the constant Constant1 of enumeration AnEnumeration should have value <value1>
54
+ And the constant Constant2 of enumeration AnEnumeration should have value <expected2>
55
+ And the constant Constant3 of enumeration AnEnumeration should have value <expected3>
56
+ And the constant Constant4 of enumeration AnEnumeration should have value <value4>
57
+ And the constant Constant5 of enumeration AnEnumeration should have value <expected5>
58
+
59
+ Examples:
60
+ | value1 | expected2 | expected3 | value4 | expected5 |
61
+ | 1 | 2 | 3 | 4 | 5 |
62
+ | 0 | 1 | 2 | 10 | 11 |
63
+
64
+ Scenario Outline: Define a constant with an interpreted expression
65
+ Given I have defined a valid enumeration named AnEnumeration
66
+ And I define a valid constant named Expressive with value <expression>
67
+ When I get the result hash
68
+ Then the constant Expressive should have value <output>
69
+
70
+ Examples:
71
+ | expression | output |
72
+ | 0 | 0 |
73
+ | Math.cos(0) | 1 |
74
+ | 0x10 | 16 |
75
+ | 1 << 8 | 256 |
76
+