emacs-ruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 48feb954ed9b208c200465691884fd7b9ab838e8
4
+ data.tar.gz: 6dfa9346a8f1fae937ed77f57062671c142dfec0
5
+ SHA512:
6
+ metadata.gz: 0d7a23b7a6834262cd2668f3e7d3660f87188c165a05006f982edbf237cc914ddc76e43bb9a30512b58c45b824fa95607811016500293b7cc96f146e2cc7eeb3
7
+ data.tar.gz: d96d734fe30a55e127377b08993a5aa7d808cf462d0867931971a1de73e5709cf629d1b3800c0e75c2bae451eaf9b448dad782f0253446ec2287968bfd1ca643
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ # Ignore bundler lock file
2
+ /Gemfile.lock
3
+
4
+ # Ignore pkg folder
5
+ /pkg
6
+
7
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'rake'
7
+ gem 'rdoc'
8
+ gem 'yard'
9
+ gem 'pry'
10
+ gem 'tilt'
11
+ end
12
+
13
+ group :test do
14
+ gem 'cucumber'
15
+ gem 'fivemat'
16
+ gem 'aruba'
17
+ gem 'rspec'
18
+ end
data/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # What
2
+
3
+ This is an emacs wrapper written in ruby. Currently it only support running emacs batch command, which is used by [middleman-org](https://github.com/xiaoxinghu/middleman-org) to get natively exported html.
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
3
+ require 'emacs-ruby/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'emacs-ruby'
7
+ s.version = EmacsRuby::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ['Xiaoxing Hu']
10
+ s.email = ['dawnstar.hu@gmail.com']
11
+ s.homepage = 'http://github.com/xiaoxinghu/emacs-ruby'
12
+ s.summary = %q{emacs wrapper in ruby}
13
+ s.description = %q{An emacs wrapper written in ruby.}
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
17
+ s.require_paths = ['lib']
18
+ s.license = 'MIT'
19
+ # s.add_runtime_dependency('middleman-core', ['~> 3.3'])
20
+ end
data/lib/emacs-ruby.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'emacs-ruby/version'
2
+ require 'emacs-ruby/emacs'
3
+ require 'emacs-ruby/tilt'
4
+
5
+ module EmacsRuby
6
+ end
@@ -0,0 +1,32 @@
1
+ module EmacsRuby
2
+ class Emacs
3
+ attr_accessor :emacs
4
+
5
+ def initialize
6
+ @emacs = 'emacs'
7
+ end
8
+
9
+ def org_to_html(org_file, load: nil, func: 'org-html-export-to-html')
10
+ html = nil
11
+ batch target: org_file, load: load, func: func
12
+ html_file = org_file.sub(/.org$/, '.html')
13
+ return html unless File.exist? html_file
14
+ File.open(html_file) do |file|
15
+ html = file.read
16
+ end
17
+ FileUtils.rm_rf html_file
18
+ html
19
+ end
20
+
21
+ def batch(target: nil, load: nil, func: nil)
22
+ return unless func
23
+ cmd = [@emacs]
24
+ cmd << target if target
25
+ cmd << '--batch'
26
+ cmd += ['-l', load] if load
27
+ cmd += ['-f', func] if func
28
+ cmd << '--kill'
29
+ `#{cmd.join ' '}`
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,24 @@
1
+ module Tilt
2
+ module EmacsRuby
3
+ class OrgTemplate < Template
4
+ def self.engine_initialized?
5
+ defined? Middleman::Org
6
+ end
7
+
8
+ def initialize_engine
9
+ require 'emacs-ruby'
10
+ end
11
+
12
+ def prepare
13
+ @engine = ::EmacsRuby::Emacs.new
14
+ @output = nil
15
+ end
16
+
17
+ def evaluate(scope, locals, &block)
18
+ @output = @engine.org_to_html file
19
+ end
20
+ end
21
+ end
22
+
23
+ Tilt.register Tilt::EmacsRuby::OrgTemplate, 'org'
24
+ end
@@ -0,0 +1,3 @@
1
+ module EmacsRuby
2
+ VERSION = '0.1.0'
3
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: emacs-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Xiaoxing Hu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-29 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: An emacs wrapper written in ruby.
14
+ email:
15
+ - dawnstar.hu@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - Gemfile
22
+ - README.md
23
+ - emacs-ruby.gemspec
24
+ - lib/emacs-ruby.rb
25
+ - lib/emacs-ruby/emacs.rb
26
+ - lib/emacs-ruby/tilt.rb
27
+ - lib/emacs-ruby/version.rb
28
+ homepage: http://github.com/xiaoxinghu/emacs-ruby
29
+ licenses:
30
+ - MIT
31
+ metadata: {}
32
+ post_install_message:
33
+ rdoc_options: []
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ requirements: []
47
+ rubyforge_project:
48
+ rubygems_version: 2.4.6
49
+ signing_key:
50
+ specification_version: 4
51
+ summary: emacs wrapper in ruby
52
+ test_files: []
53
+ has_rdoc: