rubyworks / facets Goto Github PK
View Code? Open in Web Editor NEWRuby Facets
Home Page: http://rubyworks.github.com/facets
License: Other
Ruby Facets
Home Page: http://rubyworks.github.com/facets
License: Other
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
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
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.
They need module_function or self to be able to call.
Add #yes?
and #no?
methods as convenient variations of #ask
.
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
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()?
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!).
From http://banisterfiend.wordpress.com/, consider:
def let(&block)
# number of required parameters
num_required = block.arity >= 0 ? block.arity : ~block.arity
yield *([nil] * num_required)
end
Following the links to Core and Standard on the Documentation page (http://rubyworks.github.io/facets/learn.html) renders only empty pages.
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)>'
I'm not sure whether Shellwords#escape
should do this or not. If it should then I also suggest to write in #alt_escape
's doc that it does not escape "$", "*" and "?".
Consider reworking OpEsc to convert operators into plain words instead of op_ prefixed abbreviations. E.g. '-' => 'subtract' and '^' => 'xor'.
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:
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.
This file is required by lib/core/facets/array/recursively.rb
but the file has been renamed to facets/hom.rb
: 24d11bc
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>'
(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.
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]
Kernel#deep_copy does not work for instances of anonymous classes.
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?
On https://rubygems.org/gems/facets the "Documentation" link points to http://rubyworls.github.com/facets/learn.html
. It needs correcting from "rubyworls" to "rubyworks".
The #resc method isn't needed anymore thanks to String#to_re. Might also consider adding Regexp[].
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.
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.
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
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.
To properly go along with "Ruby Way" #to_mod should be used b/c Hash is not an actual a Module.
Consider deep_merge (https://github.com/danielsdeleo/deep_merge)
See how it compares to Facets Hash#deep_merge.
See how it compares to #weave, too.
Note, this was suggested by Steve Midgley two years ago!
May be to expand domain of applicability of Shellwords#escape to Windows shell too?
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 }
All these are implemented in git://github.com/LavirtheWhiolet/facets.git
In facets 2.9.0, requiring facets/random causes LoadError because it attempts to load facets/hash/zipnew which doesn't exist anymore (according to the HISTORY document, it's been renamed to zip)
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
Maybe Symbol#setter? should actually be called Symbol#writer? Likewise for #plain? and #reader?
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?
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:
[[: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, 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
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.
I think this could well be spelled
descendants
Thanks!
-r
I get the following error:
Using facets (2.8.4)
Installing hpricot (0.8.3) with native extensions c:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/installer.rb:483:in `build_
extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
Don't know which gem is guilty, but facets gem > 2.6 silently breaks WillPaginate::Collection#total_entries instance method.
Didn't have this problem with the old facets 2.5
Issue posted on http://github.com/mislav/will_paginate/issues/ too
Best
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.
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?
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 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).
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
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.
Following code:
"test.txt".file.open("w") { |io| io.puts "Hello" }
creates empty file.
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>'
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:in
method_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: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/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: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/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:in
build'
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:in
build'
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.
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...
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!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.