nudge 0.1.2 → 0.1.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.
@@ -0,0 +1,50 @@
1
+ # coding: utf-8
2
+
3
+ # This file was automatically generated when <%=@camelcased_type_name%> was created
4
+ #
5
+ # Your class should define (at least) the four following methods
6
+ # The calls to 'super' will raise exceptions until replaced with valid code
7
+ #
8
+
9
+ module NudgeType
10
+
11
+
12
+ class <%=@camelcased_type_name%>
13
+ extend TypeBehaviors
14
+
15
+ def self.from_s(string_value)
16
+ super # this will raise an exception until you edit it out!
17
+
18
+ # uncomment and replace this method with one that converts a string representation of a value
19
+ # into a Ruby object you can use in instruction code
20
+ #
21
+ # for example, the IntType class
22
+ # uses 'string_value.to_i'
23
+ end
24
+
25
+
26
+ def self.recognizes?(a_thing)
27
+ super # this will raise an exception until you edit it out!
28
+
29
+ # uncomment and replace this method with one that looks at a Ruby object (the 'a_thing' argument)
30
+ # and returns true if it is the 'right kind' of object for this type
31
+ #
32
+ # for example, in the IntType class,
33
+ # this method uses
34
+ # '!a_thing.kind_of?(String) && !a_thing.nil? && a_thing.respond_to?(:to_i)'
35
+ end
36
+
37
+
38
+ def self.random_value(params = {})
39
+ super # this will raise an exception until you edit it out!
40
+
41
+ # replace this method with one that generates a single random value
42
+ end
43
+
44
+
45
+ def self.any_value(options ={})
46
+ super # this will raise an exception until you edit it out!
47
+ self.random_value(options)
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,32 @@
1
+ #encoding: utf-8
2
+
3
+ # This rspec file was automatically generated when class <%=@camelcased_type_name%> was created
4
+ # Edit the specs to make them pass
5
+ # Add a link to an appropriate spec_helper.rb file to simplify your work
6
+
7
+ require 'nudge'
8
+ include Nudge
9
+
10
+ describe "<%=@camelcased_type_name%>" do
11
+
12
+ it "#from_s should require a parameter" do
13
+ <%=@camelcased_type_name%>.method(:from_s).arity.should == 1
14
+ end
15
+
16
+ it "#recognizes? should require a parameter" do
17
+ <%=@camelcased_type_name%>.method(:recognizes?).arity.should == 1
18
+ end
19
+
20
+ it "#random_value should require a parameter" do
21
+ <%=@camelcased_type_name%>.method(:random_value).arity.should == 1
22
+ end
23
+
24
+ it "#any_value should not require a parameter" do
25
+ <%=@camelcased_type_name%>.method(:any_value).arity.should == 0
26
+ end
27
+
28
+ it "should use #from_s to parse a string and produce a Ruby instance"
29
+
30
+ it "should have a #recognizes? method that returns true if the arg matches"
31
+
32
+ end
@@ -0,0 +1,6 @@
1
+ class <%=@instname%> < Instruction
2
+ include YankInstruction
3
+ def initialize(context)
4
+ super(context, :<%=@type%>)
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class <%=@instname%> < Instruction
2
+ include YankdupInstruction
3
+ def initialize(context)
4
+ super(context, :<%=@type%>)
5
+ end
6
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 2
9
- version: 0.1.2
8
+ - 3
9
+ version: 0.1.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Bill Tozier
@@ -16,35 +16,34 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-03-28 00:00:00 -04:00
19
+ date: 2010-04-01 00:00:00 -04:00
20
20
  default_executable: nudge
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
- name: treetop
23
+ name: activesupport
24
24
  prerelease: false
25
25
  requirement: &id001 !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  segments:
30
- - 1
31
- - 4
30
+ - 2
32
31
  - 3
33
- version: 1.4.3
32
+ - 5
33
+ version: 2.3.5
34
34
  type: :runtime
35
35
  version_requirements: *id001
36
36
  - !ruby/object:Gem::Dependency
37
- name: activesupport
37
+ name: thor
38
38
  prerelease: false
39
39
  requirement: &id002 !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
43
  segments:
44
- - 2
45
- - 3
46
- - 5
47
- version: 2.3.5
44
+ - 0
45
+ - 13
46
+ version: "0.13"
48
47
  type: :runtime
49
48
  version_requirements: *id002
50
49
  description: Provides a Ruby library & CLI implementing a flexible Nudge Language interpreter, plus a set of generators for adding domain-specific instructions and types.
@@ -59,6 +58,7 @@ files:
59
58
  - .gitignore
60
59
  - LICENSE.txt
61
60
  - Rakefile
61
+ - Thorfile
62
62
  - VERSION
63
63
  - bin/nudge
64
64
  - lib/cli/runner.rb
@@ -235,6 +235,7 @@ files:
235
235
  - lib/nudge.rb
236
236
  - readme.md
237
237
  - spec/command_line/command_line_spec.rb
238
+ - spec/command_line/thor_spec.rb
238
239
  - spec/fixtures/just_block.example
239
240
  - spec/fixtures/just_block_with_newline.example
240
241
  - spec/fixtures/long_arithmetic.example
@@ -376,12 +377,24 @@ files:
376
377
  - spec/interpreter/nudge_program_spec.rb
377
378
  - spec/interpreter/reference_point_spec.rb
