sorcerer 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -4,6 +4,8 @@ require 'rake/clean'
4
4
  require 'rake/testtask'
5
5
  require 'rake/rdoctask'
6
6
 
7
+ require 'lib/sorcerer/version'
8
+
7
9
  begin
8
10
  require 'rubygems'
9
11
  require 'rake/gempackagetask'
@@ -13,7 +15,7 @@ end
13
15
 
14
16
  PROJ = 'sorcerer'
15
17
  RUBY = ENV['RUBY19'] || 'ruby19'
16
- PKG_VERSION = '0.0.5'
18
+ PKG_VERSION = Sorcerer::VERSION
17
19
 
18
20
  PKG_FILES = FileList[
19
21
  'README.textile',
@@ -32,19 +34,6 @@ BASE_RDOC_OPTIONS = [
32
34
 
33
35
  task :default => :test
34
36
 
35
- # Modify the TestTask to allow running ruby19 for the tests
36
- class Ruby19TestTask < Rake::TestTask
37
- def ruby(*args)
38
- sh "#{RUBY} #{args.join(' ')}"
39
- end
40
- end
41
-
42
- Ruby19TestTask.new(:test) do |t|
43
- t.warning = true
44
- t.verbose = false
45
- t.test_files = FileList["test/#{PROJ}/*_test.rb"]
46
- end
47
-
48
37
  rd = Rake::RDocTask.new("rdoc") do |rdoc|
49
38
  rdoc.rdoc_dir = 'html'
50
39
  rdoc.template = 'doc/jamis.rb'
@@ -21,7 +21,7 @@ module Sorcerer
21
21
 
22
22
  def resource(sexp)
23
23
  return unless sexp
24
- handler = Handlers[sexp.first]
24
+ handler = HANDLERS[sexp.first]
25
25
  raise NoHandlerError.new(sexp.first) unless handler
26
26
  if @debug
27
27
  puts "----------------------------------------------------------"
@@ -98,11 +98,13 @@ module Sorcerer
98
98
 
99
99
  VOID_STATEMENT = [:stmts_add, [:stmts_new], [:void_stmt]]
100
100
  VOID_BODY = [:body_stmt, VOID_STATEMENT, nil, nil, nil]
101
+ VOID_BODY2 = [:bodystmt, VOID_STATEMENT, nil, nil, nil]
101
102
 
102
103
  def void?(sexp)
103
104
  sexp.nil? ||
104
105
  sexp == VOID_STATEMENT ||
105
- sexp == VOID_BODY
106
+ sexp == VOID_BODY ||
107
+ sexp == VOID_BODY2
106
108
  end
107
109
 
108
110
  NYI = lambda { |src, sexp| src.nyi(sexp) }
@@ -113,7 +115,7 @@ module Sorcerer
113
115
  PASS2 = lambda { |src, sexp| src.resource(sexp[2]) }
114
116
  EMIT1 = lambda { |src, sexp| src.emit(sexp[1]) }
115
117
 
116
- Handlers = {
118
+ HANDLERS = {
117
119
  # parser keywords
118
120
 
119
121
  :BEGIN => lambda { |src, sexp|
@@ -258,7 +260,7 @@ module Sorcerer
258
260
  :call => lambda { |src, sexp|
259
261
  src.resource(sexp[1])
260
262
  src.emit(sexp[2])
261
- src.resource(sexp[3])
263
+ src.resource(sexp[3]) unless sexp[3] == :call
262
264
  },
263
265
  :case => lambda { |src, sexp|
264
266
  src.emit("case ")
@@ -707,6 +709,7 @@ module Sorcerer
707
709
  :@words_beg => NYI,
708
710
  :@words_sep => NYI,
709
711
  }
712
+ HANDLERS[:bodystmt] = HANDLERS[:body_stmt]
710
713
  end
711
714
 
712
715
  end
@@ -0,0 +1,11 @@
1
+ module Sorcerer
2
+ VERSION_MAJOR = 0
3
+ VERSION_MINOR = 0
4
+ VERSION_BUILD = 6
5
+ VERSION_BETA = 0
6
+
7
+ VERSION_NUMBERS = [VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD] +
8
+ (VERSION_BETA > 0 ? [VERSION_BETA] : [])
9
+
10
+ VERSION = VERSION_NUMBERS.join('.')
11
+ end
@@ -5,9 +5,60 @@ namespace "git" do
5
5
  sh "git tag #{PROJ}-#{PKG_VERSION}"
6
6
  end
7
7
 
8
+ desc "Fail if the current project is not clean"
9
+ task :ensure_clean do
10
+ out = `git status | grep "nothing to commit"`
11
+ if out == ''
12
+ fail "Repo is not clean"
13
+ end
14
+ end
15
+ end
16
+
17
+ namespace "gem" do
8
18
  desc "Build and Push the current gem"
9
19
  task :push => :gem do
20
+ fail "Can't push beta versions (#{PKG_VERSION})" if
21
+ Sorcerer::VERSION_NUMBERS.size > 3
10
22
  sh "gem push pkg/#{PROJ}-#{PKG_VERSION}.gem"
11
23
  end
12
-
13
24
  end
25
+
26
+ task "version" do
27
+ puts PKG_VERSION
28
+ end
29
+
30
+ module Version
31
+ def self.write(build, beta)
32
+ open("lib/sorcerer/version.rb", "w") do |out|
33
+ out.puts "module Sorcerer"
34
+ out.puts " VERSION_MAJOR = #{Sorcerer::VERSION_MAJOR}"
35
+ out.puts " VERSION_MINOR = #{Sorcerer::VERSION_MINOR}"
36
+ out.puts " VERSION_BUILD = #{build}"
37
+ out.puts " VERSION_BETA = #{beta}"
38
+ out.puts
39
+ out.puts " VERSION_NUMBERS = [VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD] +"
40
+ out.puts " (VERSION_BETA > 0 ? [VERSION_BETA] : [])"
41
+ out.puts
42
+ out.puts " VERSION = VERSION_NUMBERS.join('.')"
43
+ out.puts "end"
44
+ end
45
+ end
46
+ end
47
+
48
+ namespace "version" do
49
+ desc "Cut a new version"
50
+ task "cut" => [:test, "git:ensure_clean", "git:tag", "gem:push"]
51
+
52
+ namespace "bump" do
53
+ desc "Bump the Beta version"
54
+ task "beta" do
55
+ Version.write(Sorcerer::VERSION_BUILD, Sorcerer::VERSION_BETA+1)
56
+ end
57
+
58
+ desc "Bump the Build version"
59
+ task "build" do
60
+ Version.write(Sorcerer::VERSION_BUILD+1, 0)
61
+ end
62
+ end
63
+ end
64
+
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Modify the TestTask to allow running ruby19 for the tests
4
+ class Ruby19TestTask < Rake::TestTask
5
+ def ruby(*args)
6
+ sh "#{RUBY} #{args.join(' ')}"
7
+ end
8
+ end
9
+
10
+ Ruby19TestTask.new(:test) do |t|
11
+ t.warning = true
12
+ t.verbose = false
13
+ t.test_files = FileList["test/#{PROJ}/*_test.rb"]
14
+ end
15
+
@@ -132,6 +132,13 @@ class SourcerTest < Test::Unit::TestCase
132
132
  assert_resource "->(a) { b }"
133
133
  end
134
134
 
135
+ def test_can_source_dot_calls
136
+ if RUBY_VERSION >= "1.9.2"
137
+ # This causes a bus fault on version 1.9.1
138
+ assert_resource "p.(a)"
139
+ end
140
+ end
141
+
135
142
  def test_can_source_numbers
136
143
  assert_resource "1"
137
144
  assert_resource "3.14"
@@ -193,7 +200,7 @@ class SourcerTest < Test::Unit::TestCase
193
200
  assert_resource "/\./"
194
201
  assert_resource "/[a-z]/"
195
202
  assert_resource "/\[a-z\]/"
196
- assert_resource "/#{name}/"
203
+ assert_resource '/#{name}/'
197
204
  end
198
205
 
199
206
  def test_can_source_range
@@ -466,7 +473,7 @@ class SourcerTest < Test::Unit::TestCase
466
473
  assert_resource "def f(a); x; y; end"
467
474
  end
468
475
 
469
- def test_can_source_class
476
+ def test_can_source_class_without_parent
470
477
  assert_resource "class X; end"
471
478
  assert_resource "class X; x; end"
472
479
  assert_resource "class X; def f(); end; end"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sorcerer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Weirich
@@ -27,10 +27,12 @@ files:
27
27
  - doc/jamis.rb
28
28
  - rakelib/git.rake
29
29
  - rakelib/readme.rake
30
+ - rakelib/testing.rake
30
31
  - lib/sorcerer/resource.rb
31
32
  - lib/sorcerer/subexpression.rb
33
+ - lib/sorcerer/version.rb
32
34
  - lib/sorcerer.rb
33
- - test/sorcerer/sorcerer_test.rb
35
+ - test/sorcerer/resource_test.rb
34
36
  - test/sorcerer/subexpression_test.rb
35
37
  has_rdoc: true
36
38
  homepage: http://github.com/jimweirich/sorcerer