doc_frac 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bce1e61d763b5b0a29ef22a62b6afcfbe074e740
4
+ data.tar.gz: 5a023a0ad417472fdb419e333d210f9e863aa744
5
+ SHA512:
6
+ metadata.gz: ed666302a96adc41a4d9cb1816cb96f884cb0b27f4132e6fed04b0625e4de4a6d9c7ec92cd33384ce936b5f3d30340d514056ae2013ac014a053393c3a355bcf
7
+ data.tar.gz: 275bf8b38f34c50a9ea1a8c2335d856f080fdf43ea7a70030247de3ef846d07665f63b48d15d1a4a8a8b915415ec5db6f0286b2bd57ccae41719dd71ef0a5312
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in doc_frac.gemspec
4
+ gemspec
@@ -0,0 +1,35 @@
1
+ # DocFrac
2
+
3
+ This gem uses the DocFrac unix utility for doing document conversion. Converts between RTF, HTML and text documents.
4
+
5
+ [DocFrac Website](http://docfrac.net/wordpress/)
6
+
7
+ I created this gem really quick for a need I had, please feel free to contribute to make it better.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'doc_frac'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install doc_frac
22
+
23
+ ## Usage
24
+
25
+ @document = DocFrac::Convert.new(:from_rtf, :to_html)
26
+ @document.text = "rtf text"
27
+ @document.convert
28
+
29
+ ## Contributing
30
+
31
+ 1. Fork it
32
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
33
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
34
+ 4. Push to the branch (`git push origin my-new-feature`)
35
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,3 @@
1
+ require 'doc_frac/utilities'
2
+ require 'doc_frac/format'
3
+ require 'doc_frac/convert'
@@ -0,0 +1,20 @@
1
+ module DocFrac
2
+ class Convert
3
+ attr_accessor :text
4
+ def initialize(from, to)
5
+ @from_format = DocFrac::Format.new(from)
6
+ @to_format = DocFrac::Format.new(to)
7
+ @text = ""
8
+ end
9
+
10
+ def convert
11
+ from_file = "/tmp/#{DocFrac::Utilities.random_string}.#{@from_format.ext}"
12
+ to_file = "/tmp/#{DocFrac::Utilities.random_string}.#{@to_format.ext}"
13
+ File.open(from_file, "w") {|f| f.write(@text) }
14
+ `docfrac #{@from_format.format_text} #{from_file} #{@to_format.format_text} #{to_file}`
15
+ file = File.open(to_file, "r").read
16
+ File.delete(from_file, to_file)
17
+ return file
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ module DocFrac
2
+ class Format
3
+ attr_reader :format_text, :ext
4
+ def initialize(format)
5
+ formats = {
6
+ :to_rtf => "--to-rtf",
7
+ :from_rtf => "--from-rtf",
8
+ :to_html => "--to-html",
9
+ :from_html => "--from-html",
10
+ :to_text => "--to-text",
11
+ :from_text => "--from-text"
12
+ }
13
+ @format_text = formats[format]
14
+ @ext = format.to_s.split("_").last
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,10 @@
1
+ module DocFrac
2
+ class Utilities
3
+ def self.random_string(length=10)
4
+ string = ''
5
+ chars = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ123456789'
6
+ length.times { |i| string << chars[rand(chars.length)] }
7
+ string
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ module DocFrac
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: doc_frac
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Donavan White
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-19 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.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
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
+ description: Ruby wrapper library for DocFrac document converter
42
+ email:
43
+ - digi.cazter@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - Gemfile
49
+ - README.md
50
+ - Rakefile
51
+ - lib/doc_frac.rb
52
+ - lib/doc_frac/convert.rb
53
+ - lib/doc_frac/format.rb
54
+ - lib/doc_frac/utilities.rb
55
+ - lib/doc_frac/version.rb
56
+ homepage: https://github.com/Digi-Cazter/doc_frac
57
+ licenses:
58
+ - MIT
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.2.1
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: 'Simple Ruby wrapper library for using DocFrac on Unix systems, handles the
80
+ following document formats: RTF, HTML, and ASCII. This includes RTF to HTML and
81
+ HTML to RTF.'
82
+ test_files: []