Permalink
Browse files

out with the old

  • Loading branch information...
1 parent e3cbe63 commit 4a1ef0a7bcb32b8e1529886c4bc304615a91baf2 Vanson Samuel committed May 12, 2011
View
@@ -1,4 +0,0 @@
-=== 0.0.1 2010-04-27
-
-* 1 major enhancement:
- * Initial release
View
@@ -1,11 +0,0 @@
-History.txt
-Manifest.txt
-PostInstall.txt
-README.rdoc
-Rakefile
-lib/cpre.rb
-script/console
-script/destroy
-script/generate
-test/test_cpre.rb
-test/test_helper.rb
View
@@ -1,7 +0,0 @@
-
-For more information on cpre, see http://cpre.rubyforge.org
-
-NOTE: Change this information in PostInstall.txt
-You can also delete it if you don't want it.
-
-
View
@@ -1,72 +0,0 @@
-cpre
- from the utility method
- args
- source (not documented)
- collect
- sources
- filters
-
- collect, source
- filters, source
- collect, filters, source
-
- collect, filters
- collect, sources
- filters, sources
- collect, filters, sources
- options
- dsl
- long way
- short way
- from an array
- comprehend block
- dsl block
- long way
- short way
- from a hash
- comprehend block
- dsl block
- long way
- short way
-
-= cpre
-
-* http://github.com/binq/cpre
-
-== DESCRIPTION:
-
-FIX (describe your package)
-
-== FEATURES/PROBLEMS:
-
-* FIX (list of features or problems)
-
-== SYNOPSIS:
-
- FIX (code sample of usage)
-
-== REQUIREMENTS:
-
-* FIX (list of requirements)
-
-== INSTALL:
-
-* FIX (sudo gem install, anything else)
-
-== LICENSE:
-
- cpre
- Copyright (C) 2010 Vanson Samuel
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
View
@@ -1,25 +0,0 @@
-require 'rubygems'
-gem 'hoe', '>= 2.1.0'
-require 'hoe'
-require 'fileutils'
-require './lib/cpre'
-
-Hoe.plugin :newgem
-# Hoe.plugin :website
-# Hoe.plugin :cucumberfeatures
-
-# Generate all the Rake tasks
-# Run 'rake -T' to see list of generated tasks (from gem root directory)
-$hoe = Hoe.spec 'cpre' do
- self.developer 'Vanson Samuel', 'vs@binq.com'
- # self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
- self.rubyforge_name = self.name # TODO this is default value
- # self.extra_deps = [['activesupport','>= 2.0.2']]
-end
-
-require 'newgem/tasks'
-Dir['tasks/**/*.rake'].each { |t| load t }
-
-# TODO - want other tests/tasks run by default? Add them to the list
-# remove_task :default
-# task :default => [:spec, :features]
View
@@ -1,40 +0,0 @@
-require File.dirname(__FILE__) + '/test_helper.rb'
-
-class TestCpre < Test::Unit::TestCase
-
- def setup
- end
-
- def test_method_is_setup
- assert respond_to?(:cpre)
- end
-
- def test_base_case_should_work
- assert_nothing_raised do
- cpre
- end
-
- assert_equal cpre.to_a, []
- assert_equal cpre(1, 2, 3).to_a, [[1], [2], [3]]
- assert_equal cpre([1, 2, 3]).to_a, [[1], [2], [3]]
- assert_equal cpre(%w(a b), [1, 2]).to_a, [['a', 1], ['a', 2],
- ['b', 1], ['b', 2]]
- assert_equal cpre(%w(a b), %w(y z)).collect { i.join }, %w(ay az by bz)
- end
-end
-
-# describe "a basic cpre call should return a arrya" do
-# vowel_check = lambda do
-# vowels = %w(a e i o u)
-# lambda do |l|
-# letters, tld = [l[0..-2], l[-1]]
-# min_length, max_length = lambda{
-# lengths = [letters.length / 3, letters.length / 4]
-# [lengths.min, lengths.max]
-# }
-# (min_length..max_length).include?((letters - vowels).length)
-# end
-# end.call
-#
-# [lambda { |l| l.join }, [%w(com net org us), *Array.new(3) { 'a'..'z' }], {lambda {}}].cpre
-# end
View
@@ -1,3 +0,0 @@
-require 'stringio'
-require 'test/unit'
-require File.dirname(__FILE__) + '/../lib/cpre'
View
@@ -1,20 +0,0 @@
-%w(ostruct).collect { |i| require i }
-
-$:.unshift(File.dirname(__FILE__)) unless
- $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
-
-class Cpre
- VERSION = '0.0.1'
-end
-
-#Reordered from:
-#%(%w()).insert(-2, Pathname.glob('lib/cpre/*').collect { |p| p.relative_path_from(Pathname('lib')).to_s.gsub('.rb', '').gsub(/^cpre./, '') }.join(' '))
-%w(utilities base defaults validations args_parser args_parser_dsl ops setup).collect { |i| require "cpre/%s" % i }
-
-Cpre.class_eval {
- const_set(:IN_SETUP, true)
- setup_in_kernel
- # setup_in_array
- # setup_in_hash
- remove_const(:IN_SETUP)
-}
View
@@ -1,37 +0,0 @@
-module Cpre::ArgsParser
- module ClassMethods
- def parse(*args, &block)
- block_given? ? Cpre.new(:sources => args, &block) : Cpre.new(:sources => args)
- end
- end
-
- module InstanceMethods
- #returns a new comprehension with the values supplied through the ArgsParserDsl
- def update(&block)
- raise ArgumentError unless block_given?
- options = Hash[*MAIN_ARGS.collect { |i| [i.to_sym, send(i.to_sym)] }.flatten]
- Cpre.new(update_options(options, &block))
- end
-
- private
-
- #get new arguments from the ArgsParserDsl and return a hash that can be used to instantiate a new comprehension
- def update_options(options, &block)
- raise ArgumentError unless block_given?
-
- Hash[*Cpre::MAIN_ARGS.inject(:parsed => Cpre::ArgsParserDsl.new(options).dsl_eval(&block), :result => []) { |memo, i|
- memo[:result] << i.to_sym << memo[:parsed].send(i)
- memo
- }[:result]]
- end
- end
-
- def self.included(klass)
- klass.class_eval do
- extend ClassMethods
- include InstanceMethods
- end
- end
-end
-
-Cpre.class_eval { include self::ArgsParser }
@@ -1,32 +0,0 @@
-class Cpre::ArgsParserDsl
- Cpre::MAIN_ARGS.each { |i| attr_accessor i }
-
- def initialize(options)
- @collect, @sources, @filters = Cpre::MAIN_ARGS.collect { |i| options[i.to_sym] }
- end
-
- def dsl_eval(&block)
- raise ArgumentError unless block_given?
- self.tap { self.instance_eval(&block) }
- end
-
- def set_collect(new_value)
- self.collect = new_value
- end
-
- def add_source(value)
- self.sources << value
- end
-
- def remove_source(value)
- self.sources.delete(value)
- end
-
- def add_filter(value)
- self.filters << value
- end
-
- def remove_filter(value)
- self.filters.delete(value)
- end
-end
View
@@ -1,54 +0,0 @@
-class Cpre
- MAIN_ARGS = %w(collect sources filters names)
-
- include Enumerable
-
- MAIN_ARGS.each { |i| attr_reader i }
-
- def initialize(*args, &block)
- raise ArgumentError unless args.empty? || args.length == 1 && args.first.is_a?(Hash) && valid_options?(args.first)
- options = block_given? ? update_options(scrub_options(args.first), &block) : scrub_options(args.first)
- @collect, @sources, @filters = options.values_at(*MAIN_ARGS.collect { |i| i.to_sym })
- end
-
- def accepted_by_filters?(result)
- filters.inject(true) { |memo, filter| memo &&= result.instance_eval(&filter) }
- end
-
- def each
- return self unless block_given? && sources.length > 0
-
- generators = sources.collect { |i| Enumerator.new(i) }
-
- current_list = generators.collect do |generator|
- begin
- generator.next
- rescue StopIteration
- return
- end
- end
-
- loop do
- OpenStruct.new(:items => current_list).tap do |result|
- yield(result.instance_eval(&collect)) if accepted_by_filters?(result)
- end
-
- current_list = generators.zip(current_list).inject(:finding => true, :current_list => []) { |result, pair|
- generator, current = pair
- result.tap do
- if result[:finding]
- begin
- result[:current_list] << generator.next
- result[:finding] = false
- rescue StopIteration
- return if generator == generators.last
- result[:current_list] << generator.rewind.next
- end
- else
- result[:current_list] << current
- end
- end
- }[:current_list]
- end
- end
-end
View
@@ -1,27 +0,0 @@
-module Cpre::Defaults
- def default_args
- Cpre::MAIN_ARGS.collect { |i| send("default_%s" % [i]) }
- end
-
- def default_collect
- lambda { items.length == 1 ? items.first : items }
- end
-
- def default_sources
- []
- end
-
- def default_filters
- []
- end
-
- def default_names
- nil
- end
-end
-
-Cpre.class_eval do
- private
-
- extend Cpre::Defaults
-end
View
@@ -1,10 +0,0 @@
-class Cpre
- def *(multiplicand)
- end
-
- def /(divisor)
- end
-
- def %(operand)
- end
-end
View
@@ -1,31 +0,0 @@
-class << Cpre
- def setup_in_kernel(options={})
- return if respond_to?(:dont_setup_in_kernel) && send(:dont_setup_in_kernel) && respond_to?(:in_setup)
-
- cpre_methods = %w(c cpre comprehend)
- cpre_methods = options[:without].is_a?(Array) ? cpre_methods - options[:without] :
- options[:without].is_a?(String) ? cpre_methods - [options[:without]] :
- cpre_methods
- cpre_methods = options[:as].is_a?(Array) ? cpre_methods + options[:as] :
- options[:as].is_a?(String) ? cpre_methods + [options[:as]] :
- cpre_methods
-
- Kernel.module_eval do
- cpre_methods.each do |cpre_method|
- eval(<<-EOT % [cpre_method])
- def %s(*args, &block)
- block_given? ? Cpre.new(*args, &block) : Cpre.new(*args)
- end
- EOT
- end
- end
- end
-
- def setup_in_array(options={})
- return if respond_to?(:dont_setup_in_array) && send(:dont_setup_in_array) && respond_to?(:in_setup)
- end
-
- def setup_in_hash(options={})
- return if respond_to?(:dont_setup_in_hash) && send(:dont_setup_in_hash) && respond_to?(:in_setup)
- end
-end
View
@@ -1,10 +0,0 @@
-module Cpre::Utilities
- def flatten_pair
- lambda { |memo, pair| memo << pair[0] << pair[1] }
- end
-end
-
-Cpre.class_eval do
- extend self::Utilities
- include self::Utilities
-end
Oops, something went wrong.

0 comments on commit 4a1ef0a

Please sign in to comment.