flake 0.0.3
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 +4 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/README.md +4 -0
- data/Rakefile +7 -0
- data/flake.gemspec +22 -0
- data/lib/flake.rb +10 -0
- data/lib/flake/bang.rb +18 -0
- data/lib/flake/core_ext/string.rb +3 -0
- data/lib/flake/core_ext/symbol.rb +3 -0
- data/lib/flake/mustache.rb +18 -0
- data/lib/flake/version.rb +3 -0
- data/spec/flake/core_ext/string_spec.rb +34 -0
- data/spec/flake/core_ext/symbol_spec.rb +34 -0
- data/spec/flake/mustache_spec.rb +34 -0
- data/spec/spec_helper.rb +3 -0
- metadata +101 -0
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/README.md
ADDED
data/Rakefile
ADDED
data/flake.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "flake/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "flake"
|
7
|
+
s.version = Flake::VERSION
|
8
|
+
s.authors = ["Jeremy Ruppel"]
|
9
|
+
s.email = ["jeremy.ruppel@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{A simple mustache'd proxy object}
|
12
|
+
s.description = %q{A simple mustache'd proxy object'}
|
13
|
+
|
14
|
+
s.rubyforge_project = "flake"
|
15
|
+
|
16
|
+
s.add_development_dependency "rspec", "~> 2.6.0"
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
end
|
data/lib/flake.rb
ADDED
data/lib/flake/bang.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Flake
|
2
|
+
class Mustache
|
3
|
+
|
4
|
+
def initialize( options={} )
|
5
|
+
@options = options
|
6
|
+
end
|
7
|
+
|
8
|
+
def method_missing( method, *args, &blk )
|
9
|
+
@options[ method ] || template_for( method )
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
def template_for( method )
|
15
|
+
method.bang? ? "{{{#{method.unbang}}}}" : "{{#{method}}}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe String do
|
4
|
+
|
5
|
+
describe '#bang?' do
|
6
|
+
|
7
|
+
it 'should respond to bang?' do
|
8
|
+
''.should respond_to( :bang? )
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should be true if banged' do
|
12
|
+
'sup!'.bang?.should be_true
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should be false if not banged' do
|
16
|
+
'sup?'.bang?.should be_false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#unbang' do
|
21
|
+
|
22
|
+
it 'should respond to unbang' do
|
23
|
+
''.should respond_to( :unbang )
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should remove the bang from the end of a string' do
|
27
|
+
'sup!'.unbang.should eq( 'sup' )
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should not modify a string without a bang' do
|
31
|
+
'sup?'.unbang.should eq( 'sup?' )
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Symbol do
|
4
|
+
|
5
|
+
context '#bang?' do
|
6
|
+
|
7
|
+
it 'should respond to bang?' do
|
8
|
+
:sup.should respond_to( :bang? )
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should be true if banged' do
|
12
|
+
:sup!.bang?.should be_true
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should be false if not banged' do
|
16
|
+
:sup?.bang?.should be_false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context '#unbang' do
|
21
|
+
|
22
|
+
it 'should respond to unbang' do
|
23
|
+
:sup.should respond_to( :unbang )
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should remove the bang from the end of a string' do
|
27
|
+
:sup!.unbang.should eq( :sup )
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should not modify a string without a bang' do
|
31
|
+
:sup?.unbang.should eq( :sup? )
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Flake::Mustache do
|
4
|
+
|
5
|
+
context 'a default mustache flake' do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@flake = Flake::Mustache.new
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should return a mustached string of any property' do
|
12
|
+
@flake.testing.should eq( '{{testing}}' )
|
13
|
+
@flake.whatevs.should eq( '{{whatevs}}' )
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should triple-mustache any banged properties' do
|
17
|
+
@flake.testing!.should eq( '{{{testing}}}' )
|
18
|
+
@flake.whatevs!.should eq( '{{{whatevs}}}' )
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'a mustache proxy with overrides' do
|
23
|
+
|
24
|
+
before do
|
25
|
+
@flake = Flake::Mustache.new :status => 'baller', :drinks => 'beers'
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should return the overridden property' do
|
29
|
+
@flake.status.should eq( 'baller' )
|
30
|
+
@flake.drinks.should eq( 'beers' )
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: flake
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Jeremy Ruppel
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-11-11 00:00:00 -08:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rspec
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 23
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 6
|
33
|
+
- 0
|
34
|
+
version: 2.6.0
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
37
|
+
description: A simple mustache'd proxy object'
|
38
|
+
email:
|
39
|
+
- jeremy.ruppel@gmail.com
|
40
|
+
executables: []
|
41
|
+
|
42
|
+
extensions: []
|
43
|
+
|
44
|
+
extra_rdoc_files: []
|
45
|
+
|
46
|
+
files:
|
47
|
+
- .gitignore
|
48
|
+
- .rspec
|
49
|
+
- Gemfile
|
50
|
+
- README.md
|
51
|
+
- Rakefile
|
52
|
+
- flake.gemspec
|
53
|
+
- lib/flake.rb
|
54
|
+
- lib/flake/bang.rb
|
55
|
+
- lib/flake/core_ext/string.rb
|
56
|
+
- lib/flake/core_ext/symbol.rb
|
57
|
+
- lib/flake/mustache.rb
|
58
|
+
- lib/flake/version.rb
|
59
|
+
- spec/flake/core_ext/string_spec.rb
|
60
|
+
- spec/flake/core_ext/symbol_spec.rb
|
61
|
+
- spec/flake/mustache_spec.rb
|
62
|
+
- spec/spec_helper.rb
|
63
|
+
has_rdoc: true
|
64
|
+
homepage: ""
|
65
|
+
licenses: []
|
66
|
+
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 3
|
78
|
+
segments:
|
79
|
+
- 0
|
80
|
+
version: "0"
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
hash: 3
|
87
|
+
segments:
|
88
|
+
- 0
|
89
|
+
version: "0"
|
90
|
+
requirements: []
|
91
|
+
|
92
|
+
rubyforge_project: flake
|
93
|
+
rubygems_version: 1.5.2
|
94
|
+
signing_key:
|
95
|
+
specification_version: 3
|
96
|
+
summary: A simple mustache'd proxy object
|
97
|
+
test_files:
|
98
|
+
- spec/flake/core_ext/string_spec.rb
|
99
|
+
- spec/flake/core_ext/symbol_spec.rb
|
100
|
+
- spec/flake/mustache_spec.rb
|
101
|
+
- spec/spec_helper.rb
|