idl_erep 0.0.1

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 (8) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/Gemfile +6 -0
  4. data/README.md +74 -0
  5. data/Rakefile +1 -0
  6. data/bin/idl_erep +105 -0
  7. data/idl_erep.gemspec +23 -0
  8. metadata +94 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e1e1bfbc20802f8a27546d8f818a21d1a8898de6
4
+ data.tar.gz: 03f132d9907d6ccfeaddcbe9d565c152a38e6787
5
+ SHA512:
6
+ metadata.gz: 71d2ac3c4f3b44f785f3b88fe5dfa17f4b28746b45d4565101518a4ac4192470d78b2b18ad0649b600fa6274fd5e85d8e84212869cb28571ba76f10983369a89
7
+ data.tar.gz: 0929d8acf0e20847658e80a78c90aed221d995f920c524da72ef8ca27fa07a769d3c13455c805516d49e2ecb56623c579c82d297c63edcdc1c0098e0770d467a
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ /.idl_history
2
+
3
+ *.gem
4
+ *.rbc
5
+ .bundle
6
+ .config
7
+ .yardoc
8
+ Gemfile.lock
9
+ InstalledFiles
10
+ _yardoc
11
+ coverage
12
+ doc/
13
+ lib/bundler/man
14
+ pkg
15
+ rdoc
16
+ spec/reports
17
+ test/tmp
18
+ test/version_tmp
19
+ tmp
20
+
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'rb-readline'
6
+
data/README.md ADDED
@@ -0,0 +1,74 @@
1
+ IDL-EREP
2
+ ===
3
+ An enhanced interactive environment for IDL (Interactive Data Language).
4
+
5
+ It provides stronger command history, tab-completion, and key shortcuts.
6
+
7
+ ### idl\_erep
8
+ This is the *IDL Enhanced REPl*
9
+ which gives an enhanced interactive environment.
10
+
11
+
12
+ Installation
13
+ ---
14
+
15
+ Just execute
16
+
17
+ $ gem install idl_erep
18
+
19
+ Then, you can execute `idl_erep`.
20
+
21
+
22
+ Usage
23
+ ---
24
+
25
+ Just execute `idl_erep` like following:
26
+
27
+ $ idl\_erep
28
+
29
+
30
+ Key mappings
31
+ ---
32
+ Key mappings depends on `rb-readline`.
33
+
34
+ | key mappings | description |
35
+ |:-------------|:------------------------------------------------------------------------------|
36
+ | Tab | Auto-complete files and folder names |
37
+ | Ctrl + A | Go to the beginning of the line you are currently typing on |
38
+ | Ctrl + E | Go to the end of the line you are currently typing on |
39
+ | Ctrl + U | Clears the line before the cursor position. If you are at the end of the line, clears the entire line. |
40
+ | Ctrl + H | Same as backspace |
41
+ | Ctrl + R | Let's you search through previously used commands |
42
+ | Ctrl + W | Delete the word before the cursor |
43
+ | Ctrl + K | Clear the line after the cursor |
44
+ | Ctrl + T | Swap the last two characters before the cursor |
45
+ | Esc + T | Swap the last two words before the cursor |
46
+ | Alt + F | Move cursor forward one word on the current line |
47
+ | Alt + B | Move cursor backward one word on the current line |
48
+
49
+
50
+ Command History
51
+ ---
52
+
53
+ When start this program, if there's a `.idl_history` file in current directory,
54
+ it will be loaded and `~/.idl_history` won't be loaded.
55
+ If there's no `.idl_history`, `~/.idl_hisoty` will be loaded.
56
+
57
+ It will allow you to keep command history only inside the project.
58
+
59
+
60
+ Configurations
61
+ ---
62
+
63
+ In `~/.idl_profile`, you can set some configurations of this environment.
64
+
65
+ | variable | default | description |
66
+ |:-----------|:--------------------------|:-----------------------------------------------------|
67
+ | `idlbin` | 'idl' | PATH of IDL executable file |
68
+ | `prompt` | 'IDL-EREP> ' | prompt string of this environment |
69
+ | `idlhist` | '~/.idl/idl/rbuf/history' | PATH of default IDL history file (used only reading) |
70
+ | `homehist` | '~/.idl\_history' | PATH of IDL-EREP history file in home directory |
71
+ | `currhist` | './.idl\_history' | PATH of IDL-EREP history file in current directory |
72
+ | `histlim` | 10000 | limit number of IDL-EREP history file elements |
73
+
74
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/idl_erep ADDED
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+
4
+ # IDL enhanced REPL
5
+ # idl_erep
6
+
7
+ require 'open3'
8
+ require 'readline'
9
+
10
+ profile = '~/.idl_profile'
11
+ idlbin = 'idl'
12
+ prompt = 'IDL-EREP> '
13
+ idlhist = '~/.idl/idl/rbuf/history'
14
+ homehist = '~/.idl_history'
15
+ currhist = './.idl_history'
16
+ histlim = 10000
17
+
18
+ def extract_idl_command(line)
19
+ line.gsub(/ <!--.*-->$/, '')
20
+ end
21
+
22
+ def read_hist_from_file(file)
23
+ res = []
24
+ if File.exist?(File.expand_path(file)) then
25
+ open(File.expand_path(file)) do |f|
26
+ while l = f.gets
27
+ res << extract_idl_command(l.chomp)
28
+ end
29
+ end
30
+ end
31
+ res.reverse
32
+ end
33
+
34
+ def readline_hist_management(prompt)
35
+ line = Readline.readline(prompt, false)
36
+ Readline::HISTORY << line.chomp
37
+ return nil if line.nil?
38
+ if line =~ /^\s*$/ then
39
+ Readline::HISTORY.pop
40
+ end
41
+ line
42
+ end
43
+
44
+ # main routine
45
+
46
+ # initialize
47
+
48
+ # read profile
49
+ if File.exist?(File.expand_path(profile)) then
50
+ eval File.read File.expand_path(profile)
51
+ end
52
+
53
+ read_hist_from_file(idlhist).map do |h|
54
+ Readline::HISTORY << h
55
+ end
56
+
57
+ if File.exist?(File.expand_path(currhist)) then
58
+ open(File.expand_path(currhist)) do |f|
59
+ while l = f.gets
60
+ Readline::HISTORY << l.chomp
61
+ end
62
+ end
63
+ histfile = currhist
64
+ elsif File.exist?(File.expand_path(homehist)) then
65
+ open(File.expand_path(homehist)) do |f|
66
+ while l = f.gets
67
+ Readline::HISTORY << l.chomp
68
+ end
69
+ end
70
+ histfile = homehist
71
+ else
72
+ open(File.expand_path(homehist), 'w').close()
73
+ histfile = homehist
74
+ end
75
+
76
+ Open3.popen2e(idlbin) do |i, o, w|
77
+
78
+ # stdout, stderr
79
+ Thread.new do
80
+ o.each do |line|
81
+ puts "\033[2K\r" + line
82
+ print prompt
83
+ end
84
+ end
85
+
86
+ # main loop
87
+ while input = readline_hist_management(prompt)
88
+ i.puts input
89
+
90
+ break if input =~ /^\s*exit\s*$/
91
+ end
92
+
93
+ i.close
94
+
95
+ # status
96
+ puts w.value
97
+
98
+ end
99
+
100
+ # finalize
101
+ open(File.expand_path(histfile), 'w') do |f|
102
+ f.puts Readline::HISTORY.to_a.reverse.take(histlim).reverse
103
+ end
104
+
105
+
data/idl_erep.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "idl_erep"
7
+ spec.version = "0.0.1"
8
+ spec.authors = ["Rintaro Okamura"]
9
+ spec.email = ["rintaro.okamura+github@gmail.com"]
10
+ spec.summary = %q{An enhanced interactive environment for IDL}
11
+ spec.description = %q{An enhanced interactive environment for IDL}
12
+ spec.homepage = "https://github.com/rinx/idl-erep"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.5"
21
+ spec.add_development_dependency "rake", "~> 0"
22
+ spec.add_runtime_dependency "rb-readline", "~> 0"
23
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: idl_erep
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Rintaro Okamura
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rb-readline
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: An enhanced interactive environment for IDL
56
+ email:
57
+ - rintaro.okamura+github@gmail.com
58
+ executables:
59
+ - idl_erep
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - Gemfile
65
+ - README.md
66
+ - Rakefile
67
+ - bin/idl_erep
68
+ - idl_erep.gemspec
69
+ homepage: https://github.com/rinx/idl-erep
70
+ licenses:
71
+ - MIT
72
+ metadata: {}
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 2.2.2
90
+ signing_key:
91
+ specification_version: 4
92
+ summary: An enhanced interactive environment for IDL
93
+ test_files: []
94
+ has_rdoc: