genRelease 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4f77cc0b64bd944b6d92fdaacf9f3842b9bdbbd9
4
+ data.tar.gz: f974ed647361a226f26732fbfdd9c95b75511c4a
5
+ SHA512:
6
+ metadata.gz: 6f8da4d91797d58140cfeb6530fe96bf2c4b8e8dac6475b1d83a99dd2ac0139b83d7fcac03ade316f33decab5bec9e90eddb37fdab7c18685ee34e9a4fe71a69
7
+ data.tar.gz: 760753e09ff4f9db86666054d08226217ff92ac06ace4a6df649b7d42fac11c257cf3af0295205df623cf90873e1406d60a2451435d80a76d920019ca23710bb
@@ -0,0 +1,3 @@
1
+ # Created by .gitignore support plugin (hsz.mobi)
2
+ .idea
3
+ testfiles
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
@@ -0,0 +1,46 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ genRelease (0.0.1)
5
+ gli (= 2.12.2)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ aruba (0.6.1)
11
+ childprocess (>= 0.3.6)
12
+ cucumber (>= 1.1.1)
13
+ rspec-expectations (>= 2.7.0)
14
+ builder (3.2.2)
15
+ childprocess (0.5.5)
16
+ ffi (~> 1.0, >= 1.0.11)
17
+ cucumber (1.3.17)
18
+ builder (>= 2.1.2)
19
+ diff-lcs (>= 1.1.3)
20
+ gherkin (~> 2.12)
21
+ multi_json (>= 1.7.5, < 2.0)
22
+ multi_test (>= 0.1.1)
23
+ diff-lcs (1.2.5)
24
+ ffi (1.9.6)
25
+ gherkin (2.12.2)
26
+ multi_json (~> 1.3)
27
+ gli (2.12.2)
28
+ json (1.8.1)
29
+ multi_json (1.10.1)
30
+ multi_test (0.1.1)
31
+ rake (10.4.2)
32
+ rdoc (4.2.0)
33
+ json (~> 1.4)
34
+ rspec-expectations (3.1.2)
35
+ diff-lcs (>= 1.2.0, < 2.0)
36
+ rspec-support (~> 3.1.0)
37
+ rspec-support (3.1.2)
38
+
39
+ PLATFORMS
40
+ ruby
41
+
42
+ DEPENDENCIES
43
+ aruba
44
+ genRelease!
45
+ rake
46
+ rdoc
@@ -0,0 +1,6 @@
1
+ = genRelease
2
+
3
+ Describe your project here
4
+
5
+ :include:genRelease.rdoc
6
+
@@ -0,0 +1,44 @@
1
+ require 'rake/clean'
2
+ require 'rubygems'
3
+ require 'rubygems/package_task'
4
+ require 'rdoc/task'
5
+ require 'cucumber'
6
+ require 'cucumber/rake/task'
7
+ Rake::RDocTask.new do |rd|
8
+ rd.main = "README.rdoc"
9
+ rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
10
+ rd.title = 'Your application title'
11
+ end
12
+
13
+ spec = eval(File.read('genRelease.gemspec'))
14
+
15
+ Gem::PackageTask.new(spec) do |pkg|
16
+ end
17
+ CUKE_RESULTS = 'results.html'
18
+ CLEAN << CUKE_RESULTS
19
+ desc 'Run features'
20
+ Cucumber::Rake::Task.new(:features) do |t|
21
+ opts = "features --format html -o #{CUKE_RESULTS} --format progress -x"
22
+ opts += " --tags #{ENV['TAGS']}" if ENV['TAGS']
23
+ t.cucumber_opts = opts
24
+ t.fork = false
25
+ end
26
+
27
+ desc 'Run features tagged as work-in-progress (@wip)'
28
+ Cucumber::Rake::Task.new('features:wip') do |t|
29
+ tag_opts = ' --tags ~@pending'
30
+ tag_opts = ' --tags @wip'
31
+ t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty -x -s#{tag_opts}"
32
+ t.fork = false
33
+ end
34
+
35
+ task :cucumber => :features
36
+ task 'cucumber:wip' => 'features:wip'
37
+ task :wip => 'features:wip'
38
+ require 'rake/testtask'
39
+ Rake::TestTask.new do |t|
40
+ t.libs << "test"
41
+ t.test_files = FileList['test/*_test.rb']
42
+ end
43
+
44
+ task :default => [:test,:features]
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/env ruby
2
+ require 'gli'
3
+ begin # XXX: Remove this begin/rescue before distributing your app
4
+ require 'genRelease'
5
+ rescue LoadError
6
+ STDERR.puts "In development, you need to use `bundle exec bin/genRelease` to run your app"
7
+ STDERR.puts "At install-time, RubyGems will make sure lib, etc. are in the load path"
8
+ STDERR.puts "Feel free to remove this message from bin/genRelease now"
9
+ exit 64
10
+ end
11
+ # require commands files
12
+ Dir.glob("./lib/genRelease/commands/*.rb").sort.each do |f|
13
+ require f
14
+ end
15
+
16
+ include GLI::App
17
+
18
+ program_desc 'Describe your application here'
19
+
20
+ version GenRelease::VERSION
21
+
22
+ subcommand_option_handling :normal
23
+ arguments :strict
24
+
25
+ desc 'Describe some switch here'
26
+ switch [:s,:switch]
27
+ desc 'Whether print the details'
28
+ switch :verbose, :negatable => false
29
+ desc 'Describe some flag here'
30
+ default_value 'the default'
31
+ arg_name 'The name of the argument'
32
+ flag [:f,:flagname]
33
+
34
+ desc 'Generate the packages file including checksum of all files'
35
+ arg_name 'buildpath',:multiple
36
+ command :build do |c|
37
+ desc 'set up one Hostname for the release'
38
+ c.flag [:h,:hostname,'host-name'], :required => true
39
+
40
+ c.action do |global_options,options,args|
41
+ # Your command logic here
42
+ # If you have any errors, just raise them
43
+ # raise "that command made no sense"
44
+ builder = GenRelease::Commands::Build.new(global_options,*args)
45
+ builder.build options
46
+ end
47
+ end
48
+
49
+ desc 'Describe clean here'
50
+ arg_name 'Describe arguments to clean here'
51
+ command :clean do |c|
52
+ c.action do |global_options,options,args|
53
+ puts "clean command ran"
54
+ end
55
+ end
56
+
57
+ desc 'Create a new RSA keypair'
58
+ command :create do |c|
59
+ c.action do |global_options,options,args|
60
+ GenRelease::Commands::Create.new(global_options).create
61
+ end
62
+ end
63
+
64
+ desc 'Use RSA to sign the packages'
65
+ command :sign do |c|
66
+ c.action do |global_options,options,args|
67
+ signer = GenRelease::Commands::Sign.new(options).sign
68
+ end
69
+ end
70
+
71
+ pre do |global,command,options,args|
72
+ # Pre logic here
73
+ # Return true to proceed; false to abort and not call the
74
+ # chosen command
75
+ # Use skips_pre before a command to skip this block
76
+ # on that command only
77
+ true
78
+ end
79
+
80
+ post do |global,command,options,args|
81
+ # Post logic here
82
+ # Use skips_post before a command to skip this
83
+ # block on that command only
84
+ end
85
+
86
+ on_error do |exception|
87
+ # Error logic here
88
+ # return false to skip default error handling
89
+ true
90
+ end
91
+
92
+ exit run(ARGV)
@@ -0,0 +1,8 @@
1
+ Feature: My bootstrapped app kinda works
2
+ In order to get going on coding my awesome app
3
+ I want to have aruba and cucumber setup
4
+ So I don't have to do it myself
5
+
6
+ Scenario: App just runs
7
+ When I get help for "genRelease"
8
+ Then the exit status should be 0
@@ -0,0 +1,6 @@
1
+ When /^I get help for "([^"]*)"$/ do |app_name|
2
+ @app_name = app_name
3
+ step %(I run `#{app_name} help`)
4
+ end
5
+
6
+ # Add more step definitions here
@@ -0,0 +1,15 @@
1
+ require 'aruba/cucumber'
2
+
3
+ ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
4
+ LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
5
+
6
+ Before do
7
+ # Using "announce" causes massive warnings on 1.9.2
8
+ @puts = true
9
+ @original_rubylib = ENV['RUBYLIB']
10
+ ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
11
+ end
12
+
13
+ After do
14
+ ENV['RUBYLIB'] = @original_rubylib
15
+ end
@@ -0,0 +1,23 @@
1
+ # Ensure we require the local version and not one we might have installed already
2
+ require File.join([File.dirname(__FILE__),'lib','genRelease','version.rb'])
3
+ spec = Gem::Specification.new do |s|
4
+ s.name = 'genRelease'
5
+ s.version = GenRelease::VERSION
6
+ s.author = 'megrez'
7
+ s.email = 'lujiajing1126@gmail.com'
8
+ s.homepage = 'http://megrez.dajipai.org'
9
+ s.platform = Gem::Platform::RUBY
10
+ s.summary = 'A cli tool to generate RSA key-pair and output a recursive filelist'
11
+ s.files = `git ls-files`.split("
12
+ ")
13
+ s.require_paths << 'lib'
14
+ s.has_rdoc = true
15
+ s.extra_rdoc_files = ['README.rdoc','genRelease.rdoc']
16
+ s.rdoc_options << '--title' << 'genRelease' << '--main' << 'README.rdoc' << '-ri'
17
+ s.bindir = 'bin'
18
+ s.executables << 'genRelease'
19
+ s.add_development_dependency('rake')
20
+ s.add_development_dependency('rdoc')
21
+ s.add_development_dependency('aruba')
22
+ s.add_runtime_dependency('gli','2.12.2')
23
+ end
@@ -0,0 +1,5 @@
1
+ = genRelease
2
+
3
+ Generate this with
4
+ genRelease rdoc
5
+ After you have described your command line interface
@@ -0,0 +1,4 @@
1
+ require 'genRelease/version.rb'
2
+
3
+ # Add requires for other files you add to your project here, so
4
+ # you just need to require this one file in your bin file
@@ -0,0 +1,63 @@
1
+ require 'digest/md5'
2
+ require 'digest/sha1'
3
+ require 'genRelease/commands/help_modules/FileUtils'
4
+ module GenRelease
5
+ module Commands
6
+ class Build
7
+ FILTERS = %w{'.','..','.DS_Store'}
8
+ FILENAME = 'Packages'
9
+ RELEASE = 'Release'
10
+ CHECKSUM = %w{'md5','sha1'}
11
+ def initialize(global_options,*directory_lists)
12
+ @global_options = global_options
13
+ @directories = directory_lists
14
+ @current_dir = Dir.getwd
15
+ @checksum = {}
16
+ end
17
+ def build (options)
18
+ @hostname = options[:hostname]
19
+ @directories.each do |directory|
20
+ enum_path "#{@current_dir}#{File::SEPARATOR}#{directory}"
21
+ end
22
+ write_to_modules
23
+ sign
24
+ end
25
+
26
+ private
27
+ def enum_path full_directory
28
+ Dir.foreach(full_directory).reject{|filename| FILTERS.include? filename or filename.start_with? '.'}.each do |file|
29
+ full_file_name = "#{full_directory}#{File::SEPARATOR}#{file}"
30
+ if File.directory? full_file_name
31
+ enum_path full_file_name
32
+ elsif File.file? full_file_name
33
+ write_md5 full_file_name
34
+ end
35
+ end
36
+ end
37
+
38
+ def write_md5(file_path)
39
+ file_name = "#{file_path.gsub(@current_dir,@hostname)}"
40
+ file = File.open(file_path,'rb'){|fs| fs.read}
41
+ @checksum[file_name] = {}
42
+ @checksum[file_name][:md5] = Digest::MD5.hexdigest(file)
43
+ @checksum[file_name][:sha1] = Digest::SHA1.hexdigest(file)
44
+ p "#{file_name} md5:#{@checksum[file_name][:md5]} sha1:#{@checksum[file_name][:sha1]}" if @global_options[:verbose]
45
+ end
46
+
47
+ def write_to_modules
48
+ FileUtils::write(FILENAME,FileUtils::format(@checksum))
49
+ end
50
+ def sign
51
+ content = File.open("#{@current_dir}#{File::SEPARATOR}Packages") { |file| file.read }
52
+ md5 = Digest::MD5.hexdigest(content.gsub("\n",""))
53
+ sha1 = Digest::SHA1.hexdigest(content.gsub("\n",""))
54
+ checksum = {}
55
+ checksum[@hostname] = {
56
+ :md5 => md5,
57
+ :sha1 => sha1
58
+ }
59
+ FileUtils::write(RELEASE,FileUtils::format(checksum))
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,15 @@
1
+ require 'genRelease/commands/help_modules/OpenSSLUtils'
2
+ module GenRelease
3
+ module Commands
4
+ class Create
5
+ def initialize global_options
6
+ @global_options = global_options
7
+ @current_dir = Dir.getwd
8
+ end
9
+
10
+ def create
11
+ OpenSSLUtils::new_certification_file
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,24 @@
1
+ module GenRelease
2
+ module FileUtils
3
+ extend self
4
+ def write(file,content)
5
+ tmpfile = touch file
6
+ tmpfile.flock File::LOCK_EX
7
+ tmpfile.print content
8
+ tmpfile.flock File::LOCK_UN
9
+ tmpfile.close
10
+ end
11
+
12
+ def touch file
13
+ File.open(file,'w')
14
+ end
15
+
16
+ def format(content)
17
+ result = ""
18
+ content.each do |k,v|
19
+ result << ::Kernel::sprintf("%s\nmd5:%s\nsha1:%s\n\n",k.to_s,v[:md5],v[:sha1])
20
+ end
21
+ result
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,18 @@
1
+ 'genRelease/commands/help_modules/FileUtils'
2
+ module GenRelease
3
+ module OpenSSLUtils
4
+ extend self
5
+ PUBKEY = "id_rsa.pub"
6
+ PRIKEY = "id_rsa"
7
+ PEM = "rsa.pem"
8
+
9
+ def new_certification_file
10
+ rsa = OpenSSL::PKey::RSA.new 2048
11
+ p rsa.to_pem
12
+ FileUtils::write PRIKEY, rsa.to_pem
13
+ p rsa.public_key.to_s
14
+ FileUtils::write PUBKEY, rsa.public_key.to_s
15
+ FileUtils::write PEM, "#{rsa.public_key}#{rsa.to_pem}"
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,22 @@
1
+ require 'digest/md5'
2
+ require 'digest/sha1'
3
+ require 'genRelease/commands/help_modules/FileUtils'
4
+
5
+ module GenRelease
6
+ module Commands
7
+ class Sign
8
+ FILENAME = "Release.rsa"
9
+ def initialize options
10
+ @options = options
11
+ @current_dir = Dir.getwd
12
+ end
13
+
14
+ def sign
15
+ @rsa = OpenSSL::PKey::RSA.new File.read "#{@current_dir}#{File::SEPARATOR}rsa.pem"
16
+ content = File.open("#{@current_dir}#{File::SEPARATOR}Release",'rb') {|file| file.read}
17
+ message = @rsa.private_encrypt(content.gsub("\n",""))
18
+ FileUtils::write "#{@current_dir}#{File::SEPARATOR}#{FILENAME}",message
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module GenRelease
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,14 @@
1
+ require 'test_helper'
2
+
3
+ class DefaultTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ end
7
+
8
+ def teardown
9
+ end
10
+
11
+ def test_the_truth
12
+ assert true
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ require 'test/unit'
2
+
3
+ # Add test libraries you want to use here, e.g. mocha
4
+
5
+ class Test::Unit::TestCase
6
+
7
+ # Add global extensions to the test case class here
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: genRelease
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - megrez
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rdoc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: aruba
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: gli
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 2.12.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 2.12.2
69
+ description:
70
+ email: lujiajing1126@gmail.com
71
+ executables:
72
+ - genRelease
73
+ extensions: []
74
+ extra_rdoc_files:
75
+ - README.rdoc
76
+ - genRelease.rdoc
77
+ files:
78
+ - ".gitignore"
79
+ - Gemfile
80
+ - Gemfile.lock
81
+ - README.rdoc
82
+ - Rakefile
83
+ - bin/genRelease
84
+ - features/genRelease.feature
85
+ - features/step_definitions/genRelease_steps.rb
86
+ - features/support/env.rb
87
+ - genRelease.gemspec
88
+ - genRelease.rdoc
89
+ - lib/genRelease.rb
90
+ - lib/genRelease/commands/build.rb
91
+ - lib/genRelease/commands/create.rb
92
+ - lib/genRelease/commands/help_modules/FileUtils.rb
93
+ - lib/genRelease/commands/help_modules/OpenSSLUtils.rb
94
+ - lib/genRelease/commands/sign.rb
95
+ - lib/genRelease/version.rb
96
+ - test/default_test.rb
97
+ - test/test_helper.rb
98
+ homepage: http://megrez.dajipai.org
99
+ licenses: []
100
+ metadata: {}
101
+ post_install_message:
102
+ rdoc_options:
103
+ - "--title"
104
+ - genRelease
105
+ - "--main"
106
+ - README.rdoc
107
+ - "-ri"
108
+ require_paths:
109
+ - lib
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.2.2
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: A cli tool to generate RSA key-pair and output a recursive filelist
127
+ test_files: []