eventhub-command 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7769b08c03ee849b3de62533861b3ffb1a18181
4
- data.tar.gz: b22385d58cb84daff12fb9f9419bf885c458763a
3
+ metadata.gz: 0302cea6be0586be4c4a88446e1e6b44559494a3
4
+ data.tar.gz: 5d0c50461efd466abe535adabc24b1139e03451d
5
5
  SHA512:
6
- metadata.gz: b7026d968e9d50f61b1fe0cdb14a6829ad4d6c494565ffd8c30ed5164d84ca52baf256e1eb2504455ef22bb4086e2d616c79c7c8a2584159a107f832628bd213
7
- data.tar.gz: 4f8b613ec706f709b2bda96a2785e83b598e24bf6c8096f32af383f5723e1f9b31ea6ef0b092e19f1a2107e30466c344ce891996a80d8707ad8f575169f8c2da
6
+ metadata.gz: 204ef7824c0ac03b05cdb2096a32d2a0fe3f79c40aa5261ea2483938dc311238f34b26b3701d00d57783ca3c0d9cb1de6afdc1382bd04ef4f953f8eb52e204e0
7
+ data.tar.gz: 0d27e3d786904a399a70d3d271a48904a6800d1d19bc22925964fdaaf8429f660ff94a6d919f2e9ece0ba8f34b04b6f3ea7cd9ef726e0464a4cd593e28ad9db4
data/.gitignore CHANGED
@@ -1,18 +1,18 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
18
  .DS_Store
