railsrumble-rumble-tools 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +20 -0
- data/README.rdoc +33 -0
- data/bin/rumble +102 -0
- data/config/rumble.yml +4 -0
- data/lib/rails_rumble/git.rb +30 -0
- data/lib/rails_rumble/network_helpers.rb +54 -0
- data/lib/rails_rumble/tumble.rb +26 -0
- data/lib/rails_rumble/tweet.rb +18 -0
- data/lib/rumble-tools.rb +84 -0
- data/test/rumble_tools_test.rb +7 -0
- data/test/test_helper.rb +9 -0
- metadata +76 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Darcy Laycock
|
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,33 @@
|
|
1
|
+
= RailsRumble Tools
|
2
|
+
|
3
|
+
A few example uses:
|
4
|
+
|
5
|
+
1. rumble identify <api-key>
|
6
|
+
|
7
|
+
Given your api key (available from the rails rumble website),
|
8
|
+
identify will store it and download an initial set of user details
|
9
|
+
from the website.
|
10
|
+
|
11
|
+
2. rumble clone [optional-path-to-repo]
|
12
|
+
|
13
|
+
After rumble identify, rumble clone will attempt to clone the git
|
14
|
+
repository (with the correct remote repository).
|
15
|
+
|
16
|
+
3. rumble tag
|
17
|
+
|
18
|
+
This task will apply the correct tag to your repository and, if the
|
19
|
+
correct remote exists, it will then push said tag to github. Once done,
|
20
|
+
it will attempt to very the tag was set correctly. NOTE: it uses head
|
21
|
+
(the currently checked out tag).
|
22
|
+
|
23
|
+
4. rumble verify
|
24
|
+
|
25
|
+
Attempts to verify the following criteria related to your submission
|
26
|
+
being valid:
|
27
|
+
A) The release is tagged and the correct tag is stored.
|
28
|
+
B) Your vps is accessible
|
29
|
+
C) Your page is accessible via the correct urls
|
30
|
+
|
31
|
+
== Copyright
|
32
|
+
|
33
|
+
Copyright (c) 2009 Darcy Laycock. See LICENSE for details.
|
data/bin/rumble
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'thor'
|
5
|
+
require 'readline'
|
6
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'rumble-tools')
|
7
|
+
|
8
|
+
class RumbleTools < Thor
|
9
|
+
|
10
|
+
map "twitter:setup" => :twitter_setup
|
11
|
+
map "tumblr:setup" => :tumblr_setup
|
12
|
+
|
13
|
+
# Twitter Tasks
|
14
|
+
desc "twitter:setup","setup your twitter information"
|
15
|
+
def twitter_setup
|
16
|
+
RailsRumble.update_user_config!(:twitter_username => (ask "Twitter Username:"), :twitter_password => (ask "Twitter Password:"))
|
17
|
+
puts "Twitter account set up"
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "tweet", "tweet an update on your application"
|
21
|
+
def tweet
|
22
|
+
puts RailsRumble.twitter.post_tweet(ask("Message:")) ? "Successfully posted to Twitter" : "Unable to post to Twitter"
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
# Tumblr Tasks
|
27
|
+
desc "tumblr:setup", "set up your tumblr information"
|
28
|
+
def tumblr_setup
|
29
|
+
RailsRumble.update_user_config!(:tumblr_url => (ask "Tumblr URL:"), :tumblr_email => (ask "Tumblr Email:"), :tumblr_password => (ask "Tumblr Password:"))
|
30
|
+
puts "Tumblr account set up"
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "tumble", "write a quick post on your progress"
|
34
|
+
def tumble
|
35
|
+
if id = RailsRumble.tumblr.blog
|
36
|
+
puts "Successfully blogged."
|
37
|
+
puts RailsRumble.twitter.post_tweet("Update available at http://#{RailsRumble.user_config.tumblr_url}/post/#{id}") ? "Successfully posted to Twitter" : "Unable to post to Twitter"
|
38
|
+
else
|
39
|
+
puts "Unable to post the blog"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Git Tasks
|
44
|
+
desc "tag", "apply tag to the repository and push to github"
|
45
|
+
def tag
|
46
|
+
RailsRumble.git.tag! RailsRumble.configuration.final_tag
|
47
|
+
puts "Tagged with '#{RailsRumble.configuration.final_tag}' and pushed tags."
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "clone", "Clones the repository, if a path is provided it provides that to git"
|
51
|
+
def clone(path = nil)
|
52
|
+
team_info = RailsRumble.live_configuration["team"]
|
53
|
+
if team_info.nil?
|
54
|
+
puts "You don't appear to be on a team"
|
55
|
+
exit!
|
56
|
+
end
|
57
|
+
repository = team_info["github-repository"]
|
58
|
+
if repository.nil?
|
59
|
+
puts "We were unable to find a repository name - it might not be available yet."
|
60
|
+
exit!
|
61
|
+
end
|
62
|
+
has_path = path.to_s != ""
|
63
|
+
repo_url = "git@github.com:#{RailsRumble.configuration.github_user}/#{repository}.git"
|
64
|
+
puts "Cloning repository #{repo_url} #{has_path ? "to the default directory" : "To #{path.inspect}"}"
|
65
|
+
RailsRumble::Git.new(path).clone(repo_url)
|
66
|
+
init(has_path ? path : repository)
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
# Other Tasks
|
71
|
+
desc "identify [API_KEY]","identify your application and grab rumble information"
|
72
|
+
def identify(api_key)
|
73
|
+
RailsRumble.update_user_config! :api_key => api_key.to_s
|
74
|
+
puts "API Key Saved. Testing"
|
75
|
+
RailsRumble.live_configuration(true)
|
76
|
+
puts "API Key Accepted."
|
77
|
+
end
|
78
|
+
|
79
|
+
desc "init","set the current directory as your application"
|
80
|
+
def init(path = Dir.pwd)
|
81
|
+
RailsRumble.update_user_config! :repository => File.expand_path(path)
|
82
|
+
puts "Repository path '#{path}' stored."
|
83
|
+
end
|
84
|
+
|
85
|
+
protected
|
86
|
+
|
87
|
+
def ask(text = "")
|
88
|
+
Readline.readline("#{text.to_s.strip} ")
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
STDOUT.puts "=== Rumble - Client Tools ==="
|
94
|
+
|
95
|
+
# Check if we have arguments, we run the normal
|
96
|
+
# thor task otherwise we just print the help
|
97
|
+
# message.
|
98
|
+
if ARGV.empty?
|
99
|
+
RumbleTools.new.help
|
100
|
+
else
|
101
|
+
RumbleTools.start
|
102
|
+
end
|
data/config/rumble.yml
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
module RailsRumble
|
2
|
+
class Git
|
3
|
+
|
4
|
+
attr_accessor :repository
|
5
|
+
|
6
|
+
def initialize(path)
|
7
|
+
self.repository = path
|
8
|
+
end
|
9
|
+
|
10
|
+
def tag!(tag_name)
|
11
|
+
git :tag, "-a", tag_name.to_s, "-m", "Created the '#{tag_name.gsub "'", '\\\''''}'"
|
12
|
+
git :push, "--tags"
|
13
|
+
end
|
14
|
+
|
15
|
+
def clone(repo_url)
|
16
|
+
arguments = ["git", "clone", repo_url]
|
17
|
+
arguments << @repository if @repository.to_s != ""
|
18
|
+
system(*arguments)
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
|
23
|
+
def git(command, *args)
|
24
|
+
Dir.chdir(self.repository) do
|
25
|
+
system "git", command.to_s, args.map { |a| a.to_s }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'net/http'
|
3
|
+
require 'yaml'
|
4
|
+
require 'json'
|
5
|
+
require 'ostruct'
|
6
|
+
require 'timeout'
|
7
|
+
require 'xmlsimple'
|
8
|
+
|
9
|
+
module RailsRumble
|
10
|
+
|
11
|
+
module NetworkHelpers
|
12
|
+
extend self
|
13
|
+
|
14
|
+
def get(path, auto_parse = false, format_xml = false, external_service = false)
|
15
|
+
uri = external_service ? URI.parse(path) : default_host.merge(path)
|
16
|
+
res = process_request(uri, Net::HTTP::Get.new(uri.request_uri))
|
17
|
+
autoparse_conditionally(auto_parse, res, format_xml)
|
18
|
+
end
|
19
|
+
|
20
|
+
def post(path, params = {}, auto_parse = false, auth = nil, external_service = false)
|
21
|
+
uri = external_service ? URI.parse(path) : default_host.merge(path)
|
22
|
+
req = Net::HTTP::Post.new(uri.path)
|
23
|
+
req.form_data = params
|
24
|
+
req.basic_auth(auth[:user],auth[:password]) if auth && auth[:user] && auth[:password]
|
25
|
+
res = process_request(uri, req)
|
26
|
+
autoparse_conditionally(auto_parse, res)
|
27
|
+
end
|
28
|
+
|
29
|
+
def default_host
|
30
|
+
@@default_host ||= URI.parse(RailsRumble.configuration.competition_host)
|
31
|
+
end
|
32
|
+
|
33
|
+
def process_request(uri, req)
|
34
|
+
req.basic_auth(uri.user, uri.password) if uri.user
|
35
|
+
res = Net::HTTP.new(uri.host, uri.port).start do |http|
|
36
|
+
http.request(req)
|
37
|
+
end
|
38
|
+
return res
|
39
|
+
end
|
40
|
+
|
41
|
+
def autoparse_conditionally(condition, response, format_xml = false)
|
42
|
+
if condition
|
43
|
+
if format_xml
|
44
|
+
return response.code =~ /^2\d+$/ ? XmlSimple.xml_in(response.body) : nil
|
45
|
+
else
|
46
|
+
return response.code =~ /^2\d+$/ ? JSON.parse(response.body) : nil
|
47
|
+
end
|
48
|
+
else
|
49
|
+
return response
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module RailsRumble
|
2
|
+
class Tumble
|
3
|
+
include RailsRumble::NetworkHelpers
|
4
|
+
|
5
|
+
attr_accessor :url, :email, :password
|
6
|
+
|
7
|
+
def initialize(u,e,p)
|
8
|
+
self.url = u
|
9
|
+
self.email = e
|
10
|
+
self.password = p
|
11
|
+
end
|
12
|
+
|
13
|
+
def blog
|
14
|
+
print "Title: "
|
15
|
+
STDOUT.flush
|
16
|
+
title = STDIN.gets
|
17
|
+
puts "Content: (type DONE to finish):"
|
18
|
+
message = ""
|
19
|
+
while(line=STDIN.gets).chomp != "DONE" do
|
20
|
+
message += line
|
21
|
+
end
|
22
|
+
(p=post('http://www.tumblr.com/api/write',{'type' => 'regular','title' => title,'body'=> message.chomp, 'email' => self.email, 'password' => self.password},false,{}, true)).code =~ /^2\d+$/ ? p.body : nil
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module RailsRumble
|
2
|
+
class Tweet
|
3
|
+
include RailsRumble::NetworkHelpers
|
4
|
+
|
5
|
+
attr_accessor :username, :password
|
6
|
+
|
7
|
+
def initialize(u,p)
|
8
|
+
self.username = u
|
9
|
+
self.password = p
|
10
|
+
end
|
11
|
+
|
12
|
+
def post_tweet(status)
|
13
|
+
status = status + " #railsrumble" if status.length < 127
|
14
|
+
post('http://twitter.com/statuses/update.xml',{'status' => status},false,{:user => self.username, :password => self.password},true).code =~ /^2\d+$/
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
data/lib/rumble-tools.rb
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'thor'
|
5
|
+
|
6
|
+
%w{network_helpers git tumble tweet}.each{|x|require "rails_rumble/#{x}"}
|
7
|
+
|
8
|
+
module RailsRumble
|
9
|
+
|
10
|
+
CONFIG_PATH = File.expand_path("~/.railsrumble.yml")
|
11
|
+
|
12
|
+
class << self
|
13
|
+
|
14
|
+
def live_configuration(force = false)
|
15
|
+
@results = nil if force
|
16
|
+
@results ||= begin
|
17
|
+
if user_config(force).api_key.to_s == ""
|
18
|
+
puts "Please use 'rumble identify YOUR-API-KEY' first to identify yourself."
|
19
|
+
puts "You can find your api key by visiting the rumble website."
|
20
|
+
exit!
|
21
|
+
end
|
22
|
+
results = RailsRumble::NetworkHelpers.get("/users/identity.json?api_key=#{user_config.api_key}", true)
|
23
|
+
if results.has_key?("error")
|
24
|
+
puts "Error Accessing API: #{results["error"]}"
|
25
|
+
exit!
|
26
|
+
else
|
27
|
+
results["details"]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def configuration
|
33
|
+
@configuration ||= OpenStruct.new(YAML.load_file(File.join(File.dirname(__FILE__), "..", "config", "rumble.yml")))
|
34
|
+
end
|
35
|
+
|
36
|
+
def user_configuration(force = false)
|
37
|
+
@user_configuration = nil if force
|
38
|
+
@user_configuration ||= YAML.load_file(CONFIG_PATH) || {}
|
39
|
+
end
|
40
|
+
|
41
|
+
def user_config(force = false)
|
42
|
+
@user_config = nil if force
|
43
|
+
@user_config ||= OpenStruct.new(user_configuration(force))
|
44
|
+
end
|
45
|
+
|
46
|
+
def update_user_config!(params)
|
47
|
+
File.open(CONFIG_PATH, "w+") do |f|
|
48
|
+
f.write user_configuration.merge(params).to_yaml
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def git
|
53
|
+
c = user_config
|
54
|
+
if c.repository
|
55
|
+
return RailsRumble::Git.new(c.repository)
|
56
|
+
else
|
57
|
+
puts "You haven't registered your git repository yet"
|
58
|
+
return nil
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def twitter
|
63
|
+
c = user_config
|
64
|
+
if c.twitter_username && c.twitter_password
|
65
|
+
return RailsRumble::Tweet.new(c.twitter_username,c.twitter_password)
|
66
|
+
else
|
67
|
+
puts "You haven't registered your twitter account yet"
|
68
|
+
return nil
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def tumblr
|
73
|
+
c = user_config
|
74
|
+
if c.tumblr_url && c.tumblr_email && c.tumblr_password
|
75
|
+
return RailsRumble::Tumble.new(c.tumblr_url,c.tumblr_email,c.tumblr_password)
|
76
|
+
else
|
77
|
+
puts "You haven't registered your tumblr account yet"
|
78
|
+
return nil
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: railsrumble-rumble-tools
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Darcy Laycock
|
8
|
+
- Kevin W. Gisi
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2009-08-20 00:00:00 -07:00
|
14
|
+
default_executable: rumble
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: thor
|
18
|
+
type: :runtime
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
version:
|
26
|
+
description:
|
27
|
+
email: sutto@sutto.net
|
28
|
+
executables:
|
29
|
+
- rumble
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files:
|
33
|
+
- LICENSE
|
34
|
+
- README.rdoc
|
35
|
+
files:
|
36
|
+
- bin/rumble
|
37
|
+
- config/rumble.yml
|
38
|
+
- lib/rails_rumble/git.rb
|
39
|
+
- lib/rails_rumble/network_helpers.rb
|
40
|
+
- lib/rails_rumble/tumble.rb
|
41
|
+
- lib/rails_rumble/tweet.rb
|
42
|
+
- lib/rumble-tools.rb
|
43
|
+
- test/rumble_tools_test.rb
|
44
|
+
- test/test_helper.rb
|
45
|
+
- LICENSE
|
46
|
+
- README.rdoc
|
47
|
+
has_rdoc: false
|
48
|
+
homepage: http://github.com/railsrumble/cli-toolkit
|
49
|
+
licenses:
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options:
|
52
|
+
- --charset=UTF-8
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: "0"
|
60
|
+
version:
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: "0"
|
66
|
+
version:
|
67
|
+
requirements: []
|
68
|
+
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 1.3.5
|
71
|
+
signing_key:
|
72
|
+
specification_version: 3
|
73
|
+
summary: Tools for the RailsRumble
|
74
|
+
test_files:
|
75
|
+
- test/rumble_tools_test.rb
|
76
|
+
- test/test_helper.rb
|