projmgr 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ Copyright (c) 2010 Jacob Hammack, Hammackj LLC
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+ * Neither the name of the Jacob Hammack or Hammackj LLC nor the
13
+ names of its contributors may be used to endorse or promote products
14
+ derived from this software without specific prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ DISCLAIMED. IN NO EVENT SHALL JACOB HAMMACK or HAMMACKJ LLC BE LIABLE FOR ANY
20
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/NEWS.md ADDED
@@ -0,0 +1,3 @@
1
+ 0.0.1 (December 27, 2010)
2
+ ===
3
+ - Initial development
@@ -0,0 +1,78 @@
1
+ ProjMgr
2
+ ===
3
+
4
+ ProjMgr is a simple source code project manager for updating and checking local changes on multiple projects at once.
5
+
6
+ Requirements
7
+ ---
8
+
9
+ * ruby
10
+ * rubygems
11
+ * choice
12
+ * yaml
13
+
14
+
15
+ Installation
16
+ ---
17
+ Installation is really easy just gem install!
18
+
19
+ % sudo gem install projmgr
20
+
21
+ Usage
22
+ ---
23
+ Using ProjMgr is fairly simple. Once installation is complete type to create a skeleton config file:
24
+
25
+ % projmgr --create-file
26
+ [*] An empty ~/.projmgr has been created. Please edit and fill in the correct values.
27
+
28
+ This will create a empty skeleton config file, ~/.projmgr, edit this file. The file is a simple yaml configuration file structured like this:
29
+
30
+
31
+ rubyvirustotal:
32
+ name: ruby-virustotal
33
+ path: ~/Projects/public/ruby-virustotal
34
+ type: git
35
+
36
+ nessusdb:
37
+ name: nessusdb
38
+ path: ~/Projects/public/nessusdb
39
+ type: git
40
+
41
+ projectname:
42
+ name:
43
+ path:
44
+ type:
45
+
46
+ To configure ProjMgr just change projectname/name/path/type to fit your projects.
47
+
48
+ projectname - can be any string identifier
49
+ name - any string displayed during update/checks
50
+ path - the path to the repo to check/update
51
+ type - type of the repo either 'svn' or 'git'
52
+
53
+ Once the config file is edited everything is ready to go.
54
+
55
+ Simple usage is as follows:
56
+
57
+ Checking for local changes
58
+ ----
59
+
60
+ % projmgr -c
61
+ [!] ProjMgr has local changes
62
+ [!] nessusdb has local changes
63
+
64
+
65
+ Updating each project
66
+ ----
67
+
68
+ % projmgr -u
69
+ [*] Updating ProjMgr...
70
+ Already up-to-date!
71
+ [*] Updating nessusdb...
72
+ Already up-to-date!
73
+
74
+ That covers all of the basic usage of ProjMgr.
75
+
76
+ Contact
77
+ ---
78
+ You can reach me at jacob[dot]hammack[at]hammackj[dot]com.
@@ -0,0 +1,10 @@
1
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
2
+ require "projmgr"
3
+
4
+ task :build do
5
+ system "gem build projmgr.gemspec"
6
+ end
7
+
8
+ task :release => :build do
9
+ system "gem push projmgr-#{ProjMgr::VERSION}.gem"
10
+ end
data/TODO.md ADDED
@@ -0,0 +1,7 @@
1
+ TODO
2
+ ===
3
+
4
+ 0.0.2
5
+ ---
6
+ - Add support for other SCM's besides git and svn
7
+ - Create rSpec tests for everything
@@ -0,0 +1,138 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ # projmgr - A source code control managment tool
5
+ #
6
+ # hammackj - 12-27-2010 - Version 0.0.1
7
+ #
8
+
9
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '/../lib'))
10
+
11
+ $stdout.sync = true
12
+ $stderr.sync = true
13
+
14
+ require 'projmgr'
15
+
16
+ module ProjMgr
17
+
18
+ # ProjMgr Application class
19
+ #
20
+ # @author Jacob Hammack <jacob.hammack@hammackj.com>
21
+ class ProjMgr
22
+
23
+ # Creates a ProjMgr instance
24
+ #
25
+ def initialize
26
+ @root = `pwd`
27
+ end
28
+
29
+ # Main class for the ProjMgr command line tool
30
+ #
31
+ def main
32
+ Choice.options do
33
+ banner "ProjMgr - v#{VERSION}"
34
+ header 'Jacob Hammack'
35
+ header 'http://hammackj.com'
36
+ header 'Usage: projmgr [OPTIONS]'
37
+ header ''
38
+
39
+ option :check_local_changes do
40
+ short '-c'
41
+ long '--check_local_changes'
42
+ desc 'Checks local changes in configured scm repositories'
43
+ end
44
+
45
+ option :update do
46
+ short '-u'
47
+ long '--update'
48
+ desc 'Updates each configured scm repository'
49
+ end
50
+
51
+ option :create_config do
52
+ long '--create-config'
53
+ desc 'Creates a skeleton config file to use'
54
+ action do
55
+ if File.exists?(File.expand_path(CONFIG_FILE)) == false
56
+ File.open(File.expand_path(CONFIG_FILE), 'w+') do |f|
57
+ f.write("projectname: \n\tname: \n\tpath: \n\ttype: \n\n")
58
+ f.write("projectname: \n\tname: \n\tpath: \n\ttype: \n")
59
+ end
60
+
61
+ puts "[*] An empty #{CONFIG_FILE} has been created. Please edit and fill in the correct values."
62
+ exit
63
+ else
64
+ puts "[!] #{CONFIG_FILE} already exists. Please delete it if you wish to re-create it."
65
+ exit
66
+ end
67
+ end
68
+ end
69
+
70
+ separator ''
71
+ separator 'Other Options'
72
+
73
+ option :help do
74
+ short '-h'
75
+ long '--help'
76
+ desc 'Show this message'
77
+ end
78
+
79
+ option :version do
80
+ short '-v'
81
+ long '--version'
82
+ desc 'Show version'
83
+ action do
84
+ puts "ProjMgr - v#{VERSION}"
85
+ exit
86
+ end
87
+ end
88
+
89
+ footer ''
90
+ end
91
+
92
+ if ARGV.length == 0
93
+ puts Choice.help
94
+ end
95
+
96
+ if File.exists?(File.expand_path(CONFIG_FILE))
97
+ @repos = YAML.load_file File.expand_path(CONFIG_FILE)
98
+ else
99
+ puts "[!] #{CONFIG_FILE} does not exist. Please run projmgr --create-config, to create it."
100
+ exit
101
+ end
102
+
103
+ begin
104
+ @threads = Array.new
105
+ @repos.each_key do |key|
106
+ t = Thread.new do
107
+ if @repos[key]['type'] == "svn"
108
+ repo = Svn.new @repos[key]['name'], @repos[key]['path'], @repos[key]['root']
109
+ elsif @repos[key]['type'] == "git"
110
+ repo = Git.new @repos[key]['name'], @repos[key]['path'], @repos[key]['root']
111
+ end
112
+
113
+ if repo == nil
114
+ puts "[!] #{key} is a malformed entry please correct it."
115
+ next
116
+ end
117
+
118
+ if Choice.choices[:check_local_changes] != nil
119
+ puts "[!] #{@repos[key]['name']} has local changes" if repo.has_local_changes?
120
+ elsif Choice.choices[:update] != nil
121
+ puts "[*] Updating #{@repos[key]['name']}...\n #{repo.update}"
122
+ end
123
+ end
124
+ @threads << t
125
+ end
126
+
127
+ @threads.each do |t|
128
+ t.join
129
+ end
130
+ rescue Exception => e
131
+ puts "[!] Caught Exception: #{e.inspect}"
132
+ end
133
+ end
134
+ end
135
+ end
136
+
137
+ app = ProjMgr::ProjMgr.new
138
+ app.main
@@ -0,0 +1,13 @@
1
+
2
+ module ProjMgr
3
+ VERSION = "0.0.1"
4
+ CONFIG_FILE = "~/.projmgr"
5
+ end
6
+
7
+ require 'rubygems'
8
+ require 'choice'
9
+ require 'yaml'
10
+
11
+ require 'projmgr/git'
12
+ require 'projmgr/svn'
13
+ require 'projmgr/scm'
@@ -0,0 +1,40 @@
1
+ require 'projmgr/scm'
2
+
3
+ module ProjMgr
4
+
5
+ # A wrapper class for interacting with a git repository
6
+ #
7
+ # @author Jacob Hammack <jacob.hammack@hammackj.com>
8
+ class Git < Scm
9
+
10
+ # Checks for updates in the target repo
11
+ #
12
+ # @return [String] the results of 'git pull' on the target repository
13
+ def update
14
+ results = `cd #{@path} && git pull && cd #{@root}`
15
+
16
+ if results =~ /Already up-to-date./
17
+ return "Already up-to-date!\n"
18
+ else
19
+ return results
20
+ end
21
+ end
22
+
23
+ # Checks for local changes in the target repository
24
+ #
25
+ # @return [Boolean] if there is local changes or not
26
+ def has_local_changes?
27
+ results = `cd #{@path} && git status && cd #{@root}`
28
+
29
+ if results !~ /nothing to commit/
30
+ return true
31
+ elsif results =~ /Your branch is ahead of/
32
+ return true
33
+ elsif results =~ /Untracked files/
34
+ return true
35
+ else
36
+ return false
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,20 @@
1
+ module ProjMgr
2
+
3
+ # A parent class for interacting with a source code repository
4
+ #
5
+ # @author Jacob Hammack <jacob.hammack@hammackj.com>
6
+ class Scm
7
+
8
+ # Creates a instance of a SCM repository
9
+ #
10
+ # @param project name of the project
11
+ # @param path path to the project
12
+ # @param root path back to the root
13
+ #
14
+ def initialize project, path, root
15
+ @project = project
16
+ @path = path
17
+ @root = root
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,31 @@
1
+ require 'projmgr/scm'
2
+
3
+ module ProjMgr
4
+
5
+ # A parent class for interacting with a source code repository
6
+ #
7
+ # @author Jacob Hammack <jacob.hammack@hammackj.com>
8
+ class Svn < Scm
9
+
10
+ # Checks for updates in the target repo
11
+ #
12
+ # @return [String] the results of 'git pull' on the target repository
13
+ def update
14
+ results = `cd #{@path} && svn stat && svn update && cd #{@root}`
15
+ return results
16
+ end
17
+
18
+ # Checks for local changes in the target repository
19
+ #
20
+ # @return [Boolean] if there is local changes or not
21
+ def has_local_changes?
22
+ results = `cd #{@path} && svn stat && cd #{@root}`
23
+
24
+ if results.length > 0
25
+ return true
26
+ else
27
+ return false
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,33 @@
1
+ # encoding: utf-8
2
+
3
+ base = __FILE__
4
+ $:.unshift(File.join(File.dirname(base), 'lib'))
5
+
6
+ require 'projmgr'
7
+
8
+ Gem::Specification.new do |s|
9
+ s.name = 'projmgr'
10
+ s.version = ProjMgr::VERSION
11
+ s.homepage = "http://github.com/hammackj/projmgr/"
12
+ s.summary = "ProjMgr"
13
+ s.description = "ProjMgr is a source code managment tool for automating project managment"
14
+
15
+ s.author = "Jacob Hammack"
16
+ s.email = "jacob.hammack@hammackj.com"
17
+
18
+ s.files = Dir['[A-Z]*'] + Dir['lib/**/*'] + ['projmgr.gemspec']
19
+ s.default_executable = 'projmgr'
20
+ s.executables = ['projmgr']
21
+ s.require_paths = ["lib"]
22
+
23
+ s.required_rubygems_version = ">= 1.3.6"
24
+ s.rubyforge_project = "projmgr"
25
+
26
+ s.add_development_dependency "rspec"
27
+
28
+ s.has_rdoc = 'yard'
29
+ s.extra_rdoc_files = ["README.md", "LICENSE", "NEWS.md", "TODO.md"]
30
+
31
+ s.add_dependency('choice', '>= 0.1.4')
32
+
33
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: projmgr
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Jacob Hammack
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-12-29 00:00:00 -06:00
19
+ default_executable: projmgr
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rspec
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: choice
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 19
44
+ segments:
45
+ - 0
46
+ - 1
47
+ - 4
48
+ version: 0.1.4
49
+ type: :runtime
50
+ version_requirements: *id002
51
+ description: ProjMgr is a source code managment tool for automating project managment
52
+ email: jacob.hammack@hammackj.com
53
+ executables:
54
+ - projmgr
55
+ extensions: []
56
+
57
+ extra_rdoc_files:
58
+ - README.md
59
+ - LICENSE
60
+ - NEWS.md
61
+ - TODO.md
62
+ files:
63
+ - LICENSE
64
+ - NEWS.md
65
+ - Rakefile
66
+ - README.md
67
+ - TODO.md
68
+ - lib/projmgr/git.rb
69
+ - lib/projmgr/scm.rb
70
+ - lib/projmgr/svn.rb
71
+ - lib/projmgr.rb
72
+ - projmgr.gemspec
73
+ - bin/projmgr
74
+ has_rdoc: yard
75
+ homepage: http://github.com/hammackj/projmgr/
76
+ licenses: []
77
+
78
+ post_install_message:
79
+ rdoc_options: []
80
+
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ hash: 3
89
+ segments:
90
+ - 0
91
+ version: "0"
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ hash: 23
98
+ segments:
99
+ - 1
100
+ - 3
101
+ - 6
102
+ version: 1.3.6
103
+ requirements: []
104
+
105
+ rubyforge_project: projmgr
106
+ rubygems_version: 1.3.7
107
+ signing_key:
108
+ specification_version: 3
109
+ summary: ProjMgr
110
+ test_files: []
111
+