Code Monkey home page Code Monkey logo

facets's People

Contributors

aguynamedryan avatar andyt avatar anithri avatar benjamintanweihao avatar bitherder avatar ccjr avatar chocolateboy avatar cielavenir avatar codeindulgence avatar danbernier avatar emirikol avatar esparta avatar fd00 avatar ioquatix avatar ipagbox avatar jc00ke avatar jurisgalang avatar kb avatar kotp avatar lavirthewhiolet avatar leifcr avatar lucapette avatar lunks avatar msavy avatar smtlaissezfaire avatar sprachprofi avatar szuecs avatar tilo avatar trans avatar tylerrick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

facets's Issues

fix: #recurse doesn't "go deep" with multple classes (Hash/Array)

struct = [1, 2, {:a => 3, :b => [4, 5, {:c=>6}]}, [7, 8]]
struct.recurse(Array, Hash){|o| p o}

I wrongly get:

{:a=>3, :b=>[4, 5, {:c=>6}]}
[7, 8]
[1, 2, {:a=>3, :b=>[4, 5, {:c=>6}]}, [7, 8]]

After my patch[1] you get:

{:c=>6}
[4, 5, {:c=>6}]
{:a=>3, :b=>[4, 5, {:c=>6}]}
[7, 8]
[1, 2, {:a=>3, :b=>[4, 5, {:c=>6}]}, [7, 8]]

Tests pass sucesfully with:

lemon -Ilib/core test/core/array/test_recurse.rb
lemon -Ilib/core test/core/array/test_recurse.rb

You can pull my 'recurse' branch.

TODO: I should probably write new test cases in the next commits...

Guido De Rosa

[1] http://github.com/gderosa/facets/commit/c7d0b48de341a40cff423a9e194e947fbc399ce0

Facets "Essentials"

Another interesting idea would be to mark a very very few libs as "essential" like "you use these every day" File.write would be one for me. i.e. something like a

require 'facets/essentials'

-Roger Pack

Update documentation

Hello,

It would be helpful for newcomers to update the documentation to show how to make facets work with Rails >3.0.3.
I had to do the following:
Besides including in the gemwile I put the following into "config/preinitializer.rb":

require 'facets'

Then I required "config/preinitializer.rb" in "config/application.rb" just before

require 'rails/all'

Now it works.

Otherwise I was getting the following error:

gems/facets-2.9.1/lib/core/facets/module/redefine_method.rb:29:in undef_method': undefined method some_method' for class `SomeClass' (NameError)

Regards.

Enumerable#count breaks Pry in Ruby 2.0.0

The Enumerable#count method in https://github.com/rubyworks/facets/blob/master/lib/core/facets/enumerable/count.rb breaks Pry's Pry#update_input_history method:

[1] pry(main)> require 'facets/enumerable/count'
nil
TypeError: nil can't be coerced into Fixnum
from /Users/ashmoran/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/pry-0.9.12/lib/pry/pry_instance.rb:549:in `+'

Any subsequent lines of code added raise a TypeError. The line in Pry that is affected is:

Pry.current_line += code.each_line.count

from https://github.com/pry/pry/blob/master/lib/pry/pry_instance.rb#L532

cluster_by should accept integer argument.

Implemented in git://github.com/LavirtheWhiolet/facets.git

TODO: May be it cluster_by() should be overriden in Array instead of Enumerable because Array preserves order?

TODO: May be group_by() should accept integer instead of cluster_by()?

[doc] errors on Core:Enumerable#commonality

The block code in the doc for this method is erroneous.
http://facets.rubyforge.org/apidoc/api/core/classes/Enumerable.html#M000511

From an irb session:


ruby-1.9.1-p378 > [1, 2, 2, 3, 4, 4].commonality
 => {2=>[2, 2], 4=>[4, 4]} 
ruby-1.9.1-p378 > ["foo", "bar", "a"].commonality { |str| str.length }
 => {3=>["foo", "bar"]}

The collision method mentionned in the doc doesn't seem to be an existing alias of commonality (could be interesting to add it though!).

doesn't work with rails 3.0.3

I've tried to use Hashery into a rails 3 project and came across with this bug:
https://github.com/rubyworks/hashery/issues#issue/6

