caramel 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in caramel.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ Caramel
2
+ =======
3
+
4
+ irb(main):002:0> require './lib/caramel'
5
+ => true
6
+
7
+ irb(main):003:0> 'john'.is 'john'
8
+ => true
9
+
10
+ irb(main):004:0> 'john'.is.empty?
11
+ => false
12
+
13
+ irb(main):005:0> 'john'.is_not.empty?
14
+ => true
15
+
16
+ irb(main):006:0> 'john'.is_not 'steven'
17
+ => true
18
+
19
+ irb(main):007:0> shopping_list = ['orange']
20
+ => ["orange"]
21
+
22
+ irb(main):008:0> 'banana'.in shopping_list
23
+ => false
24
+
25
+ irb(main):009:0> 'banana'.is_not.in shopping_list
26
+ => true
27
+
28
+ irb(main):010:0> 'banana'.is.in shopping_list
29
+ => false
30
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/caramel.gemspec ADDED
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "caramel/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "caramel"
7
+ s.version = Caramel::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Kirill Radzikhovskyy"]
10
+ s.email = ["kirillrdy@gmail.com"]
11
+ s.homepage = "http://rubygems.org/gems/caramel"
12
+ s.summary = %q{Adds sweetness to Ruby}
13
+ s.description = %q{Adds more sweetness to Ruby}
14
+
15
+ s.rubyforge_project = "caramel"
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
data/lib/caramel.rb ADDED
@@ -0,0 +1,95 @@
1
+ module Caramel
2
+
3
+ class ObjectModifierWrapper < BasicObject
4
+ attr_accessor :parent
5
+
6
+ def initialize parent
7
+ @parent = parent
8
+ end
9
+
10
+ def method_missing(*args)
11
+ @result = @parent.send(*args)
12
+ return alter
13
+ end
14
+
15
+ def alter
16
+ @result
17
+ end
18
+
19
+ end
20
+
21
+
22
+
23
+
24
+ class NilModifierWrapper < ObjectModifierWrapper
25
+
26
+ def method_missing(*args)
27
+ if @parent != nil
28
+ @result = @parent.send(*args)
29
+ else
30
+ #parent is nil
31
+ @result = nil
32
+ end
33
+ return alter
34
+ end
35
+
36
+ end
37
+
38
+
39
+
40
+ # Intentionaly left blank
41
+ class IsWrapper < ObjectModifierWrapper
42
+ end
43
+
44
+ class NotWrapper < ObjectModifierWrapper
45
+ def alter
46
+ !@result
47
+ end
48
+ end
49
+
50
+ end
51
+
52
+ class Object
53
+
54
+ # if person.is 'John'
55
+ def is(*args)
56
+ if args.first
57
+ self == args.first
58
+ else
59
+ Caramel::IsWrapper.new self
60
+ end
61
+ end
62
+
63
+ # if my_varliable.is_not.empty?
64
+ # if 'Jack'.is_not 'John'
65
+ def not(*args)
66
+ if args.first
67
+ self != args.first
68
+ else
69
+ Caramel::NotWrapper.new self
70
+ end
71
+ end
72
+
73
+ # if person.is 'John'
74
+ def and(*args)
75
+ if args.first
76
+ self == args.first
77
+ else
78
+ Caramel::NilModifierWrapper.new self
79
+ end
80
+ end
81
+
82
+
83
+ alias :is_not :not
84
+ alias :are_not :not
85
+
86
+
87
+ # if 'apple'.in? @list_of_fruits
88
+ def in? array
89
+ array.include? self
90
+ end
91
+ alias :in :in?
92
+ alias :is_in? :in?
93
+ alias :is_in :in?
94
+
95
+ end
@@ -0,0 +1,3 @@
1
+ module Caramel
2
+ VERSION = "0.0.5"
3
+ end
metadata ADDED
@@ -0,0 +1,52 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: caramel
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kirill Radzikhovskyy
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-09-06 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Adds more sweetness to Ruby
15
+ email:
16
+ - kirillrdy@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - README.md
24
+ - Rakefile
25
+ - caramel.gemspec
26
+ - lib/caramel.rb
27
+ - lib/caramel/version.rb
28
+ homepage: http://rubygems.org/gems/caramel
29
+ licenses: []
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ requirements: []
47
+ rubyforge_project: caramel
48
+ rubygems_version: 1.8.6
49
+ signing_key:
50
+ specification_version: 3
51
+ summary: Adds sweetness to Ruby
52
+ test_files: []