jiveapps 0.1.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,4 +2,4 @@ pkg/*
2
2
  *.gem
3
3
  .bundle
4
4
  Gemfile.lock
5
-
5
+ coverage/*
data/History.txt CHANGED
@@ -1,3 +1,27 @@
1
+ === 1.0.0 2011-04-06
2
+ * Major Enhancements
3
+ * LiveDev: Make a change, save a file, and hit refresh in your browser to see your latest changes on the Sandbox
4
+ * Minor Enhancements
5
+ * Increased test coverage
6
+ * Edge Case Coverage
7
+ * Check if LiveDev is already running when starting up. Display confirmation warning if so.
8
+ * Pull changes from remote master before doing merge of livedev branch
9
+ * Verify current git branch is set to livedev branch before every commit, if it is accidentally switched it in another window.
10
+ * Check if a merge conflict occurs and display conflict info and resolution instructions if so
11
+ * Make master branch track remote jiveapps master branch by default
12
+ * When starting LiveDev, if livedev/username branch already exists, ask user if they want to recreate it or use it as is
13
+ * Delete livedev branch when stopping livedev if no changes exist
14
+ * Check if remote "jiveapps" exists, if not, create it
15
+ * Big speed boost: batch all changes from each file notification event loop into one git commit and push. Adding and removing whole directories of files is much faster.
16
+ * Catch input typed during LiveDev and interpret "exit", "quit", "\q", and ":q" as commands to quit.
17
+ * Updated run method to properly silence command output on windows
18
+
19
+ === 0.1.2 2011-03-17
20
+ * Minor enhancements
21
+ * Update absolute url paths in app generator to point to /apps/dev/... instead of /apps/... to match new dev paths
22
+ * Compatibility Fixes
23
+ * require 'thread' in bin/jiveapps for RubyGems 1.6.x compatibility, which no longer includes it by default
24
+
1
25
  === 0.1.1 2011-02-21
2
26
  * Major enhancements
3
27
  * "jiveapps clone <appname>" command, shortcut for git clone command for jive apps
data/Rakefile CHANGED
@@ -19,11 +19,12 @@ end
19
19
 
20
20
  desc "Generate RCov code coverage report"
21
21
  RSpec::Core::RakeTask.new('rcov') do |t|
22
- # t.spec_files = FileList['spec/*_spec.rb']
22
+ t.pattern = 'spec/**/*_spec.rb'
23
23
  t.rcov = true
24
- t.rcov_opts = ['--exclude', 'examples']
24
+ t.rcov_opts = ['--exclude', '/Library,spec']
25
25
  end
26
26
 
27
+
27
28
  task :default => :spec
28
29
 
29
30
  desc "Fix password"
data/autotest/discover.rb CHANGED
@@ -1 +1,7 @@
1
1
  Autotest.add_discovery { "rspec2" }
2
+
3
+ # Run RCov after every autotest run
4
+ require 'autotest/rcov'
5
+ Autotest::RCov.command = 'rcov'
6
+ Autotest::RCov.options = ['--exclude', '/Library,spec']
7
+ Autotest::RCov.pattern = 'spec/**/*_spec.rb'
data/jiveapps.gemspec CHANGED
@@ -10,7 +10,9 @@ Gem::Specification.new do |s|
10
10
  s.email = ["becker.scott@gmail.com"]
11
11
  s.homepage = "https://github.com/jivesoftware/jiveapps-gem"
12
12
  s.summary = %q{The "jiveapps" gem is a set of command line tools for building and hosting Jive App front-ends.}
13
- s.description = %q{These tools are all about making Jive App development as easy as possible. After you install the tools, it only takes a single command to:
13
+ s.description = %q{== Jiveapps
14
+
15
+ These tools are all about making Jive App development as easy as possible. After you install the tools, it only takes a single command to:
14
16
 
15
17
  1. Create a new app - a simple Hello World application.
16
18
  2. Set up version control for your code using Git.
@@ -23,15 +25,23 @@ After you install, use this simple workflow to make changes and see them reflect
23
25
  1. Make a change to the code on your local machine.
24
26
  2. Commit the changes to your local Git repository.
25
27
  3. Push the changes to the remote Jive Apps repository. This automatically updates the hosted copy on the Jive AppHosting server.
26
- 4. Refresh the app dashboard or canvas page on the Jive Apps Sandbox and see your changes.}
28
+ 4. Refresh the app dashboard or canvas page on the Jive Apps Sandbox and see your changes.
29
+
30
+ Other features:
31
+
32
+ * LiveDev: preview your changes on the Jive App Sandbox in real time
33
+ * Collaboration: add other developers to your project
34
+ * OAuth Key Management: associate consumer key/secret pairs with service names for use in your apps
27
35
 
28
- # s.rubyforge_project = "jiveapps"
36
+ }
29
37
 
