live_ast 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.rdoc CHANGED
@@ -1,6 +1,10 @@
1
1
 
2
2
  = live_ast Changes
3
3
 
4
+ == Version 1.0.2
5
+
6
+ * handle -unix, -dos, -mac special encoding suffixes
7
+
4
8
  == Version 1.0.1
5
9
 
6
10
  * add tests for "def self.f" and "def A.f" (plugins were missing this construct)
data/devel/levitate.rb CHANGED
@@ -1,5 +1,7 @@
1
1
 
2
2
  class Levitate
3
+ include Rake::DSL if defined? Rake::DSL
4
+
3
5
  def initialize(gem_name)
4
6
  @gem_name = gem_name
5
7
 
@@ -7,7 +9,7 @@ class Levitate
7
9
 
8
10
  yield self
9
11
 
10
- self.class.instance_methods(false).each do |name|
12
+ self.class.instance_methods(false).sort.each do |name|
11
13
  if name.to_s =~ %r!\Adefine_!
12
14
  send(name)
13
15
  end
@@ -259,7 +261,7 @@ class Levitate
259
261
 
260
262
  attribute :remote_levitate do
261
263
  url = ENV["LEVITATE"] ||
262
- "https://github.com/quix/levitate/raw/master/levitate.rb"
264
+ "https://raw.github.com/quix/levitate/master/levitate.rb"
263
265
  IO.popen("curl -s #{url}") { |f| f.read }
264
266
  end
265
267
 
@@ -497,7 +499,7 @@ class Levitate
497
499
  puts "Already up-to-date."
498
500
  else
499
501
  File.open(__FILE__, "w") { |f| f.print(remote_levitate) }
500
- git "commit", __FILE__, "-m", "update levitate"
502
+ git "commit", __FILE__, "-m", "update tools"
501
503
  puts "Updated levitate."
502
504
  end
503
505
  end
@@ -12,7 +12,15 @@ module LiveAST
12
12
  # magic comment overrides BOM
13
13
  encoding = contents[MAGIC_COMMENT, 1] || utf8 || "US-ASCII"
14
14
 
15
- contents.force_encoding(encoding)
15
+ contents.force_encoding(strip_special(encoding))
16
+ end
17
+
18
+ def self.strip_special(encoding)
19
+ if encoding =~ /\Autf8-mac\Z/i
20
+ "UTF8-MAC"
21
+ else
22
+ encoding.sub(/-(unix|dos|mac)\Z/i, "")
23
+ end
16
24
  end
17
25
  end
18
26
  end
@@ -1,3 +1,3 @@
1
1
  module LiveAST
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -140,7 +140,6 @@ define_unsorted_test_case "BacktraceTest", RegularTest do
140
140
 
141
141
  if will_succeed
142
142
  assert_equal orig_top, live_top
143
- here = Regexp.quote __FILE__
144
143
  assert_match(/somewhere:1002/, live_top)
145
144
  else
146
145
  assert_not_equal orig_top, live_top
@@ -5,6 +5,10 @@ class AllEncodingTest < RegularTest
5
5
  default US-ASCII
6
6
  usascii US-ASCII
7
7
  utf8 UTF-8
8
+ utf8unix UTF-8
9
+ utf8mac UTF-8
10
+ utf8mac_alt UTF8-MAC
11
+ utf8dos UTF-8
8
12
  utf8bom UTF-8
9
13
  utf8bom_only UTF-8
10
14
  usascii_with_utf8bom US-ASCII
@@ -0,0 +1,6 @@
1
+ # -*- coding: utf-8-dos -*-
2
+ module EncodingTest
3
+ def utf8dos_string
4
+ "大きな箱とねこ。"
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # -*- coding: utf-8-mac -*-
2
+ module EncodingTest
3
+ def utf8mac_string
4
+ "大きな箱とねこ。"
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # -*- coding: utf8-mac -*-
2
+ module EncodingTest
3
+ def utf8mac_alt_string
4
+ "大きな箱とねこ。"
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # -*- coding: utf-8-unix -*-
2
+ module EncodingTest
3
+ def utf8unix_string
4
+ "大きな箱とねこ。"
5
+ end
6
+ end
data/test/error_test.rb CHANGED
@@ -3,6 +3,7 @@ require_relative 'main'
3
3
  class ErrorTest < RegularTest
4
4
  def test_multiple_lambda_same_line
5
5
  a = lambda { } ; b = lambda { }
6
+ ignore(b)
6
7
 
7
8
  assert_raises LiveAST::MultipleDefinitionsOnSameLineError do
8
9
  a.to_ast
data/test/main.rb CHANGED
@@ -103,6 +103,9 @@ class BaseTest < JLMiniTest
103
103
  e.backtrace