Actually, the bug is triggered by facets.
I've read the solution provided here:
https://github.com/rubyworks/facets/issues/unreads#issue/19

and inserted "require 'facets'" in config/preinitializer.rb
and "gem 'facets'" in the Gemfile but the problem persists:

$ rails console
Loading development environment (Rails 3.0.3)
ruby-1.9.2-p0 > Post
ArgumentError: method does not exist
        from /Users/olistik/.rvm/gems/ruby-1.9.2-p0/gems/facets-2.9.0/lib/core/facets/module/redefine_method.rb:27:in `redefine_method'
        from /Users/olistik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/associations.rb:1445:in `association_accessor_methods'
        from /Users/olistik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/associations.rb:1225:in `belongs_to'
        from /Users/olistik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/autosave_association.rb:137:in `belongs_to'
        from /private/tmp/hashery_test/app/models/post.rb:2:in `<class:Post>'
        from /private/tmp/hashery_test/app/models/post.rb:1:in `<top (required)>'

object_hexid is broken on 32 bit arches with ruby 1.8.7.

ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]

irb(main):001:0> "0x%x" % (Object.new.id << 1)
=> "0x..fb741b4e8"
Note the two dots that should not be there and don't match the output of o.inspect.

This was also broken in facets 2.8.4:

  1. Failure:
    test_object_hexid(TCKernel) [./test/core/kernel/test_object_hexid.rb:8]:
    <"#Object:0xb7248ea4"> expected but was
    <"#Object:0xfb7248ea4">.

In the implementation of this version there is a distinction between RUBY_VERSION < 1.8.7, but this distinction is really between 32bit and 64bit arches.

requiring 'gem facets' breaks Rails 3.2.1 / facets 2.9.3

I have a brand-new Rails 3.2.1 project, which requires facets, and after you run "bundle install",
when you run "rails console" , this happens:

$ rails --version
3.2.1
$ rails new example
$ cd example
$ vi Gemfile
$ bundle install

