gust 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ -c
2
+ -f documentation
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/README.markdown ADDED
@@ -0,0 +1,4 @@
1
+ Gust
2
+ ====
3
+
4
+ Syntax highlighting and Markdown/Textile parsing
data/gust.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "gust"
6
+ s.version = '0.1.0'
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Jeff Kreeftmeijer"]
9
+ s.email = ["jeff@kreeftmeijer.nl"]
10
+ s.homepage = ""
11
+ s.summary = %q{Syntax highlighting and Markdown/Textile parsing}
12
+ s.description = %q{Syntax highlighting and Markdown/Textile parsing}
13
+
14
+ s.rubyforge_project = "gust"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_dependency 'rspec', ['~> 2.0']
22
+ s.add_dependency 'pygments.rb', ['~> 0.1.2']
23
+ s.add_dependency 'kramdown', ['~> 0.13.3']
24
+ s.add_dependency 'RedCloth', ['~> 4.2.7']
25
+ end
data/lib/gust.rb ADDED
@@ -0,0 +1,20 @@
1
+ require 'pygments'
2
+ require 'kramdown'
3
+ require 'RedCloth'
4
+
5
+ class Gust
6
+
7
+ def self.parse(code, options = {})
8
+
9
+ if options[:filename]
10
+ code = case options[:filename]
11
+ when /.*\.markdown$/ then Kramdown::Document.new(code).to_html
12
+ when /.*\.textile$/ then RedCloth.new(code).to_html
13
+ else return Pygments.highlight(code, options) rescue code
14
+ end
15
+ end
16
+
17
+ "<div class=\"markup\">#{code}</div>\n"
18
+ end
19
+
20
+ end
data/spec/gust_spec.rb ADDED
@@ -0,0 +1,50 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ require 'gust'
3
+
4
+ describe Gust do
5
+
6
+ describe '.parse' do
7
+
8
+ context 'when only passing "foo" as a string' do
9
+
10
+ subject { Gust.parse('foo') }
11
+
12
+ it { should == "<div class=\"markup\">foo</div>\n" }
13
+
14
+ end
15
+
16
+ context 'with an unknown filename' do
17
+
18
+ subject { Gust.parse('foo', :filename => 'foo.bar') }
19
+
20
+ it { should == "<div class=\"markup\">foo</div>\n" }
21
+
22
+ end
23
+
24
+ context 'with a ruby file' do
25
+
26
+ subject { Gust.parse('foo', :filename => 'foo.rb') }
27
+
28
+ it { should == "<div class=\"highlight\"><pre><span class=\"n\">foo</span>\n</pre>\n</div>\n" }
29
+
30
+ end
31
+
32
+ context 'with a markdown file' do
33
+
34
+ subject { Gust.parse('*foo*', :filename => 'foo.markdown') }
35
+
36
+ it { should == "<div class=\"markup\"><p><em>foo</em></p>\n</div>\n" }
37
+
38
+ end
39
+
40
+ context 'with a textile file' do
41
+
42
+ subject { Gust.parse('*foo*', :filename => 'foo.textile') }
43
+
44
+ it { should == "<div class=\"markup\"><p><strong>foo</strong></p></div>\n" }
45
+
46
+ end
47
+
48
+ end
49
+
50
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gust
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jeff Kreeftmeijer
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-06-26 00:00:00.000000000 +02:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ requirement: &2154021680 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: '2.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *2154021680
26
+ - !ruby/object:Gem::Dependency
27
+ name: pygments.rb
28
+ requirement: &2154021180 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.1.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *2154021180
37
+ - !ruby/object:Gem::Dependency
38
+ name: kramdown
39
+ requirement: &2154020700 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ version: 0.13.3
45
+ type: :runtime
46
+ prerelease: false
47
+ version_requirements: *2154020700
48
+ - !ruby/object:Gem::Dependency
49
+ name: RedCloth
50
+ requirement: &2154020220 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: 4.2.7
56
+ type: :runtime
57
+ prerelease: false
58
+ version_requirements: *2154020220
59
+ description: Syntax highlighting and Markdown/Textile parsing
60
+ email:
61
+ - jeff@kreeftmeijer.nl
62
+ executables: []
63
+ extensions: []
64
+ extra_rdoc_files: []
65
+ files:
66
+ - .gitignore
67
+ - .rspec
68
+ - Gemfile
69
+ - README.markdown
70
+ - gust.gemspec
71
+ - lib/gust.rb
72
+ - spec/gust_spec.rb
73
+ has_rdoc: true
74
+ homepage: ''
75
+ licenses: []
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project: gust
94
+ rubygems_version: 1.6.2
95
+ signing_key:
96
+ specification_version: 3
97
+ summary: Syntax highlighting and Markdown/Textile parsing
98
+ test_files:
99
+ - spec/gust_spec.rb