sofa 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.yardopts +6 -0
- data/Rakefile +76 -0
- data/doc/Sofa.html +85 -0
- data/doc/Sofa/Mapping.html +168 -0
- data/doc/Sofa/Mapping/ClassMethods.html +314 -0
- data/doc/Sofa/Mapping/InstanceMethods.html +358 -0
- data/doc/Sofa/TVRage.html +85 -0
- data/doc/Sofa/TVRage/Episode.html +358 -0
- data/doc/Sofa/TVRage/Schedule.html +207 -0
- data/doc/Sofa/TVRage/Season.html +236 -0
- data/doc/Sofa/TVRage/Show.html +904 -0
- data/doc/Sofa/TVRage/Show/ShowNotFound.html +92 -0
- data/doc/Sofa/Version.html +100 -0
- data/doc/_index.html +206 -0
- data/doc/class_list.html +137 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +23 -0
- data/doc/css/style.css +261 -0
- data/doc/file.README.html +120 -0
- data/doc/file_list.html +29 -0
- data/doc/index.html +120 -0
- data/doc/js/app.js +91 -0
- data/doc/js/full_list.js +39 -0
- data/doc/js/jquery.js +19 -0
- data/doc/method_list.html +192 -0
- data/doc/top-level-namespace.html +80 -0
- data/lib/sofa.rb +7 -0
- data/lib/sofa/mapping.rb +108 -0
- data/lib/sofa/tvrage.rb +10 -0
- data/lib/sofa/tvrage/episode.rb +56 -0
- data/lib/sofa/tvrage/schedule.rb +25 -0
- data/lib/sofa/tvrage/season.rb +36 -0
- data/lib/sofa/tvrage/show.rb +132 -0
- data/lib/sofa/version.rb +8 -0
- data/sofa.gemspec +113 -0
- data/spec/fixtures/tvrage/cases/castle.xml +228 -0
- data/spec/fixtures/tvrage/cases/community.xml +109 -0
- data/spec/fixtures/tvrage/cases/live_with_regis_and_kelly.xml +56237 -0
- data/spec/fixtures/tvrage/episode_info.xml +30 -0
- data/spec/fixtures/tvrage/episode_list.xml +1183 -0
- data/spec/fixtures/tvrage/episode_list_one_season.xml +17 -0
- data/spec/fixtures/tvrage/episode_list_two_episodes.xml +25 -0
- data/spec/fixtures/tvrage/full_schedule.xml +4731 -0
- data/spec/fixtures/tvrage/full_show_info.xml +1291 -0
- data/spec/fixtures/tvrage/quickinfo.html +17 -0
- data/spec/fixtures/tvrage/quickinfo_missing.html +1 -0
- data/spec/fixtures/tvrage/search.xml +151 -0
- data/spec/fixtures/tvrage/show_info.xml +42 -0
- data/spec/fixtures/tvrage/show_info_blank.xml +3 -0
- data/spec/fixtures/tvrage/single_episode.xml +8 -0
- data/spec/spec.opts +1 -0
- metadata +57 -32
data/.document
ADDED
data/.yardopts
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
require 'lib/sofa/version'
|
7
|
+
Jeweler::Tasks.new do |gem|
|
8
|
+
gem.name = "sofa"
|
9
|
+
gem.version = Sofa::Version::STRING
|
10
|
+
gem.summary = %Q{A Ruby library for the TVRage API.}
|
11
|
+
gem.description = %Q{A simple Ruby library for the TVRage API.}
|
12
|
+
gem.email = "henry@qlane.com"
|
13
|
+
gem.homepage = "http://github.com/hsume2/sofa"
|
14
|
+
gem.authors = ["Henry Hsu"]
|
15
|
+
gem.add_dependency "httparty"
|
16
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
17
|
+
gem.add_development_dependency "mocha"
|
18
|
+
gem.add_development_dependency "fakeweb"
|
19
|
+
gem.add_development_dependency "yard", ">= 0"
|
20
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
21
|
+
end
|
22
|
+
Jeweler::GemcutterTasks.new
|
23
|
+
rescue LoadError
|
24
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
25
|
+
end
|
26
|
+
|
27
|
+
require 'spec/rake/spectask'
|
28
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
29
|
+
spec.libs << 'lib' << 'spec'
|
30
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
31
|
+
end
|
32
|
+
|
33
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
34
|
+
spec.libs << 'lib' << 'spec'
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
spec.rcov_opts = %w{--exclude spec/*,gems/*}
|
38
|
+
end
|
39
|
+
|
40
|
+
task :spec => :check_dependencies
|
41
|
+
|
42
|
+
begin
|
43
|
+
require 'reek/adapters/rake_task'
|
44
|
+
Reek::RakeTask.new do |t|
|
45
|
+
t.fail_on_error = true
|
46
|
+
t.verbose = false
|
47
|
+
t.source_files = 'lib/**/*.rb'
|
48
|
+
end
|
49
|
+
rescue LoadError
|
50
|
+
task :reek do
|
51
|
+
abort "Reek is not available. In order to run reek, you must: sudo gem install reek"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
begin
|
56
|
+
require 'roodi'
|
57
|
+
require 'roodi_task'
|
58
|
+
RoodiTask.new do |t|
|
59
|
+
t.verbose = false
|
60
|
+
end
|
61
|
+
rescue LoadError
|
62
|
+
task :roodi do
|
63
|
+
abort "Roodi is not available. In order to run roodi, you must: sudo gem install roodi"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
task :default => :spec
|
68
|
+
|
69
|
+
begin
|
70
|
+
require 'yard'
|
71
|
+
YARD::Rake::YardocTask.new
|
72
|
+
rescue LoadError
|
73
|
+
task :yardoc do
|
74
|
+
abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
|
75
|
+
end
|
76
|
+
end
|
data/doc/Sofa.html
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta name="Content-Type" content="text/html; charset=UTF-8" />
|
6
|
+
<title>Module: Sofa</title>
|
7
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
|
8
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
9
|
+
|
10
|
+
<script type="text/javascript" charset="utf-8">
|
11
|
+
relpath = '';
|
12
|
+
if (relpath != '') relpath += '/';
|
13
|
+
</script>
|
14
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
15
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
16
|
+
|
17
|
+
</head>
|
18
|
+
<body>
|
19
|
+
<div id="header">
|
20
|
+
<div id="menu">
|
21
|
+
|
22
|
+
<a href="_index.html">Index (S)</a> »
|
23
|
+
|
24
|
+
|
25
|
+
<span class="title">Sofa</span>
|
26
|
+
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<div id="search">
|
30
|
+
<a id="class_list_link" href="#">Namespace List</a>
|
31
|
+
<a id="method_list_link" href="#">Method List</a>
|
32
|
+
<a id ="file_list_link" href="#">File List</a>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div class="clear"></div>
|
36
|
+
</div>
|
37
|
+
|
38
|
+
<iframe id="search_frame"></iframe>
|
39
|
+
|
40
|
+
<div id="content"><h1>Module: Sofa
|
41
|
+
|
42
|
+
|
43
|
+
</h1>
|
44
|
+
|
45
|
+
<dl class="box">
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
<dt class="r1 last">Defined in:</dt>
|
54
|
+
<dd class="r1 last">lib/sofa.rb<span class="defines">,<br />
|
55
|
+
lib/sofa/tvrage.rb,<br /> lib/sofa/version.rb,<br /> lib/sofa/mapping.rb,<br /> lib/sofa/tvrage/show.rb,<br /> lib/sofa/tvrage/season.rb,<br /> lib/sofa/tvrage/episode.rb,<br /> lib/sofa/tvrage/schedule.rb</span>
|
56
|
+
</dd>
|
57
|
+
|
58
|
+
</dl>
|
59
|
+
<div class="clear"></div>
|
60
|
+
|
61
|
+
<h2>Defined Under Namespace</h2>
|
62
|
+
<p class="children">
|
63
|
+
|
64
|
+
|
65
|
+
<strong class="modules">Modules:</strong> <a title="Mapping" href="Sofa/Mapping.html">Mapping</a>, <a title="TVRage" href="Sofa/TVRage.html">TVRage</a>, <a title="Version" href="Sofa/Version.html">Version</a>
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</p>
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
</div>
|
77
|
+
|
78
|
+
<div id="footer">
|
79
|
+
Generated on Sat Nov 21 20:13:52 2009 by
|
80
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool">yard</a>
|
81
|
+
0.4.0 (ruby-1.8.7).
|
82
|
+
</div>
|
83
|
+
|
84
|
+
</body>
|
85
|
+
</html>
|
@@ -0,0 +1,168 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta name="Content-Type" content="text/html; charset=UTF-8" />
|
6
|
+
<title>Module: Sofa::Mapping</title>
|
7
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
|
8
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
|
9
|
+
|
10
|
+
<script type="text/javascript" charset="utf-8">
|
11
|
+
relpath = '..';
|
12
|
+
if (relpath != '') relpath += '/';
|
13
|
+
</script>
|
14
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
15
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
16
|
+
|
17
|
+
</head>
|
18
|
+
<body>
|
19
|
+
<div id="header">
|
20
|
+
<div id="menu">
|
21
|
+
|
22
|
+
<a href="../_index.html">Index (M)</a> »
|
23
|
+
<a title="Sofa" href="../Sofa.html">Sofa</a>
|
24
|
+
»
|
25
|
+
<span class="title">Mapping</span>
|
26
|
+
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<div id="search">
|
30
|
+
<a id="class_list_link" href="#">Namespace List</a>
|
31
|
+
<a id="method_list_link" href="#">Method List</a>
|
32
|
+
<a id ="file_list_link" href="#">File List</a>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div class="clear"></div>
|
36
|
+
</div>
|
37
|
+
|
38
|
+
<iframe id="search_frame"></iframe>
|
39
|
+
|
40
|
+
<div id="content"><h1>Module: Sofa::Mapping
|
41
|
+
|
42
|
+
|
43
|
+
</h1>
|
44
|
+
|
45
|
+
<dl class="box">
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
<dt class="r1 last">Defined in:</dt>
|
54
|
+
<dd class="r1 last">lib/sofa/mapping.rb</dd>
|
55
|
+
|
56
|
+
</dl>
|
57
|
+
<div class="clear"></div>
|
58
|
+
|
59
|
+
<h2>Defined Under Namespace</h2>
|
60
|
+
<p class="children">
|
61
|
+
|
62
|
+
|
63
|
+
<strong class="modules">Modules:</strong> <a title="ClassMethods" href="Mapping/ClassMethods.html">ClassMethods</a>, <a title="InstanceMethods" href="Mapping/InstanceMethods.html">InstanceMethods</a>
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
</p>
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
<h2>Method Summary</h2>
|
73
|
+
<ul class="summary">
|
74
|
+
|
75
|
+
<li class="public ">
|
76
|
+
<span class="summary_signature"><a title="included (class method)" href="#included-class_method">+ (Object) <strong>included</strong>(base) </a>
|
77
|
+
|
78
|
+
</span>
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
<span class="summary_desc">This method is automatically called when <tt><a title="Mapping" href="">Mapping</a></tt> is included in a module.</span>
|
86
|
+
|
87
|
+
</li>
|
88
|
+
|
89
|
+
|
90
|
+
</ul>
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
<div id="method_details">
|
95
|
+
<h2>Method Details</h2>
|
96
|
+
|
97
|
+
<div class="method_details first">
|
98
|
+
<p class="signature first" id="included-class_method">
|
99
|
+
|
100
|
+
+ (<tt>Object</tt>) <strong>included</strong>(base)
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
</p><div class="docstring">
|
105
|
+
<div class="discussion">
|
106
|
+
<p>This method is automatically called when <tt><a title="Mapping" href="">Mapping</a></tt> is included in a module. It automatically adds <tt><a title="InstanceMethods" href="Mapping/InstanceMethods.html">InstanceMethods</a></tt>, <tt><a title="ClassMethods" href="Mapping/ClassMethods.html">ClassMethods</a></tt> and initializes @mappings and @mappings_procs to empty Hashes.</p>
|
107
|
+
|
108
|
+
</div>
|
109
|
+
</div>
|
110
|
+
<div class="tags">
|
111
|
+
<h3>Parameters:</h3>
|
112
|
+
<ul class="param">
|
113
|
+
|
114
|
+
<li>
|
115
|
+
|
116
|
+
<span class='type'>(<tt>Module</tt>, <tt>Class</tt>)</span>
|
117
|
+
|
118
|
+
|
119
|
+
<span class='name'>base</span>
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
—
|
124
|
+
The module that this is included in
|
125
|
+
|
126
|
+
</li>
|
127
|
+
|
128
|
+
</ul>
|
129
|
+
|
130
|
+
</div><table class="source_code">
|
131
|
+
<tr>
|
132
|
+
<td>
|
133
|
+
<pre class="lines">
|
134
|
+
|
135
|
+
|
136
|
+
8
|
137
|
+
9
|
138
|
+
10
|
139
|
+
11
|
140
|
+
12
|
141
|
+
13</pre>
|
142
|
+
</td>
|
143
|
+
<td>
|
144
|
+
<pre class="code"><span class="info file"># File 'lib/sofa/mapping.rb', line 8</span>
|
145
|
+
|
146
|
+
def self.included(base)
|
147
|
+
base.send(:include, InstanceMethods)
|
148
|
+
base.extend(ClassMethods)
|
149
|
+
base.instance_variable_set("@mappings", {})
|
150
|
+
base.instance_variable_set("@mappings_procs", {})
|
151
|
+
end</pre>
|
152
|
+
</td>
|
153
|
+
</tr>
|
154
|
+
</table>
|
155
|
+
</div>
|
156
|
+
|
157
|
+
</div>
|
158
|
+
|
159
|
+
</div>
|
160
|
+
|
161
|
+
<div id="footer">
|
162
|
+
Generated on Sat Nov 21 20:13:53 2009 by
|
163
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool">yard</a>
|
164
|
+
0.4.0 (ruby-1.8.7).
|
165
|
+
</div>
|
166
|
+
|
167
|
+
</body>
|
168
|
+
</html>
|
@@ -0,0 +1,314 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta name="Content-Type" content="text/html; charset=UTF-8" />
|
6
|
+
<title>Module: Sofa::Mapping::ClassMethods</title>
|
7
|
+
<link rel="stylesheet" href="../../css/style.css" type="text/css" media="screen" charset="utf-8" />
|
8
|
+
<link rel="stylesheet" href="../../css/common.css" type="text/css" media="screen" charset="utf-8" />
|
9
|
+
|
10
|
+
<script type="text/javascript" charset="utf-8">
|
11
|
+
relpath = '../..';
|
12
|
+
if (relpath != '') relpath += '/';
|
13
|
+
</script>
|
14
|
+
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
15
|
+
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
16
|
+
|
17
|
+
</head>
|
18
|
+
<body>
|
19
|
+
<div id="header">
|
20
|
+
<div id="menu">
|
21
|
+
|
22
|
+
<a href="../../_index.html">Index (C)</a> »
|
23
|
+
<a title="Sofa" href="../../Sofa.html">Sofa</a> » <a title="Mapping" href="../Mapping.html">Mapping</a>
|
24
|
+
»
|
25
|
+
<span class="title">ClassMethods</span>
|
26
|
+
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<div id="search">
|
30
|
+
<a id="class_list_link" href="#">Namespace List</a>
|
31
|
+
<a id="method_list_link" href="#">Method List</a>
|
32
|
+
<a id ="file_list_link" href="#">File List</a>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div class="clear"></div>
|
36
|
+
</div>
|
37
|
+
|
38
|
+
<iframe id="search_frame"></iframe>
|
39
|
+
|
40
|
+
<div id="content"><h1>Module: Sofa::Mapping::ClassMethods
|
41
|
+
|
42
|
+
|
43
|
+
</h1>
|
44
|
+
|
45
|
+
<dl class="box">
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
<dt class="r1 last">Defined in:</dt>
|
54
|
+
<dd class="r1 last">lib/sofa/mapping.rb</dd>
|
55
|
+
|
56
|
+
</dl>
|
57
|
+
<div class="clear"></div>
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
<h2>Method Summary</h2>
|
63
|
+
<ul class="summary">
|
64
|
+
|
65
|
+
<li class="public ">
|
66
|
+
<span class="summary_signature"><a title="#mappings (instance method)" href="#mappings-instance_method">- (Hash<Symbol, Symbol>) <strong>mappings</strong> </a>
|
67
|
+
|
68
|
+
</span>
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
<span class="summary_desc">Mapping of symbols to attribute names.</span>
|
76
|
+
|
77
|
+
</li>
|
78
|
+
|
79
|
+
|
80
|
+
<li class="public ">
|
81
|
+
<span class="summary_signature"><a title="#mappings_procs (instance method)" href="#mappings_procs-instance_method">- (Hash<Symbol, Proc>) <strong>mappings_procs</strong> </a>
|
82
|
+
|
83
|
+
</span>
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
<span class="summary_desc">Mapping of attribute names to a Proc filter.</span>
|
91
|
+
|
92
|
+
</li>
|
93
|
+
|
94
|
+
|
95
|
+
<li class="public ">
|
96
|
+
<span class="summary_signature"><a title="#maps (instance method)" href="#maps-instance_method">- (Object) <strong>maps</strong>(hash = {}, &block) </a>
|
97
|
+
|
98
|
+
</span>
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
<span class="summary_desc">Class method to define mappings.</span>
|
106
|
+
|
107
|
+
</li>
|
108
|
+
|
109
|
+
|
110
|
+
</ul>
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
<div id="method_details">
|
115
|
+
<h2>Method Details</h2>
|
116
|
+
|
117
|
+
<div class="method_details first">
|
118
|
+
<p class="signature first" id="mappings-instance_method">
|
119
|
+
|
120
|
+
- (<tt>Hash<Symbol, Symbol></tt>) <strong>mappings</strong>
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
</p><div class="docstring">
|
125
|
+
<div class="discussion">
|
126
|
+
<p>Mapping of symbols to attribute names</p>
|
127
|
+
|
128
|
+
</div>
|
129
|
+
</div>
|
130
|
+
<div class="tags">
|
131
|
+
<h3>Returns:</h3>
|
132
|
+
<ul class="return">
|
133
|
+
|
134
|
+
<li>
|
135
|
+
|
136
|
+
<span class='type'>(<tt>Hash<Symbol, Symbol></tt>)</span>
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
—
|
142
|
+
Mapping of symbols to attribute names
|
143
|
+
|
144
|
+
</li>
|
145
|
+
|
146
|
+
</ul>
|
147
|
+
|
148
|
+
</div><table class="source_code">
|
149
|
+
<tr>
|
150
|
+
<td>
|
151
|
+
<pre class="lines">
|
152
|
+
|
153
|
+
|
154
|
+
96
|
155
|
+
97
|
156
|
+
98</pre>
|
157
|
+
</td>
|
158
|
+
<td>
|
159
|
+
<pre class="code"><span class="info file"># File 'lib/sofa/mapping.rb', line 96</span>
|
160
|
+
|
161
|
+
def mappings
|
162
|
+
@mappings
|
163
|
+
end</pre>
|
164
|
+
</td>
|
165
|
+
</tr>
|
166
|
+
</table>
|
167
|
+
</div>
|
168
|
+
|
169
|
+
<div class="method_details ">
|
170
|
+
<p class="signature " id="mappings_procs-instance_method">
|
171
|
+
|
172
|
+
- (<tt>Hash<Symbol, Proc></tt>) <strong>mappings_procs</strong>
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
</p><div class="docstring">
|
177
|
+
<div class="discussion">
|
178
|
+
<p>Mapping of attribute names to a Proc filter.</p>
|
179
|
+
|
180
|
+
</div>
|
181
|
+
</div>
|
182
|
+
<div class="tags">
|
183
|
+
<h3>Returns:</h3>
|
184
|
+
<ul class="return">
|
185
|
+
|
186
|
+
<li>
|
187
|
+
|
188
|
+
<span class='type'>(<tt>Hash<Symbol, Proc></tt>)</span>
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
—
|
194
|
+
Mapping of attribute names to a Proc filter.
|
195
|
+
|
196
|
+
</li>
|
197
|
+
|
198
|
+
</ul>
|
199
|
+
|
200
|
+
<h3>See Also:</h3>
|
201
|
+
<ul class="see">
|
202
|
+
|
203
|
+
<li><a title="#maps" href="#maps-instance_method">#maps</a></li>
|
204
|
+
|
205
|
+
</ul>
|
206
|
+
|
207
|
+
</div><table class="source_code">
|
208
|
+
<tr>
|
209
|
+
<td>
|
210
|
+
<pre class="lines">
|
211
|
+
|
212
|
+
|
213
|
+
103
|
214
|
+
104
|
215
|
+
105</pre>
|
216
|
+
</td>
|
217
|
+
<td>
|
218
|
+
<pre class="code"><span class="info file"># File 'lib/sofa/mapping.rb', line 103</span>
|
219
|
+
|
220
|
+
def mappings_procs
|
221
|
+
@mappings_procs
|
222
|
+
end</pre>
|
223
|
+
</td>
|
224
|
+
</tr>
|
225
|
+
</table>
|
226
|
+
</div>
|
227
|
+
|
228
|
+
<div class="method_details ">
|
229
|
+
<p class="signature " id="maps-instance_method">
|
230
|
+
|
231
|
+
- (<tt>Object</tt>) <strong>maps</strong>(hash = {}, &block)
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
</p><div class="docstring">
|
236
|
+
<div class="discussion">
|
237
|
+
<p>Class method to define mappings.</p>
|
238
|
+
|
239
|
+
</div>
|
240
|
+
</div>
|
241
|
+
<div class="tags">
|
242
|
+
|
243
|
+
<div class="examples">
|
244
|
+
<h3>Examples:</h3>
|
245
|
+
|
246
|
+
<h4>Maps :examplename to :name and :link to itself.</h4>
|
247
|
+
<pre class="example code"> class Example1
|
248
|
+
include Sofa::Mapping
|
249
|
+
maps(
|
250
|
+
:examplename => :name,
|
251
|
+
:link => nil
|
252
|
+
)
|
253
|
+
end
|
254
|
+
example1 = Example1.new.update_with_mapping(:epnum => "1", :link => "http://google.com")
|
255
|
+
example1.name # => "1"
|
256
|
+
example1.link # => "http://google.com"
|
257
|
+
example1.attributes # => {:name => "1", :link => "http://google.com"}</pre>
|
258
|
+
|
259
|
+
<h4>Maps :airdate to :air_date and stores the block.</h4>
|
260
|
+
<pre class="example code"> class Example2
|
261
|
+
include Sofa::Mapping
|
262
|
+
|
263
|
+
maps(:airdate => :air_date) do |value|
|
264
|
+
Date.parse(value)
|
265
|
+
end
|
266
|
+
end
|
267
|
+
example2 = Example2.new.update_with_mapping(:airdate => "2007-07-04")
|
268
|
+
example2.attributes # => {:air_date => Wed, 04 Jul 2007}</pre>
|
269
|
+
|
270
|
+
</div>
|
271
|
+
|
272
|
+
</div><table class="source_code">
|
273
|
+
<tr>
|
274
|
+
<td>
|
275
|
+
<pre class="lines">
|
276
|
+
|
277
|
+
|
278
|
+
85
|
279
|
+
86
|
280
|
+
87
|
281
|
+
88
|
282
|
+
89
|
283
|
+
90
|
284
|
+
91
|
285
|
+
92</pre>
|
286
|
+
</td>
|
287
|
+
<td>
|
288
|
+
<pre class="code"><span class="info file"># File 'lib/sofa/mapping.rb', line 85</span>
|
289
|
+
|
290
|
+
def maps(hash = {}, &block)
|
291
|
+
hash.each do |from, to|
|
292
|
+
method = to || from
|
293
|
+
@mappings[from.to_sym] = method
|
294
|
+
attr_reader method
|
295
|
+
@mappings_procs[method] = block
|
296
|
+
end
|
297
|
+
end</pre>
|
298
|
+
</td>
|
299
|
+
</tr>
|
300
|
+
</table>
|
301
|
+
</div>
|
302
|
+
|
303
|
+
</div>
|
304
|
+
|
305
|
+
</div>
|
306
|
+
|
307
|
+
<div id="footer">
|
308
|
+
Generated on Sat Nov 21 20:13:52 2009 by
|
309
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool">yard</a>
|
310
|
+
0.4.0 (ruby-1.8.7).
|
311
|
+
</div>
|
312
|
+
|
313
|
+
</body>
|
314
|
+
</html>
|