eventhub-command 0.0.9 → 0.0.11

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 372310299a100209de8492067c9d55cba2c9df8f
4
- data.tar.gz: b87670bcd4b05c2813e860dad0f35909ca5fd8e6
3
+ metadata.gz: 70b7a78ad4e94882b668193843f68a74fc818a4c
4
+ data.tar.gz: 7a53563330fa1652f8bcd9e860efc626d1c0b32e
5
5
  SHA512:
6
- metadata.gz: 4003176015c5e04ab938e1a5109499a117aff11040e088d8f1eb744880cbf6eb1660420aed109b2e53fba89d57e0989d6d9f4966bbf55e6d1daadc0d57dc52e3
7
- data.tar.gz: 1340d21cfa6dcbddec9432d27fdea9d725821ae2d0c1340ecc3c35ba0c5ed5de36ff429e00398aeebdb4d4df608f88ec555145a5f5d41733c96f0e214c6d61d5
6
+ metadata.gz: 4e309eabd4f59d684dc038b09e8cb6d14fabfc490fa0e5c99d3d574ab5776ae2daa8cc217257a6f2494341460dd05d78892cc3be1b0cbd7fd6e085f3530a561a
7
+ data.tar.gz: a93d5876fdf04845c80e22cdac5de2b92da7013c9f1b645aacb3537c16e04619bcef30a64050e647c5f2af8ec58d7b3718894fa6135bd9db5fa462aa5d1f4b08
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,26 +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
- 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.6')
27
+ end
@@ -0,0 +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
@@ -0,0 +1,79 @@
1
+ desc 'Generates a template for a processor'
2
+ command :generate_processor do |c|
3
+ c.action do |global_options, options, args|
4
+ require 'active_support/core_ext/string/inflections'
5
+ require 'fileutils'
6
+ require 'erb'
7
+
8
+ unless args.size == 2
9
+ raise "Needs exactly 2 arguments: eh generate_processor ModuleName ProcessorName"
10
+ end
11
+
12
+ processor_module_name = args[0].camelcase
13
+ processor_class_name = args[1].camelcase
14
+ underscored_processor_module_name = processor_module_name.underscore
15
+ underscored_processor_class_name = processor_class_name.underscore
16
+
17
+ destination_dir = Eh::Settings.current.processes_src_dir
18
+ destination_dir = File.join(destination_dir, "#{underscored_processor_module_name}.#{underscored_processor_class_name}")
19
+
20
+ template_temporary_dir = "/tmp/eventhub-processor-template/"
21
+ checkout_git_repo(template_temporary_dir)
22
+
23
+ FileUtils.cp_r template_temporary_dir, destination_dir
24
+ FileUtils.rm_rf File.join(destination_dir, ".git")
25
+
26
+ puts "Generating processor #{processor_module_name}:#{processor_class_name} in #{destination_dir}"
27
+ Dir.glob(destination_dir + "/**/*.erb") do |file|
28
+ template = ERB.new(File.read(file))
29
+
30
+ File.open(file, "w") do |writeable_file|
31
+ writeable_file.puts template.result(binding)
32
+ end
33
+
34
+ FileUtils.mv file, File.join(File.dirname(file), File.basename(file, ".erb"))
35
+ end
36
+
37
+ replacements = {
38
+ "underscored_processor_class_name" => underscored_processor_class_name,
39
+ "underscored_processor_module_name" => underscored_processor_module_name
40
+ }
41
+
42
+ rename_files_with_replacements(destination_dir, replacements)
43
+
44
+ FileUtils.rm_rf template_temporary_dir
45
+
46
+ puts "Done."
47
+ end
48
+ end
49
+
50
+ def shallow_clone_git_repository(source_url, destination_dir)
51
+ system("git clone --depth 1 #{source_url} #{destination_dir}")
52
+ end
53
+
54
+ def rename_files_with_replacements(destination_dir, replacements)
55
+ Dir.glob(destination_dir + "/**/*") do |src_file_path|
56
+ if File.file? src_file_path
57
+ dir = File.dirname src_file_path
58
+ file_with_replacements = File.basename src_file_path
59
+
60
+ replacements.each do |find_string, replace_string|
61
+ file_with_replacements.sub!(find_string, replace_string)
62
+ end
63
+
64
+ dest_file_path = File.join(dir, file_with_replacements)
65
+
66
+ if src_file_path != dest_file_path
67
+ FileUtils.mv src_file_path, dest_file_path
68
+ end
69
+ end
70
+ end
71
+ end
72
+
73
+ def checkout_git_repo(destination_dir)
74
+ template_repository_url = Eh::Settings.current.processor_template_repository_url
75
+ puts "Checking out latest template from #{template_repository_url}"
76
+ FileUtils.rm_rf(destination_dir)
77
+ FileUtils.mkdir(destination_dir)
78
+ shallow_clone_git_repository(template_repository_url, destination_dir)
79
+ end
@@ -1,109 +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.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
- included_processor_names = processor_names
19
-
20
- # only include processors specified by -p option, if option is given
21
- if options['p']
22
- included_processor_names = included_processor_names.select do |processor_name|
23
- options['p'].include?(processor_name)
24
- end
25
- end
26
-
27
- # exclude processors specified by -x option, if option is given
28
- if options['x']
29
- # check if any processor has been excluded from packaging
30
- included_processor_names = included_processor_names.select do |processor_name|
31
- !options['x'].include?(processor_name)
32
- end
33
- end
34
-
35
- # make sure we have at least one processor
36
- if included_processor_names.empty?
37
- raise "There are no processor names. Either your -s directory is empty or you specified a strange combination of -x and -p"
38
- end
39
-
40
-
41
- # make sure destination directory exists
42
- FileUtils.mkdir_p(destination_dir)
43
-
44
- # Zip all processors
45
- included_processor_names.each do |processor_name|
46
-
47
- directory = File.join(source_dir, processor_name) # last slash could be omitted
48
- zipfile_name = File.join(destination_dir, "#{processor_name}.zip")
49
-
50
- # remove zip before we create a new one
51
- FileUtils.rm zipfile_name, :force => true
52
-
53
- options = {"directories-recursively"=>true}
54
-
55
- Zip::File.open(zipfile_name,Zip::File::CREATE) do |zipfile|
56
-
57
- #zipfile.add(processor_name, directory)
58
- [directory].each{ |file_to_be_zipped|
59
-
60
- if File.directory?(file_to_be_zipped)
61
- # should skip directories
62
- next if options["directories-skip"]
63
-
64
- # should recursively add directory
65
- if options["directories-recursively"]
66
- directory = file_to_be_zipped
67
- puts "zipper: archiving directory: #{directory}"
68
- directory_chosen_pathname = options["directories-recursively-splat"] ? directory : File.dirname(directory)
69
- directory_pathname = Pathname.new(directory_chosen_pathname)
70
- files = Dir[File.join(directory, '**', '**')]
71
- files.delete_if {|filename| ["log", "logs", "exceptions", "pids", "tmp"].include?(filename) }
72
- files.each do |file|
73
- file_pathname = Pathname.new(file)
74
- file_relative_pathname = file_pathname.relative_path_from(directory_pathname)
75
- zipfile.add(file_relative_pathname,file)
76
- end
77
- next
78
- end
79
- end
80
-
81
- filename = File.basename(file_to_be_zipped)
82
-
83
- puts "zipper: archiving #{file_to_be_zipped} as #{filename} into #{zipfile}"
84
-
85
- zipfile.add(filename,file_to_be_zipped)
86
- }
87
- end
88
-
89
-
90
-
91
- #source = File.join(source_dir, processor_name)
92
- #destination = File.join(destination_dir, "#{processor_name}.zip")
93
-
94
- #puts "Packaging '#{processor_name}'"
95
-
96
- #arguments = ['tmp', 'logs', 'exceptions', 'log'].map do |item|
97
- # expanded = File.join(source, item, '*')
98
- # "-x \"#{expanded}\""
99
- #end.join(' ')
100
- #arguments << " -q" unless arguments['v']
101
- #puts source_dir
102
- #cmd = "cd #{source_dir} && zip -FS -r #{destination} #{processor_name} #{arguments}"
103
- #puts "Packaging '#{processor_name}' to #{destination} with \"#{cmd}\"" if global_options['v']
104
- #system(cmd)
105
- end
106
-
107
- puts "Done packaging #{included_processor_names.size} processors"
108
- end
109
- 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,46 +1,54 @@
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 release_dir
27
- File.join(repository_root_dir, 'releases', 'ruby')
28
- end
29
-
30
- def processes_src_dir
31
- File.join(repository_root_dir, 'src', 'process')
32
- end
33
-
34
- def rails_src_dir
35
- File.join(repository_root_dir, 'src', 'rails', 'console')
36
- end
37
-
38
- def rails_release_dir
39
- File.join(repository_root_dir, 'releases', 'rails')
40
- end
41
-
42
- def package_tmp_dir
43
- './tmp'
44
- end
45
-
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 ruby_release_dir
27
+ File.join(repository_root_dir, 'releases', 'ruby')
28
+ end
29
+
30
+ def processes_src_dir
31
+ File.join(repository_root_dir, 'src', 'process')
32
+ end
33
+
34
+ def rails_src_dir
35
+ File.join(repository_root_dir, 'src', 'rails', 'console')
36
+ end
37
+
38
+ def rails_release_dir
39
+ File.join(repository_root_dir, 'releases', 'rails')
40
+ end
41
+
42
+ def source_config_dir
43
+ File.join(repository_root_dir, 'config')
44
+ end
45
+
46
+ def processor_template_repository_url
47
+ "git@github.com:thomis/eventhub-processor-template.git"
48
+ end
49
+
50
+ def package_tmp_dir
51
+ './tmp'
52
+ end
53
+
46
54
  end