104
104
  end
105
105
  end
106
+
107
+ def ignore(*args)
108
+ end
106
109
  end
107
110
 
108
111
  class RegularTest < BaseTest
@@ -40,6 +40,7 @@ class ZZY_ReplaceEvalTest < ReplaceEvalTest
40
40
 
41
41
  def moo
42
42
  a = 22
43
+ ignore(a)
43
44
  binding
44
45
  end
45
46
 
@@ -265,6 +266,7 @@ class ZZY_ReplaceEvalTest < ReplaceEvalTest
265
266
 
266
267
  def test_module_eval_binding
267
268
  x = 33
269
+ ignore(x)
268
270
  orig = Class.new
269
271
  orig.live_ast_original_module_eval %{
270
272
  define_method :value do
@@ -278,6 +280,7 @@ class ZZY_ReplaceEvalTest < ReplaceEvalTest
278
280
  assert orig.new.f.is_a?(Proc)
279
281
 
280
282
  y = 44
283
+ ignore(y)
281
284
  live = Class.new
282
285
  live.module_eval %{
283
286
  define_method :value do
@@ -339,6 +342,7 @@ class ZZY_ReplaceEvalTest < ReplaceEvalTest
339
342
 
340
343
  def test_local_var_collision
341
344
  args = 33
345
+ ignore(args)
342
346
 
343
347
  assert_equal 33, live_ast_original_eval("args")
344
348
  assert_equal 33, eval("args")
@@ -4,8 +4,15 @@ require_relative '../devel/levitate'
4
4
  class RubygemsTest < RegularTest
5
5
  def test_rubygems
6
6
  lib = File.expand_path(File.dirname(__FILE__) + "/../lib")
7
+ extra_req =
8
+ if defined?(LiveASTRipper) and LiveAST.parser == LiveASTRipper
9
+ %{require 'live_ast_ripper'}
10
+ else
11
+ ""
12
+ end
7
13
  result = Levitate.run_code_and_capture %{
8
14
  $LOAD_PATH.unshift '#{lib}'
15
+ #{extra_req}
9
16
  require 'live_ast/full'
10
17
  LiveAST.parser::Test
11
18
  f = eval %{
metadata CHANGED
@@ -1,8 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: live_ast
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 1.0.1
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 2
9
+ version: 1.0.2
6
10
  platform: ruby
7
11
  authors:
8
12
  - James M. Lawrence
@@ -10,7 +14,8 @@ autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
16
 
13
- date: 2011-05-18 00:00:00 Z
17
+ date: 2011-08-02 00:00:00 -04:00
18
+ default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: live_ast_ruby_parser
@@ -20,6 +25,10 @@ dependencies:
20
25
  requirements:
21
26
  - - ">="
22
27
  - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ - 6
31
+ - 0
23
32
  version: 0.6.0
24
33
  type: :runtime
25
34
  version_requirements: *id001
@@ -78,6 +87,10 @@ files:
78
87
  - test/encoding_test/utf8.rb
79
88
  - test/encoding_test/utf8bom.rb
80
89
  - test/encoding_test/utf8bom_only.rb
90
+ - test/encoding_test/utf8dos.rb
91
+ - test/encoding_test/utf8mac.rb
92
+ - test/encoding_test/utf8mac_alt.rb
93
+ - test/encoding_test/utf8unix.rb
81
94
  - test/error_test.rb
82
95
  - test/eval_test.rb
83
96
  - test/flush_cache_test.rb
@@ -101,6 +114,7 @@ files:
101
114
  - test/to_ast_feature_test.rb
102
115
  - test/to_ruby_feature_test.rb
103
116
  - test/to_ruby_test.rb
117
+ has_rdoc: true
104
118
  homepage: http://quix.github.com/live_ast
105
119
  licenses: []
106
120
 
@@ -144,17 +158,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
158
  requirements:
145
159
  - - ">="
146
160
  - !ruby/object:Gem::Version
161
+ segments:
162
+ - 1
163
+ - 9
164
+ - 2
147
165
  version: 1.9.2
148
166
  required_rubygems_version: !ruby/object:Gem::Requirement
149
167
  none: false
150
168
  requirements:
151
169
  - - ">="
152
170
  - !ruby/object:Gem::Version
171
+ segments:
172
+ - 0
153
173
  version: "0"
154
174
  requirements: []
155
175
 
156
176
  rubyforge_project:
157
- rubygems_version: 1.7.1
177
+ rubygems_version: 1.3.7
158
178
  signing_key:
159
179
  specification_version: 3
160
180
  summary: Live abstract syntax trees of methods and procs.