amazon-ec2 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +115 -2
- data/License.txt +20 -0
- data/Manifest.txt +10 -6
- data/Rakefile +87 -12
- data/examples/ec2-example.rb +3 -0
- data/lib/EC2.rb +1 -1
- data/lib/EC2/image_attributes.rb +1 -1
- data/lib/EC2/images.rb +1 -1
- data/lib/EC2/instances.rb +1 -1
- data/lib/EC2/keypairs.rb +1 -1
- data/lib/EC2/responses.rb +1 -1
- data/lib/EC2/security_groups.rb +1 -1
- data/lib/EC2/version.rb +1 -1
- data/scripts/txt2html +67 -0
- data/test/{test_ec2.rb → test_EC2.rb} +3 -1
- data/test/test_helper.rb +6 -4
- data/test/test_responses.rb +1 -0
- data/website/index.html +260 -0
- data/website/index.txt +173 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +129 -0
- data/website/template.rhtml +55 -0
- metadata +19 -20
- data/CHANGELOG.txt +0 -116
data/History.txt
CHANGED
@@ -1,3 +1,116 @@
|
|
1
|
-
|
1
|
+
=== 0.0.8 2007-05-30
|
2
|
+
* Repackaged with updated newgem generator v. 0.10.3 from http://newgem.rubyforge.org/ to take advantage of new deployment goodness.
|
2
3
|
|
3
|
-
|
4
|
+
=== 0.0.7 2007-03-15
|
5
|
+
* Applied patch from Kevin Clark which does the following:
|
6
|
+
* New method to the instances.rb to allow for issuing a reboot command to an EC2 instance.
|
7
|
+
* New Mocha based tests (Mocha test suite must be installed to run tests. 'sudo gem install mocha')
|
8
|
+
* Cleanup of the test directory.
|
9
|
+
* Applied patch from Randy Bias related to CGI escaping error. From his notes:
|
10
|
+
|
11
|
+
I finally figured out what was going on. It was a compound problem. The first being that you can't CGI::encode the UserData early. You have to just Base64 encode it. Unfortunately, when you Base64 encode it, it means that some encodings will be padded with extra chars, specifically the '=', but &, ? and = get stripped by EC2.canonial_string. So if a Base64 encoding has trailing ='s for padding, these get stripped and then you sign the UserData Base64 payload sans the padding. But it looks like Amazon's side is doing the right thing and is signing the padding. So, the signatures mis-match.
|
12
|
+
|
13
|
+
I've got the complete patch here and it's about as elegant/clean as I could make it in a short period of time. It's a little tough to strip those equal signs when there are so many in the URI. I think this works pretty well, though. I'm splitting the URI on '&', then for each field ripping out all '&' and '?' and only the first '='. Then stitching it back together.
|
14
|
+
|
15
|
+
|
16
|
+
=== 0.0.6 2007-03-02
|
17
|
+
* Patched instances.rb with a bugfix and patch provided by Randy Bias (Thanks Randy!).
|
18
|
+
Only minimally tested so please let me know if this causes any problems for anyone.
|
19
|
+
|
20
|
+
From his notes:
|
21
|
+
I wanted to let you know that there appears to be a bug in how user data is passed. In
|
22
|
+
instances.rb the line that creates the base64 encoded package of user data is as follows:
|
23
|
+
|
24
|
+
userData = CGI::escape(Base64.encode64(in_params[:userData]).strip())
|
25
|
+
|
26
|
+
This may have worked prior, but at least right now the
|
27
|
+
CGI::escape appears to cause a breakage. More specifically it
|
28
|
+
turns something like this (the actual base64 encoded string):
|
29
|
+
|
30
|
+
YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh
|
31
|
+
eHh4eHh4eHh4eHh4eHh4eHh4eHgg
|
32
|
+
|
33
|
+
Into this:
|
34
|
+
|
35
|
+
YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh%
|
36
|
+
0AeHh4eHh4eHh4eHh4eHh4eHh4eHgg
|
37
|
+
|
38
|
+
And it looks like EC2 chokes on the %0, which is CGI::escape's
|
39
|
+
way for handling an EOL. Unfortunately, the Base64.encode64 (at
|
40
|
+
least in my 1.8.5 version of Ruby) inserts a EOL at every 47 chars,
|
41
|
+
no matter what:
|
42
|
+
|
43
|
+
---
|
44
|
+
[randyb@master randyb] cat /tmp/foo.rb
|
45
|
+
#!/usr/bin/env ruby
|
46
|
+
#
|
47
|
+
require 'rubygems'
|
48
|
+
require_gem 'amazon-ec2'
|
49
|
+
require 'getoptlong'
|
50
|
+
puts Base64.encode64
|
51
|
+
("012345678901234567890123456789012345678901234567890123456789")
|
52
|
+
|
53
|
+
[randyb@master randyb] /tmp/foo.rb
|
54
|
+
MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0
|
55
|
+
NTY3ODkwMTIzNDU2Nzg5
|
56
|
+
---
|
57
|
+
|
58
|
+
The best way to handle this is to strip the CRLFs/EOLs before passing to CGI.escape.
|
59
|
+
|
60
|
+
|
61
|
+
=== 0.0.5 2006-12-21
|
62
|
+
* Changes to home page documentation and example files to indicate that you
|
63
|
+
should use 'require_gem' instead of a simple require. Not sure if this
|
64
|
+
is a result of something I am doing in the packaging of the gem that is
|
65
|
+
incorrect or if this is right and proper. I will investigate further.
|
66
|
+
* Patched instances.rb run_instances method to allow for submission of
|
67
|
+
user data with the command to start an instance. Patch submitted
|
68
|
+
anonymously on RubyForge. This had not been functionally implemented
|
69
|
+
in the Amazon Web Services sample library prior to this patch.
|
70
|
+
* Added simple framework for adding unit tests for the library under test dir.
|
71
|
+
No functional unit tests exist yet.
|
72
|
+
|
73
|
+
=== 0.0.4 2006-12-21
|
74
|
+
* Applied patch from Kevin Clark to svn version 7. Thanks for the
|
75
|
+
patch and the description Kevin! Please report if you
|
76
|
+
encounter any issues with this patched version. Here is Kevin's
|
77
|
+
description which I requested : "It helps me to think of modules as boxes full of classes and
|
78
|
+
methods. REXML is a module which holds various classes related to parsing XML
|
79
|
+
including REXML::Node, REXML::Document and REXML::XPath. When you
|
80
|
+
include a module it takes everything out of the box and places it in
|
81
|
+
the local context. So, when you include REXML in the global namespace
|
82
|
+
on line 27 of EC2.rb, it includes classes called Node, Document and XPath in the
|
83
|
+
global object space. This means that I can't have a class called Node
|
84
|
+
in my own project (which I do). The library would be a much better
|
85
|
+
neighbor if it instead accessed the REXML::Document and REXML::XPath
|
86
|
+
classes explicitly through the module."
|
87
|
+
|
88
|
+
=== 0.0.3 2006-12-16
|
89
|
+
* API CHANGE : Changed method name 'authorize' to 'authorize_security_group_ingress' to ensure consistent
|
90
|
+
naming of Ruby library methods to match AWS EC2 API actions. Alias to 'authorize' for backwards compatibility.
|
91
|
+
* API CHANGE : Changed method name 'revoke' to 'revoke_security_group_ingress' to ensure consistent
|
92
|
+
naming of Ruby library methods to match AWS EC2 API actions. Alias to 'revoke' for backwards compatibility.
|
93
|
+
* API CHANGE : Changed method name 'delete_securitygroup' to 'delete_security_group' to ensure consistent
|
94
|
+
naming of Ruby library methods to match AWS EC2 API actions. Alias to 'delete_securitygroup' for backwards compatibility.
|
95
|
+
* API CHANGE : Changed method name 'describe_securitygroups' to 'describe_security_group' to ensure consistent
|
96
|
+
naming of Ruby library methods to match AWS EC2 API actions. Alias to 'describe_securitygroups' for backwards compatibility.
|
97
|
+
* API CHANGE : Changed method name 'create_securitygroup' to 'create_security_group' to ensure consistent
|
98
|
+
naming of Ruby library methods to match AWS EC2 API actions. Alias to 'create_securitygroup' for backwards compatibility.
|
99
|
+
* Added many API rdoc's, some method descriptions copied from Amazon Query API Developer Guide.
|
100
|
+
* Extracted some parts of the formerly monolithic EC2 library out into separate files for manageability.
|
101
|
+
* Changed the HTTP 'User-Agent' string used for each request so that we have our own user agent
|
102
|
+
to identify this library's calls. Now set the version # in the user agent string based on the
|
103
|
+
master version number for this library which is stored in lib/EC2/version.rb and should only
|
104
|
+
be defined in one place.
|
105
|
+
* Set @http.verify_mode = OpenSSL::SSL::VERIFY_NONE to avoid seeing SSL Cert warning
|
106
|
+
"warning: peer certificate won't be verified in this SSL session". File EC2.rb:96
|
107
|
+
* Make 'pathlist' utility method a private method (EC2.rb:111). No reason I can see for this to be exposed.
|
108
|
+
|
109
|
+
=== 0.0.2 2006-12-14
|
110
|
+
* Bugfix in run_instances method. Method works now. Patch submitted by Stephen Caudill on AWS forums. Thanks!
|
111
|
+
|
112
|
+
=== 0.0.1 2006-12-13
|
113
|
+
* Initial release of the Ruby Gem. This includes the version of the library exactly as provided by
|
114
|
+
Amazon Web Services as example code. No changes or enhancements to that code were made other than
|
115
|
+
packaging it as a Ruby Gem.
|
116
|
+
* RubyForge project created. http://amazon-ec2.rubyforge.org
|
data/License.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2007 Glenn Rempe
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
+
examples/ec2-example.rb
|
1
2
|
History.txt
|
3
|
+
License.txt
|
2
4
|
Manifest.txt
|
3
5
|
README.txt
|
4
|
-
CHANGELOG.txt
|
5
6
|
Rakefile
|
6
|
-
setup.rb
|
7
7
|
lib/EC2.rb
|
8
8
|
lib/EC2/version.rb
|
9
9
|
lib/EC2/responses.rb
|
@@ -12,9 +12,13 @@ lib/EC2/instances.rb
|
|
12
12
|
lib/EC2/keypairs.rb
|
13
13
|
lib/EC2/image_attributes.rb
|
14
14
|
lib/EC2/security_groups.rb
|
15
|
-
|
16
|
-
|
15
|
+
scripts/txt2html
|
16
|
+
setup.rb
|
17
|
+
test/test_EC2.rb
|
17
18
|
test/test_helper.rb
|
18
19
|
test/test_responses.rb
|
19
|
-
|
20
|
-
|
20
|
+
website/index.html
|
21
|
+
website/index.txt
|
22
|
+
website/javascripts/rounded_corners_lite.inc.js
|
23
|
+
website/stylesheets/screen.css
|
24
|
+
website/template.rhtml
|
data/Rakefile
CHANGED
@@ -8,6 +8,7 @@ require 'rake/rdoctask'
|
|
8
8
|
require 'rake/contrib/rubyforgepublisher'
|
9
9
|
require 'fileutils'
|
10
10
|
require 'hoe'
|
11
|
+
|
11
12
|
include FileUtils
|
12
13
|
require File.join(File.dirname(__FILE__), 'lib', 'EC2', 'version')
|
13
14
|
|
@@ -15,21 +16,48 @@ AUTHOR = ["Amazon Web Services LLC", "Glenn Rempe"] # can also be an array of A
|
|
15
16
|
EMAIL = "grempe@rubyforge.org"
|
16
17
|
DESCRIPTION = "An interface library that allows Ruby or Ruby on Rails applications to easily connect to the HTTP 'Query API' for the Amazon Web Services Elastic Compute Cloud (EC2) and manipulate server instances."
|
17
18
|
GEM_NAME = "amazon-ec2" # what ppl will type to install your gem
|
18
|
-
|
19
|
+
|
20
|
+
@config_file = "~/.rubyforge/user-config.yml"
|
21
|
+
@config = nil
|
22
|
+
def rubyforge_username
|
23
|
+
unless @config
|
24
|
+
begin
|
25
|
+
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
26
|
+
rescue
|
27
|
+
puts <<-EOS
|
28
|
+
ERROR: No rubyforge config file found: #{@config_file}"
|
29
|
+
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
30
|
+
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
31
|
+
EOS
|
32
|
+
exit
|
33
|
+
end
|
34
|
+
end
|
35
|
+
@rubyforge_username ||= @config["username"]
|
36
|
+
end
|
37
|
+
|
38
|
+
RUBYFORGE_PROJECT = 'amazon-ec2' # The unix name for your project
|
19
39
|
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
40
|
+
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
20
41
|
RELEASE_TYPES = %w( gem ) # can use: gem, tar, zip
|
21
42
|
|
22
|
-
|
23
43
|
NAME = "amazon-ec2"
|
24
|
-
REV = nil
|
25
|
-
|
26
|
-
|
27
|
-
|
44
|
+
REV = nil
|
45
|
+
# UNCOMMENT IF REQUIRED:
|
46
|
+
# REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
|
47
|
+
VERS = EC2::VERSION::STRING + (REV ? ".#{REV}" : "")
|
48
|
+
CLEAN.include ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']
|
49
|
+
RDOC_OPTS = ['--quiet', '--title', 'Amazon EC2 documentation',
|
28
50
|
"--opname", "index.html",
|
29
51
|
"--line-numbers",
|
30
52
|
"--main", "README.txt",
|
31
53
|
"--inline-source"]
|
32
54
|
|
55
|
+
class Hoe
|
56
|
+
def extra_deps
|
57
|
+
@extra_deps.reject { |x| Array(x).first == 'hoe' }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
33
61
|
# Generate all the Rake tasks
|
34
62
|
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
35
63
|
hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
@@ -41,17 +69,64 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
|
41
69
|
p.summary = DESCRIPTION
|
42
70
|
p.url = HOMEPATH
|
43
71
|
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
44
|
-
p.test_globs = ["test
|
72
|
+
p.test_globs = ["test/**/test_*.rb"]
|
45
73
|
p.clean_globs = CLEAN #An array of file patterns to delete on clean.
|
46
74
|
|
75
|
+
# == Optional
|
76
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
77
|
+
#p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
|
78
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
47
79
|
p.spec_extras = {
|
48
|
-
:extra_rdoc_files => ["README.txt", "History.txt"
|
80
|
+
:extra_rdoc_files => ["README.txt", "History.txt"],
|
49
81
|
:rdoc_options => RDOC_OPTS,
|
50
82
|
:autorequire => "EC2"
|
51
83
|
}
|
52
84
|
|
53
|
-
# == Optional
|
54
|
-
#p.changes - A description of the release's latest changes.
|
55
|
-
#p.extra_deps - An array of rubygem dependencies.
|
56
|
-
#p.spec_extras - A hash of extra values to set in the gemspec.
|
57
85
|
end
|
86
|
+
|
87
|
+
CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\n\n")
|
88
|
+
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
89
|
+
hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
90
|
+
|
91
|
+
desc 'Generate website files'
|
92
|
+
task :website_generate do
|
93
|
+
Dir['website/**/*.txt'].each do |txt|
|
94
|
+
sh %{ ruby scripts/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
desc 'Upload website files to rubyforge'
|
99
|
+
task :website_upload do
|
100
|
+
host = "#{rubyforge_username}@rubyforge.org"
|
101
|
+
remote_dir = "/var/www/gforge-projects/#{PATH}/"
|
102
|
+
local_dir = 'website'
|
103
|
+
sh %{rsync -av #{local_dir}/ #{host}:#{remote_dir}}
|
104
|
+
end
|
105
|
+
|
106
|
+
desc 'Generate and upload website files'
|
107
|
+
task :website => [:website_generate, :website_upload]
|
108
|
+
|
109
|
+
desc 'Release the website and new gem version'
|
110
|
+
task :deploy => [:check_version, :website, :release] do
|
111
|
+
puts "Remember to create SVN tag:"
|
112
|
+
puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
|
113
|
+
"svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
|
114
|
+
puts "Suggested comment:"
|
115
|
+
puts "Tagging release #{CHANGES}"
|
116
|
+
end
|
117
|
+
|
118
|
+
desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
|
119
|
+
task :local_deploy => [:website_generate, :install_gem]
|
120
|
+
|
121
|
+
task :check_version do
|
122
|
+
unless ENV['VERSION']
|
123
|
+
puts 'Must pass a VERSION=x.y.z release version'
|
124
|
+
exit
|
125
|
+
end
|
126
|
+
unless ENV['VERSION'] == VERS
|
127
|
+
puts "Please update your version.rb to match the release version, currently #{VERS}"
|
128
|
+
exit
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
|
data/examples/ec2-example.rb
CHANGED
@@ -23,6 +23,9 @@ SECURITY_GROUP_NAME = "ec2-example-rb-test-group"
|
|
23
23
|
|
24
24
|
conn = EC2::AWSAuthConnection.new(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
|
25
25
|
|
26
|
+
puts "----- GEM Version -----"
|
27
|
+
puts EC2::VERSION::STRING
|
28
|
+
|
26
29
|
puts "----- listing images -----"
|
27
30
|
puts conn.describe_images()
|
28
31
|
|
data/lib/EC2.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Amazon Web Services EC2 Query API Ruby Library
|
2
2
|
# This library has been packaged as a Ruby Gem
|
3
|
-
# by Glenn Rempe (
|
3
|
+
# by Glenn Rempe ( grempe @nospam@ rubyforge.org ).
|
4
4
|
#
|
5
5
|
# Source code and gem hosted on RubyForge
|
6
6
|
# under the Ruby License as of 12/14/2006:
|
data/lib/EC2/image_attributes.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Amazon Web Services EC2 Query API Ruby Library
|
2
2
|
# This library has been packaged as a Ruby Gem
|
3
|
-
# by Glenn Rempe (
|
3
|
+
# by Glenn Rempe ( grempe @nospam@ rubyforge.org ).
|
4
4
|
#
|
5
5
|
# Source code and gem hosted on RubyForge
|
6
6
|
# under the Ruby License as of 12/14/2006:
|
data/lib/EC2/images.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Amazon Web Services EC2 Query API Ruby Library
|
2
2
|
# This library has been packaged as a Ruby Gem
|
3
|
-
# by Glenn Rempe (
|
3
|
+
# by Glenn Rempe ( grempe @nospam@ rubyforge.org ).
|
4
4
|
#
|
5
5
|
# Source code and gem hosted on RubyForge
|
6
6
|
# under the Ruby License as of 12/14/2006:
|
data/lib/EC2/instances.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Amazon Web Services EC2 Query API Ruby Library
|
2
2
|
# This library has been packaged as a Ruby Gem
|
3
|
-
# by Glenn Rempe (
|
3
|
+
# by Glenn Rempe ( grempe @nospam@ rubyforge.org ).
|
4
4
|
#
|
5
5
|
# Source code and gem hosted on RubyForge
|
6
6
|
# under the Ruby License as of 12/14/2006:
|
data/lib/EC2/keypairs.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Amazon Web Services EC2 Query API Ruby Library
|
2
2
|
# This library has been packaged as a Ruby Gem
|
3
|
-
# by Glenn Rempe (
|
3
|
+
# by Glenn Rempe ( grempe @nospam@ rubyforge.org ).
|
4
4
|
#
|
5
5
|
# Source code and gem hosted on RubyForge
|
6
6
|
# under the Ruby License as of 12/14/2006:
|
data/lib/EC2/responses.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Amazon Web Services EC2 Query API Ruby Library
|
2
2
|
# This library has been packaged as a Ruby Gem
|
3
|
-
# by Glenn Rempe (
|
3
|
+
# by Glenn Rempe ( grempe @nospam@ rubyforge.org ).
|
4
4
|
#
|
5
5
|
# Source code and gem hosted on RubyForge
|
6
6
|
# under the Ruby License as of 12/14/2006:
|
data/lib/EC2/security_groups.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Amazon Web Services EC2 Query API Ruby Library
|
2
2
|
# This library has been packaged as a Ruby Gem
|
3
|
-
# by Glenn Rempe (
|
3
|
+
# by Glenn Rempe ( grempe @nospam@ rubyforge.org ).
|
4
4
|
#
|
5
5
|
# Source code and gem hosted on RubyForge
|
6
6
|
# under the Ruby License as of 12/14/2006:
|
data/lib/EC2/version.rb
CHANGED
data/scripts/txt2html
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'redcloth'
|
5
|
+
require 'syntax/convertors/html'
|
6
|
+
require 'erb'
|
7
|
+
require File.dirname(__FILE__) + '/../lib/EC2/version.rb'
|
8
|
+
|
9
|
+
version = EC2::VERSION::STRING
|
10
|
+
download = 'http://rubyforge.org/projects/amazon-ec2'
|
11
|
+
|
12
|
+
class Fixnum
|
13
|
+
def ordinal
|
14
|
+
# teens
|
15
|
+
return 'th' if (10..19).include?(self % 100)
|
16
|
+
# others
|
17
|
+
case self % 10
|
18
|
+
when 1: return 'st'
|
19
|
+
when 2: return 'nd'
|
20
|
+
when 3: return 'rd'
|
21
|
+
else return 'th'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class Time
|
27
|
+
def pretty
|
28
|
+
return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def convert_syntax(syntax, source)
|
33
|
+
return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
|
34
|
+
end
|
35
|
+
|
36
|
+
if ARGV.length >= 1
|
37
|
+
src, template = ARGV
|
38
|
+
template ||= File.dirname(__FILE__) + '/../website/template.rhtml'
|
39
|
+
|
40
|
+
else
|
41
|
+
puts("Usage: #{File.split($0).last} source.txt [template.rhtml] > output.html")
|
42
|
+
exit!
|
43
|
+
end
|
44
|
+
|
45
|
+
template = ERB.new(File.open(template).read)
|
46
|
+
|
47
|
+
title = nil
|
48
|
+
body = nil
|
49
|
+
File.open(src) do |fsrc|
|
50
|
+
title_text = fsrc.readline
|
51
|
+
body_text = fsrc.read
|
52
|
+
syntax_items = []
|
53
|
+
body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</>!m){
|
54
|
+
ident = syntax_items.length
|
55
|
+
element, syntax, source = $1, $2, $3
|
56
|
+
syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
|
57
|
+
"syntax-temp-#{ident}"
|
58
|
+
}
|
59
|
+
title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
|
60
|
+
body = RedCloth.new(body_text).to_html
|
61
|
+
body.gsub!(%r!(?:<pre><code>)?syntax-temp-(d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
|
62
|
+
end
|
63
|
+
stat = File.stat(src)
|
64
|
+
created = stat.ctime
|
65
|
+
modified = stat.mtime
|
66
|
+
|
67
|
+
$stdout << template.result(binding)
|