jiveapps 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,4 +1,21 @@
1
+ === 0.0.4 2010-11-22
2
+ * Major enhancements
3
+ * SSL support
4
+ * App install command
5
+ * Added support in the client for app names with periods (.) in them
6
+ * Update help page with info on newer commands
7
+ * Version check
8
+ * Updated doc links in template
9
+
10
+ === 0.0.3 2010-11-19
11
+ * Major enhancements
12
+ * New template
13
+
14
+ === 0.0.2 2010-11-19
15
+ * First release to rubygems.org
16
+
1
17
  === 0.0.1 2010-09-29
2
18
 
3
19
  * 1 major enhancement:
4
20
  * Initial release
21
+
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ $hoe = Hoe.spec 'jiveapps' do
14
14
  self.developer 'Scott Becker', 'becker.scott@gmail.com'
15
15
  self.description = "A set of command line tools for creating Jive Apps."
16
16
  self.summary = self.description
17
- self.version = "0.0.3"
17
+ self.version = "0.0.4"
18
18
  self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
19
19
  self.rubyforge_name = self.name # TODO this is default value
20
20
  self.extra_deps = [
@@ -2,87 +2,86 @@
2
2
  "http://www.w3.org/TR/html4/strict.dtd">
3
3
 
4
4
  <html lang="en">
5
- <head>
6
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7
- <title>Hello World!</title>
8
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
9
- <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.js"></script>
10
- <script>
11
- $(function() {
12
- $( "#devlinks" ).accordion( {
13
- autoHeight: false,
14
- navigation: true
15
- });
5
+ <head>
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7
+ <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
8
+ <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.js"></script>
9
+ <script>
10
+ $(function() {
11
+ $( "#devlinks" ).accordion({
12
+ autoHeight: false,
13
+ navigation: true
14
+ });
16
15
  gadgets.window.adjustHeight();
17
- });
18
- </script>
19
- <style type="text/css" media="screen">
20
- body {background: #fff; font-size:90%;color:#333;font-family: arial, helvetica, sans-serif;}
21
- #wrapper {width:350px;}
22
- #wrapper div {padding:0;margin:0;}
23
- #wrapper p {padding:0;margin:0;}
24
- ol {padding:0px; margin:0px 0px 0px 20px;}
25
- ol li {font-weight:bold;margin-bottom:7px;}
26
- ol li span {font-size:90%;font-weight:normal;}
27
- a {color:#333;}
28
- h1 {font-size:150%;margin-bottom:2px;}
29
- h2 {font-size:110%;margin-bottom:5px;}
30
- h3 {background-color:#e5e5e5;padding:3px;font-size:105%;}
31
- h5 {font-size:105%;margin:0;}
32
- #devlinks h3 {margin:2px;}
33
- #devlinks div.community {padding:0;margin:0;background: url('images/j-icon-jaf-48.png') no-repeat; background-position: 10px 2px ; height:70px;}
34
- #devlinks div.documentation {padding:0;margin:0;background: url('images/j-icon-jaf-48.png') no-repeat; background-position: 10px 2px ; height:70px;}
35
- #devlinks div.login {padding:0;margin:0;background: url('images/j-icon-jaf-48.png') no-repeat; background-position: 10px 2px ; height:70px;}
36
- #devlinks div.market {padding:0;margin:0;background: url('images/j-icon-jaf-48.png') no-repeat; background-position: 10px 2px ; height:70px;}
37
- #devlinks div p {margin:10px 0px 0px 80px;}
38
- #devlinks h3 a,a:hover {text-decoration:none;}
39
- #devlinks ul {margin:5px 0px 0px 50px;}
40
- #devlinks li a {font-size:95%;}
41
- </style>
42
- </head>
43
- <body>
44
- <div id="wrapper">
45
- <h1>Congratulations!</h1>
46
- <h5>Your Jive App "<%= name %>" has been created.</h5>
47
- <hr />
48
- <ol>
49
- <li>Update your app code.<br /><span>by replacing the sample app with your own app code</span></li>
50
- <li>Require the features you need.<br /><span>by adding them to the &#60;ModulePrefs&#62; &#60;/ModulePrefs&#62;</span></li>
51
- <li>Modify javascripts/main.js<br /><span>by incorporating scripts that complete your app</span></li>
52
- </ol>
53
- <hr />
54
- <h2>Developer Resources</h2>
55
- <div class="content">
16
+ });
17
+ </script>
18
+ <style type="text/css" media="screen">
19
+ body {background: #fff; font-size:90%;color:#333;font-family: arial, helvetica, sans-serif;}
20
+ #wrapper {width:350px;}
21
+ #wrapper div {padding:0;margin:0;}
22
+ #wrapper p {padding:0;margin:0;}
23
+ ol {padding:0px; margin:0px 0px 0px 20px;}
24
+ ol li {font-weight:bold;margin-bottom:7px;}
25
+ ol li span {font-size:90%;font-weight:normal;}
26
+ a {color:#333;}
27
+ h1 {font-size:150%;margin-bottom:2px;}
28
+ h2 {font-size:110%;margin-bottom:5px;}
29
+ h3 {background-color:#e5e5e5;padding:3px;font-size:105%;}
30
+ h5 {font-size:105%;margin:0;}
31
+ #devlinks h3 {margin:2px;}
32
+ #devlinks div.community {padding:0;margin:0;background: url('images/j-icon-jaf-48.png') no-repeat; background-position: 10px 2px ; height:70px;}
33
+ #devlinks div.documentation {padding:0;margin:0;background: url('images/j-icon-jaf-48.png') no-repeat; background-position: 10px 2px ; height:70px;}
34
+ #devlinks div.login {padding:0;margin:0;background: url('images/j-icon-jaf-48.png') no-repeat; background-position: 10px 2px ; height:70px;}
35
+ #devlinks div.market {padding:0;margin:0;background: url('images/j-icon-jaf-48.png') no-repeat; background-position: 10px 2px ; height:70px;}
36
+ #devlinks div p {margin:10px 0px 0px 80px;}
37
+ #devlinks h3 a,a:hover {text-decoration:none;}
38
+ #devlinks ul {margin:5px 0px 0px 50px;}
39
+ #devlinks li a {font-size:95%;}
40
+ </style>
41
+ </head>
42
+ <body>
43
+ <div id="wrapper">
44
+ <h1>Congratulations!</h1>
45
+ <h5>Your Jive App "<%= name %>" has been created.</h5>
46
+ <hr />
47
+ <ol>
48
+ <li>Update your app code.<br /><span>by replacing the sample app with your own app code</span></li>
49
+ <li>Require the features you need.<br /><span>by adding them to the &#60;ModulePrefs&#62; &#60;/ModulePrefs&#62;</span></li>
50
+ <li>Modify javascripts/main.js<br /><span>by incorporating scripts that complete your app</span></li>
51
+ </ol>
52
+ <hr />
53
+ <h2>Developer Resources</h2>
54
+ <div class="content">
56
55
 
57
- <div id="devlinks">
58
- <h3><a href="#">Community</a></h3>
59
- <div class="community">
60
- <ul>
61
- <li><a href="http://developers.jivesoftware.com/community/blogs">Developer Blog</a></li>
62
- <li><a href="">Bug Tracker</a></li>
63
- <li><a href="">IRC Channel</a></li>
64
- <li><a href="http://www.jivesoftware.com/">Jive Software</a></li>
65
- </ul>
66
- </div>
67
- <h3><a href="#">Documentation</a></h3>
68
- <div class="documentation">
69
- <ul>
70
- <li><a href="">Jive Apps</a></li>
71
- <li><a href="">Jive Core API</a></li>
72
- <li><a href="">Jive Connects</a></li>
73
- <li><a href="">OpenSocial</a></li>
74
- </ul>
75
- </div>
76
- <h3><a href="#">Developer Login</a></h3>
77
- <div class="login">
78
- <p><a href="">Log in</a> to your Jive Apps Developer Account.</p>
79
- </div>
80
- <h3><a href="#">Apps Market</a></h3>
81
- <div class="market">
82
- <p>Browse the <a href="">Apps Market</a> to learn about new apps.</p>
83
- </div>
84
- </div>
85
- </div>
86
- </div>
87
- </body>
56
+ <div id="devlinks">
57
+ <h3><a href="#">Community</a></h3>
58
+ <div class="community">
59
+ <ul>
60
+ <li><a href="https://developers.jivesoftware.com/community">Developer Community</a></li>
61
+ <li><a href="https://developers.jivesoftware.com/community/blogs">Developer Blog</a></li>
62
+ <li><a href="http://www.jivesoftware.com/">Jive Software</a></li>
63
+ </ul>
64
+ </div>
65
+ <h3><a href="#">Documentation</a></h3>
66
+ <div class="documentation">
67
+ <ul>
68
+ <li><a href="https://developers.jivesoftware.com/community/docs/DOC-1113">Jive Apps SDK</a></li>
69
+ <li><a href="https://developers.jivesoftware.com/community/docs/DOC-1131">Jive Core API</a></li>
70
+ <li><a href="https://developers.jivesoftware.com/community/docs/DOC-1118">Jive Connects</a></li>
71
+ <li><a href="https://developers.jivesoftware.com/community/docs/DOC-1119">Jive App Gateway</a></li>
72
+ <li><a href="https://developers.jivesoftware.com/community/docs/DOC-1116">OpenSocial API</a></li>
73
+ </ul>
74
+ </div>
75
+ <h3><a href="#">Developer Login</a></h3>
76
+ <div class="login">
77
+ <p><a href="https://developers.jivesoftware.com/devcenter/">Log in</a> to your Jive Apps Developer Account.</p>
78
+ </div>
79
+ <h3><a href="#">Apps Market</a></h3>
80
+ <div class="market">
81
+ <p>Browse the <a href="#">Apps Market</a> to learn about new apps.</p>
82
+ </div>
83
+ </div>
84
+ </div>
85
+ </div>
86
+ </body>
88
87
  </html>
data/lib/jiveapps.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Jiveapps
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.4'
3
3
  WEBHOST = 'apphosting.jivesoftware.com'
4
4
  GITHOST = 'apphosting.jivesoftware.com'
5
5
  end
@@ -5,7 +5,7 @@ require 'json'
5
5
  class Jiveapps::Client
6
6
 
7
7
  def self.version
8
- '0.0.1'
8
+ '0.0.4'
9
9
  end
10
10
 
11
11
  def self.gem_version_string
@@ -34,8 +34,8 @@ class Jiveapps::Client
34
34
 
35
35
  def info(name)
36
36
  begin
37
- item = get("/apps/#{name}")
38
- item['app']
37
+ item = get("/apps/#{escape(name)}")
38
+ item.class == Hash && item['app'] ? item['app'] : item
39
39
  rescue RestClient::ResourceNotFound
40
40
  nil
41
41
  end
@@ -60,7 +60,17 @@ class Jiveapps::Client
60
60
  end
61
61
 
62
62
  def register(name)
63
- item = post("/apps/#{name}/register", {})
63
+ item = post("/apps/#{escape(name)}/register", {})
64
+
65
+ if item.class == Hash && item['app']
66
+ item['app']
67
+ else
68
+ nil
69
+ end
70
+ end
71
+
72
+ def install(name)
73
+ item = post("/apps/#{escape(name)}/register", {})
64
74
 
65
75
  if item.class == Hash && item['app']
66
76
  item['app']
@@ -92,12 +102,11 @@ class Jiveapps::Client
92
102
  end
93
103
 
94
104
  def remove_key(name)
95
- ### Ugly hack - nginx/passenger unescapes the name before it gets to rails, causing routes to fail. double encode in production
96
- if Jiveapps::WEBHOST =~ /^becker/ # in dev mode
97
- delete("/ssh_keys/#{escape(name)}").to_s
98
- else # in production mode
99
- delete("/ssh_keys/#{escape(escape(name))}").to_s
100
- end
105
+ delete("/ssh_keys/#{escape(name)}").to_s
106
+ end
107
+
108
+ def version
109
+ get("/gem_version").to_s
101
110
  end
102
111
 
103
112
  ### General
@@ -125,17 +134,24 @@ class Jiveapps::Client
125
134
  def process(method, uri, extra_headers={}, payload=nil)
126
135
  headers = jiveapps_headers.merge(extra_headers)
127
136
  args = [method, payload, headers].compact
128
- response = resource(uri).send(*args)
137
+ begin
138
+ response = resource(uri).send(*args)
129
139
 
130
- extract_warning(response)
131
- parse_response(response.to_s)
140
+ extract_warning(response)
141
+ parse_response(response.to_s)
142
+ rescue => e
143
+ puts e.response
144
+ end
132
145
  end
133
146
 
134
147
  def parse_response(response)
135
- if response == 'null' || response.strip.length == 0
136
- return nil
148
+ return nil if response == 'null' || response.strip.length == 0
149
+ response_text = response.strip
150
+
151
+ if response_text =~ /^\{|^\[/
152
+ return JSON.parse(response_text)
137
153
  else
138
- return JSON.parse(response.strip)
154
+ return response_text
139
155
  end
140
156
  end
141
157
 
@@ -150,17 +166,26 @@ class Jiveapps::Client
150
166
  }
151
167
  end
152
168
 
153
- def escape(value) # :nodoc:
169
+ def escape(value) # :nodoc:
170
+ ### Ugly hack - nginx/passenger unescapes the name before it gets to rails, causing routes to fail. double encode in production
171
+ if Jiveapps::WEBHOST =~ /^becker/ # in dev mode
172
+ _escape(value)
173
+ else # in production mode
174
+ _escape(_escape(value))
175
+ end
176
+ end
177
+
178
+ def _escape(value) # :nodoc:
154
179
  escaped = URI.escape(value.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
155
180
  escaped.gsub('.', '%2E') # not covered by the previous URI.escape
156
181
  end
157
182
 
158
183
  def resource(uri)
159
184
  RestClient.proxy = ENV['HTTP_PROXY'] || ENV['http_proxy']
160
- if uri =~ /^https?/
185
+ if uri =~ /^http?/
161
186
  RestClient::Resource.new(uri, user, password)
162
187
  else
163
- RestClient::Resource.new("http://#{host}", user, password)[uri]
188
+ RestClient::Resource.new("https://#{host}", user, password)[uri]
164
189
  end
165
190
  end
166
191
 
@@ -26,12 +26,7 @@ module Jiveapps::Command
26
26
  display "App not found."
27
27
  else
28
28
  display "=== #{app['name']}"
29
- display "Git URL: #{app['git_url']}"
30
- display "App URL: #{app['app_url']}"
31
- display "Sandbox Canvas URL: #{app['sandbox_canvas_url']}"
32
- display "Sandbox Dashboard URL: #{app['sandbox_dashboard_url']}"
33
- display "OAuth Consumer Key: #{app['oauth_consumer_key']}"
34
- display "OAuth Consumer Secret: #{app['oauth_consumer_secret']}"
29
+ display_app_info(app)
35
30
  end
36
31
  end
37
32
  end
@@ -46,8 +41,14 @@ module Jiveapps::Command
46
41
  create_notify_user
47
42
  end
48
43
 
49
- def version
50
- puts Jiveapps::Client.version
44
+ def install
45
+ app = jiveapps.install(app_name)
46
+ if app == nil
47
+ display "App not found."
48
+ else
49
+ display "=== #{app['name']} - Installed"
50
+ display_app_info(app)
51
+ end
51
52
  end
52
53
 
53
54
  private
@@ -66,7 +67,7 @@ module Jiveapps::Command
66
67
  def create_remote_app
67
68
  debug "Creating remote app."
68
69
  @current_app = jiveapps.create(app_name)
69
- if @current_app["errors"]
70
+ if @current_app.class == Hash && @current_app["errors"]
70
71
  if @current_app["errors"]["name"]
71
72
  display "Error: Name #{@current_app["errors"]["name"]}"
72
73
  end
@@ -99,18 +100,6 @@ module Jiveapps::Command
99
100
  end
100
101
  end
101
102
 
102
- def mute_stdout
103
- orig_stdout = $stdout
104
-
105
- # redirect stdout to /dev/null
106
- $stdout = File.new('/dev/null', 'w')
107
-
108
- yield
109
-
110
- # restore stdout
111
- $stdout = orig_stdout
112
- end
113
-
114
103
  def register_app
115
104
  return unless current_app
116
105
  debug "Registering app."
@@ -127,14 +116,18 @@ module Jiveapps::Command
127
116
  display ""
128
117
  display "Congratulations, you have created a new Jive App!"
129
118
  display "================================================="
130
- display "Git URL: #{current_app['git_url']}"
131
- display "App URL: #{current_app['app_url']}"
132
- display "Sandbox Canvas URL: #{current_app['sandbox_canvas_url']}"
133
- display "Sandbox Dashboard URL: #{current_app['sandbox_dashboard_url']}"
134
- display "OAuth Consumer Key: #{current_app['oauth_consumer_key']}"
135
- display "OAuth Consumer Secret: #{current_app['oauth_consumer_secret']}"
119
+ display_app_info(current_app)
136
120
  end
137
121
 
122
+ def display_app_info(app)
123
+ display "Git URL: #{app['git_url']}"
124
+ display "App URL: #{app['app_url']}"
125
+ display "Sandbox Canvas URL: #{app['sandbox_canvas_url']}"
126
+ display "Sandbox Dashboard URL: #{app['sandbox_dashboard_url']}"
127
+ display "OAuth Consumer Key: #{app['oauth_consumer_key']}"
128
+ display "OAuth Consumer Secret: #{app['oauth_consumer_secret']}"
129
+ end
130
+
138
131
  def app_name
139
132
  args.first
140
133
  end
@@ -12,6 +12,7 @@ help # show this usage
12
12
 
13
13
  list # list your apps
14
14
  create <name> # create a new app
15
+ install <name> # install an app on the sandbox (if you removed it, you can reinstall)
15
16
 
16
17
  keys # show your user's public keys
17
18
  keys:add [<path to keyfile>] # add a public key. optionally include path
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, "http://#{Jiveapps::WEBHOST}#{path}")
16
+ stub_request(method, "https://#{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: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
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-11-19 00:00:00 -08:00
18
+ date: 2010-11-22 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency