{ "info": { "author": "Matt Pizzimenti", "author_email": "mjpizz+rython@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Ruby", "Topic :: Software Development", "Topic :: Software Development :: Libraries :: Ruby Modules", "Topic :: Software Development :: Object Brokering" ], "description": "Overview\n========\n\nIf you've ever needed to use Ruby for a particular task, but wanted\nto use Python as your primary language, *Rython* lets you easily\nmix the two languages together.\n\n*Why would I want to mix Ruby and Python?* There are many reasons:\n\n* you need a Ruby Gem that provides unique functionality which no Python module provides\n* you need a simpler syntax for manipulating regular expressions\n* you want to quickly bridge to code you've already written in Ruby\n\nQuickstart\n==========\n\nIn this example, we will use Watir (http://wtr.rubyforge.org), a high level web application\ntesting Gem that has no equivalent in Python. First, you need to declare a Ruby context that will run the Ruby code.::\n\n import rython\n \n ctx = rython.RubyContext(requires=[\"rubygems\", \"watir\"])\n\nNext, instantiate a Watir::Browser object and assign it to a Python variable.\nThe object will be an instance of rython.RubyProxy::\n\n my_browser = ctx(\"Watir::Browser.new\")\n \n assert isinstance(my_browser, rython.RubyProxy)\n\nAnd now we can call any method on the object instance as well. This example grabs\na DIV element from the page by CSS ID 'foobar'. We can then execute more Ruby\nmethods on the div_element if we want::\n\n div_element = my_browser(\"div(:id, 'foobar')\")\n \n assert isinstance(div_element, rython.RubyProxy)\n \n exists_in_browser = div_element(\"exists?\")\n\nAdvanced\n========\n\nThere are deeper features you can take advantage of in Rython.\n\nCalling methods with RubyProxy arguments\n----------------------------------------\n\nLet's say you have a Ruby method that takes a complex Ruby object. This\nobject will be proxied in the Python context as a RubyProxy. To pass\nthis object to a method, simply use the *repr* string substitution. The\nfollowing example passes a RubyProxied Browser object to a method::\n\n my_browser = ctx(\"Watir::Browser.new\")\n my_foobar = ctx(\"Foobar.new\")\n \n my_foobar(\"method_that_takes_browser(%(browser)r)\", browser=my_browser)\n\nRython will automatically convert a RubyProxy argument to the appropriate\nRuby expression that refers to the object in the Ruby context.\n\nApply monkeypatches to the context\n----------------------------------\n\nWhen instantiating a RubyContext, you can specify a 'setup' parameter that\ncontains raw Ruby code to execute after doing the require statements. This\nis perfect for adding monkeypatches to Ruby objects, or just performing additional\nsetup.\n\nThis example monkeypatches the String object with a 'to_safe_string' method.\nThis makes it easy to convert all strings into printable characters::\n\n import rython\n \n monkeypatches = '''\n class String\n GOOD_NONUNICODE_CHARS = ((\"A\"..\"Z\").to_a + (\"a\"..\"z\").to_a + (\"0\"..\"9\").to_a).to_a\n def to_safe_string\n final = \"\"\n each_char do |ch|\n final += \"#{ch}\" if GOOD_NONUNICODE_CHARS.include? ch\n end\n final\n end\n end\n '''\n \n ctx = rython.RubyContext(setup=monkeypatches)\n\nRunning the context in debug mode\n---------------------------------\n\nThis is helpful when Rython appears to be failing due to problems in the Ruby context.\nBy default, all logging messages are suppressed from the Ruby context. You can reenable them by\nsetting the debug flag::\n\n import rython\n \n ctx = rython.RubyContext(debug=True)", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pypi.python.org/pypi/rython/", "keywords": null, "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "rython", "package_url": "https://pypi.org/project/rython/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/rython/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://pypi.python.org/pypi/rython/" }, "release_url": "https://pypi.org/project/rython/0.0.1/", "requires_dist": null, "requires_python": null, "summary": "rython transparently mixes Ruby code into Python", "version": "0.0.1" }, "last_serial": 799150, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "084c2685fddf6efcdc74bf8d801428c5", "sha256": "2c18b6b40a99b10262b57048c50aa008ca6a03bc935db65bca211a70d1dc2f35" }, "downloads": -1, "filename": "rython-0.0.1.tar.gz", "has_sig": false, "md5_digest": "084c2685fddf6efcdc74bf8d801428c5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7665, "upload_time": "2009-05-21T09:49:07", "url": "https://files.pythonhosted.org/packages/9b/b7/82ce015d732a10ef46417726ae66e314b14655402ad1729ffada7051dcec/rython-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "084c2685fddf6efcdc74bf8d801428c5", "sha256": "2c18b6b40a99b10262b57048c50aa008ca6a03bc935db65bca211a70d1dc2f35" }, "downloads": -1, "filename": "rython-0.0.1.tar.gz", "has_sig": false, "md5_digest": "084c2685fddf6efcdc74bf8d801428c5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7665, "upload_time": "2009-05-21T09:49:07", "url": "https://files.pythonhosted.org/packages/9b/b7/82ce015d732a10ef46417726ae66e314b14655402ad1729ffada7051dcec/rython-0.0.1.tar.gz" } ] }