yo 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm --create use ruby-1.9.2@yo
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in yo.gemspec
4
+ gemspec
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,74 @@
1
+ #yo: Street-oriented programming in Ruby
2
+
3
+ Shake those classes baby! Have you ever felt like bored after you wrote a
4
+ snippet like this?
5
+
6
+ class Person
7
+ attr_accessor :name, :age, :mood, :money
8
+ end
9
+
10
+ Just `gem install yo` or put `gem 'yo'` in your Gemfile, put your badass face
11
+ and type this:
12
+
13
+ require 'yo'
14
+
15
+ class Person
16
+ extend Yo
17
+
18
+ so i think it goes like this
19
+
20
+ defnly he shud have an accessor 'name'
21
+ a person also has a property 'age', yeah
22
+
23
+ ya should know he has some freakin 'money', too
24
+ prolly he demands some privacy on da 'money', yo
25
+
26
+ he might as well have a pretty badass 'mood'
27
+ but you never know inthis neighborhood
28
+
29
+ but hey maybe its all bullshit, so
30
+ we better get going bro
31
+
32
+ shake it baby, yeah
33
+
34
+ end
35
+
36
+ You can check it's all flawlessly working:
37
+
38
+ john = Person.new
39
+ john.name = "John"
40
+ john.name # => "John"
41
+
42
+ john.age = 29
43
+ john.age # => 29
44
+
45
+ john.money = "$3"
46
+ john.money # => "$3"
47
+
48
+ john.mood = :badass
49
+ john.mood # => :badass
50
+
51
+ Now that's some street-oriented programming!
52
+
53
+ ##Install
54
+
55
+ gem install yo
56
+
57
+ ... or if you use Bundler:
58
+
59
+ gem 'yo'
60
+
61
+ ##Contribute!
62
+
63
+ * Fork the project.
64
+ * Make your feature addition or bug fix.
65
+ * Add specs for it. This is important so I don't break it in a future
66
+ version unintentionally.
67
+ * Commit, do not mess with rakefile, version, or history.
68
+ If you want to have your own version, that is fine but bump version
69
+ in a commit by itself I can ignore when I pull.
70
+ * Send me a pull request. Bonus points for topic branches.
71
+
72
+ ## Copyright
73
+
74
+ Copyright (c) 2011 Josep M. Bach. See LICENSE for details.
@@ -0,0 +1,42 @@
1
+ require_relative '../lib/yo'
2
+
3
+ class Person
4
+ extend Yo
5
+
6
+ so i think it goes like this
7
+
8
+ defnly he shud have an accessor 'name'
9
+ a person also has a property 'age', yeah
10
+
11
+ ya should know he has some freakin 'money', too
12
+ prolly he demands some privacy on da 'money', yo
13
+
14
+ he might as well have a pretty badass 'mood'
15
+ but you never know inthis neighborhood
16
+
17
+ but hey maybe its all bullshit, so
18
+ we better get going bro
19
+
20
+ shake it baby, yeah
21
+
22
+ end
23
+
24
+ # The same as:
25
+ #
26
+ # class Person
27
+ # attr_accessor :name, :age, :mood, :money
28
+ # end
29
+
30
+ john = Person.new
31
+ john.name = "John"
32
+ puts john.name # => "John"
33
+
34
+ john.age = 29
35
+ puts john.age # => 29
36
+
37
+ john.money = "$3"
38
+ puts john.money # => "$3"
39
+
40
+ john.mood = :badass
41
+ puts john.mood # => :badass
42
+
@@ -0,0 +1,65 @@
1
+ module Yo
2
+
3
+ def method_missing(method, *args)
4
+ process_metainf_from(method, *args)
5
+ do_what_you_have_to
6
+ nil
7
+ end
8
+
9
+ private
10
+
11
+ def process_metainf_from(method, *args)
12
+ if value = args.detect {|a| String === a}
13
+ @__value = value
14
+ end
15
+
16
+ case method
17
+ when :it then {}
18
+ when :has, :have
19
+ @__have = true
20
+ if args.detect {|a| a == :not }
21
+ @__negative = true
22
+ end
23
+ when :maybe, :might, :may
24
+ @__maybe = true
25
+ when :accessor, :property
26
+ @__have_what = :accessor
27
+ when :reader, :getter
28
+ @__have_what = :reader
29
+ when :writer, :setter
30
+ @__have_what = :writer
31
+ when :privacy
32
+ @__set_private_method = true
33
+ end
34
+ end
35
+
36
+ def do_what_you_have_to
37
+ if @__have && !@__negative
38
+ string = case @__have_what
39
+ when :reader
40
+ string = """
41
+ def #{@__value}
42
+ @#{@__value}
43
+ end
44
+ """
45
+ when :writer
46
+ string = """
47
+ def #{@__value}=(value)
48
+ @#{@__value} = value
49
+ end
50
+ """
51
+ when :accessor, nil
52
+ string = """
53
+ def #{@__value}
54
+ @#{@__value}
55
+ end
56
+ def #{@__value}=(value)
57
+ @#{@__value} = value
58
+ end
59
+ """
60
+ end
61
+ class_eval string
62
+ end
63
+ end
64
+
65
+ end
@@ -0,0 +1,3 @@
1
+ module Yo
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "yo/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "yo"
7
+ s.version = Yo::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Josep M. Bach"]
10
+ s.email = ["josep.m.bach@gmail.com"]
11
+ s.homepage = "http://github.com/txus/yo"
12
+ s.summary = %q{Street-oriented programming in Ruby}
13
+ s.description = %q{Street-oriented programming in Ruby}
14
+
15
+ s.rubyforge_project = "yo"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yo
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Josep M. Bach
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-01-13 00:00:00 +01:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: Street-oriented programming in Ruby
22
+ email:
23
+ - josep.m.bach@gmail.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - .gitignore
32
+ - .rvmrc
33
+ - Gemfile
34
+ - Rakefile
35
+ - Readme.md
36
+ - examples/person.rb
37
+ - lib/yo.rb
38
+ - lib/yo/version.rb
39
+ - yo.gemspec
40
+ has_rdoc: true
41
+ homepage: http://github.com/txus/yo
42
+ licenses: []
43
+
44
+ post_install_message:
45
+ rdoc_options: []
46
+
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ requirements: []
66
+
67
+ rubyforge_project: yo
68
+ rubygems_version: 1.3.7
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: Street-oriented programming in Ruby
72
+ test_files: []
73
+