l5m-tools 0.0.2.beta

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "rdoc", "~> 3.12"
11
+ gem "bundler", "~> 1.2.0"
12
+ gem "jeweler", "~> 1.8.4"
13
+ #gem "etc"
14
+ #gem "rcov", ">= 0"
15
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Ronghai
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,19 @@
1
+ = l5m-tools
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to l5m-tools
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2013 Ronghai. See LICENSE.txt for
18
+ further details.
19
+
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = l5m-tools
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to l5m-tools
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2013 Ronghai. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,54 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "l5m-tools"
18
+ gem.homepage = "http://github.com/RONGHAI/l5m-tools"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{A tool set for Lake5Media and QingheTech developer }
21
+ gem.description = %Q{A tool set for Lake5Media and QingheTech developer}
22
+ gem.email = "ronghai.wei@outlook.com"
23
+ #gem.platform = Gem::Platform::Win32
24
+ gem.authors = ["RONGHAI"]
25
+ # dependencies defined in Gemfile
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rake/testtask'
30
+ Rake::TestTask.new(:test) do |test|
31
+ test.libs << 'lib' << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+
36
+ #require 'rcov/rcovtask'
37
+ #Rcov::RcovTask.new do |test|
38
+ # test.libs << 'test'
39
+ # test.pattern = 'test/**/test_*.rb'
40
+ # test.verbose = true
41
+ # test.rcov_opts << '--exclude "gems/*"'
42
+ #end
43
+
44
+ task :default => :test
45
+
46
+ require 'rdoc/task'
47
+ Rake::RDocTask.new do |rdoc|
48
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
49
+
50
+ rdoc.rdoc_dir = 'rdoc'
51
+ rdoc.title = "l5m-tools #{version}"
52
+ rdoc.rdoc_files.include('README*')
53
+ rdoc.rdoc_files.include('lib/**/*.rb')
54
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.2.beta
data/bin/duplicate-app ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'l5m-tools'
3
+ L5MTools.application.duplicate_app(*ARGV)
data/bin/l5m ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ require 'l5m-tools'
3
+ if ARGV[0] == 'svn'
4
+ L5MTools.svn.run(*ARGV)
5
+ else
6
+ L5MTools.application.run(*ARGV)
7
+ end
data/bin/make-app ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'l5m-tools'
3
+ L5MTools.application.make_app(*ARGV)
data/bin/set_env.sh ADDED
@@ -0,0 +1,19 @@
1
+ #!/bin/sh
2
+ alias svn.log='svn.tool log'
3
+ alias svn.status='svn.tool status'
4
+ alias svn.update='svn.tool update'
5
+ alias update.root='rm -rf $CATALINA_HOME/webapps/ROOT && rm -rf $CATALINA_HOME/webapps/ROOT.war && scp $DEV_HOST:/home/l5m/mytc/webapps/ROOT.war $CATALINA_HOME/webapps'
6
+ #export JAVA_HOME="C:/Program Files/Java/jdk1.5.0_14"
7
+ function update.28(){
8
+ ssh 28 "cd ~/project && ./make_wars.sh $@ && ./deploy_on_28.sh $@"
9
+ }
10
+ export WEBAPPS='$CATALINA_HOME/webapps'
11
+ function sync.package(){
12
+ svn.tool.rb status $1 | awk '{print $2}' | sed '/^$/d' | sed -e 's/\\/\//g' | while read fi ; do echo $fi && cp $WORKSPACE/$1/src/$fi $WORKSPACE/$2/src/$fi; done
13
+ }
14
+ for i in $CATALINA_HOME/common/lib/ $CATALINA_HOME/common/i18n/
15
+ do
16
+ export CLASS_PATH=$CLASS_PATH;(find $i -regex ".*\.\(jar\|zip\)" | xargs echo |tr ' ' ';')
17
+ done
18
+
19
+ export CLASSPATH=$CLASS_PATH
data/bin/svn.tool ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'l5m-tool'
3
+ L5MTools.svn.run(*ARGV)
data/info ADDED
File without changes
data/l5m-tools.gemspec ADDED
@@ -0,0 +1,83 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "l5m-tools"
8
+ s.version = "0.0.2.beta"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["RONGHAI"]
12
+ s.date = "2013-02-07"
13
+ s.description = "A tool set for Lake5Media and QingheTech developer"
14
+ s.email = "ronghai.wei@outlook.com"
15
+ s.executables = ["duplicate-app", "l5m", "make-app", "set_env.sh", "svn.tool"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE.txt",
18
+ "README",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ "Gemfile",
24
+ "LICENSE.txt",
25
+ "README",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "bin/duplicate-app",
30
+ "bin/l5m",
31
+ "bin/make-app",
32
+ "bin/set_env.sh",
33
+ "bin/svn.tool",
34
+ "info",
35
+ "l5m-tools.gemspec",
36
+ "lib/l5m-tools.rb",
37
+ "lib/l5m-tools/application.rb",
38
+ "lib/l5m-tools/array.rb",
39
+ "lib/l5m-tools/env.rb",
40
+ "lib/l5m-tools/ignore/svn_ingore.yaml",
41
+ "lib/l5m-tools/l5m-tools-module.rb",
42
+ "lib/l5m-tools/string.rb",
43
+ "lib/l5m-tools/svn.rb",
44
+ "lib/l5m-tools/template/Template.jsp",
45
+ "lib/l5m-tools/template/TemplateBaseAbstractWorker.java",
46
+ "lib/l5m-tools/template/TemplateServicerImpl.java",
47
+ "lib/l5m-tools/template/TemplateWorker.java",
48
+ "lib/l5m-tools/template/frt.jsp",
49
+ "lib/l5m-tools/template/ms2.jsp",
50
+ "lib/l5m-tools/template/rad.jsp",
51
+ "lib/l5m-tools/template/ttv2.jsp",
52
+ "lib/l5m-tools/tools.rb",
53
+ "test/helper.rb",
54
+ "test/test_l5m-tools.rb"
55
+ ]
56
+ s.homepage = "http://github.com/RONGHAI/l5m-tools"
57
+ s.licenses = ["MIT"]
58
+ s.require_paths = ["lib"]
59
+ s.rubygems_version = "1.8.17"
60
+ s.summary = "A tool set for Lake5Media and QingheTech developer"
61
+
62
+ if s.respond_to? :specification_version then
63
+ s.specification_version = 3
64
+
65
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
66
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
67
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
68
+ s.add_development_dependency(%q<bundler>, ["~> 1.2.0"])
69
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
70
+ else
71
+ s.add_dependency(%q<shoulda>, [">= 0"])
72
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
73
+ s.add_dependency(%q<bundler>, ["~> 1.2.0"])
74
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
75
+ end
76
+ else
77
+ s.add_dependency(%q<shoulda>, [">= 0"])
78
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
79
+ s.add_dependency(%q<bundler>, ["~> 1.2.0"])
80
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
81
+ end
82
+ end
83
+
@@ -0,0 +1,41 @@
1
+ require 'l5m-tools/env'
2
+ require 'pathname'
3
+
4
+ module L5MTools
5
+ TEMPLATE_DIR = Pathname.new(__FILE__).parent + 'template'
6
+ class Application
7
+ require 'l5m-tools/tools'
8
+ include Tools
9
+ def duplicate_app(*args)
10
+ replacements = {args[1] => args[2]}
11
+ File.open(args[0], "r") do |infile|
12
+ while (line = infile.gets)
13
+ line = line.chomp.strip
14
+ duplicate_and_replace( line.chomp , replacements ) if line.length > 0 && line[0] != '#'
15
+ end
16
+ end
17
+ end
18
+ def make_app(package, application, use_base_worker, &block)
19
+ application[0] = application[0].capitalize
20
+ replacements = {
21
+ '!REPLACE_ME_FILE!' => application,
22
+ '!REPLACE_STYLE!' => package
23
+ }
24
+ copy_silently( use_base_worker ? (TEMPLATE_DIR+"TemplateBaseAbstractWorker.java") : (TEMPLATE_DIR+"TemplateWorker.java") ,
25
+ "#{WORKSPACE}/#{package}/src/com/l5m/#{package}/engine/worker/#{application}Worker.java" , replacements )
26
+ copy_silently( TEMPLATE_DIR+"TemplateServicerImpl.java" ,
27
+ "#{WORKSPACE}/#{package}/src/com/l5m/#{package}/engine/servicer/#{application}ServicerImpl.java" , replacements )
28
+ if File.exist?( TEMPLATE_DIR+"#{package}.jsp")
29
+ copy_silently( TEMPLATE_DIR+"#{package}.jsp" ,
30
+ "#{WORKSPACE}/#{package}/src/jsp/#{application}.jsp" , replacements )
31
+ else
32
+ copy_silently( TEMPLATE_DIR+"Template.jsp" ,
33
+ "#{WORKSPACE}/#{package}/src/jsp/#{application}.jsp" , replacements )
34
+ end
35
+ block.call(Time.now, package, application, use_base_worker) if block_given?
36
+ end
37
+
38
+
39
+
40
+ end
41
+ end
@@ -0,0 +1,13 @@
1
+ class Array
2
+ ##
3
+ # This method will return the argument value.
4
+ # = Example
5
+ # ["svn", "--email", "ronghai@test.com"].option!('--email)' => "ronghai@test.com"
6
+ # And the list will be ["svn"]
7
+ # get option index --email index, delete --email, then delete value next to --email
8
+ def option!(opt)
9
+ if i = self.index(opt)
10
+ return self.delete_at(i) && self.delete_at(i)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+ module L5MTools
2
+ raise "no WORKSPACE env " unless WORKSPACE = ENV["WORKSPACE"] || ENV["workspace"]
3
+ raise "no CATALINA_HOME env" unless CATALINA_HOME = ENV["CATALINA_HOME"]
4
+ raise "no SVN_USER env" unless SVN_USER = ENV["SVN_USER"]
5
+ raise "no SENDER_EMAIL env" unless SENDER_EMAIL = ENV["SENDER_EMAIL"]
6
+ PACKAGES = ENV["PACKAGES"].split(/[,;:]/) if ENV["PACKAGES"]
7
+ DEV_HOST = ENV["DEV_HOST"]
8
+ end
@@ -0,0 +1,21 @@
1
+ ---
2
+ customtags:
3
+ - M com\l5m\customtags\tags\servlets\ContextInitListener.java
4
+ qhtcommon:
5
+ - M com\l5m\common\engine\DbHandler.java
6
+ - M com\l5m\common\bean\NavigationBean.java
7
+ - M com\l5m\common\bean\PackageFileBean.java
8
+ - M com\l5m\common\util\BASE64Encoder.java
9
+ - M com\l5m\common\util\AppLog.java
10
+ common:
11
+ - "? javascript\\timespan.js"
12
+ - "? javascript\\prototypeV7.js"
13
+ - "? javascript\\timespanlite.js"
14
+ - "? javascript\\timespanweekly.js"
15
+ - D javascript\prototype.js
16
+ - M jsp\TimeSpanNew.jsp
17
+ - M com\l5m\common\engine\DbHandler.java
18
+ - M com\l5m\common\l5m_util\module\DemoModule.java
19
+ - M com\l5m\common\util\NavigationAccessUtil.java
20
+ - "? com\\l5m\\common\\util\\view"
21
+ - "? com\\l5m\\common\\util\\db"
@@ -0,0 +1,12 @@
1
+ require 'l5m-tools/application'
2
+ require 'l5m-tools/svn'
3
+ module L5MTools
4
+ class << self
5
+ def application
6
+ @application ||= L5MTools::Application.new
7
+ end
8
+ def svn
9
+ @svn ||= L5MTools::SVN.new
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ class String
2
+ def to_boolean
3
+ return true if self == true || self =~ (/(true|t|yes|y|1)$/i)
4
+ return false if self == false || self.nil? || self =~ (/(false|f|no|n|0)$/i)
5
+ raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
6
+ end
7
+ end
@@ -0,0 +1,109 @@
1
+ require 'l5m-tools/env'
2
+ require 'pathname'
3
+
4
+ module L5MTools
5
+ class SVN
6
+ require 'l5m-tools/tools'
7
+ include Tools
8
+ require 'l5m-tools/array'
9
+ require 'yaml'
10
+
11
+ class << self
12
+ require "fileutils"
13
+ include FileUtils
14
+ end
15
+ copy(Pathname.new(__FILE__).parent + 'ignore/svn_ingore.yaml', File.expand_path('~/svn_ingore.yaml')) unless File.exists? File.expand_path('~/svn_ingore.yaml')
16
+ IGNORE_FILES = YAML::load(File.open(File.expand_path('~/svn_ingore.yaml'), 'rb') { |f| f.read } )
17
+ SPERATE = "------------------------------------------------------------------------"
18
+ class << self
19
+ def method_missing(method_id, *arguments, &block)
20
+ self.class_eval %{
21
+ def self.#{method_id}(*args, &b)
22
+ cmd = "svn #{method_id} "
23
+ cmd << args.join(" ") if args
24
+ `\#{cmd}`
25
+ end
26
+ }, __FILE__, __LINE__
27
+ send(method_id, *arguments, &block)
28
+ end
29
+ end
30
+
31
+ def method_missing(method_id, *arguments, &block)
32
+ self.class.class_eval %{
33
+ def #{method_id}(packz, options={}, svn_options=[], &b)
34
+ rs = ''
35
+ packz.each{|pac|
36
+ next unless change_to_package_directory(pac)
37
+ rs << SVN.#{method_id}(*svn_options)
38
+ }
39
+ rs
40
+ end
41
+ }, __FILE__, __LINE__
42
+ puts
43
+ send(method_id, arguments[0], arguments[1], arguments[2], &block)
44
+ end
45
+
46
+ def change_to_package_directory package
47
+ change_directory "#{WORKSPACE}/#{package}"
48
+ end
49
+
50
+
51
+ def log packages, options={}, svn_options=[]
52
+ log = ''
53
+ usr = options[:username] || ''
54
+ date = options[:date] || Date.today.strftime("%F")
55
+ reverse = options[:reverse]
56
+ packages.each{|pac|
57
+ next unless change_to_package_directory(pac)
58
+ commits = SVN.log("-q", "-r", "HEAD:{#{date}}") .split($/).delete_if{|c| c[0] == '-' || (usr != '' && c.split("|")[1].strip != usr)}.collect! {|c| c.split("|")[0].strip[1..-1]}.sort!
59
+ commits.reverse! if reverse
60
+ commits.each{|c|
61
+ log << SVN.log("-v", "-r", c).gsub!(/(#{$/}){2,}/m,$/+$/)
62
+ }
63
+ }
64
+ log.gsub!(/(#{SPERATE}#{$/}#{SPERATE})/m, SPERATE)
65
+ log
66
+ end
67
+
68
+ def status packages, options={}, svn_options=[]
69
+ status = ''
70
+ packages.each{|pac|
71
+ innert_dirs =(pac.include?("tag"))?["src", "WebContent"]:["src"];
72
+ lines = [];
73
+ innert_dirs.each{|d|
74
+ next unless change_to_package_directory("#{pac}/#{d}")
75
+ lines += (SVN.status).split($/)
76
+ }
77
+ lines -= IGNORE_FILES[pac] unless IGNORE_FILES[pac].nil?
78
+ status << "#{pac} #{$/}" << lines.join($/) << "#{$/}" unless lines.empty?
79
+ }
80
+ status
81
+ end
82
+
83
+ def update packages, options={}, svn_options=[]
84
+ log = ''
85
+ packages.each{|pac|
86
+ next unless change_to_package_directory(pac)
87
+ log << pac+"...#{$/}"
88
+ log << SVN.update
89
+ }
90
+ log
91
+ end
92
+ alias :st :status
93
+ def run(*args, &block)
94
+ cmd = args.shift
95
+ args , svn_args = args[0..(args.index '--')], args[((args.index '--')+1)..-1] if args.index '--'
96
+
97
+ options = {username:(args.option! '--user' || SVN_USER), reverse:(args.delete('-r')), date: (args.option!('--date')), mail:(args.delete('-e') || args.delete('--email')) }
98
+ options[:sendto] = args.option!('-s') || SENDER_EMAIL
99
+ options[:title] = args.option!('--title') || "svn #{cmd} @#{Time.now.strftime("%F %T")}"
100
+
101
+ packages = args.empty? ? PACKAGES : args
102
+
103
+ result = send cmd, packages, options, svn_args
104
+ send_mail(options[:sendto], options[:title] , result) if options[:mail]
105
+ block.call(result) if block_given?
106
+ result
107
+ end
108
+ end
109
+ end