vrome 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,6 @@
1
+ === 1.0.0 / 2010-02-15
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
6
+
data/Manifest.txt ADDED
@@ -0,0 +1,7 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ bin/vrome
6
+ lib/vrome.rb
7
+ lib/server.rb
data/README.txt ADDED
@@ -0,0 +1,26 @@
1
+ = vrome
2
+
3
+ == LICENSE:
4
+
5
+ (The MIT License)
6
+
7
+ Copyright (c) 2010 Jinzhu
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining
10
+ a copy of this software and associated documentation files (the
11
+ 'Software'), to deal in the Software without restriction, including
12
+ without limitation the rights to use, copy, modify, merge, publish,
13
+ distribute, sublicense, and/or sell copies of the Software, and to
14
+ permit persons to whom the Software is furnished to do so, subject to
15
+ the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be
18
+ included in all copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
21
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require 'lib/vrome'
6
+
7
+ Hoe.spec 'vrome' do
8
+ developer('Jinzhu', 'wosmvp+vrome@gmail.com')
9
+
10
+ # self.rubyforge_name = 'vrome' # if different than 'vrome'
11
+ end
12
+
13
+ # vim: syntax=ruby
data/bin/vrome ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ # Jinzhu (wosmvp@gmail.com)
3
+
4
+ load File.join(File.dirname(__FILE__),'..','lib','server.rb')
data/lib/server.rb ADDED
@@ -0,0 +1,58 @@
1
+ require 'webrick'
2
+ require 'tempfile'
3
+ require 'json'
4
+
5
+ class EditorServer < WEBrick::HTTPServlet::AbstractServlet
6
+
7
+ def do_POST(request, response)
8
+ request = JSON.parse(request.body)
9
+ status, content_type, body = self.send(request['method'].to_sym,request)
10
+
11
+ response.status = status
12
+ response['Content-Type'] = content_type
13
+ response.body = body
14
+ end
15
+
16
+ def open_editor(request)
17
+ editor = request['editor']
18
+ tmpfile = Tempfile.new('editor')
19
+ tmpfile.write request['data']
20
+ tmpfile.flush
21
+ editor = 'gvim -f' if editor == 'gvim' # Foreground: Don't fork when starting GUI
22
+ system("#{editor} #{tmpfile.path}")
23
+ text = File.read(tmpfile.path)
24
+ tmpfile.delete
25
+
26
+ return 200, "text/plain", text
27
+ end
28
+
29
+ def get_configure(request)
30
+ config_file = File.join(ENV['HOME'],'.vromerc')
31
+ vromeConfig = {:set => {},:imap => {},:map => {},:cmap => {}};
32
+
33
+ if File.exist?(config_file)
34
+ File.read(config_file).split("\n").map do |line|
35
+ array = line.split(/\s+/)
36
+ case line
37
+ when /^imap\s+/
38
+ vromeConfig[:imap][array[1]] = array[2];
39
+ when /^map\s+/
40
+ vromeConfig[:map][array[1]] = array[2];
41
+ when /^cmap\s+/
42
+ vromeConfig[:cmap][array[1]] = array[2];
43
+ when /^set\s+/
44
+ array = line.split(/\s+/,2)
45
+ array = array[1].split(/\+?=/,2)
46
+ vromeConfig[:set][array[0]] = [array[1], line =~ /^set\s+\w+\+=/ ? true : false]
47
+ end
48
+ end
49
+
50
+ return 200, "text/plain", vromeConfig.to_json
51
+ end
52
+ end
53
+ end
54
+
55
+ server = WEBrick::HTTPServer.new(:Port => 20000)
56
+ server.mount "/", EditorServer
57
+ trap(:INT) { server.shutdown }
58
+ server.start
data/lib/vrome.rb ADDED
@@ -0,0 +1,3 @@
1
+ class Vrome
2
+ VERSION = '1.0.0'
3
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vrome
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jinzhu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-02-21 00:00:00 +08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rubyforge
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.0.3
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: gemcutter
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.3.0
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: hoe
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 2.5.0
44
+ version:
45
+ description: ""
46
+ email:
47
+ - wosmvp+vrome@gmail.com
48
+ executables:
49
+ - vrome
50
+ extensions: []
51
+
52
+ extra_rdoc_files:
53
+ - History.txt
54
+ - Manifest.txt
55
+ - README.txt
56
+ files:
57
+ - History.txt
58
+ - Manifest.txt
59
+ - README.txt
60
+ - Rakefile
61
+ - bin/vrome
62
+ - lib/vrome.rb
63
+ - lib/server.rb
64
+ has_rdoc: true
65
+ homepage:
66
+ licenses: []
67
+
68
+ post_install_message:
69
+ rdoc_options:
70
+ - --main
71
+ - README.txt
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ version:
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: "0"
85
+ version:
86
+ requirements: []
87
+
88
+ rubyforge_project: vrome
89
+ rubygems_version: 1.3.5
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: ""
93
+ test_files: []
94
+