data/lib/eh/version.rb CHANGED
@@ -1,3 +1,3 @@
1
- module Eh
2
- VERSION = '0.0.9'
3
- end
1
+ module Eh
2
+ VERSION = '0.0.11'
3
+ end
data/lib/eh-commands.rb CHANGED
@@ -1,6 +1,6 @@
1
-
2
-
3
- # All commands are required here
4
- require 'eh/commands/release'
5
- require 'eh/commands/package_rails'
6
- require 'eh/commands/package'
1
+
2
+ # All commands are required here
3
+ require 'eh/commands/copy_config'
4
+ require 'eh/commands/generate_processor'
5
+ require 'eh/commands/package_rails'
6
+ 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.9
4
+ version: 0.0.11
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-11 00:00:00.000000000 Z
12
+ date: 2014-09-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -81,6 +81,20 @@ dependencies:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
83
  version: '1.0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: activesupport
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: 4.1.6
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: 4.1.6
84
98
  description: Event Hub Command Line Tool which supports you with various Event Hub
85
99
  related administrative development features.
86
100
  email:
@@ -105,9 +119,10 @@ files:
105
119
  - features/support/env.rb
106
120
  - lib/eh-commands.rb
107
121
  - lib/eh.rb
122
+ - lib/eh/commands/copy_config.rb
123
+ - lib/eh/commands/generate_processor.rb
108
124
  - lib/eh/commands/package.rb
109
125
  - lib/eh/commands/package_rails.rb
110
- - lib/eh/commands/release.rb
111
126
  - lib/eh/settings.rb
112
127
  - lib/eh/version.rb
113
128
  - test/default_test.rb
@@ -1,16 +0,0 @@
1
- desc 'Releases processor zip files to destination'
2
- command :release do |c|
3
- c.flag([:d, :destination], :desc => "Destination directory to place created zip files.", :default_value => Eh::Settings.current.release_dir)
4
- c.flag([:s, :source], :desc => "Source directory to read processors from.", :default_value => Eh::Settings.current.package_tmp_dir)
5
-
6
- c.action do |global_options, options, args|
7
- source_dir = options['s']
8
- destination_dir = options['d']
9
- pattern = "#{source_dir}/*.zip"
10
- cmd = "cp #{pattern} #{destination_dir}"
11
- puts "Will copy #{Dir[pattern].size} files from #{source_dir} to #{destination_dir}"
12
- puts "Command: #{cmd}" if global_options['v']
13
- system cmd
14
- puts "Done."
15
- end
16
- end