30
- s.add_dependency 'activesupport', '2.3.5'
31
- s.add_dependency 'rest-client', '1.6.1'
32
- s.add_dependency 'rubigen', '1.5.5'
38
+ s.add_dependency 'activesupport', '2.3.5'
39
+ s.add_dependency 'directory_watcher', '1.3.2'
40
+ s.add_dependency 'rest-client', '1.6.1'
41
+ s.add_dependency 'rubigen', '1.5.5'
33
42
 
34
43
  s.add_development_dependency 'rspec', '>= 2.2.0'
44
+ s.add_development_dependency 'rcov', '>= 0.9.9'
35
45
  s.add_development_dependency 'webmock', '>= 1.6.1'
36
46
 
37
47
  s.files = `git ls-files`.split("\n")
@@ -71,6 +71,10 @@ class Jiveapps::Client
71
71
  post_app("/apps/#{escape(name)}/install", {})
72
72
  end
73
73
 
74
+ def livedev(name, mode)
75
+ post_app("/apps/#{escape(name)}/livedev?mode=#{mode}", {})
76
+ end
77
+
74
78
  ### SSH Keys
75
79
 
76
80
  def keys
@@ -99,7 +103,7 @@ class Jiveapps::Client
99
103
 
100
104
  ### OAuth Services
101
105
 
102
- def oauth_services(app_name)
106
+ def list_oauth_services(app_name)
103
107
  services = get("/apps/#{app_name}/oauth_services")
104
108
 
105
109
  if services.class == Array
@@ -47,7 +47,7 @@ module Jiveapps::Command
47
47
  display "=== #{@appname} folder already exists."
48
48
  else
49
49
  display "=== Cloning #{@appname}..."
50
- `git clone #{app['git_url']} --origin jiveapps`
50
+ run("git clone #{app['git_url']} --origin jiveapps")
51
51
  end
52
52
  end
53
53
  end
@@ -83,17 +83,6 @@ module Jiveapps::Command
83
83
 
84
84
  private
85
85
 
86
- def debug_mode?
87
- return @debug_mode if @debug_mode.nil? == false
88
-
89
- if args.include?('--debug')
90
- args.delete('--debug')
91
- @debug_mode = true
92
- else
93
- @debug_mode = false
94
- end
95
- end
96
-
97
86
  def create_remote_app
98
87
  display "Step 1 of 4. Check availability and create remote repository: ", false
99
88
  @current_app = jiveapps.create(@appname)
@@ -122,6 +111,7 @@ module Jiveapps::Command
122
111
  run('git commit -m "initial commit"')
123
112
  run("git remote add jiveapps #{current_app['git_url']}")
124
113
  run("git push jiveapps master")
114
+ run("git branch --set-upstream master jiveapps/master")
125
115
  end
126
116
 
127
117
  if $? == 0
@@ -175,23 +165,6 @@ module Jiveapps::Command
175
165
  display_oauth_services(oauth_services, app['name'])
176
166
  end
177
167
  end
178
-
179
- def run(command)
180
- if debug_mode?
181
- puts "DEBUG: $ #{command}"
182
- `#{command}`
183
- elsif running_on_windows?
184
- `#{command}` # TODO: figure out how to silence on Windows
185
- else
186
- `#{command} > /dev/null 2>&1` # silent
187
- end
188
- end
189
-
190
- def debug(msg)
191
- if debug_mode?
192
- puts "DEBUG: #{msg}"
193
- end
194
- end
195
168
 
196
169
  def handle_response_errors
197
170
  if @current_app.class == Hash && @current_app["errors"]
@@ -2,45 +2,46 @@ module Jiveapps::Command
2
2
  class Help < Base
