gyazz-markup 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gemtest ADDED
File without changes
data/History.txt ADDED
@@ -0,0 +1,3 @@
1
+ === 0.0.1 2012-05-24
2
+
3
+ * first release.
data/Manifest.txt ADDED
@@ -0,0 +1,12 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.rdoc
4
+ Rakefile
5
+ lib/gyazz-markup.rb
6
+ lib/gyazz-markup/markup.rb
7
+ script/console
8
+ script/destroy
9
+ script/generate
10
+ test/test_gyazz-markup.rb
11
+ test/test_helper.rb
12
+ bin/gyazz-markup
data/README.rdoc ADDED
@@ -0,0 +1,46 @@
1
+ = gyazz-markup
2
+
3
+ * http://github.com/shokai/gyazz-markup
4
+
5
+ == DESCRIPTION:
6
+
7
+ markup Gyazz.com syntax.
8
+
9
+ == SYNOPSIS:
10
+
11
+ require 'rubygems'
12
+ require 'gyazz-markup'
13
+ puts GyazzMarkup.markup(open("input.txt").read)
14
+
15
+ or
16
+
17
+ puts GyazzMarkup.markup(open("input.txt").read, "shokai")
18
+
19
+ == INSTALL:
20
+
21
+ * gem install gyazz-markup
22
+
23
+ == LICENSE:
24
+
25
+ (The MIT License)
26
+
27
+ Copyright (c) 2012 Sho Hashimoto
28
+
29
+ Permission is hereby granted, free of charge, to any person obtaining
30
+ a copy of this software and associated documentation files (the
31
+ 'Software'), to deal in the Software without restriction, including
32
+ without limitation the rights to use, copy, modify, merge, publish,
33
+ distribute, sublicense, and/or sell copies of the Software, and to
34
+ permit persons to whom the Software is furnished to do so, subject to
35
+ the following conditions:
36
+
37
+ The above copyright notice and this permission notice shall be
38
+ included in all copies or substantial portions of the Software.
39
+
40
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
41
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
42
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
43
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
44
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
45
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
46
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,25 @@
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ require './lib/gyazz-markup'
6
+
7
+ Hoe.plugin :newgem
8
+ # Hoe.plugin :website
9
+ # Hoe.plugin :cucumberfeatures
10
+
11
+ # Generate all the Rake tasks
12
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
+ $hoe = Hoe.spec 'gyazz-markup' do
14
+ self.developer 'Sho Hashimoto', 'hashimoto@shokai.org'
15
+ self.rubyforge_name = self.name # TODO this is default value
16
+ # self.extra_deps = [['activesupport','>= 2.0.2']]
17
+
18
+ end
19
+
20
+ require 'newgem/tasks'
21
+ Dir['tasks/**/*.rake'].each { |t| load t }
22
+
23
+ # TODO - want other tests/tasks run by default? Add them to the list
24
+ # remove_task :default
25
+ # task :default => [:spec, :features]
data/bin/gyazz-markup ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+ require 'rubygems'
4
+ ## $:.unshift File.dirname(__FILE__)+'/../lib/'
5
+
6
+ require 'gyazz-markup'
7
+
8
+ input, base = ARGV[0..1]
9
+ unless input
10
+ STDERR.puts "gyazz-markup input.txt"
11
+ STDERR.puts "gyazz-markup input.txt 増井"
12
+ exit 1
13
+ end
14
+
15
+ puts GyazzMarkup.markup(open(input).read, base)
@@ -0,0 +1,54 @@
1
+
2
+ module GyazzMarkup
3
+
4
+ def self.markup(txt, base="test")
5
+ lines = txt.split(/[\r\n]/).delete_if{|line|
6
+ line.to_s.size < 1
7
+ }
8
+
9
+ pats = [
10
+ [ /\[{2,3}(https?:\/\/.+)\.(png|jpe?g|gif|bmp)\]{2,3}/, "<a href=\"#{$1}.#{$2}\"><img src=\"#{$1}.#{$2}\"></a>"],
11
+ [ /\[{2}(https?:\/\/.+)\]{2}/, "<a href=\"#{$1}\">#{$1}</a>"],
12
+ [ /\[\[(.+)\]\]/, "<a href=\"http://gyazz.com/#{base}/#{$1}\">#{$1}</a>"]
13
+ ]
14
+
15
+ lines.map do |line|
16
+ line = self.markup_url_with_image line
17
+ line = self.markup_image line
18
+ line = self.markup_strong line
19
+ line = self.markup_url_with_title line
20
+ line = self.markup_url line
21
+ line = self.markup_inner_link(line, base)
22
+ end
23
+ end
24
+
25
+ def self.markup_image(str)
26
+ pat = /\[{2,3}(https?:\/\/.+)\.(png|jpe?g|gif|bmp)\]{2,3}/
27
+ str !~ pat ? str : str.gsub(pat, "<a href=\"#{$1}.#{$2}\"><img src=\"#{$1}.#{$2}\"></a>")
28
+ end
29
+
30
+ def self.markup_url(str)
31
+ pat = /\[{2}(https?:\/\/.+)\]{2}/
32
+ str !~ pat ? str : str.gsub(pat, "<a href=\"#{$1}\">#{$1}</a>")
33
+ end
34
+
35
+ def self.markup_inner_link(str, base='gyazz')
36
+ pat = /\[{2}(.+)\]{2}/
37
+ str !~ pat ? str : str.gsub(pat, "<a href=\"http://gyazz.com/#{base}/#{$1}\">#{$1}</a>")
38
+ end
39
+
40
+ def self.markup_strong(str)
41
+ pat = /\[{3}(.+)\]{3}/
42
+ str !~ pat ? str : str.gsub(pat, "<strong>#{$1}</strong>")
43
+ end
44
+
45
+ def self.markup_url_with_title(str)
46
+ pat = /\[{2}(https?:\/\/.+)\s(.+)\]{2}/
47
+ str !~ pat ? str : str.gsub(pat, "<a href=\"#{$1}\">#{$2}</a>")
48
+ end
49
+
50
+ def self.markup_url_with_image(str)
51
+ pat = /\[{2}(https?:\/\/.+)\s(https?:\/\/.+)\.(png|jpe?g|gif|bmp)\]{2}/
52
+ str !~ pat ? str : str.gsub(pat, "<a href=\"#{$1}\"><img src=\"#{$2}.#{$3}\"></a>")
53
+ end
54
+ end
@@ -0,0 +1,8 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ require 'gyazz-markup/markup'
5
+
6
+ module GyazzMarkup
7
+ VERSION = '0.0.1'
8
+ end
data/script/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/gyazz-markup.rb'}"
9
+ puts "Loading gyazz-markup gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestGyazzMarkup < Test::Unit::TestCase
4
+
5
+ def setup
6
+ end
7
+
8
+ def test_truth
9
+ assert true
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ require 'stringio'
2
+ require 'test/unit'
3
+ require File.dirname(__FILE__) + '/../lib/gyazz-markup'
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gyazz-markup
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Sho Hashimoto
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-05-24 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rdoc
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 19
29
+ segments:
30
+ - 3
31
+ - 10
32
+ version: "3.10"
33
+ type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: newgem
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 5
44
+ segments:
45
+ - 1
46
+ - 5
47
+ - 3
48
+ version: 1.5.3
49
+ type: :development
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: hoe
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ hash: 29
60
+ segments:
61
+ - 2
62
+ - 15
63
+ version: "2.15"
64
+ type: :development
65
+ version_requirements: *id003
66
+ description: markup Gyazz.com syntax.
67
+ email:
68
+ - hashimoto@shokai.org
69
+ executables:
70
+ - gyazz-markup
71
+ extensions: []
72
+
73
+ extra_rdoc_files:
74
+ - History.txt
75
+ - Manifest.txt
76
+ - README.rdoc
77
+ files:
78
+ - History.txt
79
+ - Manifest.txt
80
+ - README.rdoc
81
+ - Rakefile
82
+ - lib/gyazz-markup.rb
83
+ - lib/gyazz-markup/markup.rb
84
+ - script/console
85
+ - script/destroy
86
+ - script/generate
87
+ - test/test_gyazz-markup.rb
88
+ - test/test_helper.rb
89
+ - bin/gyazz-markup
90
+ - .gemtest
91
+ homepage: http://github.com/shokai/gyazz-markup
92
+ licenses: []
93
+
94
+ post_install_message:
95
+ rdoc_options:
96
+ - --main
97
+ - README.rdoc
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ hash: 3
106
+ segments:
107
+ - 0
108
+ version: "0"
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ none: false
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ hash: 3
115
+ segments:
116
+ - 0
117
+ version: "0"
118
+ requirements: []
119
+
120
+ rubyforge_project: gyazz-markup
121
+ rubygems_version: 1.8.17
122
+ signing_key:
123
+ specification_version: 3
124
+ summary: markup Gyazz.com syntax.
125
+ test_files:
126
+ - test/test_gyazz-markup.rb
127
+ - test/test_helper.rb