s3aps 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/Gemfile +3 -0
- data/README.rdoc +105 -0
- data/Rakefile +2 -0
- data/bin/s3aps +17 -0
- data/doc/S3aps.html +161 -0
- data/doc/S3aps/FileAdapter.html +335 -0
- data/doc/S3aps/Runner.html +363 -0
- data/doc/S3aps/S3Adapter.html +322 -0
- data/doc/S3aps/Sync.html +380 -0
- data/doc/created.rid +7 -0
- data/doc/index.html +87 -0
- data/doc/lib/s3aps/file_adapter_rb.html +52 -0
- data/doc/lib/s3aps/runner_rb.html +58 -0
- data/doc/lib/s3aps/s3_adapter_rb.html +56 -0
- data/doc/lib/s3aps/sync_rb.html +58 -0
- data/doc/lib/s3aps/version_rb.html +52 -0
- data/doc/lib/s3aps_rb.html +62 -0
- data/doc/rdoc.css +706 -0
- data/lib/s3aps.rb +5 -0
- data/lib/s3aps/file_adapter.rb +58 -0
- data/lib/s3aps/runner.rb +83 -0
- data/lib/s3aps/s3_adapter.rb +40 -0
- data/lib/s3aps/sync.rb +110 -0
- data/lib/s3aps/version.rb +3 -0
- data/s3aps.gemspec +23 -0
- metadata +103 -0
data/Gemfile
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
= s3aps
|
2
|
+
|
3
|
+
The "s3" bit of the name refers to Amazon's {S3}[http://aws.amazon.com/s3/]
|
4
|
+
(simple storage service). The "aps" bit of the name is a reference to the
|
5
|
+
{taps}[https://github.com/ricardochimal/taps] gem that inspired this gem. Taps will
|
6
|
+
push and pull data between remote and local databases. S3aps will push and pull files between S3
|
7
|
+
and the filesystem.
|
8
|
+
|
9
|
+
== Usage
|
10
|
+
|
11
|
+
List the files in an S3 bucket and on filesystem
|
12
|
+
|
13
|
+
s3aps list
|
14
|
+
|
15
|
+
Copy files from S3 to filesystem
|
16
|
+
|
17
|
+
s3aps pull
|
18
|
+
|
19
|
+
Copy files from filesystem to S3
|
20
|
+
|
21
|
+
s3aps push
|
22
|
+
|
23
|
+
== S3 Credentials
|
24
|
+
|
25
|
+
You can provide your S3 credentials either on the command line or in a YAML file. By default, S3aps
|
26
|
+
will look for a file called <tt>s3.yml</tt> in the current directory and then in a sub-directory called +config+.
|
27
|
+
If your YAML is somewhere else then use the <tt>--config</tt> option:
|
28
|
+
|
29
|
+
s3aps list --config my_s3.yml
|
30
|
+
|
31
|
+
It looks for the following values:
|
32
|
+
|
33
|
+
* bucket
|
34
|
+
* key (aliased as access_key_id)
|
35
|
+
* secret (aliased as secret_access_key)
|
36
|
+
|
37
|
+
The YAML file might look like this:
|
38
|
+
|
39
|
+
bucket: foo
|
40
|
+
key: 01234567890123456789
|
41
|
+
secret: abcdefabcdefabcdef
|
42
|
+
|
43
|
+
If your YAML file is separated into environments then you'll need to tell it which one you're interested
|
44
|
+
in:
|
45
|
+
|
46
|
+
s3aps list --config my_s3.yml --env production
|
47
|
+
|
48
|
+
In which case, the YAML file might look like this:
|
49
|
+
|
50
|
+
staging:
|
51
|
+
bucket: foo.staging
|
52
|
+
key: 01234567890123456789
|
53
|
+
secret: abcdefabcdefabcdef
|
54
|
+
production:
|
55
|
+
bucket: foo.production
|
56
|
+
key: 01234567890123456780
|
57
|
+
secret: abcdefabcdefabcdef
|
58
|
+
|
59
|
+
You can also define (or override) the credentials on the command line:
|
60
|
+
|
61
|
+
s3aps list --bucket foo --key 01234567890123456789 --secret abcdefabcdefabcdef
|
62
|
+
|
63
|
+
== Synchronizing two S3 buckets
|
64
|
+
|
65
|
+
You can do this by pulling the files to the filesystem and then pushing them to a new
|
66
|
+
bucket. For instance, if you have two environments setup in <tt>s3.yml</tt>, you might do this:
|
67
|
+
|
68
|
+
s3aps pull --env production
|
69
|
+
s3aps push --env staging
|
70
|
+
|
71
|
+
== SSL
|
72
|
+
|
73
|
+
S3aps uses the http protocol on port 80. This is not configurable.
|
74
|
+
|
75
|
+
== Sloppy Sync
|
76
|
+
|
77
|
+
This early version is satisfied that two files are synchronized if the file exists locally and remotely.
|
78
|
+
That works for what I need it for right now. I don't change files, just add new ones. However, I'd like
|
79
|
+
to add an MD5 check too. I'd make that an option rather than the default because it makes it more time
|
80
|
+
consuming.
|
81
|
+
|
82
|
+
It doesn't attempt to delete files that shouldn't be there. That would be useful and I am considering
|
83
|
+
adding a <tt>--delete</tt> option to do that. It's also a little scary.
|
84
|
+
|
85
|
+
== Hand Holding
|
86
|
+
|
87
|
+
It's quite easy to write stuff to production. We should seek confirmation, like Taps does. Fortunately,
|
88
|
+
that risk is mitigated a little by not having a delete feature. I guess we should make it a bit more
|
89
|
+
cautious when we do have delete.
|
90
|
+
|
91
|
+
== Performance
|
92
|
+
|
93
|
+
I only use this on a smallish bucket. Only a few thousand files and none more than a couple of Mb in
|
94
|
+
size. It works very well in that situation. It does some non-scalable things like put a list of
|
95
|
+
all the local and remote files in a couple of arrays so that it can quickly see what is different. At
|
96
|
+
some point that is going to be a problem if you are dealing with lots of files.
|
97
|
+
|
98
|
+
Similarly, it copies the file by reading the whole lot and then writing it out again. That won't work
|
99
|
+
very well if you have files that are, say, 1Gb in size.
|
100
|
+
|
101
|
+
== Meta
|
102
|
+
|
103
|
+
Written and maintained by {Bill Horsman}[http://bill.logicalcobwebs.com]. Hat tip to {Ricardo Chimal, Jr}[http://github.com/ricardochimal] for inspiration with {Taps}[https://github.com/ricardochimal/taps]. Thanks to {Mikel Lindsaar's}[https://github.com/mikel] RailsConf 2010 talk, {Itch Scratching the ActionMailer API}[http://en.oreilly.com/rails2010/public/schedule/detail/14225], for encouragement to contribute.
|
104
|
+
|
105
|
+
Released under the {MIT License}[http://www.opensource.org/licenses/mit-license.php]
|
data/Rakefile
ADDED
data/bin/s3aps
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib') unless $LOAD_PATH.include?(File.dirname(__FILE__) + '/../lib')
|
5
|
+
|
6
|
+
require 's3aps'
|
7
|
+
|
8
|
+
begin
|
9
|
+
success = S3aps::Runner.new(ARGV.dup).run
|
10
|
+
Kernel.exit(success ? 0 : 1)
|
11
|
+
rescue SystemExit => e
|
12
|
+
Kernel.exit(e.status)
|
13
|
+
rescue Exception => e
|
14
|
+
STDERR.puts("#{e.message} (#{e.class})")
|
15
|
+
STDERR.puts(e.backtrace.join("\n"))
|
16
|
+
Kernel.exit 1
|
17
|
+
end
|
data/doc/S3aps.html
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
7
|
+
|
8
|
+
<title>Module: S3aps</title>
|
9
|
+
|
10
|
+
<link rel="stylesheet" href="./rdoc.css" type="text/css" media="screen" />
|
11
|
+
|
12
|
+
<script src="./js/jquery.js" type="text/javascript"
|
13
|
+
charset="utf-8"></script>
|
14
|
+
<script src="./js/thickbox-compressed.js" type="text/javascript"
|
15
|
+
charset="utf-8"></script>
|
16
|
+
<script src="./js/quicksearch.js" type="text/javascript"
|
17
|
+
charset="utf-8"></script>
|
18
|
+
<script src="./js/darkfish.js" type="text/javascript"
|
19
|
+
charset="utf-8"></script>
|
20
|
+
|
21
|
+
</head>
|
22
|
+
<body class="module">
|
23
|
+
|
24
|
+
<div id="metadata">
|
25
|
+
<div id="home-metadata">
|
26
|
+
<div id="home-section" class="section">
|
27
|
+
<h3 class="section-header">
|
28
|
+
<a href="./index.html">Home</a>
|
29
|
+
<a href="./index.html#classes">Classes</a>
|
30
|
+
<a href="./index.html#methods">Methods</a>
|
31
|
+
</h3>
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="file-metadata">
|
36
|
+
<div id="file-list-section" class="section">
|
37
|
+
<h3 class="section-header">In Files</h3>
|
38
|
+
<div class="section-body">
|
39
|
+
<ul>
|
40
|
+
|
41
|
+
<li><a href="./lib/s3aps/file_adapter_rb.html?TB_iframe=true&height=550&width=785"
|
42
|
+
class="thickbox" title="lib/s3aps/file_adapter.rb">lib/s3aps/file_adapter.rb</a></li>
|
43
|
+
|
44
|
+
<li><a href="./lib/s3aps/runner_rb.html?TB_iframe=true&height=550&width=785"
|
45
|
+
class="thickbox" title="lib/s3aps/runner.rb">lib/s3aps/runner.rb</a></li>
|
46
|
+
|
47
|
+
<li><a href="./lib/s3aps/s3_adapter_rb.html?TB_iframe=true&height=550&width=785"
|
48
|
+
class="thickbox" title="lib/s3aps/s3_adapter.rb">lib/s3aps/s3_adapter.rb</a></li>
|
49
|
+
|
50
|
+
<li><a href="./lib/s3aps/sync_rb.html?TB_iframe=true&height=550&width=785"
|
51
|
+
class="thickbox" title="lib/s3aps/sync.rb">lib/s3aps/sync.rb</a></li>
|
52
|
+
|
53
|
+
<li><a href="./lib/s3aps/version_rb.html?TB_iframe=true&height=550&width=785"
|
54
|
+
class="thickbox" title="lib/s3aps/version.rb">lib/s3aps/version.rb</a></li>
|
55
|
+
|
56
|
+
</ul>
|
57
|
+
</div>
|
58
|
+
</div>
|
59
|
+
|
60
|
+
|
61
|
+
</div>
|
62
|
+
|
63
|
+
<div id="class-metadata">
|
64
|
+
|
65
|
+
<!-- Parent Class -->
|
66
|
+
|
67
|
+
|
68
|
+
<!-- Namespace Contents -->
|
69
|
+
|
70
|
+
<div id="namespace-list-section" class="section">
|
71
|
+
<h3 class="section-header">Namespace</h3>
|
72
|
+
<ul class="link-list">
|
73
|
+
|
74
|
+
<li><span class="type">CLASS</span> <a href="S3aps/FileAdapter.html">S3aps::FileAdapter</a></li>
|
75
|
+
|
76
|
+
<li><span class="type">CLASS</span> <a href="S3aps/Runner.html">S3aps::Runner</a></li>
|
77
|
+
|
78
|
+
<li><span class="type">CLASS</span> <a href="S3aps/S3Adapter.html">S3aps::S3Adapter</a></li>
|
79
|
+
|
80
|
+
<li><span class="type">CLASS</span> <a href="S3aps/Sync.html">S3aps::Sync</a></li>
|
81
|
+
|
82
|
+
</ul>
|
83
|
+
</div>
|
84
|
+
|
85
|
+
|
86
|
+
<!-- Method Quickref -->
|
87
|
+
|
88
|
+
|
89
|
+
<!-- Included Modules -->
|
90
|
+
|
91
|
+
</div>
|
92
|
+
|
93
|
+
<div id="project-metadata">
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
<div id="classindex-section" class="section project-section">
|
98
|
+
<h3 class="section-header">Class Index
|
99
|
+
<span class="search-toggle"><img src="./images/find.png"
|
100
|
+
height="16" width="16" alt="[+]"
|
101
|
+
title="show/hide quicksearch" /></span></h3>
|
102
|
+
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
103
|
+
<fieldset>
|
104
|
+
<legend>Quicksearch</legend>
|
105
|
+
<input type="text" name="quicksearch" value=""
|
106
|
+
class="quicksearch-field" />
|
107
|
+
</fieldset>
|
108
|
+
</form>
|
109
|
+
|
110
|
+
<ul class="link-list">
|
111
|
+
|
112
|
+
<li><a href="./S3aps/FileAdapter.html">S3aps::FileAdapter</a></li>
|
113
|
+
|
114
|
+
<li><a href="./S3aps/Runner.html">S3aps::Runner</a></li>
|
115
|
+
|
116
|
+
<li><a href="./S3aps/S3Adapter.html">S3aps::S3Adapter</a></li>
|
117
|
+
|
118
|
+
<li><a href="./S3aps/Sync.html">S3aps::Sync</a></li>
|
119
|
+
|
120
|
+
</ul>
|
121
|
+
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
122
|
+
</div>
|
123
|
+
|
124
|
+
|
125
|
+
</div>
|
126
|
+
</div>
|
127
|
+
|
128
|
+
<div id="documentation">
|
129
|
+
<h1 class="module">S3aps</h1>
|
130
|
+
|
131
|
+
<div id="description">
|
132
|
+
|
133
|
+
</div>
|
134
|
+
|
135
|
+
<!-- Constants -->
|
136
|
+
|
137
|
+
|
138
|
+
<!-- Attributes -->
|
139
|
+
|
140
|
+
|
141
|
+
<!-- Methods -->
|
142
|
+
|
143
|
+
|
144
|
+
</div>
|
145
|
+
|
146
|
+
|
147
|
+
<div id="rdoc-debugging-section-dump" class="debugging-section">
|
148
|
+
|
149
|
+
<p>Disabled; run with --debug to generate this.</p>
|
150
|
+
|
151
|
+
</div>
|
152
|
+
|
153
|
+
<div id="validator-badges">
|
154
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
155
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
156
|
+
Rdoc Generator</a> 1.1.6</small>.</p>
|
157
|
+
</div>
|
158
|
+
|
159
|
+
</body>
|
160
|
+
</html>
|
161
|
+
|
@@ -0,0 +1,335 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
7
|
+
|
8
|
+
<title>Class: S3aps::FileAdapter</title>
|
9
|
+
|
10
|
+
<link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
|
11
|
+
|
12
|
+
<script src="../js/jquery.js" type="text/javascript"
|
13
|
+
charset="utf-8"></script>
|
14
|
+
<script src="../js/thickbox-compressed.js" type="text/javascript"
|
15
|
+
charset="utf-8"></script>
|
16
|
+
<script src="../js/quicksearch.js" type="text/javascript"
|
17
|
+
charset="utf-8"></script>
|
18
|
+
<script src="../js/darkfish.js" type="text/javascript"
|
19
|
+
charset="utf-8"></script>
|
20
|
+
|
21
|
+
</head>
|
22
|
+
<body class="class">
|
23
|
+
|
24
|
+
<div id="metadata">
|
25
|
+
<div id="home-metadata">
|
26
|
+
<div id="home-section" class="section">
|
27
|
+
<h3 class="section-header">
|
28
|
+
<a href="../index.html">Home</a>
|
29
|
+
<a href="../index.html#classes">Classes</a>
|
30
|
+
<a href="../index.html#methods">Methods</a>
|
31
|
+
</h3>
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="file-metadata">
|
36
|
+
<div id="file-list-section" class="section">
|
37
|
+
<h3 class="section-header">In Files</h3>
|
38
|
+
<div class="section-body">
|
39
|
+
<ul>
|
40
|
+
|
41
|
+
<li><a href="../lib/s3aps/file_adapter_rb.html?TB_iframe=true&height=550&width=785"
|
42
|
+
class="thickbox" title="lib/s3aps/file_adapter.rb">lib/s3aps/file_adapter.rb</a></li>
|
43
|
+
|
44
|
+
</ul>
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
|
48
|
+
|
49
|
+
</div>
|
50
|
+
|
51
|
+
<div id="class-metadata">
|
52
|
+
|
53
|
+
<!-- Parent Class -->
|
54
|
+
|
55
|
+
<div id="parent-class-section" class="section">
|
56
|
+
<h3 class="section-header">Parent</h3>
|
57
|
+
|
58
|
+
<p class="link">Object</p>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
|
62
|
+
|
63
|
+
<!-- Namespace Contents -->
|
64
|
+
|
65
|
+
|
66
|
+
<!-- Method Quickref -->
|
67
|
+
|
68
|
+
<div id="method-list-section" class="section">
|
69
|
+
<h3 class="section-header">Methods</h3>
|
70
|
+
<ul class="link-list">
|
71
|
+
|
72
|
+
<li><a href="#method-c-new">::new</a></li>
|
73
|
+
|
74
|
+
<li><a href="#method-i-list">#list</a></li>
|
75
|
+
|
76
|
+
<li><a href="#method-i-read">#read</a></li>
|
77
|
+
|
78
|
+
<li><a href="#method-i-write">#write</a></li>
|
79
|
+
|
80
|
+
</ul>
|
81
|
+
</div>
|
82
|
+
|
83
|
+
|
84
|
+
<!-- Included Modules -->
|
85
|
+
|
86
|
+
</div>
|
87
|
+
|
88
|
+
<div id="project-metadata">
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
<div id="classindex-section" class="section project-section">
|
93
|
+
<h3 class="section-header">Class Index
|
94
|
+
<span class="search-toggle"><img src="../images/find.png"
|
95
|
+
height="16" width="16" alt="[+]"
|
96
|
+
title="show/hide quicksearch" /></span></h3>
|
97
|
+
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
98
|
+
<fieldset>
|
99
|
+
<legend>Quicksearch</legend>
|
100
|
+
<input type="text" name="quicksearch" value=""
|
101
|
+
class="quicksearch-field" />
|
102
|
+
</fieldset>
|
103
|
+
</form>
|
104
|
+
|
105
|
+
<ul class="link-list">
|
106
|
+
|
107
|
+
<li><a href="../S3aps/FileAdapter.html">S3aps::FileAdapter</a></li>
|
108
|
+
|
109
|
+
<li><a href="../S3aps/Runner.html">S3aps::Runner</a></li>
|
110
|
+
|
111
|
+
<li><a href="../S3aps/S3Adapter.html">S3aps::S3Adapter</a></li>
|
112
|
+
|
113
|
+
<li><a href="../S3aps/Sync.html">S3aps::Sync</a></li>
|
114
|
+
|
115
|
+
</ul>
|
116
|
+
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
117
|
+
</div>
|
118
|
+
|
119
|
+
|
120
|
+
</div>
|
121
|
+
</div>
|
122
|
+
|
123
|
+
<div id="documentation">
|
124
|
+
<h1 class="class">S3aps::FileAdapter</h1>
|
125
|
+
|
126
|
+
<div id="description">
|
127
|
+
<p>
|
128
|
+
Reads, writes and lists files on the filesystem.
|
129
|
+
</p>
|
130
|
+
|
131
|
+
</div>
|
132
|
+
|
133
|
+
<!-- Constants -->
|
134
|
+
|
135
|
+
|
136
|
+
<!-- Attributes -->
|
137
|
+
|
138
|
+
|
139
|
+
<!-- Methods -->
|
140
|
+
|
141
|
+
<div id="public-class-method-details" class="method-section section">
|
142
|
+
<h3 class="section-header">Public Class Methods</h3>
|
143
|
+
|
144
|
+
|
145
|
+
<div id="new-method" class="method-detail ">
|
146
|
+
<a name="method-c-new"></a>
|
147
|
+
|
148
|
+
<div class="method-heading">
|
149
|
+
|
150
|
+
<span class="method-name">new</span><span
|
151
|
+
class="method-args">(options = {})</span>
|
152
|
+
<span class="method-click-advice">click to toggle source</span>
|
153
|
+
|
154
|
+
</div>
|
155
|
+
|
156
|
+
<div class="method-description">
|
157
|
+
|
158
|
+
<p>
|
159
|
+
Options:
|
160
|
+
</p>
|
161
|
+
<ul>
|
162
|
+
<li><p>
|
163
|
+
:path - where the local files are (default is <tt>tmp</tt>)
|
164
|
+
</p>
|
165
|
+
</li>
|
166
|
+
</ul>
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
<div class="method-source-code"
|
171
|
+
id="new-source">
|
172
|
+
<pre>
|
173
|
+
<span class="ruby-comment cmt"># File lib/s3aps/file_adapter.rb, line 9</span>
|
174
|
+
9: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">options</span> = {})
|
175
|
+
10: <span class="ruby-ivar">@path</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:path</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">"tmp"</span>
|
176
|
+
11: <span class="ruby-keyword kw">end</span></pre>
|
177
|
+
</div>
|
178
|
+
|
179
|
+
</div>
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
</div>
|
185
|
+
|
186
|
+
|
187
|
+
</div>
|
188
|
+
|
189
|
+
<div id="public-instance-method-details" class="method-section section">
|
190
|
+
<h3 class="section-header">Public Instance Methods</h3>
|
191
|
+
|
192
|
+
|
193
|
+
<div id="list-method" class="method-detail ">
|
194
|
+
<a name="method-i-list"></a>
|
195
|
+
|
196
|
+
<div class="method-heading">
|
197
|
+
|
198
|
+
<span class="method-name">list</span><span
|
199
|
+
class="method-args">()</span>
|
200
|
+
<span class="method-click-advice">click to toggle source</span>
|
201
|
+
|
202
|
+
</div>
|
203
|
+
|
204
|
+
<div class="method-description">
|
205
|
+
|
206
|
+
<p>
|
207
|
+
List all the files in the path, recursively
|
208
|
+
</p>
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
<div class="method-source-code"
|
213
|
+
id="list-source">
|
214
|
+
<pre>
|
215
|
+
<span class="ruby-comment cmt"># File lib/s3aps/file_adapter.rb, line 14</span>
|
216
|
+
14: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">list</span>
|
217
|
+
15: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-node">"#{@path}/**/*"</span>).<span class="ruby-identifier">select</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-identifier">path</span>) }.<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
|
218
|
+
16: <span class="ruby-identifier">path</span>.<span class="ruby-identifier">sub</span> <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"^#{@path}\/"</span>), <span class="ruby-value str">''</span>
|
219
|
+
17: <span class="ruby-keyword kw">end</span>
|
220
|
+
18: <span class="ruby-keyword kw">end</span></pre>
|
221
|
+
</div>
|
222
|
+
|
223
|
+
</div>
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
</div>
|
229
|
+
|
230
|
+
|
231
|
+
<div id="read-method" class="method-detail ">
|
232
|
+
<a name="method-i-read"></a>
|
233
|
+
|
234
|
+
<div class="method-heading">
|
235
|
+
|
236
|
+
<span class="method-name">read</span><span
|
237
|
+
class="method-args">(path)</span>
|
238
|
+
<span class="method-click-advice">click to toggle source</span>
|
239
|
+
|
240
|
+
</div>
|
241
|
+
|
242
|
+
<div class="method-description">
|
243
|
+
|
244
|
+
<p>
|
245
|
+
Read the file.
|
246
|
+
</p>
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
<div class="method-source-code"
|
251
|
+
id="read-source">
|
252
|
+
<pre>
|
253
|
+
<span class="ruby-comment cmt"># File lib/s3aps/file_adapter.rb, line 38</span>
|
254
|
+
38: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">read</span>(<span class="ruby-identifier">path</span>)
|
255
|
+
39: <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@path</span>, <span class="ruby-identifier">path</span>),<span class="ruby-value str">"rb"</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">io</span><span class="ruby-operator">|</span> <span class="ruby-identifier">io</span>.<span class="ruby-identifier">read</span>}
|
256
|
+
40: <span class="ruby-keyword kw">end</span></pre>
|
257
|
+
</div>
|
258
|
+
|
259
|
+
</div>
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
</div>
|
265
|
+
|
266
|
+
|
267
|
+
<div id="write-method" class="method-detail ">
|
268
|
+
<a name="method-i-write"></a>
|
269
|
+
|
270
|
+
<div class="method-heading">
|
271
|
+
|
272
|
+
<span class="method-name">write</span><span
|
273
|
+
class="method-args">(path, value, md5sum = nil)</span>
|
274
|
+
<span class="method-click-advice">click to toggle source</span>
|
275
|
+
|
276
|
+
</div>
|
277
|
+
|
278
|
+
<div class="method-description">
|
279
|
+
|
280
|
+
<p>
|
281
|
+
Write the file. It will always write the file whether it’s there or
|
282
|
+
not, unless you supply an <tt>md5sum</tt> in which case it will check
|
283
|
+
whether it’s different first.
|
284
|
+
</p>
|
285
|
+
|
286
|
+
|
287
|
+
|
288
|
+
<div class="method-source-code"
|
289
|
+
id="write-source">
|
290
|
+
<pre>
|
291
|
+
<span class="ruby-comment cmt"># File lib/s3aps/file_adapter.rb, line 23</span>
|
292
|
+
23: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">md5sum</span> = <span class="ruby-keyword kw">nil</span>)
|
293
|
+
24: <span class="ruby-identifier">just_path</span> = <span class="ruby-identifier">path</span>.<span class="ruby-identifier">sub</span> <span class="ruby-regexp re">/\/[^\/]*$/</span>, <span class="ruby-value str">''</span>
|
294
|
+
25: <span class="ruby-identifier">local_md5</span> = <span class="ruby-identifier">md5sum</span>(<span class="ruby-identifier">path</span>)
|
295
|
+
26: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">local_md5</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">local_md5</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">md5sum</span>
|
296
|
+
27: <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@path</span>, <span class="ruby-identifier">just_path</span>))
|
297
|
+
28: <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@path</span>, <span class="ruby-identifier">path</span>), <span class="ruby-value str">'w'</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">outfile</span><span class="ruby-operator">|</span>
|
298
|
+
29: <span class="ruby-identifier">outfile</span>.<span class="ruby-identifier">print</span>(<span class="ruby-identifier">value</span>)
|
299
|
+
30: }
|
300
|
+
31: <span class="ruby-keyword kw">true</span>
|
301
|
+
32: <span class="ruby-keyword kw">else</span>
|
302
|
+
33: <span class="ruby-keyword kw">false</span>
|
303
|
+
34: <span class="ruby-keyword kw">end</span>
|
304
|
+
35: <span class="ruby-keyword kw">end</span></pre>
|
305
|
+
</div>
|
306
|
+
|
307
|
+
</div>
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
</div>
|
313
|
+
|
314
|
+
|
315
|
+
</div>
|
316
|
+
|
317
|
+
|
318
|
+
</div>
|
319
|
+
|
320
|
+
|
321
|
+
<div id="rdoc-debugging-section-dump" class="debugging-section">
|
322
|
+
|
323
|
+
<p>Disabled; run with --debug to generate this.</p>
|
324
|
+
|
325
|
+
</div>
|
326
|
+
|
327
|
+
<div id="validator-badges">
|
328
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
329
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
330
|
+
Rdoc Generator</a> 1.1.6</small>.</p>
|
331
|
+
</div>
|
332
|
+
|
333
|
+
</body>
|
334
|
+
</html>
|
335
|
+
|