jiveapps 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +10 -0
- data/History.txt +8 -0
- data/Manifest.txt +1 -0
- data/Rakefile +17 -3
- data/lib/jiveapps.rb +3 -3
- data/lib/jiveapps/client.rb +21 -31
- data/lib/jiveapps/commands/app.rb +39 -14
- data/lib/jiveapps/commands/auth.rb +1 -1
- data/lib/jiveapps/commands/help.rb +1 -0
- data/spec/spec_helper.rb +1 -1
- metadata +9 -8
data/Gemfile
ADDED
data/History.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
=== 0.0.5 2010-12-06
|
2
|
+
* Bug Fixes
|
3
|
+
* Re-enabled re-authentication
|
4
|
+
* Major Enhancements
|
5
|
+
* Better user feedback when creating apps
|
6
|
+
* Better error reporting
|
7
|
+
* No longer require JSON C extension (no GCC or XCode required)
|
8
|
+
|
1
9
|
=== 0.0.4 2010-11-22
|
2
10
|
* Major enhancements
|
3
11
|
* SSL support
|
data/Manifest.txt
CHANGED
data/Rakefile
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
$LOAD_PATH << './lib'
|
2
|
+
|
1
3
|
require 'rubygems'
|
2
4
|
gem 'hoe', '>= 2.1.0'
|
3
5
|
require 'hoe'
|
4
6
|
require 'fileutils'
|
5
|
-
require '
|
7
|
+
require 'jiveapps'
|
6
8
|
|
7
9
|
Hoe.plugin :newgem
|
8
10
|
# Hoe.plugin :website
|
@@ -14,12 +16,12 @@ $hoe = Hoe.spec 'jiveapps' do
|
|
14
16
|
self.developer 'Scott Becker', 'becker.scott@gmail.com'
|
15
17
|
self.description = "A set of command line tools for creating Jive Apps."
|
16
18
|
self.summary = self.description
|
17
|
-
self.version = "0.0.
|
19
|
+
self.version = "0.0.5"
|
18
20
|
self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
|
19
21
|
self.rubyforge_name = self.name # TODO this is default value
|
20
22
|
self.extra_deps = [
|
21
23
|
['rest-client'],
|
22
|
-
['
|
24
|
+
['json_pure'],
|
23
25
|
['rubigen']
|
24
26
|
]
|
25
27
|
end
|
@@ -66,3 +68,15 @@ RSpec::Core::RakeTask.new('rcov') do |t|
|
|
66
68
|
end
|
67
69
|
|
68
70
|
task :default => :spec
|
71
|
+
|
72
|
+
desc "Fix password"
|
73
|
+
task "fix_pass" do
|
74
|
+
system "rm ~/.jiveapps/credentials"
|
75
|
+
system "cp ~/.jiveapps/credentials_right ~/.jiveapps/credentials"
|
76
|
+
end
|
77
|
+
|
78
|
+
desc "Break password"
|
79
|
+
task "break_pass" do
|
80
|
+
system "rm ~/.jiveapps/credentials"
|
81
|
+
system "cp ~/.jiveapps/credentials_wrong ~/.jiveapps/credentials"
|
82
|
+
end
|
data/lib/jiveapps.rb
CHANGED
data/lib/jiveapps/client.rb
CHANGED
@@ -4,12 +4,8 @@ require 'json'
|
|
4
4
|
|
5
5
|
class Jiveapps::Client
|
6
6
|
|
7
|
-
def self.version
|
8
|
-
'0.0.4'
|
9
|
-
end
|
10
|
-
|
11
7
|
def self.gem_version_string
|
12
|
-
"jiveapps-gem/#{
|
8
|
+
"jiveapps-gem/#{Jiveapps::VERSION}"
|
13
9
|
end
|
14
10
|
|
15
11
|
attr_reader :host, :user, :password
|
@@ -28,7 +24,7 @@ class Jiveapps::Client
|
|
28
24
|
if apps.class == Array
|
29
25
|
apps.map { |item| item['app'] }
|
30
26
|
else
|
31
|
-
return
|
27
|
+
return apps
|
32
28
|
end
|
33
29
|
end
|
34
30
|
|
@@ -41,13 +37,13 @@ class Jiveapps::Client
|
|
41
37
|
end
|
42
38
|
end
|
43
39
|
|
44
|
-
def
|
40
|
+
def post_app(path, obj)
|
45
41
|
begin
|
46
|
-
item = post(
|
42
|
+
item = post(path, obj)
|
47
43
|
if item.class == Hash && item['app']
|
48
44
|
item['app']
|
49
45
|
else
|
50
|
-
|
46
|
+
item
|
51
47
|
end
|
52
48
|
rescue => e
|
53
49
|
if e.response.body =~ /^\{/ # assume this is JSON if it starts with "{"
|
@@ -59,24 +55,16 @@ class Jiveapps::Client
|
|
59
55
|
end
|
60
56
|
end
|
61
57
|
|
62
|
-
def
|
63
|
-
|
58
|
+
def create(name)
|
59
|
+
post_app("/apps", {:app => {:name => name}})
|
60
|
+
end
|
64
61
|
|
65
|
-
|
66
|
-
|
67
|
-
else
|
68
|
-
nil
|
69
|
-
end
|
62
|
+
def register(name)
|
63
|
+
post_app("/apps/#{escape(name)}/register", {})
|
70
64
|
end
|
71
65
|
|
72
66
|
def install(name)
|
73
|
-
|
74
|
-
|
75
|
-
if item.class == Hash && item['app']
|
76
|
-
item['app']
|
77
|
-
else
|
78
|
-
nil
|
79
|
-
end
|
67
|
+
post_app("/apps/#{escape(name)}/install", {})
|
80
68
|
end
|
81
69
|
|
82
70
|
### SSH Keys
|
@@ -134,13 +122,14 @@ class Jiveapps::Client
|
|
134
122
|
def process(method, uri, extra_headers={}, payload=nil)
|
135
123
|
headers = jiveapps_headers.merge(extra_headers)
|
136
124
|
args = [method, payload, headers].compact
|
125
|
+
|
137
126
|
begin
|
138
127
|
response = resource(uri).send(*args)
|
139
|
-
|
140
128
|
extract_warning(response)
|
141
129
|
parse_response(response.to_s)
|
142
|
-
rescue => e
|
143
|
-
puts e.response
|
130
|
+
rescue RestClient::BadRequest => e
|
131
|
+
puts e.response.body
|
132
|
+
return nil
|
144
133
|
end
|
145
134
|
end
|
146
135
|
|
@@ -167,11 +156,12 @@ class Jiveapps::Client
|
|
167
156
|
end
|
168
157
|
|
169
158
|
def escape(value) # :nodoc:
|
170
|
-
### Ugly hack - nginx/passenger unescapes the name before it gets
|
171
|
-
|
172
|
-
|
173
|
-
else # in production mode
|
159
|
+
### Ugly hack - nginx/passenger unescapes the name before it gets
|
160
|
+
### to rails, causing routes to fail. double encode in production
|
161
|
+
if Jiveapps::MODE == 'production'
|
174
162
|
_escape(_escape(value))
|
163
|
+
else
|
164
|
+
_escape(value)
|
175
165
|
end
|
176
166
|
end
|
177
167
|
|
@@ -185,7 +175,7 @@ class Jiveapps::Client
|
|
185
175
|
if uri =~ /^http?/
|
186
176
|
RestClient::Resource.new(uri, user, password)
|
187
177
|
else
|
188
|
-
RestClient::Resource.new(
|
178
|
+
RestClient::Resource.new(host, user, password)[uri]
|
189
179
|
end
|
190
180
|
end
|
191
181
|
|
@@ -3,8 +3,15 @@ module Jiveapps::Command
|
|
3
3
|
|
4
4
|
attr_reader :current_app
|
5
5
|
|
6
|
+
def version
|
7
|
+
display Jiveapps::Client.gem_version_string
|
8
|
+
end
|
9
|
+
|
6
10
|
def list
|
7
|
-
|
11
|
+
jiveapps_list = jiveapps.list
|
12
|
+
return if jiveapps_list.nil?
|
13
|
+
|
14
|
+
formatted_list = jiveapps_list.map do |app|
|
8
15
|
" - " + app['name']
|
9
16
|
end
|
10
17
|
|
@@ -32,8 +39,10 @@ module Jiveapps::Command
|
|
32
39
|
end
|
33
40
|
|
34
41
|
def create
|
35
|
-
|
36
|
-
Jiveapps::Command.run_internal('auth:check', [])
|
42
|
+
debug "Running in debug mode."
|
43
|
+
app_list = Jiveapps::Command.run_internal('auth:check', []) # check auth credentials and ssh key before generating app
|
44
|
+
return unless app_list.class == Array
|
45
|
+
display "Creating new Jive App \"#{app_name}\"..."
|
37
46
|
create_remote_app
|
38
47
|
generate_app
|
39
48
|
create_local_git_repo_and_push_to_remote
|
@@ -42,11 +51,13 @@ module Jiveapps::Command
|
|
42
51
|
end
|
43
52
|
|
44
53
|
def install
|
54
|
+
display "Installing \"#{app_name}\" on the Jive App Sandbox: ", false
|
45
55
|
app = jiveapps.install(app_name)
|
56
|
+
handle_response_errors
|
46
57
|
if app == nil
|
47
58
|
display "App not found."
|
48
59
|
else
|
49
|
-
display "=== #{app['name']}
|
60
|
+
display "=== #{app['name']}"
|
50
61
|
display_app_info(app)
|
51
62
|
end
|
52
63
|
end
|
@@ -65,19 +76,14 @@ module Jiveapps::Command
|
|
65
76
|
end
|
66
77
|
|
67
78
|
def create_remote_app
|
68
|
-
|
79
|
+
display "Step 1 of 4. Check availability and create remote repository: ", false
|
69
80
|
@current_app = jiveapps.create(app_name)
|
70
|
-
|
71
|
-
if @current_app["errors"]["name"]
|
72
|
-
display "Error: Name #{@current_app["errors"]["name"]}"
|
73
|
-
end
|
74
|
-
@current_app = nil
|
75
|
-
end
|
81
|
+
handle_response_errors
|
76
82
|
end
|
77
83
|
|
78
84
|
def generate_app
|
79
85
|
return unless current_app
|
80
|
-
|
86
|
+
display "Step 2 of 4. Generate app scaffolding."
|
81
87
|
|
82
88
|
require 'rubygems'
|
83
89
|
require 'rubigen'
|
@@ -88,7 +94,7 @@ module Jiveapps::Command
|
|
88
94
|
|
89
95
|
def create_local_git_repo_and_push_to_remote
|
90
96
|
return unless current_app
|
91
|
-
|
97
|
+
display "Step 3 of 4. Creating local Git repository and push to remote: ", false
|
92
98
|
|
93
99
|
Dir.chdir(File.join(Dir.pwd, app_name)) do
|
94
100
|
|
@@ -98,13 +104,20 @@ module Jiveapps::Command
|
|
98
104
|
run("git remote add jiveapps #{current_app['git_url']}")
|
99
105
|
run("git push jiveapps master")
|
100
106
|
end
|
107
|
+
|
108
|
+
if $? == 0
|
109
|
+
display "SUCCESS"
|
110
|
+
else
|
111
|
+
display "FAILURE"
|
112
|
+
end
|
101
113
|
end
|
102
114
|
|
103
115
|
def register_app
|
104
116
|
return unless current_app
|
105
|
-
|
117
|
+
display "Step 4 of 4. Registering app on the Jive Apps Dev Center and installing on sandbox: ", false
|
106
118
|
|
107
119
|
@current_app = jiveapps.register(app_name)
|
120
|
+
handle_response_errors
|
108
121
|
end
|
109
122
|
|
110
123
|
def create_notify_user
|
@@ -149,5 +162,17 @@ module Jiveapps::Command
|
|
149
162
|
end
|
150
163
|
end
|
151
164
|
|
165
|
+
def handle_response_errors
|
166
|
+
if @current_app.class == Hash && @current_app["errors"]
|
167
|
+
display "FAILURE"
|
168
|
+
@current_app["errors"].each do |key, value|
|
169
|
+
display "Error on \"#{key}\": #{value}"
|
170
|
+
end
|
171
|
+
@current_app = nil
|
172
|
+
else
|
173
|
+
display "SUCCESS"
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
152
177
|
end
|
153
178
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -13,7 +13,7 @@ Dir["#{File.dirname(__FILE__)}/../lib/jiveapps/commands/*"].each { |c| require c
|
|
13
13
|
require 'jiveapps/client'
|
14
14
|
|
15
15
|
def stub_api_request(method, path)
|
16
|
-
stub_request(method, "
|
16
|
+
stub_request(method, "#{Jiveapps::WEBHOST}#{path}")
|
17
17
|
end
|
18
18
|
|
19
19
|
def prepare_command(klass)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jiveapps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Scott Becker
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-12-06 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
type: :runtime
|
34
34
|
version_requirements: *id001
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
|
-
name:
|
36
|
+
name: json_pure
|
37
37
|
prerelease: false
|
38
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
@@ -87,9 +87,9 @@ dependencies:
|
|
87
87
|
hash: 19
|
88
88
|
segments:
|
89
89
|
- 2
|
90
|
-
-
|
91
|
-
-
|
92
|
-
version: 2.
|
90
|
+
- 7
|
91
|
+
- 0
|
92
|
+
version: 2.7.0
|
93
93
|
type: :development
|
94
94
|
version_requirements: *id005
|
95
95
|
description: A set of command line tools for creating Jive Apps.
|
@@ -105,6 +105,7 @@ extra_rdoc_files:
|
|
105
105
|
- PostInstall.txt
|
106
106
|
files:
|
107
107
|
- .rspec
|
108
|
+
- Gemfile
|
108
109
|
- History.txt
|
109
110
|
- Manifest.txt
|
110
111
|
- PostInstall.txt
|