$ rails c
/Users/myusername/.rvm/gems/ruby-1.9.2-p180@rails_3.2/gems/railties-3.2.1/lib/rails/engine.rb:504:in `block in initializers': undefined method `initializers' for #<Instance:0x007fd52b3ae7d0 @delegate=:all> (NoMethodError)
        from /Users/myusername/.rvm/gems/ruby-1.9.2-p180@rails_3.2/gems/railties-3.2.1/lib/rails/engine.rb:500:in `each'
        from /Users/myusername/.rvm/gems/ruby-1.9.2-p180@rails_3.2/gems/railties-3.2.1/lib/rails/engine.rb:500:in `initializers'
        from /Users/myusername/.rvm/gems/ruby-1.9.2-p180@rails_3.2/gems/railties-3.2.1/lib/rails/application.rb:202:in `initializers'
        from /Users/myusername/.rvm/gems/ruby-1.9.2-p180@rails_3.2/gems/railties-3.2.1/lib/rails/initializable.rb:54:in `run_initializers'
        from /Users/myusername/.rvm/gems/ruby-1.9.2-p180@rails_3.2/gems/railties-3.2.1/lib/rails/application.rb:136:in `initialize!'
        from /Users/myusername/.rvm/gems/ruby-1.9.2-p180@rails_3.2/gems/railties-3.2.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
        from /private/tmp/DELETEME/config/environment.rb:5:in `<top (required)>'
        from /Users/myusername/.rvm/gems/ruby-1.9.2-p180@rails_3.2/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:251:in `require'
        from /Users/myusername/.rvm/gems/ruby-1.9.2-p180@rails_3.2/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:251:in `block in require'
        from /Users/myusername/.rvm/gems/ruby-1.9.2-p180@rails_3.2/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:236:in `load_dependency'
        from /Users/myusername/.rvm/gems/ruby-1.9.2-p180@rails_3.2/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:251:in `require'
        from /Users/myusername/.rvm/gems/ruby-1.9.2-p180@rails_3.2/gems/railties-3.2.1/lib/rails/application.rb:103:in `require_environment!'
        from /Users/myusername/.rvm/gems/ruby-1.9.2-p180@rails_3.2/gems/railties-3.2.1/lib/rails/commands.rb:40:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

Range#at_rand() enhancement.

(x..y).at_rand() should return random floating point number (whether Float, BigNum or whatever else) if x and y are floating point numbers.

Also (x..y).at_rand() should not convert the range to array when possible.

Also (x..y).at_rand() should return y sometimes but (x...y).at_rand() should never return y.

Hash#delete_values return value

While #delete_values works as expected, it might return something more useful. Currently:

    a = { :a => 1, :b => 2, :c => 3 }
    a.delete_values(1)  #=> [nil, 1, nil]

Rename String#margin to #trim

Seem like #trim is a much more fitting name for what the method actually does.

Of course, the question is, is it worth the loss of backward compatibility?

Deprecate Kernel#resc

The #resc method isn't needed anymore thanks to String#to_re. Might also consider adding Regexp[].

Unit tests

Hi! I just forked the HEAD and tried to run tests with rake test:core. After some tests failed (for obsolete String#outdent) I wanted to fix these, but there seem to be two test suites: one based on lemon and the other 'test/unit' ones. Which ones are preferred? How do you run the lemon tests? In any case, the docs should be updated to reflect the changes.

Incompatible with rails3.0.0.beta4

facets in incompatible with rails3.0.0.beta4. Rails implements its own version of cattr_accessor that can take hash arguments. This conflicts with the version in facets, that triest to handle arguments as a new class variables.
The resulting behaviour is that rails doesn't run when facets is loaded.

rails console

gems/facets-2.8.4/lib/core/facets/class/cattr.rb:35: syntax error, unexpected $undefined (SyntaxError)
unless defined? @@{:instance_writer=>true}
...
from gems/ruby-1.9.2-rc1/bundler/gems/rails-f33ee69/activesupport/lib/active_support/cache.rb:148

Patch: Indexable::rand

I have forked facets to add a rand() method to Indexable, which returns a random element. It's at git://github.com/CraigCottingham/facets.git in the indexable_rand branch.

I haven't tested it yet, because I haven't figured out how to either tell Ruby to use my working copy of facets instead of the installed gem, or how to make a new gem from my working copy. There's no .gemspec in the working directory. I found the install/uninstall tasks in Rakefile, but those don't seem to work correctly (install created core/ and more/ directories in my site_ruby/1.9.1 directory, rather than under a facets/ directory).

For now I'm going to overwrite indexable.rb in my gem tree, but even I know that's a hack and half. Any suggestions on how to do this properly will be gratefully welcomed.

Cannot run facets with Rubinius

Rubinius creates compiled ruby .rbc files in the same directories as its .rb counterparts. This causes an issue with how facets loads its files. Right now it uses:

Dir["dir/*"].each { |x| require x }

it should use

Dir["dir/*.rb"].each { |x| require x }

Various enhancements

  1. String#include? should accept Regexp-s.
  2. Enumerable#has?() and Enumerable#have?() using "===" equality test.
  3. StringScanner#scan_before().
  4. SafeOpenStructable class.

All these are implemented in git://github.com/LavirtheWhiolet/facets.git

Error when requiring "facets/random" after "facets"

irb(main):002:0> require 'facets'
/var/lib/gems/1.8/gems/facets-2.9.3/lib/core/facets/filetest/separator_pattern.rb:5: warning: already initialized constant SEPARATOR_PATTERN
/var/lib/gems/1.8/gems/facets-2.9.3/lib/core/facets/string/bracket.rb:3: warning: already initialized constant BRA2KET
=> true
irb(main):003:0> require 'facets/random'
SystemStackError: stack level too deep
        from /var/lib/gems/1.8/gems/facets-2.9.3/lib/core/facets/kernel/extend.rb:25:in `_extend'
        from /var/lib/gems/1.8/gems/facets-2.9.3/lib/core/facets/kernel/extend.rb:25:in `_extend'
        from /var/lib/gems/1.8/gems/facets-2.9.3/lib/core/facets/kernel/extend.rb:25:in `extend'
        from /var/lib/gems/1.8/gems/facets-2.9.3/lib/standard/facets/random.rb:338:in `included'
        from /var/lib/gems/1.8/gems/facets-2.9.3/lib/standard/facets/random.rb:442:in `include'
        from /var/lib/gems/1.8/gems/facets-2.9.3/lib/standard/facets/random.rb:442
        from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
        from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from (irb):3
        from (null):0

