ginst 0.1.3 → 0.2.2

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.
Files changed (58) hide show
  1. data.tar.gz.sig +0 -0
  2. data/Manifest +34 -8
  3. data/Rakefile +6 -3
  4. data/bin/ginst +11 -4
  5. data/features/browsing_project.feature +20 -0
  6. data/features/manage_projects.feature +36 -0
  7. data/features/manage_server.feature +17 -0
  8. data/features/step_definitions/manage_projects_steps.rb +35 -0
  9. data/features/step_definitions/manage_server_steps.rb +33 -0
  10. data/features/step_definitions/webrat_steps.rb +99 -0
  11. data/features/support/env.rb +29 -0
  12. data/features/support/git.rb +22 -0
  13. data/features/support/paths.rb +16 -0
  14. data/ginst.gemspec +8 -11
  15. data/lib/app/authorization.rb +1 -1
  16. data/lib/app/views/_commit.haml +8 -0
  17. data/lib/app/views/commit.haml +38 -8
  18. data/lib/app/views/commits.haml +1 -1
  19. data/lib/app/views/edit.haml +11 -0
  20. data/lib/app/views/layout.haml +10 -7
  21. data/lib/app/views/new.haml +19 -0
  22. data/lib/app/views/project.haml +4 -1
  23. data/lib/app/views/ref.haml +3 -0
  24. data/lib/app/views/style.sass +0 -1
  25. data/lib/app/webserver.rb +66 -76
  26. data/lib/ginst.rb +7 -5
  27. data/lib/ginst/core_extensions.rb +32 -0
  28. data/lib/ginst/ginst.rb +5 -72
  29. data/lib/ginst/project.rb +13 -38
  30. data/lib/ginst/project/base.rb +59 -0
  31. data/lib/ginst/project/build.rb +117 -0
  32. data/lib/ginst/project/commit_db.rb +29 -0
  33. data/lib/ginst/project/finders.rb +17 -0
  34. data/lib/ginst/project/grit.rb +53 -0
  35. data/lib/ginst/project/validations.rb +60 -0
  36. data/lib/ginst/test.rb +8 -0
  37. data/lib/ginst/test/base.rb +17 -0
  38. data/lib/ginst/test/dir.rb +39 -0
  39. data/lib/ginst/test/repo.rb +13 -0
  40. data/lib/ginst/test/run.rb +11 -0
  41. data/lib/ginst/web_server.rb +43 -0
  42. data/spec/fixtures/sample_repo.zip +0 -0
  43. data/spec/models/project_base_spec.rb +56 -0
  44. data/spec/models/project_build_spec.rb +18 -0
  45. data/spec/models/project_commit_db_spec.rb +19 -0
  46. data/spec/models/project_finders_spec.rb +34 -0
  47. data/spec/models/project_grit_spec.rb +19 -0
  48. data/spec/models/project_validations_spec.rb +72 -0
  49. data/spec/spec_helper.rb +8 -0
  50. metadata +56 -29
  51. metadata.gz.sig +0 -0
  52. data/lib/app/views/full_commit.haml +0 -38
  53. data/lib/app/views/project_index.haml +0 -11
  54. data/lib/ginst/command_line.rb +0 -47
  55. data/lib/ginst/master_command_line.rb +0 -40
  56. data/lib/ginst/plugin.rb +0 -16
  57. data/lib/ginst/server.rb +0 -51
  58. data/lib/ginst/templates/rgithook.rb +0 -6