data/README.md CHANGED
@@ -1,29 +1,29 @@
1
- eventhub-command
2
- ================
3
-
4
- Event Hub Command Line Tool includes the following features
5
-
6
- * Packaging Event Hub Processor's
7
- * Pushing Channel Adapter and Processor configuration files to servers
8
- * Scaffold your Event Hub Processor
9
-
10
- ## Installation
11
-
12
- Install gem and make command provided by this gem available
13
-
14
- ~~~ sh
15
- $ gem i eventhub-command
16
- $ rbenv rehash
17
- ~~~
18
-
19
- First time running the command
20
- ~~~ sh
21
- $ eh
22
- Config file missing: ~/.eh, will create it now...
23
- Please specify the Eventhub SVN root directory (i.e. the directory which contains the 'src', 'release', ... directories
24
- /Users/username/dev/event_hub
25
- Config file written to /Users/username/.eh. Please try again.
26
- $
27
- ~~~
28
-
29
- ## Usage
1
+ eventhub-command
2
+ ================
3
+
4
+ Event Hub Command Line Tool includes the following features
5
+
6
+ * Packaging Event Hub Processor's
7
+ * Pushing Channel Adapter and Processor configuration files to servers
8
+ * Scaffold your Event Hub Processor
9
+
10
+ ## Installation
11
+
12
+ Install gem and make command provided by this gem available
13
+
14
+ ~~~ sh
15
+ $ gem i eventhub-command
16
+ $ rbenv rehash
17
+ ~~~
18
+
19
+ First time running the command
20
+ ~~~ sh
21
+ $ eh
22
+ Config file missing: ~/.eh, will create it now...
23
+ Please specify the Eventhub SVN root directory (i.e. the directory which contains the 'src', 'release', ... directories
24
+ /Users/username/dev/event_hub
25
+ Config file written to /Users/username/.eh. Please try again.
26
+ $
27
+ ~~~
28
+
29
+ ## Usage
data/eh.gemspec CHANGED
@@ -1,27 +1,27 @@
1
- # Ensure we require the local version and not one we might have installed already
2
- require File.join([File.dirname(__FILE__),'lib','eh','version.rb'])
3
- spec = Gem::Specification.new do |s|
4
- s.name = 'eventhub-command'
5
- s.version = Eh::VERSION
6
- s.author = ['Pascal Betz','Thomas Steiner']
7
- s.email = ['pascal.betz@simplificator.com','thomas.steiner@ikey.ch']
8
- s.homepage = 'http://github.com/thomis/eventhub-command'
9
- s.platform = Gem::Platform::RUBY
10
- s.description = 'Event Hub Command Line Tool which supports you with various Event Hub related administrative development features.'
11
- s.summary = 'Event Hub Command Line Tool'
12
- s.license = "MIT"
13
- s.files = `git ls-files`.split("
14
- ")
15
- s.require_paths << 'lib'
16
- s.has_rdoc = true
17
- s.extra_rdoc_files = ['README.md','eh.rdoc']
18
- s.rdoc_options << '--title' << 'eh' << '--main' << 'README.rdoc' << '-ri'
19
- s.bindir = 'bin'
20
- s.executables << 'eh'
21
- s.add_development_dependency('rake', '~> 10.1')
22
- s.add_development_dependency('rdoc', '~> 4.1')
23
- s.add_development_dependency('aruba', '~> 0.5')
24
- s.add_runtime_dependency('gli','2.12.0')
25
- s.add_runtime_dependency('rubyzip', '~> 1.0')
26
- s.add_runtime_dependency('activesupport', '~> 4.1')
27
- end
1
+ # Ensure we require the local version and not one we might have installed already
2
+ require File.join([File.dirname(__FILE__),'lib','eh','version.rb'])
3
+ spec = Gem::Specification.new do |s|
4
+ s.name = 'eventhub-command'
5
+ s.version = Eh::VERSION
6
+ s.author = ['Pascal Betz','Thomas Steiner']
7
+ s.email = ['pascal.betz@simplificator.com','thomas.steiner@ikey.ch']
8
+ s.homepage = 'http://github.com/thomis/eventhub-command'
9
+ s.platform = Gem::Platform::RUBY
10
+ s.description = 'Event Hub Command Line Tool which supports you with various Event Hub related administrative development features.'
11
+ s.summary = 'Event Hub Command Line Tool'
12
+ s.license = "MIT"
13
+ s.files = `git ls-files`.split("
14
+ ")
15
+ s.require_paths << 'lib'
16
+ s.has_rdoc = true
17
+ s.extra_rdoc_files = ['README.md','eh.rdoc']
18
+ s.rdoc_options << '--title' << 'eh' << '--main' << 'README.rdoc' << '-ri'
19
+ s.bindir = 'bin'
20
+ s.executables << 'eh'
21
+ s.add_development_dependency('rake', '~> 10.1')
22
+ s.add_development_dependency('rdoc', '~> 4.1')
23
+ s.add_development_dependency('aruba', '~> 0.5')
24
+ s.add_runtime_dependency('gli','2.12.0')
25
+ s.add_runtime_dependency('rubyzip', '~> 1.0')
26
+ s.add_runtime_dependency('activesupport', '~> 4.1')
27
+ end
@@ -1,51 +1,51 @@
1
- desc 'Copies the config directory of a given processor to remote'
2
- command :copy_config do |c|
3
- c.flag([:s, :source], :desc => "Source config directory", :default_value => Eh::Settings.current.source_config_dir, :long_desc => "A local directory containing subfolders for each of the processors")
4
- c.flag([:p, :processors], :desc => "Specify what processors' configs to copy", :type => Array, :long_desc => "You can specify multiple processors by providing a comma-separated list.")
5
-
6
- c.action do |global_options, options, args|
7
- source_config_dir = options['s']
8
- repository_deployment_dir = File.join(Eh::Settings.current.repository_root_dir, "branches", "master", "src", "deployment")
9
-
10
- processor_names = Dir["#{source_config_dir}/*"].map do |dir|
11
- File.basename(dir)
12
- end
13
-
14
- included_processor_names = processor_names
15
-
16
- # only include processors specified by -p option, if option is given
17
- if options['p']
18
- included_processor_names = included_processor_names.select do |processor_name|
19
- options['p'].include?(processor_name)
20
- end
21
- end
22
-
23
- # make sure we have at least one processor
24
- if included_processor_names.empty?
25
- raise "There are no processor configs to copy. Either there is nothing in #{source_config_dir} or the processor(s) specified with -p don't exist."
26
- end
27
-
28
- included_processor_names.each do |processor_name|
29
- processor_config_source_dir = File.join(source_config_dir, processor_name)
30
-
31
- cmd = "cd #{repository_deployment_dir} && COPY_FROM_DIR=#{processor_config_source_dir} bundle exec cap event_hub:scp_copy_config"
32
-
33
- puts "Will copy config files from #{processor_config_source_dir} to remote."
34
- puts "WARNING: This will overwrite any existing files with the same name!"
35
- puts "Do you really want to do this?"
36
- input = STDIN.gets.chomp
37
-
38
- unless ['y', 'Y'].include?(input)
39
- raise "Not confirmed. Stop."
40
- end
41
-
42
- puts "Command: #{cmd}" if global_options['v']
43
-
44
- Bundler.with_clean_env do
45
- system cmd
46
- end
47
- end
48
-
49
- puts "Done."
50
- end
51
- end
1
+ desc 'Copies the config directory of a given processor to remote'
2
+ command :copy_config do |c|
3
+ c.flag([:s, :source], :desc => "Source config directory", :default_value => Eh::Settings.current.source_config_dir, :long_desc => "A local directory containing subfolders for each of the processors")
4
+ c.flag([:p, :processors], :desc => "Specify what processors' configs to copy", :type => Array, :long_desc => "You can specify multiple processors by providing a comma-separated list.")
5
+
6
+ c.action do |global_options, options, args|
7
+ source_config_dir = options['s']
8
+ repository_deployment_dir = File.join(Eh::Settings.current.repository_root_dir, "branches", "master", "src", "deployment")
9
+
10
+ processor_names = Dir["#{source_config_dir}/*"].map do |dir|
11
+ File.basename(dir)
12
+ end
13
+
14
+ included_processor_names = processor_names
15
+
16
+ # only include processors specified by -p option, if option is given
17
+ if options['p']
18
+ included_processor_names = included_processor_names.select do |processor_name|
19
+ options['p'].include?(processor_name)
20
+ end
21
+ end
22
+
23
+ # make sure we have at least one processor
24
+ if included_processor_names.empty?
25
+ raise "There are no processor configs to copy. Either there is nothing in #{source_config_dir} or the processor(s) specified with -p don't exist."
26
+ end
27
+
28
+ included_processor_names.each do |processor_name|
29
+ processor_config_source_dir = File.join(source_config_dir, processor_name)
30
+
31
+ cmd = "cd #{repository_deployment_dir} && COPY_FROM_DIR=#{processor_config_source_dir} bundle exec cap event_hub:scp_copy_config"
32
+
33
+ puts "Will copy config files from #{processor_config_source_dir} to remote."
34
+ puts "WARNING: This will overwrite any existing files with the same name!"
35
+ puts "Do you really want to do this?"
36
+ input = STDIN.gets.chomp
37
+
38
+ unless ['y', 'Y'].include?(input)
39
+ raise "Not confirmed. Stop."
40
+ end
41
+
42
+ puts "Command: #{cmd}" if global_options['v']
43
+
44
+ Bundler.with_clean_env do
45
+ system cmd
46
+ end
47
+ end
48
+
49
+ puts "Done."
50
+ end
51
+ end
@@ -1,38 +1,38 @@
1
- desc 'Deploys the app'
2
- arg_name 'stage', optional: true
3
- command :deploy do |c|
4
-
5
- c.flag([:deploy_via], :desc => "One of 'copy' or 'scm'", :default_value => 'scm')
6
- c.flag([:copy_from_dir], :desc => "Source directory for copy operation", :default_value => Eh::Settings.current.releases_dir)
7
- c.flag([:tag], :desc => "The tag to deploy")
8
- c.flag([:branch], :desc => "The branch to deploy", :default_value => "master")
9
-
10
- c.action do |global_options, options, args|
11
- stage = args[0] || "development"
12
-
13
- deployment_dir = Eh::Settings.current.deployment_dir
14
-
15
- env_variables = []
16
- env_variables << "DEPLOY_VIA=#{options[:deploy_via]}"
17
-
18
- if options[:tag]
19
- env_variables << "TAG=#{options[:tag]}"
20
- else
21
- env_variables << "BRANCH=#{options[:branch]}"
22
- end
23
-
24
- if options[:deploy_via] == "copy"
25
- env_variables << "COPY_FROM_DIR=#{options[:copy_from_dir]}"
26
- end
27
-
28
- cmd = "cd #{deployment_dir} && #{env_variables.join(' ')} bundle exec cap #{stage} event_hub"
29
-
30
- puts "Command: #{cmd}" if global_options['v']
31
-
32
- Bundler.with_clean_env do
33
- system cmd
34
- end
35
-
36
- puts "Done."
37
- end
38
- end
1
+ desc 'Deploys the app'
2
+ arg_name 'stage', optional: true
3
+ command :deploy do |c|
4
+
5
+ c.flag([:deploy_via], :desc => "One of 'copy' or 'scm'", :default_value => 'scm')
6
+ c.flag([:copy_from_dir], :desc => "Source directory for copy operation", :default_value => Eh::Settings.current.releases_dir)
7
+ c.flag([:tag], :desc => "The tag to deploy")
8
+ c.flag([:branch], :desc => "The branch to deploy", :default_value => "master")
9
+
10
+ c.action do |global_options, options, args|
11
+ stage = args[0] || "development"
12
+
13
+ deployment_dir = Eh::Settings.current.deployment_dir
14
+
15
+ env_variables = []
16
+ env_variables << "DEPLOY_VIA=#{options[:deploy_via]}"
17
+
18
+ if options[:tag]
19
+ env_variables << "TAG=#{options[:tag]}"
20
+ else
21
+ env_variables << "BRANCH=#{options[:branch]}"
22
+ end
23
+
24
+ if options[:deploy_via] == "copy"
25
+ env_variables << "COPY_FROM_DIR=#{options[:copy_from_dir]}"
26
+ end
27
+
28
+ cmd = "cd #{deployment_dir} && #{env_variables.join(' ')} bundle exec cap #{stage} event_hub"
29
+
30
+ puts "Command: #{cmd}" if global_options['v']
31
+
32
+ Bundler.with_clean_env do
33
+ system cmd
34
+ end
35
+
36
+ puts "Done."
37
+ end
38
+ end
@@ -1,90 +1,90 @@
1
- desc 'Generates a template for a processor'
2
- arg_name 'module_name processor_name'
3
-
4
- command :generate_processor do |c|
5
- c.action do |global_options, options, args|
6
- require 'active_support/core_ext/string/inflections'
7
- require 'fileutils'
8
- require 'erb'
9
-
10
- if args.size != 2
11
- puts "Needs exactly 2 arguments: eh generate_processor ModuleName ProcessorName"
12
- exit -1
13
- end
14
-
15
- processor_module_name = args[0].camelcase
16
- processor_class_name = args[1].camelcase
17
- underscored_processor_module_name = processor_module_name.underscore
18
- underscored_processor_class_name = processor_class_name.underscore
19
-
20
- destination_dir = Eh::Settings.current.processes_src_dir
21
- destination_dir = File.join(destination_dir, "#{underscored_processor_module_name}.#{underscored_processor_class_name}")
22
-
23
- if Dir.exists? destination_dir
24
- puts "#{destination_dir} already exists!"
25
- exit -1
26
- end
27
-
28
- template_tmp_dir = Eh::Settings.current.template_tmp_dir
29
- checkout_git_repo(template_tmp_dir)
30
-
31
- FileUtils.cp_r template_tmp_dir, destination_dir
32
- FileUtils.rm_rf File.join(destination_dir, ".git")
33
- FileUtils.rm File.join(destination_dir, 'README.md')
34
-
35
- puts "Generating processor #{processor_module_name}::#{processor_class_name} in #{destination_dir}"
36
- Dir.glob(destination_dir + "/**/*.erb") do |file|
37
- template = ERB.new(File.read(file))
38
-
39
- File.open(file, "w") do |writeable_file|
40
- writeable_file.puts template.result(binding)
41
- end
42
-
43
- FileUtils.mv file, File.join(File.dirname(file), File.basename(file, ".erb"))
44
- end
45
-
46
- replacements = [
47
- ["underscored_processor_module_name", underscored_processor_module_name],
48
- ["underscored_processor_class_name", underscored_processor_class_name],
49
- ["processor_module_name", processor_module_name],
50
- ["processor_class_name", processor_class_name]
51
- ]
52
-
53
- rename_files_with_replacements(destination_dir, replacements)
54
-
55
- FileUtils.rm_rf template_tmp_dir
56
-
57
- puts "Done."
58
- end
59
- end
60
-
61
- def shallow_clone_git_repository(source_url, destination_dir)
62
- system("git clone --depth 1 #{source_url} #{destination_dir}")
63
- end
64
-
65
- def rename_files_with_replacements(destination_dir, replacements)
66
- Dir.glob(destination_dir + "/**/*") do |src_file_path|
67
- if File.file? src_file_path
68
- dir = File.dirname src_file_path
69
- file_with_replacements = File.basename src_file_path
70
-
71
- replacements.each do |find_string, replace_string|
72
- file_with_replacements.sub!(find_string, replace_string)
73
- end
74
-
75
- dest_file_path = File.join(dir, file_with_replacements)
76
-
77
- if src_file_path != dest_file_path
78
- FileUtils.mv src_file_path, dest_file_path
79
- end
80
- end
81
- end
82
- end
83
-
84
- def checkout_git_repo(destination_dir)
85
- template_repository_url = Eh::Settings.current.processor_template_repository_url
86
- puts "Checking out latest template from #{template_repository_url}"
87
- FileUtils.rm_rf(destination_dir)
88
- FileUtils.mkdir(destination_dir)
89
- shallow_clone_git_repository(template_repository_url, destination_dir)
1
+ desc 'Generates a template for a processor'
2
+ arg_name 'module_name processor_name'
3
+
4
+ command :generate_processor do |c|
5
+ c.action do |global_options, options, args|
6
+ require 'active_support/core_ext/string/inflections'
7
+ require 'fileutils'
8
+ require 'erb'
9
+
10
+ if args.size != 2
11
+ puts "Needs exactly 2 arguments: eh generate_processor ModuleName ProcessorName"
12
+ exit -1
13
+ end
14
+
15
+ processor_module_name = args[0].camelcase
16
+ processor_class_name = args[1].camelcase
17
+ underscored_processor_module_name = processor_module_name.underscore
18
+ underscored_processor_class_name = processor_class_name.underscore
19
+
20
+ destination_dir = Eh::Settings.current.processes_src_dir
21
+ destination_dir = File.join(destination_dir, "#{underscored_processor_module_name}.#{underscored_processor_class_name}")
22
+
23
+ if Dir.exists? destination_dir
24
+ puts "#{destination_dir} already exists!"
25
+ exit -1
26
+ end
27
+
28
+ template_tmp_dir = Eh::Settings.current.template_tmp_dir
29
+ checkout_git_repo(template_tmp_dir)
30
+
31
+ FileUtils.cp_r template_tmp_dir, destination_dir
32
+ FileUtils.rm_rf File.join(destination_dir, ".git")
33
+ FileUtils.rm File.join(destination_dir, 'README.md')
34
+
35
+ puts "Generating processor #{processor_module_name}::#{processor_class_name} in #{destination_dir}"
36
+ Dir.glob(destination_dir + "/**/*.erb") do |file|
37
+ template = ERB.new(File.read(file))
38
+
39
+ File.open(file, "w") do |writeable_file|
40
+ writeable_file.puts template.result(binding)
41
+ end
42
+
43
+ FileUtils.mv file, File.join(File.dirname(file), File.basename(file, ".erb"))
44
+ end
45
+
46
+ replacements = [
47
+ ["underscored_processor_module_name", underscored_processor_module_name],
48
+ ["underscored_processor_class_name", underscored_processor_class_name],
49
+ ["processor_module_name", processor_module_name],
50
+ ["processor_class_name", processor_class_name]
51
+ ]
52
+
53
+ rename_files_with_replacements(destination_dir, replacements)
54
+
55
+ FileUtils.rm_rf template_tmp_dir
56
+
57
+ puts "Done."
58
+ end
59
+ end
60
+
61
+ def shallow_clone_git_repository(source_url, destination_dir)
62
+ system("git clone --depth 1 #{source_url} #{destination_dir}")
63
+ end
64
+
65
+ def rename_files_with_replacements(destination_dir, replacements)
66
+ Dir.glob(destination_dir + "/**/*") do |src_file_path|
67
+ if File.file? src_file_path
68
+ dir = File.dirname src_file_path
69
+ file_with_replacements = File.basename src_file_path
70
+
71
+ replacements.each do |find_string, replace_string|
72
+ file_with_replacements.sub!(find_string, replace_string)
73
+ end
74
+
75
+ dest_file_path = File.join(dir, file_with_replacements)
76
+
77
+ if src_file_path != dest_file_path
78
+ FileUtils.mv src_file_path, dest_file_path
79
+ end
80
+ end
81
+ end
82
+ end
83
+
84
+ def checkout_git_repo(destination_dir)
85
+ template_repository_url = Eh::Settings.current.processor_template_repository_url
86
+ puts "Checking out latest template from #{template_repository_url}"
87
+ FileUtils.rm_rf(destination_dir)
88
+ FileUtils.mkdir(destination_dir)
89
+ shallow_clone_git_repository(template_repository_url, destination_dir)
90
90
  end
@@ -1,97 +1,97 @@
1
- desc 'Packages processors to zip files'
2
- command :package do |c|
3
- c.flag([:x, :exclude], :desc => "Exclude processors by name.", :type => Array, :long_desc => "You can specify multiple processors by providing a comma-separated list.")
4
- c.flag([:p, :processors], :desc => "Specify what processors to package", :type => Array, :long_desc => "You can specify multiple processors by providing a comma-separated list.")
5
- c.flag([:d, :destination], :desc => "Destination directory to place created zip files.", :default_value => Eh::Settings.current.ruby_release_dir)
6
- c.flag([:s, :source], :desc => "Source directory to read processors from.", :default_value => Eh::Settings.current.processes_src_dir)
7
-
8
- c.action do |global_options, options, args|
9
- source_dir = options['s']
10
- destination_dir = options['d']
11
-
12
- puts "Will package processors from #{source_dir} to #{destination_dir}"
13
- # find all processors in the base directory
14
- processor_names = Dir["#{source_dir}/*"].map do |dir|
15
- File.basename(dir)
16
- end
17
-
18
- # Drop files, only use directories
19
- processor_names.delete_if do |item|
20
- !File.directory?("#{source_dir}/#{item}")
21
- end
22
-
23
- included_processor_names = processor_names
24
-
25
- # only include processors specified by -p option, if option is given
26
- if options['p']
27
- included_processor_names = included_processor_names.select do |processor_name|
28
- options['p'].include?(processor_name)
29
- end
30
- end
31
-
32
- # exclude processors specified by -x option, if option is given
33
- if options['x']
34
- # check if any processor has been excluded from packaging
35
- included_processor_names = included_processor_names.select do |processor_name|
36
- !options['x'].include?(processor_name)
37
- end
38
- end
39
-
40
- # make sure we have at least one processor
41
- if included_processor_names.empty?
42
- raise "There are no processor names. Either your -s directory is empty or you specified a strange combination of -x and -p"
43
- end
44
-
45
-
46
- # make sure destination directory exists
47
- FileUtils.mkdir_p(destination_dir)
48
-
49
- # Zip all processors
50
- included_processor_names.each do |processor_name|
51
-
52
- directory = File.join(source_dir, processor_name) # last slash could be omitted
53
- zipfile_name = File.join(destination_dir, "#{processor_name}.zip")
54
-
55
- # remove zip before we create a new one
56
- FileUtils.rm zipfile_name, :force => true
57
-
58
- options = {"directories-recursively" => true}
59
-
60
- Zip::File.open(zipfile_name,Zip::File::CREATE) do |zipfile|
61
-
62
- #zipfile.add(processor_name, directory)
63
- [directory].each{ |file_to_be_zipped|
64
-
65
- if File.directory?(file_to_be_zipped)
66
- # should skip directories
67
- next if options["directories-skip"]
68
-
69
- # should recursively add directory
70
- if options["directories-recursively"]
71
- directory = file_to_be_zipped
72
- puts "zipper: archiving directory: #{directory}"
73
- directory_chosen_pathname = options["directories-recursively-splat"] ? directory : File.dirname(directory)
74
- directory_pathname = Pathname.new(directory_chosen_pathname)
75
- files = Dir[File.join(directory, '**', '**')]
76
- files.delete_if {|filename| ["log", "logs", "exceptions", "pids", "tmp"].include?(filename) }
77
- files.each do |file|
78
- file_pathname = Pathname.new(file)
79
- file_relative_pathname = file_pathname.relative_path_from(directory_pathname)
80
- zipfile.add(file_relative_pathname,file)
81
- end
82
- next
83
- end
84
- end
85
-
86
- filename = File.basename(file_to_be_zipped)
87
-
88
- puts "zipper: archiving #{file_to_be_zipped} as #{filename} into #{zipfile}"
89
-
90
- zipfile.add(filename,file_to_be_zipped)
91
- }
92
- end
93
- end
94
-
95
- puts "Done packaging #{included_processor_names.size} processors"
96
- end
97
- end
1
+ desc 'Packages processors to zip files'
2
+ command :package do |c|
3
+ c.flag([:x, :exclude], :desc => "Exclude processors by name.", :type => Array, :long_desc => "You can specify multiple processors by providing a comma-separated list.")
4
+ c.flag([:p, :processors], :desc => "Specify what processors to package", :type => Array, :long_desc => "You can specify multiple processors by providing a comma-separated list.")
5
+ c.flag([:d, :destination], :desc => "Destination directory to place created zip files.", :default_value => Eh::Settings.current.ruby_release_dir)
6
+ c.flag([:s, :source], :desc => "Source directory to read processors from.", :default_value => Eh::Settings.current.processes_src_dir)
7
+
8
+ c.action do |global_options, options, args|
9
+ source_dir = options['s']
10
+ destination_dir = options['d']
11
+
12
+ puts "Will package processors from #{source_dir} to #{destination_dir}"
13
+ # find all processors in the base directory
14
+ processor_names = Dir["#{source_dir}/*"].map do |dir|
15
+ File.basename(dir)
16
+ end
17
+
18
+ # Drop files, only use directories
19
+ processor_names.delete_if do |item|
20
+ !File.directory?("#{source_dir}/#{item}")
21
+ end
22
+
23
+ included_processor_names = processor_names
24
+
25
+ # only include processors specified by -p option, if option is given
26
+ if options['p']
27
+ included_processor_names = included_processor_names.select do |processor_name|
28
+ options['p'].include?(processor_name)
29
+ end
30
+ end
31
+
32
+ # exclude processors specified by -x option, if option is given
33
+ if options['x']
34
+ # check if any processor has been excluded from packaging
35
+ included_processor_names = included_processor_names.select do |processor_name|
36
+ !options['x'].include?(processor_name)
37
+ end
38
+ end
39
+
40
+ # make sure we have at least one processor
41
+ if included_processor_names.empty?
42
+ raise "There are no processor names. Either your -s directory is empty or you specified a strange combination of -x and -p"
43
+ end
44
+
45
+
46
+ # make sure destination directory exists
47
+ FileUtils.mkdir_p(destination_dir)
48
+
49
+ # Zip all processors
50
+ included_processor_names.each do |processor_name|
51
+
52
+ directory = File.join(source_dir, processor_name) # last slash could be omitted
53
+ zipfile_name = File.join(destination_dir, "#{processor_name}.zip")
54
+
55
+ # remove zip before we create a new one
56
+ FileUtils.rm zipfile_name, :force => true
57
+
58
+ options = {"directories-recursively" => true}
59
+
60
+ Zip::File.open(zipfile_name,Zip::File::CREATE) do |zipfile|
61
+
62
+ #zipfile.add(processor_name, directory)
63
+ [directory].each{ |file_to_be_zipped|
64
+
65
+ if File.directory?(file_to_be_zipped)
66
+ # should skip directories
67
+ next if options["directories-skip"]
68
+
69
+ # should recursively add directory
70
+ if options["directories-recursively"]
71
+ directory = file_to_be_zipped
72
+ puts "zipper: archiving directory: #{directory}"
73
+ directory_chosen_pathname = options["directories-recursively-splat"] ? directory : File.dirname(directory)
74
+ directory_pathname = Pathname.new(directory_chosen_pathname)
75
+ files = Dir[File.join(directory, '**', '**')]
76
+ files.delete_if {|filename| ["log", "logs", "exceptions", "pids", "tmp"].include?(filename) }
77
+ files.each do |file|
78
+ file_pathname = Pathname.new(file)
79
+ file_relative_pathname = file_pathname.relative_path_from(directory_pathname)
80
+ zipfile.add(file_relative_pathname,file)
81
+ end
82
+ next
83
+ end
84
+ end
85
+
86
+ filename = File.basename(file_to_be_zipped)
87
+
88
+ puts "zipper: archiving #{file_to_be_zipped} as #{filename} into #{zipfile}"
89
+
90
+ zipfile.add(filename,file_to_be_zipped)
91
+ }
92
+ end
93
+ end
94
+
95
+ puts "Done packaging #{included_processor_names.size} processors"
96
+ end
97
+ end
@@ -1,97 +1,97 @@
1
- desc 'Packages Rails Console to zip file'
2
- command :package_rails do |c|
3
- #c.flag([:x, :exclude], :desc => "Exclude processors by name.", :type => Array, :long_desc => "You can specify multiple processors by providing a comma-separated list.")
4
- #c.flag([:p, :processors], :desc => "Specify what processors to package", :type => Array, :long_desc => "You can specify multiple processors by providing a comma-separated list.")
5
- c.flag([:d, :destination], :desc => "Destination directory to place created zip file.", :default_value => Eh::Settings.current.rails_release_dir)
6
- c.flag([:s, :source], :desc => "Source directory to read rails console from.", :default_value => Eh::Settings.current.rails_src_dir)
7
-
8
- c.action do |global_options, options, args|
9
- source_dir = options['s']
10
- destination_dir = options['d']
11
-
12
- puts "Will package rails console from #{source_dir} to #{destination_dir}"
13
-
14
- console = Dir["#{source_dir}"]
15
-
16
- FileUtils.mkdir_p(destination_dir)
17
-
18
- options = {"directories-recursively"=>true}
19
-
20
- zipfile_name = File.join(destination_dir, "console.zip")
21
- directory = source_dir
22
-
23
- # remove zip before we create a new one
24
- FileUtils.rm zipfile_name, :force => true
25
-
26
- Zip::File.open(zipfile_name,Zip::File::CREATE) do |zipfile|
27
-
28
- #zipfile.add(processor_name, directory)
29
- [directory].each{ |file_to_be_zipped|
30
- if File.directory?(file_to_be_zipped)
31
- # should skip directories
32
- next if options["directories-skip"]
33
- # should recursively add directory
34
- if options["directories-recursively"]
35
- directory = file_to_be_zipped
36
- puts "zipper: archiving directory: #{directory}"
37
- directory_chosen_pathname = options["directories-recursively-splat"] ? directory : File.dirname(directory)
38
- directory_pathname = Pathname.new(directory_chosen_pathname)
39
- files = Dir[File.join(directory, '**', '**')]
40
- files.delete_if {|filename| ["#{source_dir}/log", "#{source_dir}/logs", "#{source_dir}/exceptions", "#{source_dir}/tmp/pids"].include?(filename) }
41
- files.each do |file|
42
- file_pathname = Pathname.new(file)
43
- file_relative_pathname = file_pathname.relative_path_from(directory_pathname)
44
- zipfile.add(file_relative_pathname,file)
45
- end
46
- next
47
- end
48
- end
49
- filename = File.basename(file_to_be_zipped)
50
-
51
- puts "zipper: archiving #{file_to_be_zipped} as #{filename} into #{zipfile}"
52
-
53
- zipfile.add(filename,file_to_be_zipped)
54
- }
55
- end
56
-
57
- # find all processors in the base directory
58
- #console = Dir["#{source_dir}/*"].map do |dir|
59
- # File.basename(dir)
60
- #end
61
-
62
- #included_processor_names = processor_names
63
-
64
- # only include processors specified by -p option, if option is given
65
- #if options['p']
66
- # included_processor_names = included_processor_names.select do |processor_name|
67
- # options['p'].include?(processor_name)
68
- # end
69
- #end
70
- #
71
- ## exclude processors specified by -x option, if option is given
72
- #if options['x']
73
- # # check if any processor has been excluded from packaging
74
- # included_processor_names = included_processor_names.select do |processor_name|
75
- # !options['x'].include?(processor_name)
76
- # end
77
- #end
78
-
79
- # make sure we have at least one processor
80
- #if included_processor_names.empty?
81
- # raise "There are no processor names. Either your -s directory is empty or you specified a strange combination of -x and -p"
82
- #end
83
-
84
-
85
- # make sure destination directory exists
86
- #FileUtils.mkdir_p(destination_dir)
87
- #
88
- ## Zip all processors
89
- #included_processor_names.each do |processor_name|
90
- #
91
- #directory = File.join(source_dir, processor_name) # last slash could be omitted
92
- #zipfile_name = File.join(destination_dir, "#{processor_name}.zip")
93
- #
94
-
95
- puts "Done packaging #{console.size} processors"
96
- end
97
- end
1
+ desc 'Packages Rails Console to zip file'
2
+ command :package_rails do |c|
3
+ #c.flag([:x, :exclude], :desc => "Exclude processors by name.", :type => Array, :long_desc => "You can specify multiple processors by providing a comma-separated list.")
4
+ #c.flag([:p, :processors], :desc => "Specify what processors to package", :type => Array, :long_desc => "You can specify multiple processors by providing a comma-separated list.")
5
+ c.flag([:d, :destination], :desc => "Destination directory to place created zip file.", :default_value => Eh::Settings.current.rails_release_dir)
6
+ c.flag([:s, :source], :desc => "Source directory to read rails console from.", :default_value => Eh::Settings.current.rails_src_dir)
7
+
8
+ c.action do |global_options, options, args|
9
+ source_dir = options['s']
10
+ destination_dir = options['d']
11
+
12
+ puts "Will package rails console from #{source_dir} to #{destination_dir}"
13
+
14
+ console = Dir["#{source_dir}"]
15
+
16
+ FileUtils.mkdir_p(destination_dir)
17
+
18
+ options = {"directories-recursively"=>true}
19
+
20
+ zipfile_name = File.join(destination_dir, "console.zip")
21
+ directory = source_dir
22
+
23
+ # remove zip before we create a new one
24
+ FileUtils.rm zipfile_name, :force => true
25
+
26
+ Zip::File.open(zipfile_name,Zip::File::CREATE) do |zipfile|
27
+
28
+ #zipfile.add(processor_name, directory)
29
+ [directory].each{ |file_to_be_zipped|
30
+ if File.directory?(file_to_be_zipped)
31
+ # should skip directories
32
+ next if options["directories-skip"]
33
+ # should recursively add directory
34
+ if options["directories-recursively"]
35
+ directory = file_to_be_zipped
36
+ puts "zipper: archiving directory: #{directory}"
37
+ directory_chosen_pathname = options["directories-recursively-splat"] ? directory : File.dirname(directory)
38
+ directory_pathname = Pathname.new(directory_chosen_pathname)
39
+ files = Dir[File.join(directory, '**', '**')]
40
+ files.delete_if {|filename| ["#{source_dir}/log", "#{source_dir}/logs", "#{source_dir}/exceptions", "#{source_dir}/tmp/pids"].include?(filename) }
41
+ files.each do |file|
42
+ file_pathname = Pathname.new(file)
43
+ file_relative_pathname = file_pathname.relative_path_from(directory_pathname)
44
+ zipfile.add(file_relative_pathname,file)
45
+ end
46
+ next
47
+ end
48
+ end
49
+ filename = File.basename(file_to_be_zipped)
50
+
51
+ puts "zipper: archiving #{file_to_be_zipped} as #{filename} into #{zipfile}"
52
+
53
+ zipfile.add(filename,file_to_be_zipped)
54
+ }
55
+ end
56
+
57
+ # find all processors in the base directory
58
+ #console = Dir["#{source_dir}/*"].map do |dir|
59
+ # File.basename(dir)
60
+ #end
61
+
62
+ #included_processor_names = processor_names
63
+
64
+ # only include processors specified by -p option, if option is given
65
+ #if options['p']
66
+ # included_processor_names = included_processor_names.select do |processor_name|
67
+ # options['p'].include?(processor_name)
68
+ # end
69
+ #end
70
+ #
71
+ ## exclude processors specified by -x option, if option is given
72
+ #if options['x']
73
+ # # check if any processor has been excluded from packaging
74
+ # included_processor_names = included_processor_names.select do |processor_name|
75
+ # !options['x'].include?(processor_name)
76
+ # end
77
+ #end
78
+
79
+ # make sure we have at least one processor
80
+ #if included_processor_names.empty?
81
+ # raise "There are no processor names. Either your -s directory is empty or you specified a strange combination of -x and -p"
82
+ #end
83
+
84
+
85
+ # make sure destination directory exists
86
+ #FileUtils.mkdir_p(destination_dir)
87
+ #
88
+ ## Zip all processors
89
+ #included_processor_names.each do |processor_name|
90
+ #
91
+ #directory = File.join(source_dir, processor_name) # last slash could be omitted
92
+ #zipfile_name = File.join(destination_dir, "#{processor_name}.zip")
93
+ #
94
+
95
+ puts "Done packaging #{console.size} processors"
96
+ end
97
+ end
data/lib/eh/settings.rb CHANGED
@@ -1,66 +1,66 @@
1
- class Eh::Settings
2
- attr_reader :data
3
- def self.load(file)
4
- data = File.read(file)
5
- json = JSON.parse(data)
6
- Eh::Settings.new(json)
7
- end
8
-
9
- def self.current=(value)
10
- Thread.current[:eh_settings] = value
11
- end
12
-
13
- def self.current
14
- Thread.current[:eh_settings]
15
- end
16
-
17
- def initialize(data)
18
- @data = data
19
- end
20
-
21
-
22
- def repository_root_dir
23
- File.expand_path(data['repository_root_dir'])
24
- end
25
-
26
- def releases_dir
27
- File.join(repository_root_dir, 'releases')
28
- end
29
-
30
- def rails_release_dir
31
- File.join(releases_dir, 'rails')
32
- end
33
-
34
- def ruby_release_dir
35
- File.join(releases_dir, 'ruby')
36
- end
37
-
38
- def processes_src_dir
39
- File.join(repository_root_dir, 'src', 'process')
40
- end
41
-
42
- def deployment_dir
43
- File.join(repository_root_dir, 'src', 'deployment')
44
- end
45
-
46
- def rails_src_dir
47
- File.join(repository_root_dir, 'src', 'rails', 'console')
48
- end
49
-
50
- def source_config_dir
51
- File.join(repository_root_dir, 'config')
52
- end
53
-
54
- def processor_template_repository_url
55
- "git@github.com:thomis/eventhub-processor-template.git"
56
- end
57
-
58
- def package_tmp_dir
59
- './tmp'
60
- end
61
-
62
- def template_tmp_dir
63
- "/tmp/eventhub-processor-template/"
64
- end
65
-
1
+ class Eh::Settings
2
+ attr_reader :data
3
+ def self.load(file)
4
+ data = File.read(file)
5
+ json = JSON.parse(data)
6
+ Eh::Settings.new(json)
7
+ end
8
+
9
+ def self.current=(value)
10
+ Thread.current[:eh_settings] = value
11
+ end
12
+
13
+ def self.current
14
+ Thread.current[:eh_settings]
15
+ end
16
+
17
+ def initialize(data)
18
+ @data = data
19
+ end
20
+
21
+
22
+ def repository_root_dir
23
+ File.expand_path(data['repository_root_dir'])
24
+ end
25
+
26
+ def releases_dir
27
+ File.join(repository_root_dir, 'releases')
28
+ end
29
+
30
+ def rails_release_dir
31
+ File.join(releases_dir, 'rails')
32
+ end
33
+
34
+ def ruby_release_dir
35
+ File.join(releases_dir, 'ruby')
36
+ end
37
+
38
+ def processes_src_dir
39
+ File.join(repository_root_dir, 'src', 'process')
40
+ end
41
+
42
+ def deployment_dir
43
+ File.join(repository_root_dir, 'src', 'deployment')
44
+ end
45
+
46
+ def rails_src_dir
47
+ File.join(repository_root_dir, 'src', 'rails', 'console')
48
+ end
49
+
50
+ def source_config_dir
51
+ File.join(repository_root_dir, 'config')
52
+ end
53
+
54
+ def processor_template_repository_url
55
+ "https://github.com/thomis/eventhub-processor-template.git"
56
+ end
57
+
58
+ def package_tmp_dir
59
+ './tmp'
60
+ end
61
+
62
+ def template_tmp_dir
63
+ "/tmp/eventhub-processor-template/"
64
+ end
65
+
66
66
  end
data/lib/eh/version.rb CHANGED
@@ -1,3 +1,3 @@
1
- module Eh
2
- VERSION = '0.0.15'
3
- end
1
+ module Eh
2
+ VERSION = '0.0.16'
3
+ end
data/lib/eh-commands.rb CHANGED
@@ -1,7 +1,7 @@
1
-
2
- # All commands are required here
3
- require 'eh/commands/deploy'
4
- require 'eh/commands/copy_config'
5
- require 'eh/commands/generate_processor'
6
- require 'eh/commands/package_rails'
7
- require 'eh/commands/package'
1
+
2
+ # All commands are required here
3
+ require 'eh/commands/deploy'
4
+ require 'eh/commands/copy_config'
5
+ require 'eh/commands/generate_processor'
6
+ require 'eh/commands/package_rails'
7
+ require 'eh/commands/package'
data/lib/eh.rb CHANGED
@@ -1,7 +1,7 @@
1
- module Eh
2
- end
3
- require 'zip'
4
- require 'pathname'
5
-
6
- require 'eh/version'
1
+ module Eh
2
+ end
3
+ require 'zip'
4
+ require 'pathname'
5
+
6
+ require 'eh/version'
7
7
  require 'eh/settings'
data/todo.txt CHANGED
@@ -1,9 +1,9 @@
1
- -- -------------------------------------
2
- -- to do
3
- -- -------------------------------------
4
-
5
- - eh relase -r or --repository plate_store or http path -u user -p password
6
- - folder filter, default and customize
7
- - extension filter, default and custmize
8
- - it could take config settings from a local .ehconfig file
1
+ -- -------------------------------------
2
+ -- to do
3
+ -- -------------------------------------
4
+
5
+ - eh relase -r or --repository plate_store or http path -u user -p password
6
+ - folder filter, default and customize
7
+ - extension filter, default and custmize
8
+ - it could take config settings from a local .ehconfig file
9
9
  - would be nice to have a release all feature
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventhub-command
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pascal Betz
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-09-26 00:00:00.000000000 Z
12
+ date: 2014-10-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake