relevance-obsidian 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +9 -21
- data/lib/obsidian/extensions/object.rb +31 -0
- data/lib/obsidian/extensions/try.rb +16 -0
- data/lib/obsidian.rb +1 -1
- data/obsidian.gemspec +9 -11
- metadata +8 -7
- data/Manifest.txt +0 -23
- data/README.txt +0 -96
data/Rakefile
CHANGED
@@ -2,36 +2,24 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'rake/testtask'
|
4
4
|
require 'rake/rdoctask'
|
5
|
-
require '
|
5
|
+
require 'echoe'
|
6
6
|
require 'lib/obsidian'
|
7
7
|
|
8
|
-
|
8
|
+
echoe = Echoe.new('obsidian', Obsidian::VERSION) do |p|
|
9
9
|
p.rubyforge_name = "thinkrelevance"
|
10
|
-
p.description = "It's metastable"
|
11
|
-
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
|
12
|
-
p.name = 'obsidian'
|
13
|
-
p.summary = "It's metastable"
|
14
10
|
p.author = "Relevance"
|
15
11
|
p.email = "opensource@thinkrelevance.com"
|
12
|
+
p.summary = "It's metastable"
|
13
|
+
p.description = "Bits of Ruby code we've found helpful for simplifying various tasks"
|
16
14
|
p.url = "http://opensource.thinkrelevance.com"
|
17
15
|
p.rdoc_pattern = /^(lib|bin|ext)|txt|rdoc$/
|
18
|
-
|
16
|
+
rdoc_template = `allison --path`.strip << ".rb"
|
17
|
+
p.rdoc_template = rdoc_template
|
19
18
|
end
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
gem "markaby"
|
25
|
-
rd.main = "README.rdoc"
|
26
|
-
# rd.options << '-d' if RUBY_PLATFORM !~ /win32/ and `which dot` =~ /\/dot/ and not ENV['NODOT']
|
27
|
-
rd.rdoc_dir = 'doc'
|
28
|
-
files = hoe.spec.files.grep(hoe.rdoc_pattern)
|
29
|
-
files -= ['Manifest.txt']
|
30
|
-
rd.rdoc_files.push(*files)
|
31
|
-
|
32
|
-
title = "#{hoe.name}-#{hoe.version} Documentation"
|
33
|
-
title = "#{hoe.rubyforge_name}'s " + title if hoe.rubyforge_name != hoe.name
|
34
|
-
end
|
20
|
+
echoe.spec.add_development_dependency "echoe"
|
21
|
+
echoe.spec.add_development_dependency "allison"
|
22
|
+
echoe.spec.add_development_dependency "markaby"
|
35
23
|
|
36
24
|
begin
|
37
25
|
require 'rcov'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Metaclass goodness thanks to why:
|
2
|
+
# see: http://whytheluckystiff.net/articles/seeingMetaclassesClearly.html
|
3
|
+
module Obsidian
|
4
|
+
module Extensions
|
5
|
+
module Object
|
6
|
+
# The hidden singleton lurks behind everyone
|
7
|
+
def metaclass
|
8
|
+
class << self
|
9
|
+
self
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def meta_eval &blk
|
14
|
+
metaclass.instance_eval &blk
|
15
|
+
end
|
16
|
+
|
17
|
+
# Adds methods to a metaclass
|
18
|
+
def meta_def name, &blk
|
19
|
+
meta_eval { define_method name, &blk }
|
20
|
+
end
|
21
|
+
|
22
|
+
# Defines an instance method within a class
|
23
|
+
def class_def name, &blk
|
24
|
+
class_eval { define_method name, &blk }
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
Object.class_eval { include Obsidian::Extensions::Object }
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Obsidian
|
2
|
+
module Extensions
|
3
|
+
module Try
|
4
|
+
# Instead of
|
5
|
+
# @person ? @person.name : nil
|
6
|
+
# Use try:
|
7
|
+
# @person.try(:name)
|
8
|
+
def try(method)
|
9
|
+
send method if respond_to? method
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
Object.class_eval { include Obsidian::Extensions::Try }
|
data/lib/obsidian.rb
CHANGED
data/obsidian.gemspec
CHANGED
@@ -1,22 +1,20 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
1
|
Gem::Specification.new do |s|
|
4
2
|
s.name = %q{obsidian}
|
5
|
-
s.version = "0.0.
|
3
|
+
s.version = "0.0.6"
|
6
4
|
|
7
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
6
|
s.authors = ["Relevance"]
|
9
|
-
s.date = %q{2008-
|
7
|
+
s.date = %q{2008-11-13}
|
10
8
|
s.description = %q{It's metastable}
|
11
9
|
s.email = %q{opensource@thinkrelevance.com}
|
12
|
-
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.
|
13
|
-
s.files = ["History.txt", "LICENSE", "Manifest.txt", "README.rdoc", "
|
10
|
+
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.rdoc"]
|
11
|
+
s.files = ["History.txt", "LICENSE", "Manifest.txt", "README.rdoc", "Rakefile", "lib/obsidian.rb", "lib/obsidian/extensions/object.rb", "lib/obsidian/extensions/try.rb", "lib/obsidian/rails/helper_test.rb", "lib/obsidian/rails/model_update_tracker.rb", "lib/obsidian/spec.rb", "lib/obsidian/spec/map_spec_helper.rb", "lib/obsidian/spec/set_spec_helper.rb", "obsidian.gemspec", "test/obsidian_test.rb", "test/test_helper.rb", "test/units/obsidian/object_extensions_test.rb", "test/units/obsidian/rails/model_update_tracker_test.rb", "test/units/obsidian/spec/map_spec_helper_test.rb", "test/units/obsidian/spec/set_spec_helper_test.rb", "test/units/obsidian/spec_test.rb", "test/units/obsidian/try_test.rb"]
|
14
12
|
s.has_rdoc = true
|
15
13
|
s.homepage = %q{http://opensource.thinkrelevance.com}
|
16
|
-
s.rdoc_options = ["--main", "README.
|
14
|
+
s.rdoc_options = ["--main", "README.rdoc"]
|
17
15
|
s.require_paths = ["lib"]
|
18
16
|
s.rubyforge_project = %q{thinkrelevance}
|
19
|
-
s.rubygems_version = %q{1.3.
|
17
|
+
s.rubygems_version = %q{1.3.1}
|
20
18
|
s.summary = %q{It's metastable}
|
21
19
|
s.test_files = ["test/obsidian_test.rb", "test/units/obsidian/object_extensions_test.rb", "test/units/obsidian/rails/model_update_tracker_test.rb", "test/units/obsidian/spec/map_spec_helper_test.rb", "test/units/obsidian/spec/set_spec_helper_test.rb", "test/units/obsidian/spec_test.rb", "test/units/obsidian/try_test.rb"]
|
22
20
|
|
@@ -25,11 +23,11 @@ Gem::Specification.new do |s|
|
|
25
23
|
s.specification_version = 2
|
26
24
|
|
27
25
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
28
|
-
s.add_development_dependency(%q<hoe>, [">= 1.8.
|
26
|
+
s.add_development_dependency(%q<hoe>, [">= 1.8.2"])
|
29
27
|
else
|
30
|
-
s.add_dependency(%q<hoe>, [">= 1.8.
|
28
|
+
s.add_dependency(%q<hoe>, [">= 1.8.2"])
|
31
29
|
end
|
32
30
|
else
|
33
|
-
s.add_dependency(%q<hoe>, [">= 1.8.
|
31
|
+
s.add_dependency(%q<hoe>, [">= 1.8.2"])
|
34
32
|
end
|
35
33
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relevance-obsidian
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Relevance
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-11-13 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 1.8.
|
22
|
+
version: 1.8.2
|
23
23
|
version:
|
24
24
|
description: It's metastable
|
25
25
|
email: opensource@thinkrelevance.com
|
@@ -30,15 +30,16 @@ extensions: []
|
|
30
30
|
extra_rdoc_files:
|
31
31
|
- History.txt
|
32
32
|
- Manifest.txt
|
33
|
-
- README.
|
33
|
+
- README.rdoc
|
34
34
|
files:
|
35
35
|
- History.txt
|
36
36
|
- LICENSE
|
37
37
|
- Manifest.txt
|
38
38
|
- README.rdoc
|
39
|
-
- README.txt
|
40
39
|
- Rakefile
|
41
40
|
- lib/obsidian.rb
|
41
|
+
- lib/obsidian/extensions/object.rb
|
42
|
+
- lib/obsidian/extensions/try.rb
|
42
43
|
- lib/obsidian/rails/helper_test.rb
|
43
44
|
- lib/obsidian/rails/model_update_tracker.rb
|
44
45
|
- lib/obsidian/spec.rb
|
@@ -47,18 +48,18 @@ files:
|
|
47
48
|
- obsidian.gemspec
|
48
49
|
- test/obsidian_test.rb
|
49
50
|
- test/test_helper.rb
|
51
|
+
- test/units/obsidian/object_extensions_test.rb
|
50
52
|
- test/units/obsidian/rails/model_update_tracker_test.rb
|
51
53
|
- test/units/obsidian/spec/map_spec_helper_test.rb
|
52
54
|
- test/units/obsidian/spec/set_spec_helper_test.rb
|
53
55
|
- test/units/obsidian/spec_test.rb
|
54
|
-
- test/units/obsidian/object_extensions_test.rb
|
55
56
|
- test/units/obsidian/try_test.rb
|
56
57
|
has_rdoc: true
|
57
58
|
homepage: http://opensource.thinkrelevance.com
|
58
59
|
post_install_message:
|
59
60
|
rdoc_options:
|
60
61
|
- --main
|
61
|
-
- README.
|
62
|
+
- README.rdoc
|
62
63
|
require_paths:
|
63
64
|
- lib
|
64
65
|
required_ruby_version: !ruby/object:Gem::Requirement
|
data/Manifest.txt
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
History.txt
|
2
|
-
LICENSE
|
3
|
-
Manifest.txt
|
4
|
-
README.rdoc
|
5
|
-
README.txt
|
6
|
-
Rakefile
|
7
|
-
lib/obsidian.rb
|
8
|
-
lib/obsidian/extensions/object.rb
|
9
|
-
lib/obsidian/extensions/try.rb
|
10
|
-
lib/obsidian/rails/helper_test.rb
|
11
|
-
lib/obsidian/rails/model_update_tracker.rb
|
12
|
-
lib/obsidian/spec.rb
|
13
|
-
lib/obsidian/spec/map_spec_helper.rb
|
14
|
-
lib/obsidian/spec/set_spec_helper.rb
|
15
|
-
obsidian.gemspec
|
16
|
-
test/obsidian_test.rb
|
17
|
-
test/test_helper.rb
|
18
|
-
test/units/obsidian/object_extensions_test.rb
|
19
|
-
test/units/obsidian/rails/model_update_tracker_test.rb
|
20
|
-
test/units/obsidian/spec/map_spec_helper_test.rb
|
21
|
-
test/units/obsidian/spec/set_spec_helper_test.rb
|
22
|
-
test/units/obsidian/spec_test.rb
|
23
|
-
test/units/obsidian/try_test.rb
|
data/README.txt
DELETED
@@ -1,96 +0,0 @@
|
|
1
|
-
= Obsidian
|
2
|
-
|
3
|
-
== DESCRIPTION
|
4
|
-
|
5
|
-
Obsidian. It's metastable.
|
6
|
-
|
7
|
-
In the tangible world, obsidian is a naturally-occurring glass that is metastable at the earth's
|
8
|
-
surface. It's commonly found within the margins of rhyolitic lava flows, where cooling of the lava is
|
9
|
-
rapid. [1] In the slightly less tangible world of programming, <b>Obsidian</b> is home to chunks of
|
10
|
-
Ruby code that we've found helpful. These bits of code are often found at the bottom of a mountain of
|
11
|
-
yak hair, the occasionally-occurring product of simplifying various tasks.
|
12
|
-
|
13
|
-
1 http://en.wikipedia.org/wiki/Obsidian
|
14
|
-
|
15
|
-
== FEATURES
|
16
|
-
|
17
|
-
=== Model Update Tracker
|
18
|
-
This library allows you to functionally test updates to models with clearer and more focused intent.
|
19
|
-
It forces you to have a better understanding of how your objects interact and lets you demonstrate
|
20
|
-
that knowledge by specifying it in your tests. For example, consider the following test which asserts
|
21
|
-
that the code block persists an Asset record.
|
22
|
-
|
23
|
-
assert_difference Asset :count do
|
24
|
-
post :create, :asset => {}
|
25
|
-
end
|
26
|
-
|
27
|
-
Is it okay if the code block also persists a Location record? An AssetOwner record? Some other record?
|
28
|
-
Chances are that the developer knows the answer to this question, but the test fails to capture that
|
29
|
-
knowledge. Side effects matter, and our tests should adequately validate that the desired side effects
|
30
|
-
(and <i>only</i> the desired side effects) are taking place. In the example below, assert_models_created
|
31
|
-
allows us to validate that an Asset is created <i>and</i> that no other objects are inadvertently
|
32
|
-
persisted.
|
33
|
-
|
34
|
-
assert_models_created(Asset) do
|
35
|
-
post :create, :asset => {}
|
36
|
-
end
|
37
|
-
|
38
|
-
If the code block happened to create records other than just an Asset, a friendly test failure would let
|
39
|
-
you know right away.
|
40
|
-
|
41
|
-
Suppose, on the other hand, that you expect the creation of an Asset to <i>also</i> produce an AssetOwner
|
42
|
-
and a Location. This is where you exercise your deep domain knowledge muscles and make your new
|
43
|
-
Obsidian-powered test express and validate your intent.
|
44
|
-
|
45
|
-
assert_models_created(Asset, AssetOwner, Location) do
|
46
|
-
post: create, :asset => {}
|
47
|
-
end
|
48
|
-
|
49
|
-
Now, if your code block fails to create the expected records, the above test would fail stating that it
|
50
|
-
expected more to happen. If future changes to your code cause things to fall out of place, this test will
|
51
|
-
catch that regression where the original assert_difference may not. In addition to assert_models_created,
|
52
|
-
Model Update Tracker provides a whole host of other methods that provide similar functionality for
|
53
|
-
asserting behavior related to updates, deletes, or even validating that nothing happened.
|
54
|
-
|
55
|
-
* assert_models_created(models)
|
56
|
-
* assert_models_updated(models)
|
57
|
-
* assert_models_destroyed(models)
|
58
|
-
* assert_no_models_created
|
59
|
-
* assert_no_models_destroyed
|
60
|
-
* assert_no_models_updated
|
61
|
-
|
62
|
-
== INSTALL
|
63
|
-
|
64
|
-
sudo gem install obsidian
|
65
|
-
|
66
|
-
== URLS
|
67
|
-
|
68
|
-
* Log bugs, issues, and suggestions on Trac: http://opensource.thinkrelevance.com/wiki/obsidian
|
69
|
-
* View Source: http://github.com/relevance/obsidian/tree/master
|
70
|
-
* Git clone Source: git://github.com/relevance/obsidian.git
|
71
|
-
* RDocs: http://thinkrelevance.rubyforge.org/obsidian/
|
72
|
-
|
73
|
-
== LICENSE
|
74
|
-
|
75
|
-
(The MIT License)
|
76
|
-
|
77
|
-
Copyright (c) 2008 Relevance, Inc. - http://thinkrelevance.com
|
78
|
-
|
79
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
80
|
-
a copy of this software and associated documentation files (the
|
81
|
-
'Software'), to deal in the Software without restriction, including
|
82
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
83
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
84
|
-
permit persons to whom the Software is furnished to do so, subject to
|
85
|
-
the following conditions:
|
86
|
-
|
87
|
-
The above copyright notice and this permission notice shall be
|
88
|
-
included in all copies or substantial portions of the Software.
|
89
|
-
|
90
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
91
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
92
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
93
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
94
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
95
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
96
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|