ycn 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/License.txt +20 -0
- data/Manifest.txt +36 -0
- data/PostInstall.txt +7 -0
- data/README.txt +48 -0
- data/Rakefile +4 -0
- data/bin/ycn-gen +96 -0
- data/config/hoe.rb +74 -0
- data/config/requirements.rb +15 -0
- data/lib/ycn/header.rb +10 -0
- data/lib/ycn/java_klass.rb +169 -0
- data/lib/ycn/klass.rb +95 -0
- data/lib/ycn/string_manip.rb +31 -0
- data/lib/ycn/version.rb +9 -0
- data/lib/ycn/ycn.rb +47 -0
- data/lib/ycn/ycn_functions.rb +40 -0
- data/lib/ycn.rb +16 -0
- data/script/console +10 -0
- data/script/console.cmd +1 -0
- data/script/destroy +14 -0
- data/script/destroy.cmd +1 -0
- data/script/generate +14 -0
- data/script/generate.cmd +1 -0
- data/script/txt2html +82 -0
- data/script/txt2html.cmd +1 -0
- data/setup.rb +1585 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/test_helper.rb +2 -0
- data/test/test_ycn.rb +11 -0
- data/website/index.html +11 -0
- data/website/index.txt +83 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.html.erb +48 -0
- metadata +112 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
def correct_for_blank_last_method file
|
|
2
|
+
# Without this, a blank mapping on the last line of the file
|
|
3
|
+
# is incorrectly interpreted as a String.
|
|
4
|
+
content = file.read
|
|
5
|
+
content += "\n"
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def check_for_inheritance class_name
|
|
9
|
+
if class_name =~ /.+<.+/
|
|
10
|
+
klass = class_name.split(/\s*<\s*/)
|
|
11
|
+
return {:name => klass[0], :parent => klass[1]}
|
|
12
|
+
else
|
|
13
|
+
return {:name => class_name}
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def fix_inheritance_and_overrides classes
|
|
18
|
+
classes.each { |klass|
|
|
19
|
+
klass.parent = (classes.find_all{ |c| c.name == klass.parent })[0]
|
|
20
|
+
}.each { |klass|
|
|
21
|
+
klass.extract_default_values
|
|
22
|
+
}.each { |klass|
|
|
23
|
+
klass.fix_default_overrides }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def attribute_hash_to_class class_name, attribute_hash
|
|
27
|
+
inheritance = check_for_inheritance(class_name)
|
|
28
|
+
name = inheritance[:name]
|
|
29
|
+
parent = inheritance[:parent]
|
|
30
|
+
properties = attribute_hash['properties']
|
|
31
|
+
methods = attribute_hash['methods']
|
|
32
|
+
new_params = attribute_hash['new']
|
|
33
|
+
package = configatron.package
|
|
34
|
+
|
|
35
|
+
Klass.new(name, parent, properties, methods, new_params, package)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def extension
|
|
39
|
+
{:java => 'java', :ruby => 'rb'}
|
|
40
|
+
end
|
data/lib/ycn.rb
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
|
3
|
+
|
|
4
|
+
require 'yaml'
|
|
5
|
+
|
|
6
|
+
require File.join(File.dirname(__FILE__), 'ycn', 'ycn')
|
|
7
|
+
require File.join(File.dirname(__FILE__), 'ycn', 'header')
|
|
8
|
+
require File.join(File.dirname(__FILE__), 'ycn', 'java_klass')
|
|
9
|
+
require File.join(File.dirname(__FILE__), 'ycn', 'klass')
|
|
10
|
+
require File.join(File.dirname(__FILE__), 'ycn', 'string_manip')
|
|
11
|
+
require File.join(File.dirname(__FILE__), 'ycn', 'ycn_functions')
|
|
12
|
+
|
|
13
|
+
module Ycn
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
puts "BEHOLD!"
|
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/ycn.rb'}"
|
|
9
|
+
puts "Loading ycn gem"
|
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/console.cmd
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@ruby script/console %*
|
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/destroy.cmd
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@ruby script/destroy %*
|
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)
|
data/script/generate.cmd
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@ruby script/generate %*
|
data/script/txt2html
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
GEM_NAME = 'ycn' # what ppl will type to install your gem
|
|
4
|
+
RUBYFORGE_PROJECT = 'ycn'
|
|
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 = Ycn::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)
|
data/script/txt2html.cmd
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@ruby script/txt2html %*
|