thoughtful 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ == 0.0.1 2008-02-19
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/License.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Jay Fields
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 ADDED
@@ -0,0 +1,30 @@
1
+ History.txt
2
+ License.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ config/hoe.rb
7
+ config/requirements.rb
8
+ lib/thoughtful.rb
9
+ lib/thoughtful/object.rb
10
+ lib/thoughtful/require.rb
11
+ lib/thoughtful/symbol.rb
12
+ lib/thoughtful/thoughtful.rake
13
+ lib/thoughtful/version.rb
14
+ log/debug.log
15
+ script/destroy
16
+ script/generate
17
+ script/txt2html
18
+ setup.rb
19
+ tasks/deployment.rake
20
+ tasks/environment.rake
21
+ tasks/website.rake
22
+ test/test_helper.rb
23
+ test/thoughtful/object_test.rb
24
+ test/thoughtful/require_test.rb
25
+ test/thoughtful/symbol_test.rb
26
+ website/index.html
27
+ website/index.txt
28
+ website/javascripts/rounded_corners_lite.inc.js
29
+ website/stylesheets/screen.css
30
+ website/template.rhtml
data/README.txt ADDED
@@ -0,0 +1 @@
1
+ README
data/Rakefile ADDED
@@ -0,0 +1,19 @@
1
+ require 'config/requirements'
2
+ require 'config/hoe' # setup Hoe + all gem configuration
3
+
4
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
5
+
6
+
7
+ class Rake::Task
8
+ def abandon
9
+ @actions.clear
10
+ end
11
+ end
12
+
13
+ Rake::Task[:test].abandon
14
+
15
+ Rake::TestTask.new do |t|
16
+ t.libs << "test"
17
+ t.pattern = 'test/**/*_test.rb'
18
+ t.verbose = true
19
+ end
data/config/hoe.rb ADDED
@@ -0,0 +1,70 @@
1
+ require 'thoughtful/version'
2
+
3
+ AUTHOR = 'Jay Fields' # can also be an array of Authors
4
+ EMAIL = "thoughtful@jayfields.com"
5
+ DESCRIPTION = "rails extensions for making you more productive"
6
+ GEM_NAME = 'thoughtful' # what ppl will type to install your gem
7
+ RUBYFORGE_PROJECT = 'thoughtful' # The unix name for your project
8
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
+ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
+
11
+ @config_file = "~/.rubyforge/user-config.yml"
12
+ @config = nil
13
+ RUBYFORGE_USERNAME = "unknown"
14
+ def rubyforge_username
15
+ unless @config
16
+ begin
17
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
18
+ rescue
19
+ puts <<-EOS
20
+ ERROR: No rubyforge config file found: #{@config_file}
21
+ Run 'rubyforge setup' to prepare your env for access to Rubyforge
22
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
23
+ EOS
24
+ exit
25
+ end
26
+ end
27
+ RUBYFORGE_USERNAME.replace @config["username"]
28
+ end
29
+
30
+
31
+ REV = nil
32
+ # UNCOMMENT IF REQUIRED:
33
+ # REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
34
+ VERS = Thoughtful::VERSION::STRING + (REV ? ".#{REV}" : "")
35
+ RDOC_OPTS = ['--quiet', '--title', 'thoughtful documentation',
36
+ "--opname", "index.html",
37
+ "--line-numbers",
38
+ "--main", "README",
39
+ "--inline-source"]
40
+
41
+ class Hoe
42
+ def extra_deps
43
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
44
+ @extra_deps
45
+ end
46
+ end
47
+
48
+ # Generate all the Rake tasks
49
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
50
+ hoe = Hoe.new(GEM_NAME, VERS) do |p|
51
+ p.developer(AUTHOR, EMAIL)
52
+ p.description = DESCRIPTION
53
+ p.summary = DESCRIPTION
54
+ p.url = HOMEPATH
55
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
56
+ p.test_globs = ["test/**/test_*.rb"]
57
+ p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
58
+
59
+ # == Optional
60
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
61
+ #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
62
+
63
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
64
+
65
+ end
66
+
67
+ CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
68
+ PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
69
+ hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
70
+ hoe.rsync_args = '-av --delete --ignore-errors'
@@ -0,0 +1,17 @@
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]))
16
+
17
+ require 'thoughtful'
@@ -0,0 +1,25 @@
1
+ class Object
2
+ def metaclass
3
+ class << self ; self ; end
4
+ end
5
+
6
+ def r(arg)
7
+ raise arg.inspect
8
+ end
9
+
10
+ def not
11
+ Not.new(self)
12
+ end
13
+
14
+ class Not
15
+ private(*instance_methods.select { |m| m !~ /(^__|^\W|^binding$)/ })
16
+
17
+ def initialize(subject)
18
+ @subject = subject
19
+ end
20
+
21
+ def method_missing(sym, *args, &blk)
22
+ !@subject.send(sym,*args,&blk)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,39 @@
1
+ class Require
2
+ class << self
3
+ attr_accessor :path_to_gems
4
+ end
5
+
6
+ def self.files_in(path)
7
+ files = files_for(path)
8
+ raise ArgumentError.new("no files found in #{path}") if files.empty?
9
+ files.each do |file|
10
+ require file
11
+ end
12
+ end
13
+
14
+ def self.unpacked_gem(*gem_names)
15
+ gem_names.each { |gem| require_unpacked_gem(gem) }
16
+ end
17
+
18
+ def self.require_unpacked_gem(gem)
19
+ raise ArgumentError.new("unpacked gem #{gem} could not be found") if gem_path(gem).empty?
20
+ gem_path(gem).each do |dir|
21
+ add_load_path "#{dir}/lib"
22
+ require dir + "/lib/#{gem}" if File.exist?(dir + "/lib/#{gem}.rb")
23
+ end
24
+ end
25
+
26
+ def self.files_for(path)
27
+ Dir["#{RAILS_ROOT}/#{path}/*"]
28
+ end
29
+
30
+ def self.gem_path(gem)
31
+ return Dir[path_to_gems + "#{gem}*"] if path_to_gems
32
+ Dir[RAILS_ROOT + "/vendor/gems/#{gem}*"]
33
+ end
34
+
35
+ def self.add_load_path(path)
36
+ $: << path
37
+ end
38
+
39
+ end
@@ -0,0 +1,7 @@
1
+ class Symbol
2
+
3
+ def <=>(other)
4
+ to_s <=> other.to_s
5
+ end
6
+
7
+ end
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'fileutils'
4
+
5
+ namespace :thoughtful do
6
+ desc "freeze thoughtful to vendor/gems"
7
+ task :freeze do
8
+ unpacked_msg = %x[gem unpack thoughtful]
9
+ unpacked_location = unpacked_msg.gsub(/^.*'(.*)'$/, '\1').chomp
10
+ Dir["vendor/gems/thoughtful/**/.svn"].each do |file|
11
+ mv(file, "#{unpacked_location}/lib/" + file.gsub(/^vendor\/gems\/thoughtful\/(.*)/,'\1').chomp) if file =~ /.svn/
12
+ end
13
+ rm_rf "vendor/gems/thoughtful"
14
+ mv "#{unpacked_location}/lib/", "vendor/gems/thoughtful"
15
+ mkdir_p "lib/tasks"
16
+ mv "vendor/gems/thoughtful/thoughtful/thoughtful.rake", "lib/tasks"
17
+ rm_rf unpacked_location
18
+ end
19
+ end
@@ -0,0 +1,9 @@
1
+ module Thoughtful #:nodoc:
2
+ module VERSION #:nodoc:
3
+ MAJOR = 0
4
+ MINOR = 0
5
+ TINY = 6
6
+
7
+ STRING = [MAJOR, MINOR, TINY].join('.')
8
+ end
9
+ end
data/lib/thoughtful.rb ADDED
@@ -0,0 +1,3 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/thoughtful/require")
2
+ require File.expand_path(File.dirname(__FILE__) + "/thoughtful/object")
3
+ require File.expand_path(File.dirname(__FILE__) + "/thoughtful/symbol")
data/log/debug.log ADDED
File without changes
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = 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.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 ADDED
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ begin
5
+ require 'newgem'
6
+ rescue LoadError
7
+ puts "\n\nGenerating the website requires the newgem RubyGem"
8
+ puts "Install: gem install newgem\n\n"
9
+ exit(1)
10
+ end
11
+ require 'redcloth'
12
+ require 'syntax/convertors/html'
13
+ require 'erb'
14
+ require File.dirname(__FILE__) + '/../lib/thoughtful/version.rb'
15
+
16
+ version = Thoughtful::VERSION::STRING
17
+ download = 'http://rubyforge.org/projects/thoughtful'
18
+
19
+ class Fixnum
20
+ def ordinal
21
+ # teens
22
+ return 'th' if (10..19).include?(self % 100)
23
+ # others
24
+ case self % 10
25
+ when 1: return 'st'
26
+ when 2: return 'nd'
27
+ when 3: return 'rd'
28
+ else return 'th'
29
+ end
30
+ end
31
+ end
32
+
33
+ class Time
34
+ def pretty
35
+ return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
36
+ end
37
+ end
38
+
39
+ def convert_syntax(syntax, source)
40
+ return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
41
+ end
42
+
43
+ if ARGV.length >= 1
44
+ src, template = ARGV
45
+ template ||= File.join(File.dirname(__FILE__), '/../website/template.rhtml')
46
+
47
+ else
48
+ puts("Usage: #{File.split($0).last} source.txt [template.rhtml] > output.html")
49
+ exit!
50
+ end
51
+
52
+ template = ERB.new(File.open(template).read)
53
+
54
+ title = nil
55
+ body = nil
56
+ File.open(src) do |fsrc|
57
+ title_text = fsrc.readline
58
+ body_text = fsrc.read
59
+ syntax_items = []
60
+ body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
61
+ ident = syntax_items.length
62
+ element, syntax, source = $1, $2, $3
63
+ syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
64
+ "syntax-temp-#{ident}"
65
+ }
66
+ title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
67
+ body = RedCloth.new(body_text).to_html
68
+ body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
69
+ end
70
+ stat = File.stat(src)
71
+ created = stat.ctime
72
+ modified = stat.mtime
73
+
74
+ $stdout << template.result(binding)