Aspect Oriented Programming in Ruby [closed] - ruby

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
What frameworks exist to add AOP to Ruby?

With Ruby 2.0+, you don't necessarily need a framework:
module BarkLogger
def bark
puts "Logging ##name's bark!"
super
end
end
class Dog
prepend BarkLogger
def initialize(name)
#name = name
end
def bark
puts "##name the dog says bark!"
end
end
Dog.new("Rufus").bark
Output:
Logging Rufus's bark!
Rufus the dog says bark!

You haven't specified any criteria for evaluating different frameworks, so here's one that I found after 3 seconds on Google: Aquarium.
Another one, suggested by #Telemachus: gazer.

Shameless plug: aspector could be what you are looking for. It allows you to define aspect and then apply to one or more targets.

I tried 2 or 3 years ago Aquarium gem at university project. Worked nice, aim of project was comparing with AspectJ, to find out if it is capable of all things as AspectJ. At that time a lot of functionality, which AspectJ was capable of, was missing. But now I see a many things were added, so it's worth a try again.

AspectR (last release looks like in 2002) - originally the canonical AOP library in Ruby.
Facets - has some AOP functionality.

Related

Does a Sublime Text plugin exist that makes creating Ruby classes and methods faster? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
Is there a Sublime Text plugin for Ruby that, after I type class/def something + Enter, will automatically insert end and place the curser in the class/method?
For example, typing def initialize(args) + Enter would result in:
def initialize(args)
#cursor here
end
In Textmate if you type def + Tab, it sets things up for you like that. I believe Sublime does the same.
I haven't used sublime, but here is what i found.
you could create snippets using Ruby on Rails Snippet package
You could use the solution given in 'How to automatically add "end" to code blocks?'.

Which gem is better to use for weather feed in rails 4? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
Ruby 2.0 + rails 4.0
I want to show weather-feed on the public site, is there any gem which will show the weather according to the city name ?
without any registrations and charges.
Any suggestion ?
Why? write your using nokogiri and yahoo weather api!
it is quite a way try to do something myself and know more than using someone else's
For example:
require "nokogiri"
require "open-uri"
link = "http://weather.yahooapis.com/forecastrss?w=2123260&u=c" #2123260 this code of my city
data = Nokogiri::XML(open(link))
data.xpath("//item//yweather:condition")[0].to_s
#=> "<yweather:condition text=\"Cloudy\" code=\"26\" temp=\"-6\" date=\"Tue, 10 Dec 2013 3:30 pm MSK\"/>"
And more pictures available weather schedule for the week and so on. Just take it!
That's all

Ruby Inheritance of Modules [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
So I have three classes:
MyModule::Base
MyModule::Artist
MyModule::Song
MyModule::Artist inherits from MyModule::Base and therefore has access to all of its instance methods and is declared as such:
module MyModule
class Artist < MyModule::Base
And this all works as expected.
However, when I attempt to add a third class (MyModule::Song) to inherit also from MyModule::Base like so:
module MyModule
class Song < MyModule::Base
I get a NameError. 'Uninitialized constant'. Like MyModule::Base doesn't even exist! Am I missing something fundamental about class inheritance in Ruby or is it something else?
Thanks.
I took a look at your repo and discovered that while you correctly require your Base module via require_relative in Artist, you use a sledge-hammer require to crack nuts in Song.
Since there is kinda system-wide base, it’s being loaded instead of intended local Echonest::Base. Just go with require_relative and enjoy.
Hope that helps.

Best Zip Code Plugin for Ruby [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I need to find the city and state from a zip code. Does anyone know a good plugin/API that I can use to do this?
gem install geokit
In IRB:
require 'geokit'
geo = GeoKit::Geocoders::MultiGeocoder.multi_geocoder('90210')
if geo.success
geo.state # => CA
geo.city # => Beverly Hills
end
A more lightweight option is the Area gem.
require 'area'
'11211'.to_region #=> "Brooklyn, NY"
See Jason's answer. It works nicely.
The problem is that the USPS doesn't allow bulk downloads of their zip-code lists unless you pay for it. Google's API, which is used in the gem mentioned by Splashlin, no longer seems to support the city and state, instead it now returns the area code:
require 'open-uri'
require 'json'
json = JSON::parse(open('http://maps.google.com/maps/geo?q=852581').read)
puts json
# >> {"name"=>"852581", "Status"=>{"code"=>602, "request"=>"geocode"}}
This page shows some ways you could roll your own. The sources of the data might not be current though:
http://www.ruby-forum.com/topic/48815

how to keep my infrequently used programming language skills in shape [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I use ruby infrequently - usually it adds up to writing a script once in two months or more. I do most of my programming with C++, which is very different from ruby.
with such wide gaps between my brushes with ruby I keep forgetting basic aspects of the language (like parsing a text file and other simple stuff).
I would like to do a daily drill of the basic stuff and I was wondering if there is some site I can subscribe to and will send me the Ruby question of the day or something similar.
anyone knows of such a site / Internet service?
It's not daily, but you might be interested in Ruby Quiz.
You might also subscribe to ruby-talk and look over the posts there each day.
Check out Jim Weirich's ruby koans. It's a set of ruby scripts organized by topic that guides you through the different parts of the language by unit testing your knowledge.
def method_with_block
result = yield
result
end
def test_methods_can_take_blocks
yielded_result = method_with_block { 1 + 2 }
assert_equal __, yielded_result
end
The game is to go through these and fill in the __ blanks. Running rake will check your answers.
What about a general problem site like Project Euler( http://projecteuler.net/ ) or the ACM programming competition problem sets ( http://www.inf.bme.hu/contest/tasks/ ) and just restrict yourself to using ruby?
A more arduous (but awesome) task is the google code jam. Just assign yourself one of the problems, and set a time per week to put an hour into it. Quit while you are still working. That way, you hunger for more, and think about it in the interim time.
http://code.google.com/codejam
TL;DR: Find a large task, that is interesting. Work on it in bite-size pieces, leaving yourself hungry for more.

Resources