3
3
 
4
4
  def index
5
- puts "jiveapps gem: v#{Jiveapps::VERSION}"
6
- puts <<-eos
7
- === Summary
8
- The "jiveapps" program is a command line tool for building and hosting Jive App front-ends.
9
-
10
- === General Commands
11
-
12
- help # show this usage
13
-
14
- list # list your apps
15
- create <app_name> # create a new app
16
- clone <app_name> # clone the repository of an existing app
17
-
18
- info [--app <app_name>] # displays information about an app
19
- install [--app <app_name>] # install an app on the sandbox (if you removed it, you can reinstall)
20
-
21
- keys # show your user's public keys
22
- keys:add [<path to keyfile>] # add a public key. optionally include path
23
- keys:remove <keyname> # remove a key by name (user@host)
24
-
25
- oauth # show the oauth services for this app
26
- oauth:add <service_name> <key> <secret> # add an oauth service for this app
27
- oauth:remove <service_name> # remove an oauth service for this app
28
-
29
- sharing # list collaborators
30
- sharing:add <username> # add a collaborator
31
- sharing:remove <username> # remove a collaborator
32
-
33
- === Simple Workflow Example:
34
-
35
- $ jiveapps create myapp # create a new app named "myapp"
36
- $ cd myapp # switch into app's directory
37
-
38
- ... develop your app ...
39
-
40
- $ git add . # stage all files for commit
41
- $ git commit -m "some updates to my app" # commit to your local git repository
42
- $ git push jiveapps master # push updates to jive
43
- eos
5
+ display "jiveapps gem: v#{Jiveapps::VERSION}"
6
+ display ""
7
+ display "=== Summary"
8
+ display "The \"jiveapps\" program is a command line tool for building and hosting Jive App front-ends."
9
+ display ""
10
+ display "=== General Commands"
11
+ display ""
12
+ display "help # show this usage"
13
+ display ""
14
+ display "list # list your apps"
15
+ display "create <app_name> # create a new app"
16
+ display "clone <app_name> # clone the repository of an existing app"
17
+ display ""
18
+ display "info [--app <app_name>] # displays information about an app"
19
+ display "install [--app <app_name>] # install an app on the sandbox (if you removed it, you can reinstall)"
20
+ display ""
21
+ display "keys # show your user\'s public keys"
22
+ display "keys:add [<path to keyfile>] # add a public key. optionally include path"
23
+ display "keys:remove <keyname> # remove a key by name (user@host)"
24
+ display ""
25
+ display "oauth # show the oauth services for this app"
26
+ display "oauth:add <service_name> <key> <secret> # add an oauth service for this app"
27
+ display "oauth:remove <service_name> # remove an oauth service for this app"
28
+ display ""
29
+ display "sharing # list collaborators"
30
+ display "sharing:add <username> # add a collaborator"
31
+ display "sharing:remove <username> # remove a collaborator"
32
+ display ""
33
+ display "livedev # start livedev mode"
34
+ display ""
35
+ display "=== Simple Workflow Example:"
36
+ display ""
37
+ display "$ jiveapps create myapp # create a new app named \"myapp\""
38
+ display "$ cd myapp # switch into app\'s directory"
39
+ display ""
40
+ display " ... develop your app ..."
41
+ display ""
42
+ display "$ git add . # stage all files for commit"
43
+ display "$ git commit -m \"some updates to my app\" # commit to your local git repository"
44
+ display "$ git push jiveapps master # push updates to jive"
44
45
  end
45
46
 
46
47
  end