378
379
  - spec/interpreter/stack_spec.rb
379
- - spec/interpreter/treetophelpers.rb
380
380
  - spec/interpreter/types_spec.rb
381
381
  - spec/interpreter/value_point_spec.rb
382
382
  - spec/parsers/nudge_program_parser_spec.rb
383
383
  - spec/spec_helper.rb
384
384
  - spec/support/shared_examples.rb
385
+ - templates/nudge_define_instruction.erb
386
+ - templates/nudge_duplicate_instruction.erb
387
+ - templates/nudge_equal_q_instruction.erb
388
+ - templates/nudge_flush_instruction.erb
389
+ - templates/nudge_pop_instruction.erb
390
+ - templates/nudge_random_instruction.erb
391
+ - templates/nudge_rotate_instruction.erb
392
+ - templates/nudge_shove_instruction.erb
393
+ - templates/nudge_swap_instruction.erb
394
+ - templates/nudge_type_class.erb
395
+ - templates/nudge_type_spec.erb
396
+ - templates/nudge_yank_instruction.erb
397
+ - templates/nudge_yankdup_instruction.erb
385
398
  has_rdoc: true
386
399
  homepage: http://github.com/Vaguery/Nudge
387
400
  licenses: []
@@ -416,6 +429,7 @@ specification_version: 3
416
429
  summary: Nudge Language interpreter
417
430
  test_files:
418
431
  - spec/command_line/command_line_spec.rb
432
+ - spec/command_line/thor_spec.rb
419
433
  - spec/instructions/bool/bool_and_spec.rb
420
434
  - spec/instructions/bool/bool_define_spec.rb
421
435
  - spec/instructions/bool/bool_depth_spec.rb
@@ -551,7 +565,6 @@ test_files:
551
565
  - spec/interpreter/nudge_program_spec.rb
552
566
  - spec/interpreter/reference_point_spec.rb
553
567
  - spec/interpreter/stack_spec.rb
554
- - spec/interpreter/treetophelpers.rb
555
568
  - spec/interpreter/types_spec.rb
556
569
  - spec/interpreter/value_point_spec.rb
557
570
  - spec/parsers/nudge_program_parser_spec.rb
@@ -1,120 +0,0 @@
1
- module TreetopParserMatchers
2
- class ParserMatcher
3
- def initialize(input_string)
4
- @input_string = input_string
5
- end
6
- def matches?(parser)
7
- @parser = parser
8
- !@parser.parse(@input_string).nil?
9
- end
10
- def failure_message_for_should
11
- "expected #{@parser} to parse '#{@input_string}'\n" +
12
- "failure column: #{@parser.failure_column}\n" +
13
- "failure index: #{@parser.failure_index}\n" +
14
- "failure line: #{@parser.failure_line}\n" +
15
- "failure reason: #{@parser.failure_reason}\n"
16
- end
17
- def failure_message_for_should_not
18
- "expected #{@parser} not to parse '#{@input_string}'"
19
- end
20
- def description
21
- "parse `#{@input_string}'"
22
- end
23
- end
24
- def treetop_parse(input_string)
25
- ParserMatcher.new(input_string)
26
- end
27
- end
28
-
29
- module TrekGrammarParsingMatchers
30
- class ShouldParse
31
- def initialize(contents, parser)
32
- @contents = contents
33
- @parser = parser
34
- end
35
-
36
- def matches?(contents)
37
- string =
38
- case @contents
39
- when String
40
- @contents
41
- when File
42
- raise "shit!"
43
- end
44
-
45
- @parsed_value = @parser.parse(string)
46
-
47
- !@parsed_value.nil?
48
- end
49
-
50
- def failure_message
51
- "expected Parser to #{description} but it did not."
52
- end
53
-
54
- def negative_failure_message
55
- "expected Parser to not parse #{description} but got syntax tree: #{@parsed_value.inspect}"
56
- end
57
-
58
- def description
59
- case @contents
60
- when String
61
- "parse '#{@contents}'"
62
- when File
63
- "parse contents of file #{@contents}"
64
- end
65
- end
66
- end
67
-
68
-
69
- class ShouldCapture
70
- def initialize(name, nodes)
71
- @name = name
72
- @nodes = nodes
73
- end
74
-
75
- def matches?(contents)
76
- captured_name? && captured_with_correct_value?
77
- end
78
-
79
- def failure_message
80
- "expected parser to capture #{@name.inspect}, but it did not"
81
- end
82
-
83
- def negative_failure_message
84
- message = "did not expect parser to capture #{@name.inspect}"
85
- if captured_name?
86
- message << ", but it captured as #{@nodes.send(@name).inspect}"
87
- end
88
- message
89
- end
90
-
91
- def captured_name?
92
- @nodes.respond_to?(@name)
93
- end
94
-
95
- def captured_with_correct_value?
96
- return true unless @value
97
- @nodes.send(@name).text_value == @value
98
- end
99
-
100
- def description
101
- @description = "capture #{@name}"
102
- if defined?(@value)
103
- @description << " as '#{@value}'"
104
- end
105
- @description
106
- end
107
-
108
- def as(value)
109
- @value = value
110
- self
111
- end
112
- end
113
-
114
- def parse(contents)
115
- ShouldParse.new(contents, @parser)
116
- end
117
- def capture(name_as_symbol)
118
- ShouldCapture.new(name_as_symbol, @parsed)
119
- end
120
- end