yahoo-geoplanet 0.1.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/{README.txt → README} +1 -1
- data/lib/yahoo-geoplanet/base.rb +8 -1
- data/lib/yahoo-geoplanet/place.rb +6 -4
- data/lib/yahoo-geoplanet/version.rb +2 -2
- data/yahoo-geoplanet.gemspec +27 -0
- metadata +53 -44
- data/History.txt +0 -3
- data/License.txt +0 -20
- data/Manifest.txt +0 -21
- data/PostInstall.txt +0 -0
- data/Rakefile +0 -4
- data/config/hoe.rb +0 -75
- data/config/requirements.rb +0 -15
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/script/txt2html +0 -82
- data/setup.rb +0 -1585
- data/tasks/deployment.rake +0 -34
- data/tasks/environment.rake +0 -7
- data/tasks/website.rake +0 -17
data/{README.txt → README}
RENAMED
@@ -69,7 +69,7 @@ Additionally, yahoo-geoplanet has the following gem dependencies:
|
|
69
69
|
|
70
70
|
(The MIT License)
|
71
71
|
|
72
|
-
Copyright (c)
|
72
|
+
Copyright (c) 2010 Mattt Thompson
|
73
73
|
|
74
74
|
Permission is hereby granted, free of charge, to any person obtaining
|
75
75
|
a copy of this software and associated documentation files (the
|
data/lib/yahoo-geoplanet/base.rb
CHANGED
@@ -16,8 +16,15 @@ module Yahoo
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def api_path(resource, id, collection, *args)
|
19
|
+
args = args.extract_options!
|
20
|
+
count = args.delete(:count)
|
21
|
+
start = args.delete(:start)
|
22
|
+
collection += ";count=#{count}" if count
|
23
|
+
collection += ";start=#{start}" if start
|
24
|
+
|
19
25
|
parameters = [resource, id, collection, *args].compact
|
20
|
-
return parameters.collect!{|param| CGI::escape(param.to_s).downcase}.join('/')
|
26
|
+
# return parameters.collect!{|param| CGI::escape(param.to_s).downcase}.join('/')
|
27
|
+
return parameters.collect!{|param| param.to_s.downcase}.join('/')
|
21
28
|
end
|
22
29
|
end
|
23
30
|
|
@@ -15,7 +15,9 @@ module Yahoo
|
|
15
15
|
|
16
16
|
["admin1", "admin2", "admin3", "locality1", "locality2", "postal"].each do |optional|
|
17
17
|
begin
|
18
|
-
element = xml.at(optional)
|
18
|
+
element = xml.at(optional)
|
19
|
+
next if element.empty?
|
20
|
+
|
19
21
|
type = element.attributes["type"].downcase.gsub(/\s+/, '_')
|
20
22
|
value = element.inner_text
|
21
23
|
|
@@ -39,8 +41,8 @@ module Yahoo
|
|
39
41
|
|
40
42
|
# Association Collections
|
41
43
|
["parent", "ancestors", "belongtos", "neighbors", "siblings", "children"].each do |association|
|
42
|
-
define_method(association.to_sym) do
|
43
|
-
xml = self.class.fetch_and_parse(self.class.api_path(self.class.name, @woe_id, association), :select => :long)
|
44
|
+
define_method(association.to_sym) do |*options|
|
45
|
+
xml = self.class.fetch_and_parse(self.class.api_path(self.class.name, @woe_id, association, *options), :select => :long)
|
44
46
|
value = xml.search(self.class.name.downcase).collect{|elem| self.class.new(elem)}
|
45
47
|
return association.singularize == association ? value.first : value
|
46
48
|
end
|
@@ -70,4 +72,4 @@ module Yahoo
|
|
70
72
|
end
|
71
73
|
end
|
72
74
|
end
|
73
|
-
end
|
75
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "yahoo-geoplanet"
|
3
|
+
s.version = "0.2.1"
|
4
|
+
s.date = "2010-03-25"
|
5
|
+
s.summary = "A Ruby wrapper for the Yahoo! GeoPlanet API."
|
6
|
+
s.email = "m@mattt.me"
|
7
|
+
s.homepage = "http://github.com/mattt/yahoo-geoplanet/"
|
8
|
+
s.description = "A Ruby wrapper for the Yahoo! GeoPlanet API.
|
9
|
+
See http://developer.yahoo.com/geo/ for more information about the API."
|
10
|
+
s.authors = ["Mattt Thompson"]
|
11
|
+
|
12
|
+
s.files = [
|
13
|
+
"README",
|
14
|
+
"yahoo-geoplanet.gemspec",
|
15
|
+
"lib/yahoo-geoplanet.rb",
|
16
|
+
"lib/rest.rb",
|
17
|
+
"lib/yahoo-geoplanet/base.rb",
|
18
|
+
"lib/yahoo-geoplanet/place.rb",
|
19
|
+
"lib/yahoo-geoplanet/version.rb"
|
20
|
+
]
|
21
|
+
|
22
|
+
s.add_dependency("hpricot", ["> 0.6"])
|
23
|
+
s.add_dependency("activesupport", ["> 2.1.0"])
|
24
|
+
|
25
|
+
s.has_rdoc = false
|
26
|
+
s.rdoc_options = ["--main", "README"]
|
27
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yahoo-geoplanet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 1
|
9
|
+
version: 0.2.1
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Mattt Thompson
|
@@ -9,80 +14,84 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-03-25 00:00:00 -05:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
name: hpricot
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
|
-
- - "
|
25
|
+
- - ">"
|
22
26
|
- !ruby/object:Gem::Version
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 6
|
30
|
+
version: "0.6"
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: activesupport
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
segments:
|
41
|
+
- 2
|
42
|
+
- 1
|
43
|
+
- 0
|
44
|
+
version: 2.1.0
|
45
|
+
type: :runtime
|
46
|
+
version_requirements: *id002
|
47
|
+
description: |-
|
48
|
+
A Ruby wrapper for the Yahoo! GeoPlanet API.
|
49
|
+
See http://developer.yahoo.com/geo/ for more information about the API.
|
50
|
+
email: m@mattt.me
|
28
51
|
executables: []
|
29
52
|
|
30
53
|
extensions: []
|
31
54
|
|
32
|
-
extra_rdoc_files:
|
33
|
-
|
34
|
-
- License.txt
|
35
|
-
- Manifest.txt
|
36
|
-
- PostInstall.txt
|
37
|
-
- README.txt
|
55
|
+
extra_rdoc_files: []
|
56
|
+
|
38
57
|
files:
|
39
|
-
-
|
40
|
-
-
|
41
|
-
- Manifest.txt
|
42
|
-
- PostInstall.txt
|
43
|
-
- README.txt
|
44
|
-
- Rakefile
|
45
|
-
- config/hoe.rb
|
46
|
-
- config/requirements.rb
|
47
|
-
- lib/rest.rb
|
58
|
+
- README
|
59
|
+
- yahoo-geoplanet.gemspec
|
48
60
|
- lib/yahoo-geoplanet.rb
|
61
|
+
- lib/rest.rb
|
49
62
|
- lib/yahoo-geoplanet/base.rb
|
50
63
|
- lib/yahoo-geoplanet/place.rb
|
51
64
|
- lib/yahoo-geoplanet/version.rb
|
52
|
-
- script/console
|
53
|
-
- script/destroy
|
54
|
-
- script/generate
|
55
|
-
- script/txt2html
|
56
|
-
- setup.rb
|
57
|
-
- tasks/deployment.rake
|
58
|
-
- tasks/environment.rake
|
59
|
-
- tasks/website.rake
|
60
65
|
has_rdoc: true
|
61
|
-
homepage: http://yahoo-geoplanet
|
62
|
-
|
66
|
+
homepage: http://github.com/mattt/yahoo-geoplanet/
|
67
|
+
licenses: []
|
68
|
+
|
69
|
+
post_install_message:
|
63
70
|
rdoc_options:
|
64
71
|
- --main
|
65
|
-
- README
|
72
|
+
- README
|
66
73
|
require_paths:
|
67
74
|
- lib
|
68
75
|
required_ruby_version: !ruby/object:Gem::Requirement
|
69
76
|
requirements:
|
70
77
|
- - ">="
|
71
78
|
- !ruby/object:Gem::Version
|
79
|
+
segments:
|
80
|
+
- 0
|
72
81
|
version: "0"
|
73
|
-
version:
|
74
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
83
|
requirements:
|
76
84
|
- - ">="
|
77
85
|
- !ruby/object:Gem::Version
|
86
|
+
segments:
|
87
|
+
- 0
|
78
88
|
version: "0"
|
79
|
-
version:
|
80
89
|
requirements: []
|
81
90
|
|
82
|
-
rubyforge_project:
|
83
|
-
rubygems_version: 1.
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 1.3.6
|
84
93
|
signing_key:
|
85
|
-
specification_version:
|
86
|
-
summary:
|
94
|
+
specification_version: 3
|
95
|
+
summary: A Ruby wrapper for the Yahoo! GeoPlanet API.
|
87
96
|
test_files: []
|
88
97
|
|
data/History.txt
DELETED
data/License.txt
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2008 Mattt Thompson
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
History.txt
|
2
|
-
License.txt
|
3
|
-
Manifest.txt
|
4
|
-
PostInstall.txt
|
5
|
-
README.txt
|
6
|
-
Rakefile
|
7
|
-
config/hoe.rb
|
8
|
-
config/requirements.rb
|
9
|
-
lib/rest.rb
|
10
|
-
lib/yahoo-geoplanet.rb
|
11
|
-
lib/yahoo-geoplanet/base.rb
|
12
|
-
lib/yahoo-geoplanet/place.rb
|
13
|
-
lib/yahoo-geoplanet/version.rb
|
14
|
-
script/console
|
15
|
-
script/destroy
|
16
|
-
script/generate
|
17
|
-
script/txt2html
|
18
|
-
setup.rb
|
19
|
-
tasks/deployment.rake
|
20
|
-
tasks/environment.rake
|
21
|
-
tasks/website.rake
|
data/PostInstall.txt
DELETED
File without changes
|
data/Rakefile
DELETED
data/config/hoe.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'yahoo-geoplanet/version'
|
2
|
-
|
3
|
-
AUTHOR = "Mattt Thompson"
|
4
|
-
EMAIL = "mail@matttthompson.com"
|
5
|
-
DESCRIPTION = "yahoo-geoplanet is a wrapper to the Y! GeoPlanet REST APIs"
|
6
|
-
GEM_NAME = 'yahoo-geoplanet' # what ppl will type to install your gem
|
7
|
-
RUBYFORGE_PROJECT = 'yahoo-geoplanet' # The unix name for your project
|
8
|
-
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
9
|
-
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
10
|
-
EXTRA_DEPENDENCIES = [
|
11
|
-
['hpricot', '>= 0.6'],
|
12
|
-
['activesupport', '>= 2.1.0'],
|
13
|
-
['flexmock', '>= 0.8.2']
|
14
|
-
] # An array of rubygem dependencies [name, version]
|
15
|
-
|
16
|
-
@config_file = "~/.rubyforge/user-config.yml"
|
17
|
-
@config = nil
|
18
|
-
RUBYFORGE_USERNAME = "mattt"
|
19
|
-
def rubyforge_username
|
20
|
-
unless @config
|
21
|
-
begin
|
22
|
-
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
23
|
-
rescue
|
24
|
-
puts <<-EOS
|
25
|
-
ERROR: No rubyforge config file found: #{@config_file}
|
26
|
-
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
27
|
-
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
28
|
-
EOS
|
29
|
-
exit
|
30
|
-
end
|
31
|
-
end
|
32
|
-
RUBYFORGE_USERNAME.replace @config["username"]
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
REV = nil
|
37
|
-
# UNCOMMENT IF REQUIRED:
|
38
|
-
# REV = YAML.load(`svn info`)['Revision']
|
39
|
-
VERS = Yahoo::GeoPlanet::VERSION::STRING + (REV ? ".#{REV}" : "")
|
40
|
-
RDOC_OPTS = ['--quiet', '--title', 'yahoo-geoplanet documentation',
|
41
|
-
"--opname", "index.html",
|
42
|
-
"--line-numbers",
|
43
|
-
"--main", "README",
|
44
|
-
"--inline-source"]
|
45
|
-
|
46
|
-
class Hoe
|
47
|
-
def extra_deps
|
48
|
-
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
49
|
-
@extra_deps
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
# Generate all the Rake tasks
|
54
|
-
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
55
|
-
$hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
56
|
-
p.developer(AUTHOR, EMAIL)
|
57
|
-
p.description = DESCRIPTION
|
58
|
-
p.summary = DESCRIPTION
|
59
|
-
p.url = HOMEPATH
|
60
|
-
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
61
|
-
p.test_globs = ["test/**/test_*.rb"]
|
62
|
-
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
|
63
|
-
|
64
|
-
# == Optional
|
65
|
-
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
66
|
-
#p.extra_deps = EXTRA_DEPENDENCIES
|
67
|
-
|
68
|
-
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
69
|
-
end
|
70
|
-
|
71
|
-
CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
72
|
-
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
73
|
-
$hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
74
|
-
$hoe.rsync_args = '-av --delete --ignore-errors'
|
75
|
-
$hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
|
data/config/requirements.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
include FileUtils
|
3
|
-
|
4
|
-
require 'rubygems'
|
5
|
-
%w[rake hoe newgem rubigen].each do |req_gem|
|
6
|
-
begin
|
7
|
-
require req_gem
|
8
|
-
rescue LoadError
|
9
|
-
puts "This Rakefile requires the '#{req_gem}' RubyGem."
|
10
|
-
puts "Installation: gem install #{req_gem} -y"
|
11
|
-
exit
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
data/script/console
DELETED
@@ -1,10 +0,0 @@
|
|
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/yahoo-music.rb'}"
|
9
|
-
puts "Loading yahoo-music gem"
|
10
|
-
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
DELETED
@@ -1,14 +0,0 @@
|
|
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
DELETED
@@ -1,14 +0,0 @@
|
|
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)
|
data/script/txt2html
DELETED
@@ -1,82 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
GEM_NAME = 'yahoo-music' # what ppl will type to install your gem
|
4
|
-
RUBYFORGE_PROJECT = 'yahoo-music'
|
5
|
-
|
6
|
-
require 'rubygems'
|
7
|
-
begin
|
8
|
-
require 'newgem'
|
9
|
-
require 'rubyforge'
|
10
|
-
rescue LoadError
|
11
|
-
puts "\n\nGenerating the website requires the newgem RubyGem"
|
12
|
-
puts "Install: gem install newgem\n\n"
|
13
|
-
exit(1)
|
14
|
-
end
|
15
|
-
require 'redcloth'
|
16
|
-
require 'syntax/convertors/html'
|
17
|
-
require 'erb'
|
18
|
-
require File.dirname(__FILE__) + "/../lib/#{GEM_NAME}/version.rb"
|
19
|
-
|
20
|
-
version = Yahoo::Music::VERSION::STRING
|
21
|
-
download = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
22
|
-
|
23
|
-
def rubyforge_project_id
|
24
|
-
RubyForge.new.autoconfig["group_ids"][RUBYFORGE_PROJECT]
|
25
|
-
end
|
26
|
-
|
27
|
-
class Fixnum
|
28
|
-
def ordinal
|
29
|
-
# teens
|
30
|
-
return 'th' if (10..19).include?(self % 100)
|
31
|
-
# others
|
32
|
-
case self % 10
|
33
|
-
when 1: return 'st'
|
34
|
-
when 2: return 'nd'
|
35
|
-
when 3: return 'rd'
|
36
|
-
else return 'th'
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
class Time
|
42
|
-
def pretty
|
43
|
-
return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def convert_syntax(syntax, source)
|
48
|
-
return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
|
49
|
-
end
|
50
|
-
|
51
|
-
if ARGV.length >= 1
|
52
|
-
src, template = ARGV
|
53
|
-
template ||= File.join(File.dirname(__FILE__), '/../website/template.html.erb')
|
54
|
-
else
|
55
|
-
puts("Usage: #{File.split($0).last} source.txt [template.html.erb] > output.html")
|
56
|
-
exit!
|
57
|
-
end
|
58
|
-
|
59
|
-
template = ERB.new(File.open(template).read)
|
60
|
-
|
61
|
-
title = nil
|
62
|
-
body = nil
|
63
|
-
File.open(src) do |fsrc|
|
64
|
-
title_text = fsrc.readline
|
65
|
-
body_text_template = fsrc.read
|
66
|
-
body_text = ERB.new(body_text_template).result(binding)
|
67
|
-
syntax_items = []
|
68
|
-
body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
|
69
|
-
ident = syntax_items.length
|
70
|
-
element, syntax, source = $1, $2, $3
|
71
|
-
syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
|
72
|
-
"syntax-temp-#{ident}"
|
73
|
-
}
|
74
|
-
title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
|
75
|
-
body = RedCloth.new(body_text).to_html
|
76
|
-
body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
|
77
|
-
end
|
78
|
-
stat = File.stat(src)
|
79
|
-
created = stat.ctime
|
80
|
-
modified = stat.mtime
|
81
|
-
|
82
|
-
$stdout << template.result(binding)
|