@@ -0,0 +1,224 @@
1
+ require 'directory_watcher'
2
+ module Jiveapps::Command
3
+ class Livedev < BaseWithApp
4
+
5
+ def on
6
+ info = jiveapps.info(app)
7
+ if info == nil
8
+ display "App not found."
9
+ else
10
+ check_for_jiveapps_remote(info)
11
+
12
+ # Check if LiveDev is already running...
13
+ if File.exist?(".git/livedev")
14
+ return unless confirm "LiveDev appears to already be running in another window.\nIf so, you should not run it twice, or strange things could happen.\nType \"y\" to continue anyway, or anything else to quit (recommended): (y/N)?"
15
+ else
16
+ # Create livedev run file so above check can happen
17
+ # if command is run in two separate terminals
18
+ File.open(".git/livedev", 'w') {|f| f.write("") }
19
+ end
20
+
21
+ display "=== Starting LiveDev: #{app}"
22
+
23
+ display "1/4: Checking out LiveDev branch #{livedev_branch_name}."
24
+
25
+ ask_to_recreate_branch_if_livedev_exists
26
+ checkout_livedev_branch
27
+
28
+ # sync remote livedev branch with local - force update to match local
29
+ display "2/4: Syncing local branch with remote server."
30
+ run("git push -f jiveapps #{livedev_branch_name}")
31
+
32
+ # switch server to run in livedev mode
33
+ display "3/4: Switching the Jive App Sandbox to point to LiveDev branch."
34
+ jiveapps.livedev(app, 'on')
35
+
36
+ display "4/4: Watching directory for changes. Leave this process running"
37
+ display " until you wish to quit LiveDev. Type \"exit\" to quit."
38
+ display " To view your app while in LiveDev mode, go to:"
39
+ display " #{info['sandbox_canvas_url']}"
40
+ display "================================================================"
41
+ watch_dir_and_commit_changes
42
+ end
43
+ end
44
+ alias :index :on
45
+
46
+ def off
47
+ display "\n\n\n=== Stopping LiveDev: #{app}"
48
+
49
+ # remove livedev run file if it exists
50
+ if File.exist?(".git/livedev")
51
+ File.delete(".git/livedev")
52
+ end
53
+
54
+ # switch server to run in normal mode
55
+ display "1/3: Switching the Jive App Sandbox to point to master branch."
56
+ jiveapps.livedev(app, 'off')
57
+
58
+ display "2/3: Checking out master branch and pulling any remote changes."
59
+ run("git checkout master")
60
+ run("git pull jiveapps master")
61
+
62
+ if `git diff #{livedev_branch_name} master`.length > 0
63
+ display "3/3: Merging changes from LiveDev branch without committing."
64
+ result = `git merge #{livedev_branch_name} --squash`
65
+
66
+ # Check if a merge conflict occurred and display git message if so
67
+ if result =~ /CONFLICT/
68
+ puts "\n\n=== Merge conflicts occured:"
69
+ puts result
70
+ end
71
+
72
+ display "\n\n\n=== You can now review your changes, then keep or forget them:"
73
+ display " 1. Review your changes:"
74
+ display " $ git status"
75
+ display " $ git diff --cached # review changes staged for commit"
76
+ display " $ git diff # review conflicts" if result =~ /CONFLICT/
77
+ display ""
78
+
79
+ if result =~ /CONFLICT/
80
+ display " ... edit and fix conflicts ..."
81
+ display ""
82
+ end
83
+
84
+ display " 2. Commit them to the master branch:"
85
+ display " $ git add <fixed-conflict-file-names>" if result =~ /CONFLICT/
86
+ display " $ git commit -m 'your commit message here'"
87
+ display " $ git push jiveapps master"
88
+ display " $ git branch -D #{livedev_branch_name}"
89
+ display ""
90
+ display " 3. Or forget them:"
91
+ display " $ git reset --hard HEAD"
92
+ display " $ git branch -D #{livedev_branch_name}"
93
+ else
94
+ display "=== No changes exist in the LiveDev branch. Now running in standard dev mode."
95
+ run("git branch -d #{livedev_branch_name}") # deleting livedev branch since no changes exist
96
+ end
97
+ end
98
+
99
+ private
100
+
101
+ def livedev_branch_name
102
+ "livedev/#{jiveapps.user}"
103
+ end
104
+
105
+ def current_branch_name
106
+ `git symbolic-ref HEAD`.strip.gsub(/refs\/heads\//, '')
107
+ end
108
+
109
+ def ask_to_recreate_branch_if_livedev_exists
110
+ if branch_exists?(livedev_branch_name)
111
+ display "LiveDev branch already exists! You can either:"
112
+
113
+ answer = ""
114
+ while answer != "1" && answer != "2"
115
+ display " 1. Delete and recreate branch from master"
116
+ display " 2. Continue using existing LiveDev branch"
117
+ display " Select 1 or 2: ", false
118
+ answer = gets.strip
119
+ display "#{answer} is not a valid choice!" if answer != "1" && answer != "2"
120
+ end
121
+
122
+ # if user answers "1", delete the livedev branch. it will get re-created when it is checked out
123
+ if answer == "1"
124
+ run("git checkout master")
125
+ run("git branch -D #{livedev_branch_name}")
126
+ end
127
+
128
+ end
129
+ end
130
+
131
+ def checkout_livedev_branch
132
+ # check if livedev branch exists...
133
+ if Kernel.system("git show-ref --quiet --verify refs/heads/#{livedev_branch_name}")
134
+ # if it does, switch to it
135
+ run("git checkout #{livedev_branch_name}")
136
+ else
137
+ # if it doesn't, create it and switch to it, and do an initial push
138
+ run("git checkout -b #{livedev_branch_name}")
139
+ end
140
+ end
141
+
142
+ def verify_livedev_branch
143
+ if current_branch_name != livedev_branch_name
144
+ checkout_livedev_branch
145
+ end
146
+ end
147
+
148
+ def branch_exists?(branch)
149
+ branches = `git branch`
150
+ regex = Regexp.new('[\\n\\s\\*]+' + Regexp.escape(branch.to_s) + '\\n')
151
+ result = ((branches =~ regex) ? true : false)
152
+ return result
153
+ end
154
+
155
+ def remote_exists?(remote)
156
+ remotes = `git remote`.strip.split(/\n/)
157
+ remotes.include?(remote)
158
+ end
159
+
160
+ def check_for_jiveapps_remote(info)
161
+ unless remote_exists?("jiveapps")
162
+ run("git remote add jiveapps #{info['git_url']}")
163
+ run("git branch --set-upstream master jiveapps/master")
164
+ end
165
+ end
166
+
167
+ def watch_dir_and_commit_changes
168
+ @dw = DirectoryWatcher.new '.', :glob => '**/*', :pre_load => true
169
+ @dw.interval = 1
170
+ @dw.add_observer do |*args|
171
+ verify_livedev_branch
172
+
173
+ changes = ""
174
+ args.each do |event|
175
+ if event.type == :added || event.type == :modified
176
+ run("git add #{event.path}")
177
+ elsif event.type == :removed
178
+ run("git rm #{event.path}")
179
+ end
180
+ display " - [#{Time.now.strftime("%Y-%m-%d %T")}] LiveDev: #{event.type} #{event.path}"
181
+ changes << " #{event.type} '#{event.path}'\n"
182
+ end
183
+
184
+ run("git commit -m \"LiveDev Changes\n#{changes}\"")
185
+ run("git push -f jiveapps #{livedev_branch_name}")
186
+ end
187
+
188
+ @dw.start
189
+
190
+ while true do
191
+ begin
192
+ input = gets.strip
193
+ if ["exit", "quit", "\\q", ":q"].include?(input)
194
+ prompt_to_quit_or_resume
195
+ else
196
+ display "Not a valid command. Type \"exit\" followed by [Enter] to quit."
197
+ end
198
+ rescue Interrupt # catch CTRL-C
199
+ prompt_to_quit_or_resume
200
+ end
201
+ end
202
+
203
+ end
204
+
205
+ def prompt_to_quit_or_resume
206
+ puts ""
207
+ puts "Would you like to quit LiveDev mode now? y/n? "
208
+ begin
209
+ answer = gets.strip
210
+ rescue Interrupt
211
+ end
212
+ if answer == 'y'
213
+ @dw.stop
214
+ off
215
+ exit
216
+ else
217
+ display "Resuming..."
218
+ return
219
+ end
220
+ end
221
+
222
+ end
223
+
224
+ end
@@ -3,7 +3,7 @@ module Jiveapps::Command
3
3
 
4
4
  # Lists OAuth Services registered for this app
5
5
  def list
6
- oauth_services = jiveapps.oauth_services(app)
6
+ oauth_services = jiveapps.list_oauth_services(app)
7
7
  display_oauth_services(oauth_services, app)
8
8
  end
9
9
  alias :index :list
@@ -15,7 +15,7 @@ module Jiveapps::Command
15
15
 
16
16
  display "=== Registering a new OAuth Service: \"#{@servicename}\""
17
17
  response = jiveapps.add_oauth_service(app, @servicename, @key, @secret)
18
- Jiveapps::Command.run_internal('oauth:list', ["--app", app])
18
+ list
19
19
  end
20
20
 
21
21
  # Remove an OAuth Service
@@ -26,7 +26,7 @@ module Jiveapps::Command
26
26
  return unless confirm "Are you sure you wish to remove the OAuth service \"#{@servicename}\"? (y/n)?"
27
27
  display "=== Removing Oauth Service \"#{@servicename}\""
28
28
  response = jiveapps.remove_oauth_service(app, @servicename)
29
- Jiveapps::Command.run_internal('oauth:list', ["--app", app])
29
+ list
30
30
  end
31
31
 
32
32
  end
@@ -74,6 +74,34 @@ module Jiveapps
74
74
  raise Jiveapps::Command::CommandFailed, "Missing #{list.length} parameter#{list.length > 1 ? 's' : ''}: #{list.map{|l| '<' + l.to_s + '>'}.join(' ')}#{@usage}" if list.length > 0
75
75
  end
76
76
 
77
+ def run(command)
78
+ if debug_mode?
79
+ puts "DEBUG: $ #{command}"
80
+ `#{command}`
81
+ elsif running_on_windows?
82
+ `#{command} > NUL 2>&1`
83
+ else
84
+ `#{command} > /dev/null 2>&1` # silent
85
+ end
86
+ end
87
+
88
+ def debug_mode?
89
+ return @debug_mode if @debug_mode.nil? == false
90
+
91
+ if args.include?('--debug')
92
+ args.delete('--debug')
93
+ @debug_mode = true
94
+ else
95
+ @debug_mode = false
96
+ end
97
+ end
98
+
99
+ def debug(msg)
100
+ if debug_mode?
101
+ puts "DEBUG: #{msg}"
102
+ end
103
+ end
104
+
77
105
  # Display Oauth Service list
78
106
  # Example Output:
79
107
  # === 2 OAuth services for app-name
@@ -1,3 +1,3 @@
1
1
  module Jiveapps
2
- VERSION = '0.1.2'
2
+ VERSION = '1.0.0'
3
3
  end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ module Jiveapps::Command
4
+ describe Help do
5
+ before do
6
+ @cli = prepare_command(Help)
7
+ end
8
+
9
+ it "displays a help page" do
10
+ @cli.should_receive(:display).with("=== Summary")
11
+ @cli.should_receive(:display).with("=== General Commands")
12
+ @cli.index
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,86 @@
1
+ require 'spec_helper'
2
+
3
+ module Jiveapps::Command
4
+ describe Livedev do
5
+ before do
6
+ @cli = prepare_command(Livedev)
7
+ @cli.stub(:run) # stub run so git commands are not actually called
8
+ @cli.jiveapps.stub(:user) { "testuser" }
9
+ @cli.stub(:watch_dir_and_commit_changes)
10
+ @cli.jiveapps.stub(:livedev)
11
+
12
+ File.stub(:open).with(".git/livedev", 'w').and_return(true)
13
+
14
+ @livedev_branch_name = 'livedev/testuser'
15
+ end
16
+
17
+ it "should name livedev branch name 'livedev/<username>'" do
18
+ @cli.send(:livedev_branch_name).should == @livedev_branch_name
19
+ end
20
+
21
+ context "on" do
22
+
23
+ before do
24
+ @cli.jiveapps.stub(:info).and_return({})
25
+ end
26
+
27
+ it "should display 'App not found' if jiveapps.info lookup returns nil" do
28
+ @cli.jiveapps.stub(:info).and_return(nil)
29
+ @cli.should_receive(:display).with("App not found.")
30
+ @cli.on
31
+ end
32
+
33
+ it "should display 'Starting LiveDev' if app exists" do
34
+ @cli.should_receive(:display).with("=== Starting LiveDev: myapp")
35
+ @cli.on
36
+ end
37
+
38
+ it "should check out the existing livedev branch if it exists" do
39
+ Kernel.should_receive(:system).with("git show-ref --quiet --verify refs/heads/#{@livedev_branch_name}").and_return(true)
40
+ @cli.should_receive(:run).with("git checkout #{@livedev_branch_name}")
41
+ @cli.on
42
+ end
43
+
44
+ it "should check out a new livedev branch if it does not exists" do
45
+ Kernel.should_receive(:system).with("git show-ref --quiet --verify refs/heads/#{@livedev_branch_name}").and_return(false)
46
+ @cli.should_receive(:run).with("git checkout -b #{@livedev_branch_name}")
47
+ @cli.on
48
+ end
49
+
50
+ it "should make rest call to turn livedev on if app exists" do
51
+ @cli.jiveapps.should_receive(:livedev).with('myapp', 'on')
52
+ @cli.on
53
+ end
54
+
55
+ it "should watch dir and commit changes when turned on" do
56
+ @cli.should_receive(:watch_dir_and_commit_changes)
57
+ @cli.on
58
+ end
59
+
60
+ end
61
+
62
+ context "off" do
63
+ before do
64
+ @cli.stub(:`).and_return("") # stub backtick system command
65
+ end
66
+
67
+ it "should display 'Stopping LiveDev'" do
68
+ @cli.should_receive(:display).with("\n\n\n=== Stopping LiveDev: myapp")
69
+ @cli.off
70
+ end
71
+
72
+ it "should make rest call to turn livedev off" do
73
+ @cli.jiveapps.should_receive(:livedev).with('myapp', 'off')
74
+ @cli.off
75
+ end
76
+
77
+ it "should see if changes exist between livedev and master, and if so do a merge squash" do
78
+ @cli.stub(:`).with("git diff #{@livedev_branch_name} master").and_return("differences")
79
+ @cli.should_receive(:`).with("git merge #{@livedev_branch_name} --squash")
80
+ @cli.off
81
+ end
82
+
83
+ end
84
+
85
+ end
86
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ module Jiveapps::Command
4
+ describe Oauth do
5
+ before do
6
+ @cli = prepare_command(Oauth)
7
+ end
8
+
9
+ it "lists oauth services" do
10
+ @cli.jiveapps.should_receive(:list_oauth_services).and_return([])
11
+ @cli.list
12
+ end
13
+
14
+ it "adds an oauth service if service name, key, and secret are supplied" do
15
+ @cli.stub!(:args).and_return(['service_name', 'key', 'secret'])
16
+ @cli.jiveapps.should_receive(:add_oauth_service).with('myapp', 'service_name', 'key', 'secret')
17
+ @cli.jiveapps.should_receive(:list_oauth_services).and_return([])
18
+ @cli.add
19
+ end
20
+
21
+ it "removes an oauth service if service name is supplied" do
22
+ @cli.stub!(:args).and_return(['service_name'])
23
+ @cli.stub!(:confirm).and_return(true)
24
+ @cli.jiveapps.should_receive(:remove_oauth_service).with('myapp', 'service_name')
25
+ @cli.jiveapps.should_receive(:list_oauth_services).and_return([])
26
+ @cli.remove
27
+ end
28
+ end
29
+ end
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: 31
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
- - 0
8
7
  - 1
9
- - 2
10
- version: 0.1.2
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
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: 2011-03-17 00:00:00 -07:00
18
+ date: 2011-04-06 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -35,9 +35,25 @@ dependencies:
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
38
- name: rest-client
38
+ name: directory_watcher
39
39
  prerelease: false
40
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - "="
44
+ - !ruby/object:Gem::Version
45
+ hash: 31
46
+ segments:
47
+ - 1
48
+ - 3
49
+ - 2
50
+ version: 1.3.2
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: rest-client
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
41
57
  none: false
42
58
  requirements:
43
59
  - - "="
@@ -49,11 +65,11 @@ dependencies:
49
65
  - 1
50
66
  version: 1.6.1
51
67
  type: :runtime
52
- version_requirements: *id002
68
+ version_requirements: *id003
53
69
  - !ruby/object:Gem::Dependency
54
70
  name: rubigen
55
71
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
72
+ requirement: &id004 !ruby/object:Gem::Requirement
57
73
  none: false
58
74
  requirements:
59
75
  - - "="
@@ -65,11 +81,11 @@ dependencies:
65
81
  - 5
66
82
  version: 1.5.5
67
83
  type: :runtime
68
- version_requirements: *id003
84
+ version_requirements: *id004
69
85
  - !ruby/object:Gem::Dependency
70
86
  name: rspec
71
87
  prerelease: false
72
- requirement: &id004 !ruby/object:Gem::Requirement
88
+ requirement: &id005 !ruby/object:Gem::Requirement
73
89
  none: false
74
90
  requirements:
75
91
  - - ">="
@@ -81,11 +97,27 @@ dependencies:
81
97
  - 0
82
98
  version: 2.2.0
83
99
  type: :development
84
- version_requirements: *id004
100
+ version_requirements: *id005
101
+ - !ruby/object:Gem::Dependency
102
+ name: rcov
103
+ prerelease: false
104
+ requirement: &id006 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ hash: 41
110
+ segments:
111
+ - 0
112
+ - 9
113
+ - 9
114
+ version: 0.9.9
115
+ type: :development
116
+ version_requirements: *id006
85
117
  - !ruby/object:Gem::Dependency
86
118
  name: webmock
87
119
  prerelease: false
88
- requirement: &id005 !ruby/object:Gem::Requirement
120
+ requirement: &id007 !ruby/object:Gem::Requirement
89
121
  none: false
90
122
  requirements:
91
123
  - - ">="
@@ -97,8 +129,10 @@ dependencies:
97
129
  - 1
98
130
  version: 1.6.1
99
131
  type: :development
100
- version_requirements: *id005
101
- description: |-
132
+ version_requirements: *id007
133
+ description: |+
134
+ == Jiveapps
135
+
102
136
  These tools are all about making Jive App development as easy as possible. After you install the tools, it only takes a single command to:
103
137
 
104
138
  1. Create a new app - a simple Hello World application.
@@ -113,6 +147,13 @@ description: |-
113
147
  2. Commit the changes to your local Git repository.
114
148
  3. Push the changes to the remote Jive Apps repository. This automatically updates the hosted copy on the Jive AppHosting server.
115
149
  4. Refresh the app dashboard or canvas page on the Jive Apps Sandbox and see your changes.
150
+
151
+ Other features:
152
+
153
+ * LiveDev: preview your changes on the Jive App Sandbox in real time
154
+ * Collaboration: add other developers to your project
155
+ * OAuth Key Management: associate consumer key/secret pairs with service names for use in your apps
156
+
116
157
  email:
117
158
  - becker.scott@gmail.com
118
159
  executables:
@@ -152,6 +193,7 @@ files:
152
193
  - lib/jiveapps/commands/base.rb
153
194
  - lib/jiveapps/commands/help.rb
154
195
  - lib/jiveapps/commands/keys.rb
196
+ - lib/jiveapps/commands/livedev.rb
155
197
  - lib/jiveapps/commands/oauth.rb
156
198
  - lib/jiveapps/commands/sharing.rb
157
199
  - lib/jiveapps/helpers.rb
@@ -159,7 +201,10 @@ files:
159
201
  - spec/client_spec.rb
160
202
  - spec/commands/app_spec.rb
161
203
  - spec/commands/base_spec.rb
204
+ - spec/commands/help_spec.rb
162
205
  - spec/commands/keys_spec.rb
206
+ - spec/commands/livedev_spec.rb
207
+ - spec/commands/oauth_spec.rb
163
208
  - spec/commands/sharing_spec.rb
164
209
  - spec/spec_helper.rb
165
210
  has_rdoc: true
@@ -192,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
237
  requirements: []
193
238
 
194
239
  rubyforge_project:
195
- rubygems_version: 1.6.2
240
+ rubygems_version: 1.5.0
196
241
  signing_key:
197
242
  specification_version: 3
198
243
  summary: The "jiveapps" gem is a set of command line tools for building and hosting Jive App front-ends.
@@ -200,6 +245,9 @@ test_files:
200
245
  - spec/client_spec.rb
201
246
  - spec/commands/app_spec.rb
202
247
  - spec/commands/base_spec.rb
248
+ - spec/commands/help_spec.rb
203
249
  - spec/commands/keys_spec.rb
250
+ - spec/commands/livedev_spec.rb
251
+ - spec/commands/oauth_spec.rb
204
252
  - spec/commands/sharing_spec.rb
205
253
  - spec/spec_helper.rb