Permalink
Browse files

copy files

  • Loading branch information...
1 parent 5a00de0 commit 376df676307fe29f245ff2559bf292ecc0716ec6 @hasclass hasclass committed Dec 7, 2012
Showing 805 changed files with 50,527 additions and 0 deletions.
View
@@ -0,0 +1,5 @@
+/spec/javascripts/*
+/tmp/*
+/playground/*
+/benchmark/*
+/doc/*
View
@@ -0,0 +1,96 @@
+fs = require 'fs'
+{exec} = require 'child_process'
+
+appFiles = [
+ # omit src/ and .coffee to make the below lines a little shorter
+ 'ruby'
+ 'corelib/kernel'
+ 'corelib/coerce'
+ 'corelib/object'
+
+ # 'corelib/nil_class'
+ 'corelib/breaker'
+ 'corelib/base'
+
+ 'corelib/errors'
+
+ 'corelib/comparable'
+ 'corelib/enumerable'
+ 'corelib/enumerable_array'
+ 'corelib/enumerator'
+ 'corelib/array'
+ 'corelib/hash'
+ 'corelib/range'
+
+ 'corelib/match_data'
+ 'corelib/string'
+ 'corelib/regexp'
+
+ 'corelib/numeric'
+ 'corelib/integer'
+ 'corelib/fixnum'
+ 'corelib/float'
+
+ 'corelib/time'
+]
+
+task 'stats', '', ->
+ require './lib/rubyjs'
+ klasses = R [
+ RubyJS.String
+ RubyJS.Regexp
+ RubyJS.MatchData
+ RubyJS.Numeric
+ RubyJS.Integer
+ RubyJS.Fixnum
+ RubyJS.Float
+ RubyJS.Enumerable
+ RubyJS.Array
+ RubyJS.Range
+ ]
+ klasses.each (klass) ->
+ console.log klass.name+": "
+ console.log ("#"+el for el, fn of klass.prototype).join(", ")
+ console.log "\n"
+
+task 'build_tests', 'Builds all spec files', ->
+ console.log("##################################")
+ console.log("If you get the error: pipe(): Too many open files, see following page:")
+ console.log("https://github.com/jashkenas/coffee-script/issues/1537")
+ console.log("For Mac OS X users the following comment helps:")
+ console.log("https://github.com/joyent/node/issues/2479#issuecomment-7082186")
+ console.log("##################################")
+
+ exec 'coffee -bo spec/javascripts/lib lib', defaultExecHandler
+ exec 'coffee -o spec/javascripts spec/lib', defaultExecHandler
+
+
+
+task 'build', 'Build single application file from source files', ->
+ appContents = new Array remaining = appFiles.length
+ for file, index in appFiles then do (file, index) ->
+ fs.readFile "lib/#{file}.coffee", 'utf8', (err, fileContents) ->
+ throw err if err
+ appContents[index] = fileContents
+ process() if --remaining is 0
+
+ # Compiles to ~/ and copies to spec/javascripts
+ process = ->
+ fs.writeFile 'ruby.coffee', appContents.join('\n\n'), 'utf8', (err) ->
+ throw err if err
+ exec 'coffee --compile ruby.coffee', (err, stdout, stderr) ->
+ throw err if err
+ console.log stdout + stderr
+ exec 'cp ruby.js spec/javascripts/ruby.js', defaultExecHandler
+
+
+task 'minify', 'Minify and gzip the resulting application file after build', ->
+ exec 'uglifyjs "ruby.js" > ruby.min.js && cp ruby.min.js spec/javascripts/lib && cp ruby.min.js ../rubyjs.org/', (err, stdout, stderr) ->
+ throw err if err
+ console.log stdout + stderr
+ exec "gzip -c 'ruby.min.js' > 'ruby.min.js.gz'", defaultExecHandler
+
+
+defaultExecHandler = (err, stdout, stderr) ->
+ throw err if err
+ console.log stdout + stderr
View
@@ -0,0 +1,8 @@
+source :rubygems
+
+gem 'guard'
+gem 'guard-coffeescript'
+gem 'guard-shell'
+gem 'guard-uglify'
+gem 'guard-livereload'
+gem 'jasmine'
View
@@ -0,0 +1,22 @@
+require 'guard/guard'
+
+# Output compiled JS classes for debugging
+#
+guard 'coffeescript', :output => 'tmp', :bare => true do
+ watch('^lib/**/(.*)\.coffee')
+end
+
+# Creates ~/ruby.js, and spec/javascripts/ruby-full.js for jasmine
+guard :shell do
+ watch('^lib/**/(.*)\.coffee') { `cake build` }
+end
+
+# Compiles spec/ files
+guard 'coffeescript', :output => 'spec/javascripts' do
+ watch('^spec/lib/(.*)\.coffee')
+end
+
+guard 'livereload' do
+ watch('^spec/javascripts/.+\.js$')
+ watch('^javascripts/lib/.+\.js$')
+end
View
175 Rakefile
@@ -0,0 +1,175 @@
+# Useage:
+# Update progress.txt
+# -------------------
+# rake stats > progress.txt
+#
+# Output rails style todos
+# ------------------------
+# rake notes
+#
+
+begin
+ require 'jasmine'
+ load 'jasmine/tasks/jasmine.rake'
+rescue LoadError
+ task :jasmine do
+ abort "Jasmine is not available. In order to run jasmine, you must: (sudo) gem install jasmine"
+ end
+end
+
+
+desc 'Tracks progress and filesize'
+task :stats do
+ folders = Dir['spec/lib/corelib/*']
+ padding = folders.map(&:length).max + 1
+
+ puts 'Spec completeness'
+ puts '-' * 20
+
+ folders.each do |path|
+ rb = Dir[path+'/*.rb'].length
+ cs = Dir[path+'/*.coffee'].length
+ puts "#{path.ljust(padding)} #{'.' * cs}#{'x'*rb}"
+ end
+
+ `cake build minify`
+
+ puts ''
+ puts 'Compiled Filesize'
+ puts '-' * 20
+ puts `ls -lh ruby.*`
+end
+
+
+
+# Implements the logic behind the rake tasks for annotations like
+#
+# rake notes
+# rake notes:optimize
+#
+# and friends. See <tt>rake -T notes</tt> and <tt>railties/lib/tasks/annotations.rake</tt>.
+#
+# Annotation objects are triplets <tt>:line</tt>, <tt>:tag</tt>, <tt>:text</tt> that
+# represent the line where the annotation lives, its tag, and its text. Note
+# the filename is not stored.
+#
+# Annotations are looked for in comments and modulus whitespace they have to
+# start with the tag optionally followed by a colon. Everything up to the end
+# of the line (or closing ERB comment tag) is considered to be their text.
+class SourceAnnotationExtractor
+ class Annotation < Struct.new(:line, :tag, :text)
+ def self.directories
+ @@directories ||= %w(app config lib script test) + (ENV['SOURCE_ANNOTATION_DIRECTORIES'] || '').split(',')
+ end
+
+ # Returns a representation of the annotation that looks like this:
+ #
+ # [126] [TODO] This algorithm is simple and clearly correct, make it faster.
+ #
+ # If +options+ has a flag <tt>:tag</tt> the tag is shown as in the example above.
+ # Otherwise the string contains just line and text.
+ def to_s(options={})
+ s = "[#{line.to_s.rjust(options[:indent])}] "
+ s << "[#{tag}] " if options[:tag]
+ s << text
+ end
+ end
+
+ # Prints all annotations with tag +tag+ under the root directories +app+, +config+, +lib+,
+ # +script+, and +test+ (recursively). Only filenames with extension
+ # +.builder+, +.rb+, +.erb+, +.haml+, +.slim+, +.css+, +.scss+, +.js+, and
+ # +.coffee+ are taken into account. The +options+ hash is passed to each
+ # annotation's +to_s+.
+ #
+ # This class method is the single entry point for the rake tasks.
+ def self.enumerate(tag, options={})
+ extractor = new(tag)
+ extractor.display(extractor.find, options)
+ end
+
+ attr_reader :tag
+
+ def initialize(tag)
+ @tag = tag
+ end
+
+ # Returns a hash that maps filenames under +dirs+ (recursively) to arrays
+ # with their annotations.
+ def find(dirs = Annotation.directories)
+ dirs.inject({}) { |h, dir| h.update(find_in(dir)) }
+ end
+
+ # Returns a hash that maps filenames under +dir+ (recursively) to arrays
+ # with their annotations. Only files with annotations are included, and only
+ # those with extension +.builder+, +.rb+, +.erb+, +.haml+, +.slim+, +.css+,
+ # +.scss+, +.js+, and +.coffee+
+ # are taken into account.
+ def find_in(dir)
+ results = {}
+
+ Dir.glob("#{dir}/*") do |item|
+ next if File.basename(item)[0] == ?.
+
+ if File.directory?(item)
+ results.update(find_in(item))
+ elsif item =~ /\.(builder|rb|coffee)$/
+ results.update(extract_annotations_from(item, /#\s*(#{tag}):?\s*(.*)$/))
+ elsif item =~ /\.(css|scss|js)$/
+ results.update(extract_annotations_from(item, /\/\/\s*(#{tag}):?\s*(.*)$/))
+ elsif item =~ /\.erb$/
+ results.update(extract_annotations_from(item, /<%\s*#\s*(#{tag}):?\s*(.*?)\s*%>/))
+ elsif item =~ /\.haml$/
+ results.update(extract_annotations_from(item, /-\s*#\s*(#{tag}):?\s*(.*)$/))
+ elsif item =~ /\.slim$/
+ results.update(extract_annotations_from(item, /\/\s*\s*(#{tag}):?\s*(.*)$/))
+ end
+ end
+
+ results
+ end
+
+ # If +file+ is the filename of a file that contains annotations this method returns
+ # a hash with a single entry that maps +file+ to an array of its annotations.
+ # Otherwise it returns an empty hash.
+ def extract_annotations_from(file, pattern)
+ lineno = 0
+ result = File.readlines(file).inject([]) do |list, line|
+ lineno += 1
+ next list unless line =~ pattern
+ list << Annotation.new(lineno, $1, $2)
+ end
+ result.empty? ? {} : { file => result }
+ end
+
+ # Prints the mapping from filenames to annotations in +results+ ordered by filename.
+ # The +options+ hash is passed to each annotation's +to_s+.
+ def display(results, options={})
+ options[:indent] = results.map { |f, a| a.map(&:line) }.flatten.max.to_s.size
+ results.keys.sort.each do |file|
+ puts "#{file}:"
+ results[file].each do |note|
+ puts " * #{note.to_s(options)}"
+ end
+ puts
+ end
+ end
+end
+
+desc "Enumerate all annotations (use notes:optimize, :fixme, :todo for focus)"
+task :notes do
+ SourceAnnotationExtractor.enumerate "OPTIMIZE|FIXME|TODO", :tag => true
+end
+
+namespace :notes do
+ ["OPTIMIZE", "FIXME", "TODO"].each do |annotation|
+ # desc "Enumerate all #{annotation} annotations"
+ task annotation.downcase.intern do
+ SourceAnnotationExtractor.enumerate annotation
+ end
+ end
+
+ desc "Enumerate a custom annotation, specify with ANNOTATION=CUSTOM"
+ task :custom do
+ SourceAnnotationExtractor.enumerate ENV['ANNOTATION']
+ end
+end
Oops, something went wrong.

0 comments on commit 376df67

Please sign in to comment.