ymdt 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +47 -0
- data/VERSION +1 -0
- data/lib/ymdt.rb +123 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/ymdt_spec.rb +138 -0
- data/ymdt.gemspec +58 -0
- metadata +86 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Jeff Coleman
|
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/README.rdoc
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
= ymdt
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
+
* Send me a pull request. Bonus points for topic branches.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2010 Jeff Coleman. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "ymdt"
|
8
|
+
gem.summary = %Q{Wrapper for Yahoo! Mail Development Tool}
|
9
|
+
gem.description = %Q{Wrapper for Yahoo! Mail Development Tool, handles deploying applications to Yahoo! Mail Development Platform.}
|
10
|
+
gem.email = "progressions@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/progressions/ymdt"
|
12
|
+
gem.authors = ["Jeff Coleman"]
|
13
|
+
gem.add_development_dependency "rspec", ">= 1.2.6"
|
14
|
+
gem.add_development_dependency "string_masker", ">= 0"
|
15
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'spec/rake/spectask'
|
23
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
24
|
+
spec.libs << 'lib' << 'spec'
|
25
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
26
|
+
spec.spec_opts = ['-c']
|
27
|
+
end
|
28
|
+
|
29
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
30
|
+
spec.libs << 'lib' << 'spec'
|
31
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
32
|
+
spec.rcov = true
|
33
|
+
end
|
34
|
+
|
35
|
+
task :spec => :check_dependencies
|
36
|
+
|
37
|
+
task :default => :spec
|
38
|
+
|
39
|
+
require 'rake/rdoctask'
|
40
|
+
Rake::RDocTask.new do |rdoc|
|
41
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
42
|
+
|
43
|
+
rdoc.rdoc_dir = 'rdoc'
|
44
|
+
rdoc.title = "ymdt #{version}"
|
45
|
+
rdoc.rdoc_files.include('README*')
|
46
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
47
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/lib/ymdt.rb
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'string_masker'
|
3
|
+
|
4
|
+
module YMDT
|
5
|
+
class System
|
6
|
+
def self.execute(command, params={})
|
7
|
+
if params[:return]
|
8
|
+
`#{command}`
|
9
|
+
else
|
10
|
+
system command
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Base
|
16
|
+
attr_accessor :username, :password, :applications_path, :script_path
|
17
|
+
|
18
|
+
def initialize(params={})
|
19
|
+
@username = params[:username]
|
20
|
+
@password = params[:password]
|
21
|
+
@applications_path = params[:applications_path] || "./servers"
|
22
|
+
|
23
|
+
unless @username
|
24
|
+
raise ArgumentError.new("username required")
|
25
|
+
end
|
26
|
+
unless @password
|
27
|
+
raise ArgumentError.new("password required")
|
28
|
+
end
|
29
|
+
@script_path = params[:script_path] || "./script/ymdt"
|
30
|
+
end
|
31
|
+
|
32
|
+
def put(params={})
|
33
|
+
invoke(:put, params)
|
34
|
+
end
|
35
|
+
|
36
|
+
def get(params={})
|
37
|
+
invoke(:get, params)
|
38
|
+
end
|
39
|
+
|
40
|
+
def create(params={})
|
41
|
+
raise ArgumentError.new("application_id required") unless params[:application_id]
|
42
|
+
invoke(:get, params)
|
43
|
+
end
|
44
|
+
|
45
|
+
def ls(params={})
|
46
|
+
invoke(:ls, {:return => true}.merge(params))
|
47
|
+
end
|
48
|
+
|
49
|
+
def upgrade(params={})
|
50
|
+
invoke(:upgrade, params)
|
51
|
+
end
|
52
|
+
|
53
|
+
# prepares the commands to correctly reference the application and path
|
54
|
+
#
|
55
|
+
def invoke(command, params={})
|
56
|
+
command_string = compile_command(command, params)
|
57
|
+
output_command(command_string)
|
58
|
+
execute(command_string, params)
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def output_command(command_string)
|
64
|
+
$stdout.puts
|
65
|
+
$stdout.puts StringMasker.new(command_string, :username => username, :password => password).to_s
|
66
|
+
end
|
67
|
+
|
68
|
+
def compile_command(command, params)
|
69
|
+
full_path = nil
|
70
|
+
|
71
|
+
# construct relative path to the application's location in the servers directory
|
72
|
+
#
|
73
|
+
if params[:application]
|
74
|
+
full_path = "#{applications_path}/" << params[:application]
|
75
|
+
full_path = full_path << "/" << params[:path] if params[:path]
|
76
|
+
end
|
77
|
+
|
78
|
+
# construct command line
|
79
|
+
#
|
80
|
+
options = []
|
81
|
+
|
82
|
+
# execute script
|
83
|
+
#
|
84
|
+
options << script_path
|
85
|
+
|
86
|
+
# command (:put, :get, etc)
|
87
|
+
#
|
88
|
+
options << command
|
89
|
+
|
90
|
+
# path
|
91
|
+
#
|
92
|
+
options << "\"#{full_path}\"" if full_path
|
93
|
+
|
94
|
+
# optional sync flag MUST BE PLACED HERE
|
95
|
+
#
|
96
|
+
options << "-s" if params[:sync]
|
97
|
+
|
98
|
+
# optional application ID flag
|
99
|
+
#
|
100
|
+
options << "-a#{params[:application_id]}" if params[:application_id]
|
101
|
+
|
102
|
+
# username and password
|
103
|
+
|
104
|
+
options << "-u#{username}"
|
105
|
+
options << "-p#{password}"
|
106
|
+
|
107
|
+
options.join(" ")
|
108
|
+
end
|
109
|
+
|
110
|
+
# execute the command, or not, and return the results, or not
|
111
|
+
#
|
112
|
+
def execute(command, params={})
|
113
|
+
unless params[:dry_run]
|
114
|
+
if params[:return]
|
115
|
+
System.execute(command, :return => true)
|
116
|
+
else
|
117
|
+
$stdout.puts
|
118
|
+
System.execute(command)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
data/spec/ymdt_spec.rb
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "YMDT" do
|
4
|
+
before(:each) do
|
5
|
+
$stdout.stub!(:puts)
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "instantiation" do
|
9
|
+
it "should raise error without a username and password" do
|
10
|
+
lambda {
|
11
|
+
YMDT::Base.new()
|
12
|
+
}.should raise_error(ArgumentError)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should raise error without a username" do
|
16
|
+
lambda {
|
17
|
+
YMDT::Base.new(:password => "password")
|
18
|
+
}.should raise_error(ArgumentError)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should raise error without a password" do
|
22
|
+
lambda {
|
23
|
+
YMDT::Base.new(:username => "fred")
|
24
|
+
}.should raise_error(ArgumentError)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should not raise error with a username and password" do
|
28
|
+
lambda {
|
29
|
+
YMDT::Base.new(:username => "fred", :password => "password")
|
30
|
+
}.should_not raise_error(ArgumentError)
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "instance variables" do
|
34
|
+
before(:each) do
|
35
|
+
@script_path = "./path/to/ymdt"
|
36
|
+
@username = "fred"
|
37
|
+
@password = "password"
|
38
|
+
@ymdt = YMDT::Base.new(:username => @username, :password => @password, :script_path => @script_path)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should set username" do
|
42
|
+
@ymdt.username.should == @username
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should set password" do
|
46
|
+
@ymdt.password.should == @password
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should set script_path" do
|
50
|
+
@ymdt.script_path.should == @script_path
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "invoke" do
|
56
|
+
before(:each) do
|
57
|
+
YMDT::System.stub!(:execute)
|
58
|
+
@ymdt = YMDT::Base.new(:username => "fred", :password => "password", :script_path => "./path/to/ymdt")
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should execute command" do
|
62
|
+
YMDT::System.should_receive(:execute).with("./path/to/ymdt put \"./servers/app\" -ufred -ppassword")
|
63
|
+
@ymdt.invoke(:put, :application => "app")
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should add sync flag" do
|
67
|
+
YMDT::System.should_receive(:execute).with("./path/to/ymdt put \"./servers/app\" -s -ufred -ppassword")
|
68
|
+
@ymdt.invoke(:put, :application => "app", :sync => true)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should put a path" do
|
72
|
+
YMDT::System.should_receive(:execute).with("./path/to/ymdt put \"./servers/app/views\" -ufred -ppassword")
|
73
|
+
@ymdt.invoke(:put, :application => "app", :path => "views")
|
74
|
+
end
|
75
|
+
|
76
|
+
it "shouldn't add extra slashes" do
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "shortcut methods" do
|
80
|
+
it "should put" do
|
81
|
+
YMDT::System.should_receive(:execute).with("./path/to/ymdt put \"./servers/app\" -ufred -ppassword")
|
82
|
+
@ymdt.put(:application => "app")
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should get" do
|
86
|
+
YMDT::System.should_receive(:execute).with("./path/to/ymdt get \"./servers/app\" -ufred -ppassword")
|
87
|
+
@ymdt.get(:application => "app")
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should create" do
|
91
|
+
YMDT::System.should_receive(:execute).with("./path/to/ymdt get \"./servers/app\" -a12345 -ufred -ppassword")
|
92
|
+
@ymdt.create(:application_id => "12345", :application => "app")
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should ls" do
|
96
|
+
YMDT::System.should_receive(:execute).with("./path/to/ymdt ls \"./servers/app\" -ufred -ppassword", :return => true)
|
97
|
+
@ymdt.ls(:application => "app")
|
98
|
+
end
|
99
|
+
|
100
|
+
it "ls should return results" do
|
101
|
+
@results = "These are the results."
|
102
|
+
YMDT::System.stub!(:execute).with(anything, :return => true).and_return(@results)
|
103
|
+
@ymdt.ls(:application => "app").should == @results
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe "dry run" do
|
108
|
+
it "should not execute anything for a dry run" do
|
109
|
+
YMDT::System.should_not_receive(:execute)
|
110
|
+
@ymdt.invoke(:put, :application => "app", :dry_run => true)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe "return results" do
|
115
|
+
before(:each) do
|
116
|
+
@results = "These are the results."
|
117
|
+
YMDT::System.stub!(:execute).with(anything, :return => true).and_return(@results)
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should return results from YMDT::System" do
|
121
|
+
YMDT::System.should_receive(:execute).with(anything, :return => true)
|
122
|
+
@ymdt.invoke(:put, :application => "app", :return => true)
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should return results" do
|
126
|
+
@ymdt.invoke(:put, :application => "app", :return => true).should == @results
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe "output" do
|
131
|
+
it "should not print username and password" do
|
132
|
+
$stdout.should_receive(:puts).with("./path/to/ymdt put \"./servers/app\" -u[username] -p[password]")
|
133
|
+
@ymdt.invoke(:put, :application => "app")
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
data/ymdt.gemspec
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{ymdt}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Jeff Coleman"]
|
12
|
+
s.date = %q{2010-01-13}
|
13
|
+
s.description = %q{Wrapper for Yahoo! Mail Development Tool, handles deploying applications to Yahoo! Mail Development Platform.}
|
14
|
+
s.email = %q{progressions@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"lib/ymdt.rb",
|
27
|
+
"spec/spec.opts",
|
28
|
+
"spec/spec_helper.rb",
|
29
|
+
"spec/ymdt_spec.rb",
|
30
|
+
"ymdt.gemspec"
|
31
|
+
]
|
32
|
+
s.homepage = %q{http://github.com/progressions/ymdt}
|
33
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
34
|
+
s.require_paths = ["lib"]
|
35
|
+
s.rubygems_version = %q{1.3.5}
|
36
|
+
s.summary = %q{Wrapper for Yahoo! Mail Development Tool}
|
37
|
+
s.test_files = [
|
38
|
+
"spec/spec_helper.rb",
|
39
|
+
"spec/ymdt_spec.rb"
|
40
|
+
]
|
41
|
+
|
42
|
+
if s.respond_to? :specification_version then
|
43
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
44
|
+
s.specification_version = 3
|
45
|
+
|
46
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
47
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.6"])
|
48
|
+
s.add_development_dependency(%q<string_masker>, [">= 0"])
|
49
|
+
else
|
50
|
+
s.add_dependency(%q<rspec>, [">= 1.2.6"])
|
51
|
+
s.add_dependency(%q<string_masker>, [">= 0"])
|
52
|
+
end
|
53
|
+
else
|
54
|
+
s.add_dependency(%q<rspec>, [">= 1.2.6"])
|
55
|
+
s.add_dependency(%q<string_masker>, [">= 0"])
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ymdt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeff Coleman
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-01-13 00:00:00 -06:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.2.6
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: string_masker
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
description: Wrapper for Yahoo! Mail Development Tool, handles deploying applications to Yahoo! Mail Development Platform.
|
36
|
+
email: progressions@gmail.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README.rdoc
|
44
|
+
files:
|
45
|
+
- .document
|
46
|
+
- .gitignore
|
47
|
+
- LICENSE
|
48
|
+
- README.rdoc
|
49
|
+
- Rakefile
|
50
|
+
- VERSION
|
51
|
+
- lib/ymdt.rb
|
52
|
+
- spec/spec.opts
|
53
|
+
- spec/spec_helper.rb
|
54
|
+
- spec/ymdt_spec.rb
|
55
|
+
- ymdt.gemspec
|
56
|
+
has_rdoc: true
|
57
|
+
homepage: http://github.com/progressions/ymdt
|
58
|
+
licenses: []
|
59
|
+
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options:
|
62
|
+
- --charset=UTF-8
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: "0"
|
70
|
+
version:
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: "0"
|
76
|
+
version:
|
77
|
+
requirements: []
|
78
|
+
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 1.3.5
|
81
|
+
signing_key:
|
82
|
+
specification_version: 3
|
83
|
+
summary: Wrapper for Yahoo! Mail Development Tool
|
84
|
+
test_files:
|
85
|
+
- spec/spec_helper.rb
|
86
|
+
- spec/ymdt_spec.rb
|