ripl-auto_indent 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
- == 0.1.5
2
- * Use coderay 1
1
+ == 0.2.0
2
+ * Refactor out get_indent into ruby_indentation gem. Compatible with newer coderay versions
3
3
 
4
4
  == 0.1.4
5
5
  * Compatible with multi_line 0.2.3 (proc as prompt)
@@ -1,6 +1,6 @@
1
1
  The MIT LICENSE
2
2
 
3
- Copyright (c) 2010 Jan Lelis
3
+ Copyright (c) 2010-2012 Jan Lelis
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
@@ -21,6 +21,5 @@ The plugin depends on <tt>ripl-multi_line</tt>, so you can set the multi-line pr
21
21
  == Known bugs
22
22
 
23
23
  * Not 100% correct ;)
24
- * Long lines might cause wrong rewriting (if activated)
25
24
 
26
25
  J-_-L
data/Rakefile CHANGED
@@ -1,13 +1,13 @@
1
- require 'rake'
1
+ GEMSPEC = Dir['*.gemspec'].first
2
2
  require 'fileutils'
3
3
 
4
4
  def gemspec
5
- @gemspec ||= eval(File.read('.gemspec'), binding, '.gemspec')
5
+ @gemspec ||= eval(File.read(GEMSPEC), binding, GEMSPEC)
6
6
  end
7
7
 
8
8
  desc "Build the gem"
9
9
  task :gem=>:gemspec do
10
- sh "gem build .gemspec"
10
+ sh "gem build #{GEMSPEC}"
11
11
  FileUtils.mkdir_p 'pkg'
12
12
  FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg'
13
13
  end
@@ -1,15 +1,14 @@
1
1
  require 'ripl'
2
2
  require 'ripl/multi_line'
3
- require 'coderay'
4
- require 'set'
3
+ require 'ruby_indentation'
5
4
 
6
5
  module Ripl
7
6
  module AutoIndent
8
- VERSION = '0.1.5'
7
+ VERSION = '0.2.0'
9
8
  TPUT = {
10
- :sc => `tput sc`, # save current cursor position
11
- :cuu1 => `tput cuu1`, # move cursor on line upwards
12
- :rc => `tput rc`, # return to normal cursor position
9
+ :cuu1 => "\e[A", # up
10
+ :sc => "\e7", # save
11
+ :rc => "\e8", # load
13
12
  }
14
13
 
15
14
  def before_loop
@@ -17,35 +16,6 @@ module Ripl
17
16
  super
18
17
  end
19
18
 
20
- def get_indent(buffer)
21
- opening_and_modifier_tokens = %w[if unless until while].to_set
22
- opening_tokens = %w[begin case class def for module do {].to_set
23
- closing_tokens = %w[end }].to_set
24
- separator = [';', :operator]
25
- indent = 0
26
-
27
- # parse each token
28
- buffer_tokens = [separator] + CodeRay.scan(buffer, :ruby).select{|_, kind|
29
- kind != :space
30
- }
31
-
32
- buffer_tokens.each_cons(2){ |(*old_pair), (token, kind)|
33
- if kind == :reserved || kind == :operator
34
- # modifiers cause trouble, so
35
- # fix it in 9/10 cases
36
- if opening_tokens.include?(token) ||
37
- opening_and_modifier_tokens.include?(token) &&
38
- ( old_pair == separator || old_pair == ['=', :operator ] )
39
- indent += 1
40
- elsif closing_tokens.include?(token)
41
- indent -= 1
42
- end
43
- end
44
- }
45
- # return a good value
46
- indent < 0 ? 0 : indent
47
- end
48
-
49
19
  def prompt
50
20
  @buffer ? super + config[:auto_indent_space]*@current_indent : super
51
21
  end
@@ -63,7 +33,7 @@ module Ripl
63
33
 
64
34
  def loop_eval(input)
65
35
  last_indent = ( @current_indent ||= 0 )
66
- @current_indent = get_indent( @buffer ? @buffer*";"+";"+input : input )
36
+ @current_indent = RubyIndentation[ @buffer ? @buffer*";"+";"+input : input ]
67
37
 
68
38
  if config[:auto_indent_rewrite] && @current_indent < last_indent
69
39
  rewrite_line last_indent - @current_indent
@@ -74,7 +44,7 @@ module Ripl
74
44
  end
75
45
  end
76
46
 
77
- Ripl::Shell.send :include, Ripl::AutoIndent
47
+ Ripl::Shell.include Ripl::AutoIndent
78
48
 
79
49
  # default config
80
50
  Ripl.config[:auto_indent_rewrite] = true if Ripl.config[:auto_indent_rewrite].nil?
@@ -9,12 +9,12 @@ Gem::Specification.new do |s|
9
9
  s.email = "mail@janlelis.de"
10
10
  s.homepage = "http://github.com/janlelis/ripl-auto_indent"
11
11
  s.summary = "A ripl plugin which indents your entered Ruby code."
12
- s.description = "This ripl plugin indents your multi-line Ruby input using coderay."
12
+ s.description = "This ripl plugin indents your multi-line Ruby input using ruby_indentation gem."
13
13
  s.required_rubygems_version = ">= 1.3.6"
14
- s.add_dependency 'ripl', '>= 0.3.1'
15
- s.add_dependency 'ripl-multi_line', '>= 0.2.3'
16
- s.add_dependency 'coderay', '>= 1.0.3'
17
- s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec}
14
+ s.add_dependency 'ripl', '>= 0.6.0'
15
+ s.add_dependency 'ripl-multi_line', '>= 0.3.0'
16
+ s.add_dependency 'ruby_indentation', '>= 0.2.0'
17
+ s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %W[Rakefile #{__FILE__}]
18
18
  s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
19
19
  s.license = 'MIT'
20
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ripl-auto_indent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,42 +9,43 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-01 00:00:00.000000000 Z
12
+ date: 2012-01-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ripl
16
- requirement: &17705520 !ruby/object:Gem::Requirement
16
+ requirement: &7543800 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.3.1
21
+ version: 0.6.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *17705520
24
+ version_requirements: *7543800
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: ripl-multi_line
27
- requirement: &17704800 !ruby/object:Gem::Requirement
27
+ requirement: &7543320 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
31
31
  - !ruby/object:Gem::Version
32
- version: 0.2.3
32
+ version: 0.3.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *17704800
35
+ version_requirements: *7543320
36
36
  - !ruby/object:Gem::Dependency
37
- name: coderay
38
- requirement: &17704220 !ruby/object:Gem::Requirement
37
+ name: ruby_indentation
38
+ requirement: &7542840 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
42
42
  - !ruby/object:Gem::Version
43
- version: 1.0.3
43
+ version: 0.2.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *17704220
47
- description: This ripl plugin indents your multi-line Ruby input using coderay.
46
+ version_requirements: *7542840
47
+ description: This ripl plugin indents your multi-line Ruby input using ruby_indentation
48
+ gem.
48
49
  email: mail@janlelis.de
49
50
  executables: []
50
51
  extensions: []
@@ -57,7 +58,7 @@ files:
57
58
  - README.rdoc
58
59
  - CHANGELOG.rdoc
59
60
  - Rakefile
60
- - .gemspec
61
+ - ripl-auto_indent.gemspec
61
62
  homepage: http://github.com/janlelis/ripl-auto_indent
62
63
  licenses:
63
64
  - MIT