Symbol#setter?

Maybe Symbol#setter? should actually be called Symbol#writer? Likewise for #plain? and #reader?

Module#pathize and #methodize

Consider if these work as they should. Currently camelcase becomes snakecase and module separators become double undescores __. This insures the names can be converted in either direction, but perhaps that isn't necessary?

Problems with Enumerable#map_by

I use Enumerable#map_by a lot, it's a great abstraction because, more often than not, Enumerable#group_by falls too short. However, there are a couple of closely related problems with its implementation and specifications:

  1. Implementation: insufficient checks of the returned value of the block:
[[:a, true], [:b, false], [:c, nil]].map_by { |x, y| [x, y] }
#=> {:a=>[true], :b=>[[:b, false]], :c=>[[:c, nil]]}

Would'n you expect {:a=>[true], :b=>[false], :c=>[nil]}?

  1. Specifications: "if a second value is not returned, #map_by acts like #group_by.". The problem is that you cannot tell an array (which you may intent to use as a key) from a pair [key, value]. You may for example write:
[1, 2, 3].map_by { |x| [x, 2*x] }
#=> {1=>[2], 2=>[4], 3=>[6]}

But what you expected was {[1, 2]=>[1], [2, 4]=>[2], [3, 6=>[3]}. The old Unix adagio probably applies: "do one thing and do it well".


It looks to me that while (1) is easily solvable, (2) suggests that trying to act like group_by was a bad idea after all (if you wanted a group_by shouldn't you be using group_by anyway?). Granted, that change would break some old code (though I am not sure many people were actually using map_by that way...).

I can prepare a pull request with the conclusion of the conversation, I wanted to gather some opinions first.

'string/xor.rb' should be named 'string/op_xor.rb'

string/xor.rb file should probably be called op_xor.rb instead. That's the going procedure so that facets-live.rb will be able to convert operators to names. Hover someone mentioned it seemed rather redundant to use "op" prefix. Perhaps these methods could just have names without the the prefix?

If there are no significant naming conflicts, then getting rid of the op prefix is a possibility. In the mean time a op_xor.rb alias to xor.rb will do the trick.

descendents

I think this could well be spelled
descendants
Thanks!
-r

Contributor's doc update is needed

What tools should contributor use to run tests and to build the gem (seriously, I have downloaded source code, have made some fix but could not do anything with it)? How to publish the gem or who is responsible for publishing? All these things should be described in documentation for contributors.

IndexError: key not found

I'm attempting to use Dictionary in a Rails 2.3.8 project. This is gem version 2.9.1, and it's Ruby Enterprise Edition 1.8.7.

Upon startup of the application, I'm presented with this error:

/gems/facets-2.9.1/lib/core/facets/hash/slice.rb:11:in `fetch':IndexError: key not found

This is whether I'm running the app via Passenger or even if I attempt to fire up a console.

Is there some additional requirement to using this library that I have missed?

Dir.recursive alias for Find.find

It was reported long ago: "I think it's better to implement Dir.recursive() as alias of Find.find()".

I am not so certain of this, but let us make a note of it here for the time being.

Time and DateTime extensions

Time and DateTime extensions need the most work. This has been put off for some time thinking that Ruby would get it's shit together and improve the situation. But it doesn't look like it will ever happen. So basically, at some point, some one needs to sit down study the current field --in particular ActiveSupport's methods, and polish up Facets' Time and DateTime extensions.

The elephant in room here is of course time zone support (ugh).

String.indent_to()

require 'facets/string/indent'

class String

  def indent_to(required_indentation_level, padding_char = ' ')
    raise %(padding_char must be char, not string) if padding_char.length != 1
    return padding_char * required_indentation_level if self.empty?
    current_indentation_level = self.lines.map { |line| line[/^#{"\\" + padding_char}*/].length }.min
    self.indent(required_indentation_level - current_indentation_level, padding_char)
  end

end

Bring back __HERE__ (maybe)

Turns out #source_location doesn't really cut it, since it's for Method only.

So should we bring __HERE__ back? It can be defined as:

  def __HERE__
    caller(1).first
  end

Or

  def __HERE__
    caller(1).first.split(':')
  end

If we want to split line from file.

Of course, we might also ask if __HERE__ is the best name for this.

no such file to load -- facets/methodspace (MissingSourceFile)

Trying to use unroller in a rails 2.3.14 legacy project I inherited. This is what I get:

$ gem install unroller --include-dependencies
INFO:  `gem install -y` is now default and will be removed
INFO:  use --ignore-dependencies to install only the gems you list
Successfully installed facets-2.9.3
Successfully installed quality_extensions-1.3.1
Successfully installed colored-1.2
Successfully installed unroller-1.0.0

$ ruby script/server
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- facets/methodspace (MissingSourceFile)
  from <internal:lib/rubygems/custom_require>:29:in `require'
  from /local/rvm/gems/ruby-1.9.2-p318@legacy_rails_app/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in `block in require'
  from /local/rvm/gems/ruby-1.9.2-p318@legacy_rails_app/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:547:in `new_constants_in'
  from /local/rvm/gems/ruby-1.9.2-p318@legacy_rails_app/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in `require'
  from /local/rvm/gems/ruby-1.9.2-p318@legacy_rails_app/gems/unroller-1.0.0/lib/unroller.rb:4:in `<top (required)>'
  from <internal:lib/rubygems/custom_require>:33:in `require'
  from <internal:lib/rubygems/custom_require>:33:in `rescue in require'
  from <internal:lib/rubygems/custom_require>:29:in `require'
  from /local/rvm/gems/ruby-1.9.2-p318@legacy_rails_app/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in `block in require'
  from /local/rvm/gems/ruby-1.9.2-p318@legacy_rails_app/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:547:in `new_constants_in'
  from /local/rvm/gems/ruby-1.9.2-p318@legacy_rails_app/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in `require'
  from /mathworks/home/lkyrala/perforce/legacy_rails_app/1.41/config/initializers/unroller_local_dev_trace_patch.rb:21:in `<top (required)>'
  from /local/rvm/gems/ruby-1.9.2-p318@legacy_rails_app/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:171:in `load'
  from /local/rvm/gems/ruby-1.9.2-p318@legacy_rails_app/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:171:in `block in load_with_new_constant_marking'
  from /local/rvm/gems/ruby-1.9.2-p318@legacy_rails_app/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:547:in `new_constants_in'
  from /local/rvm/gems/ruby-1.9.2-p318@legacy_rails_app/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:171:in `load_with_new_constant_marking'
  from /local/rvm/gems/ruby-1.9.2-p318@legacy_rails_app/gems/rails-2.3.14/lib/initializer.rb:622:in `block in load_application_initializers'
  from /local/rvm/gems/ruby-1.9.2-p318@legacy_rails_app/gems/rails-2.3.14/lib/initializer.rb:621:in `each'
  from /local/rvm/gems/ruby-1.9.2-p318@legacy_rails_app/gems/rails-2.3.14/lib/initializer.rb:621:in `load_application_initializers'
  from /local/rvm/gems/ruby-1.9.2-p318@legacy_rails_app/gems/rails-2.3.14/lib/initializer.rb:176:in `process'
  from /local/rvm/gems/ruby-1.9.2-p318@legacy_rails_app/gems/rails-2.3.14/lib/initializer.rb:113:in `run'
  from /mathworks/home/lkyrala/perforce/legacy_rails_app/1.41/config/environment.rb:6:in `<top (required)>'
  from <internal:lib/rubygems/custom_require>:29:in `require'
  from <internal:lib/rubygems/custom_require>:29:in `require'
  from /local/rvm/gems/ruby-1.9.2-p318@legacy_rails_app/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in `block in require'
  from /local/rvm/gems/ruby-1.9.2-p318@legacy_rails_app/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:547:in `new_constants_in'
  from /local/rvm/gems/ruby-1.9.2-p318@legacy_rails_app/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in `require'
  from /local/rvm/gems/ruby-1.9.2-p318@legacy_rails_app/gems/rails-2.3.14/lib/commands/server.rb:84:in `<top (required)>'
  from <internal:lib/rubygems/custom_require>:29:in `require'
  from <internal:lib/rubygems/custom_require>:29:in `require'
  from script/server:3:in `<main>'

Facets 2.9.1 breaks Rails 3.1.rc6

I created a brand new Rails 3.1.rc6 project and included facets in the Gemfile. I then created two simple models with an association between them. When I try to load either of the models in rails console, I get the following error:

NoMethodError: private method redefine_method' called for #<Class:0x00000106008c80> from /Users/andrew/.rvm/gems/ruby-1.9.2-p290@scheduler/gems/activerecord-3.1.0.rc6/lib/active_record/base.rb:1082:inmethod_missing'
from /Users/andrew/.rvm/gems/ruby-1.9.2-p290@scheduler/gems/activerecord-3.1.0.rc6/lib/active_record/associations/builder/association.rb:40:in define_readers' from /Users/andrew/.rvm/gems/ruby-1.9.2-p290@scheduler/gems/activerecord-3.1.0.rc6/lib/active_record/associations/builder/singular_association.rb:17:indefine_readers'
from /Users/andrew/.rvm/gems/ruby-1.9.2-p290@scheduler/gems/activerecord-3.1.0.rc6/lib/active_record/associations/builder/association.rb:33:in define_accessors' from /Users/andrew/.rvm/gems/ruby-1.9.2-p290@scheduler/gems/activerecord-3.1.0.rc6/lib/active_record/associations/builder/singular_association.rb:10:indefine_accessors'
from /Users/andrew/.rvm/gems/ruby-1.9.2-p290@scheduler/gems/activerecord-3.1.0.rc6/lib/active_record/associations/builder/association.rb:22:in build' from /Users/andrew/.rvm/gems/ruby-1.9.2-p290@scheduler/gems/activerecord-3.1.0.rc6/lib/active_record/autosave_association.rb:127:inbuild'
from /Users/andrew/.rvm/gems/ruby-1.9.2-p290@scheduler/gems/activerecord-3.1.0.rc6/lib/active_record/associations/builder/belongs_to.rb:14:in build' from /Users/andrew/.rvm/gems/ruby-1.9.2-p290@scheduler/gems/activerecord-3.1.0.rc6/lib/active_record/associations/builder/association.rb:12:inbuild'
from /Users/andrew/.rvm/gems/ruby-1.9.2-p290@scheduler/gems/activerecord-3.1.0.rc6/lib/active_record/associations.rb:1409:in `belongs_to'

Remove facets and everything works just fine.

Facets defines a private redefine_method in lib/core/facets/module/redefine_module.rb.
Rails defines a similar public redefine_method in lib/active_support/core_ext/module/remove_method.rb

Various parts of rails depend on the the redefine_method being public and loading the facets definition hoses this.

One suggested fix: have facets not define it's method if it is already defined.

Shellwords#escape in Windows? (2)

Here is the code:

def escape(cmdline)
  '"' + cmdline.gsub(/\\(?=\\*\")/, "\\\\\\").gsub(/\"/, "\\\"").gsub(/\\$/, "\\\\\\").gsub("%", "%%") + '"'
end

And here is test case:

"a"\"b\c\\"d e\f\ def {ghi} jkl; %x12% \%123"% zya\

This string, transformed with specified #escape(), is interpreted by Windows shell exactly as written above.

I don't know where to put it in Facets, because this code is for Windows only. The code should somehow determine whether it is running in Windows or *nix.

P. S. I have noticed that #escape() for *nix does not escape "${env var}" macros. Is it correct? Nevertheless, I have made escaping of analogous macros ("%env var%") in Windows (because it works too tricky). If it is not needed then just remove ".gsub("%", "%%")" in the code above.

P. P. S. Sorry, accidentally closed the issue...

"git push" failed

Hi!
I'd like to to something to facets like you described here: http://rubyworks.github.com/facets/source.html. But the push command failed (error code 22) probably becuase of missing writing permissions. To get the changes back to the origin, I need to know whereto put it. Can you give me the correct URL.

thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.