metadata.gz.sig CHANGED
Binary file
@@ -1,38 +0,0 @@
1
- = haml :commit, :layout => false, :locals => {:commit => @commit}
2
- - unless @commit.properties['testing']
3
- %form{:method => 'post'}
4
- %input{:type =>'submit', :value => 'Run hooks for this commit'}
5
- - else
6
- %form{:method => 'post'}
7
- %input{:type =>'submit', :value => 'Tests are runing now', :disabled => 'disabled'}
8
-
9
- %p.separator
10
- Commit Info
11
- %p.message
12
- = format_message @commit.message
13
- - @commit.properties.each do |key,val|
14
- %p.separator= key.to_s
15
- %p=val.to_s
16
- %p.separator
17
- Files
18
- %p.files
19
- %ul
20
- -@commit.diffs.each do |diff|
21
- - op = diff.deleted_file ? 'deleted' : (diff.new_file ? 'new' : (diff.a_path == diff.b_path ? 'update' : 'moved'))
22
- %li{ :class => op }
23
- = "(#{(diff.a_path == diff.b_path) ? 'igual' : 'cambio'})"
24
- = diff.a_path || diff.b_path
25
- %p.separator
26
- Specs
27
- %ul
28
- %li
29
- %dt Author:
30
- %dd= @commit.author.name
31
- %dt Commiter:
32
- %dd= @commit.committer.name
33
- %dt Commit Date:
34
- %dd= @commit.date
35
- %dt Work Date
36
- %dd= @commit.authored_date
37
- %dt
38
-
@@ -1,11 +0,0 @@
1
- - unless @project.rgithook.installed?
2
- .warning
3
- RGitHook is not installed
4
- %form{:method => 'post'}
5
- %input{:type => 'submit', :value => 'Install'}
6
- - else
7
- .info
8
- RGitHook is installed
9
- %form{:method => 'post'}
10
- %input{:type => 'submit', :value => 'ReInstall'}
11
-
@@ -1,47 +0,0 @@
1
- require 'optparse'
2
- require 'grit'
3
- module Ginst
4
- class CommandLine
5
- def self.run
6
- options = parse()
7
- puts %x(#{$0} --help) unless options[:command]
8
- exit(0) if options[:command] == :exit || !options[:command]
9
-
10
- if [:start,:stop,:restart,:status].include? options[:command]
11
- Server.send(options[:command],options)
12
- Process.waitall
13
- Server.status(options) unless options[:command] == :status
14
- %x(open http://127.0.0.1:#{options[:port]}) if [:start, :restart].include? options[:command]
15
- end
16
-
17
- Ginst.install(options) if options[:command] == :install
18
-
19
- rescue OptionParser::InvalidOption, OptionParser::AmbiguousOption
20
- puts "Invalid options #{ARGV}"
21
- puts %x(#{$0} --help)
22
- rescue Grit::InvalidGitRepositoryError
23
- puts "Invalid path #{options[:path]}. Not found a git repo"
24
- end
25
-
26
- def self.parse
27
- options = {}
28
- OptionParser.new do |opts|
29
- opts.banner = "Usage: #{File.basename($0)} [options]"
30
-
31
- opts.on_head('-s','--start','Start the web server') { options[:command] = :start }
32
- opts.on_head('-t','--stop', 'Stop the web server') { options[:command] = :stop }
33
- opts.on_head('-r','--restart','Restart the web server') { options[:command] = :restart }
34
- opts.on_head('-a','--status', 'Show status of the web server') { options[:command] = :status }
35
- opts.on_head('-p','--port PORT','Webserver port') {|p| options[:port] = p.to_i }
36
- opts.on_head('-i','--install [PATH]', 'Install ginst') {|p| options[:command] = :install ; p and options[:path] = p }
37
- opts.on('-p', '--path GIT_WORK_DIR', 'Specify other path (default current dir)'){|p| options[:path] = p}
38
- opts.on_tail("-h", "--help", 'Show help') { options[:command]=:exit; puts opts }
39
- opts.on_tail("-v", "--version", 'Show version') { options[:command]=:exit; puts "Ginst version #{Ginst::Version}" }
40
- end.parse!
41
-
42
- options[:path] ||= Dir.pwd
43
- options[:port] ||= 7654
44
- options
45
- end
46
- end
47
- end
@@ -1,40 +0,0 @@
1
- require 'optparse'
2
- require 'ruby-debug'
3
- module Ginst
4
- class CommandLine
5
- def self.run
6
- options = parse()
7
- puts %x(#{$0} --help) unless options[:command]
8
- exit(0) if options[:command] == :exit || !options[:command]
9
-
10
- if [:start,:stop,:restart,:status].include? options[:command]
11
- Server.send(options[:command])
12
- Process.waitall
13
- Server.status unless options[:command] == :status
14
- end
15
-
16
- rescue OptionParser::InvalidOption, OptionParser::AmbiguousOption
17
- puts "Invalid options #{ARGV}"
18
- puts %x(#{$0} --help)
19
- end
20
-
21
- def self.parse
22
- options = {}
23
- OptionParser.new do |opts|
24
- opts.banner = "Usage: #{File.basename($0)} [options]"
25
-
26
- opts.on_head('-s','--start','Start the web server') { options[:command] = :start }
27
- opts.on_head('-t','--stop', 'Stop the web server') { options[:command] = :stop }
28
- opts.on_head('-r','--restart','Restart the web server') { options[:command] = :restart }
29
- opts.on_head('-a','--status', 'Show status of the web server') { options[:command] = :status }
30
- opts.on_head('-i','--install [PATH]', 'Install ginst') {|p| options[:command] = :install ; p and options[:path] = p }
31
- opts.on('-p', '--path GIT_WORK_DIR', 'Specify other path (default current dir)'){|p| options[:path] = p}
32
- opts.on_tail("-h", "--help", 'Show help') { options[:command]=:exit; puts opts }
33
- opts.on_tail("-v", "--version", 'Show version') { options[:command]=:exit; puts "Ginst version #{Ginst::Version}" }
34
- end.parse!
35
-
36
- options[:path] ||= Dir.pwd
37
- options
38
- end
39
- end
40
- end
data/lib/ginst/plugin.rb DELETED
@@ -1,16 +0,0 @@
1
-
2
- module Ginst
3
- class GinstPlugin < ::RGitHook::Plugin
4
-
5
- module RunnerMethods
6
- def ginst_post_receive(old_commit,new_commit,ref)
7
- repo.commits_between(old_commit,new_commit).each do |commit|
8
- test(commit)
9
- end
10
-
11
- %x(say 'hello')
12
- repo.commit(old_commit).properties[:gritted] = "YES"
13
- end
14
- end
15
- end
16
- end
data/lib/ginst/server.rb DELETED
@@ -1,51 +0,0 @@
1
- require 'rubygems'
2
- require 'daemons'
3
-
4
- module Ginst
5
- class Server
6
- DEFAULT_PORT = 7654
7
-
8
- # Options are:
9
- # :port => Web server port
10
- # :path => Repo path
11
- def self.start(options = {})
12
- puts "Starting ginst for #{options[:path]} at http://localhost:#{options[:port] || DEFAULT_PORT}"
13
- fork{run_daemon_with_env(options[:path],['start','--',sinatra_options(options)])}
14
- end
15
-
16
- def self.stop(options = {})
17
- fork{run_daemon_with_env(options[:path],['stop'])}
18
- end
19
-
20
- def self.restart(options = {})
21
- puts "Restarting ginst for #{options[:path]} at http://localhost:#{options[:port] || DEFAULT_PORT}"
22
- run_daemon_with_env(options[:path],['restart','--',sinatra_options(options)])
23
- end
24
-
25
- def self.status(options = {})
26
- run_daemon_with_env(options[:path],['status']).show_status.to_s
27
- end
28
-
29
- private
30
-
31
- def self.run_daemon_with_env(path,env)
32
- rgithook = ::RGitHook::RGitHook.new(path)
33
- daemons_options = {:app_name => "ginst-#{rgithook.project_name}", :dir_mode=>:normal, :dir=>rgithook.path, :ARGV => env, :multiple => false, :log_output => true, :monitor => true, :mode => :exec}
34
- ENV['REPO_PATH'] = path
35
- Daemons.run(server_path(path),daemons_options)
36
- end
37
-
38
- def self.sinatra_options(options)
39
- sinatra_options = "-p #{options.delete(:port) || DEFAULT_PORT} -e production"
40
- end
41
-
42
- # Try to load de server of the local repo .git/ginst/webserver
43
- # but if it does not exists, load the default
44
- def self.server_path(path)
45
- local_file = File.join(Grit::Repo.new(path).path,'ginst','webserver.rb')
46
- system_file= File.expand_path(File.join(File.dirname(__FILE__),'..','app','webserver.rb'))
47
- File.file?(local_file) ? local_file : system_file
48
- end
49
-
50
- end
51
- end
@@ -1,6 +0,0 @@
1
- require 'ginst'
2
- require 'ginst/plugin'
3
-
4
- on :post_receive, :background => true do |old_commit,new_commit,ref|
5
- ginst_post_receive(old_commit,new_commit,ref)
6
- end