fusegen 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
data/README.rdoc ADDED
@@ -0,0 +1,25 @@
1
+ = fusegen
2
+
3
+ This project creates dynamic quickstarts for JBoss Fuse and JBoss A-MQ.
4
+
5
+ Try it out
6
+ ----------
7
+
8
+ If you have rails installed you should be able to try it out using:
9
+
10
+ >git clone https://github.com/dstanley/fusegen.git
11
+ >rake package
12
+ >gem install ./pkg/fusegen-0.0.1.gem
13
+
14
+
15
+ Then for a list of options
16
+
17
+ >fusegen help
18
+
19
+ Generate a camel project using 2.10.0.redhat-60060
20
+
21
+ >fusegen -f 60060 fuse camel-basic
22
+
23
+ Generate a camel project using 2.10.0.redhat-60024
24
+
25
+ >fusegen -f 60024 fuse camel-basic
data/Rakefile ADDED
@@ -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('fusegen.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]
data/bin/fusegen ADDED
@@ -0,0 +1,207 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'gli'
4
+ include GLI::App
5
+
6
+ require 'thor'
7
+
8
+ require 'fusegen'
9
+ require 'pp'
10
+
11
+ # dev mode run: bundle exec bin/fusegen
12
+
13
+ program_desc 'code generation for JBoss Fuse! (and beyond)
14
+
15
+ HELP
16
+ fusegen help <command> - for specific subcommand help'
17
+
18
+ version Fusegen::VERSION
19
+
20
+
21
+
22
+ desc 'Project category (e.g. fuse|amq|fabric|patch)'
23
+ default_value 'none'
24
+ arg_name '<category>'
25
+ flag [:c,:category]
26
+
27
+
28
+ desc 'Git base uri'
29
+ arg_name '[gitbase]'
30
+ flag [:g,:gitbase]
31
+
32
+ desc 'Creates a new project'
33
+ arg_name '[project]'
34
+ command :new do |c|
35
+ c.desc 'Fuse product version [last 5 digits]'
36
+ c.default_value '60024'
37
+ c.arg_name '[60xxx|61xxx]'
38
+ c.flag [:f,:fuseversion]
39
+
40
+ c.desc 'Maven groupId for the project'
41
+ c.default_value 'com.redhat.support'
42
+ c.arg_name '[groupid]'
43
+ c.flag [:g,:groupid]
44
+
45
+ c.desc 'Maven artifactId for the project'
46
+ c.default_value 'test-project'
47
+ c.arg_name '[artifactid]'
48
+ c.flag [:a,:artifactid]
49
+
50
+ c.desc 'Maven packaging for the project'
51
+ c.default_value 'bundle'
52
+ c.arg_name '[bundle|jar|war]'
53
+ c.flag [:p,:packaging]
54
+
55
+ c.desc 'Fabric hostname for maven deploy plugin'
56
+ c.default_value 'localhost'
57
+ c.arg_name '[hostname]'
58
+ c.flag [:h,:fabrichost]
59
+
60
+ c.action do |global_options,options,args|
61
+
62
+ # As this is a common command we add extra help
63
+ if global_options[:category] == "none"
64
+ puts "NAME"
65
+ puts " new - Creates a new project"
66
+ puts ""
67
+ puts "SYNOPSIS"
68
+ puts " fusegen [global options] new [quickstart]"
69
+ puts ""
70
+ puts "EXAMPLE"
71
+ puts " fusegen -c fuse new camel-base"
72
+ puts ""
73
+ raise "No category provided (use -c <category>). For available categories see 'fusegen quickstart categories'"
74
+ end
75
+
76
+ options[:category] = global_options[:category]
77
+ options[:projectversion] = "1.0-SNAPSHOT"
78
+ options[:name] = "my-fusegen-project"
79
+ options[:name] = args[0] unless args.nil?
80
+
81
+ g = Generator.new
82
+ g.generate(global_options,options,args)
83
+
84
+ end
85
+ end
86
+
87
+
88
+
89
+
90
+ desc 'Manage quickstarts'
91
+ command [:qs,:quickstarts] do |c|
92
+
93
+ c.desc "List available quickstart project templates"
94
+ c.command :list do |list|
95
+ list.action do |global_options,options,args|
96
+
97
+ # load top level meta data from each repo
98
+ # Display by repo by default
99
+ # If -c then display category list
100
+ # If -t then display by tag
101
+
102
+ puts "camel-base"
103
+ end
104
+ end
105
+
106
+ c.desc "List available categories"
107
+ c.command [:c,:categories] do |categories|
108
+ categories.action do |global_options,options,args|
109
+ puts "Available Categories:"
110
+ puts " fuse - JBoss Fuse projects"
111
+ puts " amq - JBoss A-MQ projects"
112
+ puts " fabric - Fuse Fabric projects"
113
+ puts " patch - JBoss Fuse patch projects"
114
+
115
+ end
116
+ end
117
+
118
+ c.desc "Add a github repo to repository db"
119
+ c.command [:ar,:addrepo] do |repo|
120
+ repo.action do |global_options,options,args|
121
+ # Validate input
122
+ # Save the repo to local config
123
+ if args.nil? || args.length == 0
124
+ puts "No repo provided.."
125
+ help_now!
126
+ else
127
+ # ... logic here
128
+ puts "[TODO] Add repo to config '" + args[0] + "'"
129
+ end
130
+ end
131
+ end
132
+
133
+ c.desc "Show quickstart info for a project"
134
+ c.arg_name '<name>'
135
+ c.command :info do |info|
136
+ info.action do |global_options,options,args|
137
+
138
+
139
+ # Validate input
140
+ if args.nil? || args.length == 0
141
+ puts "No quickstart name provided.."
142
+ help_now!
143
+ else
144
+ # ... logic here
145
+ puts "[TODO] show quickstart info for '" + args[0] + "'"
146
+ end
147
+
148
+ end
149
+ end
150
+ end
151
+
152
+
153
+ desc 'Append to an existing project'
154
+ command :util do |c|
155
+
156
+ c.desc "Add a features file to a project"
157
+ c.command [:af,:addfeature] do |feature|
158
+ feature.action do |global_options,options,args|
159
+ puts "[TODO] Add a features file to a project"
160
+ end
161
+ end
162
+
163
+ # TODO: Command to add maven dependencies for fuse features?
164
+
165
+ c.desc "Add a maven profile to a maven pom"
166
+ c.arg_name '<name> <className>'
167
+ c.command [:p,:profile] do |profile|
168
+ profile.action do |global_options,options,args|
169
+
170
+
171
+ # Validate input
172
+ if args.nil? || args.length == 0
173
+ puts "No quickstart name provided.."
174
+ help_now!
175
+ else
176
+ # ... logic here
177
+ puts "[TODO] show quickstart info for '" + args[0] + "'"
178
+ end
179
+
180
+ end
181
+ end
182
+ end
183
+
184
+
185
+
186
+ pre do |global,command,options,args|
187
+ # Pre logic here
188
+ # Return true to proceed; false to abort and not call the
189
+ # chosen command
190
+ # Use skips_pre before a command to skip this block
191
+ # on that command only
192
+ true
193
+ end
194
+
195
+ post do |global,command,options,args|
196
+ # Post logic here
197
+ # Use skips_post before a command to skip this
198
+ # block on that command only
199
+ end
200
+
201
+ on_error do |exception|
202
+ # Error logic here
203
+ # return false to skip default error handling
204
+ true
205
+ end
206
+
207
+ 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 "fusegen"
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
data/fusegen.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # Ensure we require the local version and not one we might have installed already
2
+ require File.join([File.dirname(__FILE__),'lib','fusegen','version.rb'])
3
+ spec = Gem::Specification.new do |s|
4
+ s.name = 'fusegen'
5
+ s.version = Fusegen::VERSION
6
+ s.author = 'Dave Stanley'
7
+ s.email = 'dstanleyd@gmail.com'
8
+ s.homepage = 'https://github.com/dstanley'
9
+ s.platform = Gem::Platform::RUBY
10
+ s.summary = 'JBoss Fuse Code Generator'
11
+ s.description = 'Code generator that simplifies generating new JBoss Fuse projects'
12
+ s.files = `git ls-files`.split("
13
+ ")
14
+ s.require_paths << 'lib'
15
+ s.has_rdoc = true
16
+ s.extra_rdoc_files = ['README.rdoc','fusegen.rdoc']
17
+ s.rdoc_options << '--title' << 'fusegen' << '--main' << 'README.rdoc' << '-ri'
18
+ s.bindir = 'bin'
19
+ s.executables << 'fusegen'
20
+ s.add_development_dependency('rake')
21
+ s.add_development_dependency('rdoc')
22
+ s.add_development_dependency('aruba')
23
+ s.add_runtime_dependency('gli','2.9.0')
24
+ s.add_runtime_dependency('thor','0.18.1')
25
+ end
data/fusegen.rdoc ADDED
@@ -0,0 +1,55 @@
1
+ == fusegen - JBoss Fuse Code Generation Gem
2
+
3
+ v0.0.1
4
+
5
+ === Global Options
6
+ === -f|--flagname The name of the argument
7
+
8
+ Describe some flag here
9
+
10
+ [Default Value] the default
11
+
12
+
13
+ === --help
14
+ Show this message
15
+
16
+
17
+
18
+ === -s|--[no-]switch
19
+ Describe some switch here
20
+
21
+
22
+
23
+ === --version
24
+ Display the program version
25
+
26
+
27
+
28
+ === Commands
29
+ ==== Command: <tt>help command</tt>
30
+ Shows a list of commands or help for one command
31
+
32
+ Gets help for the application or its commands. Can also list the commands in a way helpful to creating a bash-style completion function
33
+ ===== Options
34
+ ===== -c
35
+ List commands one per line, to assist with shell completion
36
+
37
+
38
+
39
+ ==== Command: <tt>new args go here</tt>
40
+ Create a new JBoss Fuse project
41
+
42
+
43
+ ===== Options
44
+ ===== -f arg
45
+
46
+ Describe a flag to new
47
+
48
+ [Default Value] default
49
+
50
+
51
+ ===== -s
52
+ Describe a switch to new
53
+
54
+
55
+
@@ -0,0 +1,152 @@
1
+ require 'thor'
2
+
3
+ class Generator < Thor
4
+ include Thor::Actions
5
+
6
+ attr_accessor :versions
7
+
8
+ desc "generate", "generate new project"
9
+ def generate(global_options,options,args)
10
+
11
+ begin
12
+ say_task "Creating " + options[:name]
13
+ create_project options
14
+ rescue Exception => e
15
+ pp global_options
16
+ pp options
17
+ pp args
18
+ puts e.message
19
+ puts e.backtrace
20
+ end
21
+ end
22
+
23
+ def self.source_root
24
+ File.dirname(__FILE__)
25
+ end
26
+
27
+ private
28
+
29
+ def initialize
30
+ super
31
+
32
+ @versions = { "60"=> { "camel"=>"2.10.0.redhat-", "activemq"=>"5.8.0.redhat-",
33
+ "cxf"=>"2.6.0.redhat-", "spring"=>"3.1.3.RELEASE",
34
+ "karaf"=>"2.3.0.redhat-" },
35
+ "61"=> { "camel"=>"2.12.0.redhat-", "activemq"=>"5.9.0.redhat-",
36
+ "cxf"=>"2.7.0.redhat-", "spring"=>"3.2.3.RELEASE",
37
+ "karaf"=>"2.3.0.redhat-" }
38
+ }
39
+
40
+ end
41
+
42
+ def create_project(options)
43
+
44
+ #begin
45
+ base_path = options[:groupid].gsub('.', '/')
46
+
47
+ # Download manifest
48
+ copy_from_github 'manifest.yml', 'manifest.yml', options
49
+
50
+ project = load_file 'manifest.yml', options
51
+
52
+ if project.size > 0
53
+
54
+ project["copies"].each do |source, destination|
55
+ destination.gsub! '@base_path',base_path
56
+ copy_from_github source, destination, options
57
+ end
58
+
59
+ project["subs"].each do |subs|
60
+ subs[1].each do |sub|
61
+ file = options[:name] + '/' + subs[0].dup
62
+ file.gsub! '@base_path',base_path
63
+ subvalue = get_substitution_value(sub, options)
64
+ regex = Regexp.new /#{sub}/
65
+ gsub_file file, regex, subvalue
66
+ end
67
+ end
68
+
69
+ remove_file options[:name] + '/manifest.yml'
70
+ else
71
+ say_error "Quickstart '" + options[:name] + "' is not valid"
72
+ end
73
+
74
+ end
75
+
76
+
77
+ def say_task(name); say "\033[1m\033[32m" + "task".rjust(10) + "\033[0m" + " #{name} .." end
78
+ def say_warn(name); say "\033[1m\033[36m" + "warn".rjust(10) + "\033[0m" + " #{name}" end
79
+ def say_error(name); say "\033[1m\033[31m" + "error".rjust(10) + "\033[0m" + " #{name}" end
80
+
81
+
82
+ def source_paths
83
+ [File.join(Dir.pwd, "templates")] + super
84
+ end
85
+
86
+ def copy_from_github(source, destination, options = {})
87
+ base = 'https://raw.github.com/dstanley/fusegen-templates/master/archetypes/'
88
+ base = options[:gitbase] unless options[:gitbase].nil?
89
+ base = base + options[:category] + '/' + options[:name] + '/'
90
+
91
+ begin
92
+ #remove_file destination
93
+ get base + source, options[:name] + '/' + destination
94
+ rescue OpenURI::HTTPError
95
+ say_error "Unable to download " + base + source
96
+ end
97
+ end
98
+
99
+ def load_file(file, options={})
100
+ begin
101
+ cfg = {}
102
+ path = options[:name] + '/' + file
103
+ cfg = YAML.load_file(path)
104
+ rescue Exception => e
105
+ end
106
+ cfg
107
+ end
108
+
109
+
110
+ def get_substitution_value(keyword, options={})
111
+ case keyword
112
+ when "@project_version"
113
+ options[:projectversion]
114
+ when "@package"
115
+ options[:groupid]
116
+ when "@package_reverse"
117
+ options[:groupid].split(".").reverse.join(".")
118
+ when "@group_id"
119
+ options[:groupid]
120
+ when "@artifact_id"
121
+ options[:artifactid]
122
+ when "@packaging"
123
+ options[:packaging]
124
+ when "@project_version"
125
+ options[:projectversion]
126
+ when "@name"
127
+ options[:name]
128
+ when "@camel_version"
129
+ get_version(options[:fuseversion],"camel")
130
+ when "@activemq_version"
131
+ get_version(options[:fuseversion],"activemq")
132
+ when "@cxf_version"
133
+ get_version(options[:fuseversion],"cxf")
134
+ when "@smx_version"
135
+ get_version(options[:fuseversion],"smx")
136
+ when "@karaf_version"
137
+ get_version(options[:fuseversion],"karaf")
138
+ when "@spring_version"
139
+ get_version(options[:fuseversion],"spring")
140
+ when "@fabric_host"
141
+ "@" + options[:fabrichost]
142
+ else
143
+ keyword
144
+ end
145
+ end
146
+
147
+ def get_version(project_version, component)
148
+ @versions[project_version[0..1]][component] + project_version
149
+ end
150
+
151
+
152
+ end
@@ -0,0 +1,3 @@
1
+ module Fusegen
2
+ VERSION = '0.0.1'
3
+ end
data/lib/fusegen.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'fusegen/version.rb'
2
+ require 'fusegen/generator.rb'
3
+
4
+
5
+ # Add requires for other files you add to your project here, so
6
+ # you just need to require this one file in your bin file
@@ -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,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fusegen
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Dave Stanley
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2014-02-16 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rake
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :development
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: rdoc
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ type: :development
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: aruba
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ type: :development
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: gli
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - "="
69
+ - !ruby/object:Gem::Version
70
+ hash: 43
71
+ segments:
72
+ - 2
73
+ - 9
74
+ - 0
75
+ version: 2.9.0
76
+ type: :runtime
77
+ version_requirements: *id004
78
+ - !ruby/object:Gem::Dependency
79
+ name: thor
80
+ prerelease: false
81
+ requirement: &id005 !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - "="
85
+ - !ruby/object:Gem::Version
86
+ hash: 85
87
+ segments:
88
+ - 0
89
+ - 18
90
+ - 1
91
+ version: 0.18.1
92
+ type: :runtime
93
+ version_requirements: *id005
94
+ description: Code generator that simplifies generating new JBoss Fuse projects
95
+ email: dstanleyd@gmail.com
96
+ executables:
97
+ - fusegen
98
+ extensions: []
99
+
100
+ extra_rdoc_files:
101
+ - README.rdoc
102
+ - fusegen.rdoc
103
+ files:
104
+ - Gemfile
105
+ - README.rdoc
106
+ - Rakefile
107
+ - bin/fusegen
108
+ - features/fusegen.feature
109
+ - features/step_definitions/fusegen_steps.rb
110
+ - features/support/env.rb
111
+ - fusegen.gemspec
112
+ - fusegen.rdoc
113
+ - lib/fusegen.rb
114
+ - lib/fusegen/generator.rb
115
+ - lib/fusegen/version.rb
116
+ - test/default_test.rb
117
+ - test/test_helper.rb
118
+ homepage: https://github.com/dstanley
119
+ licenses: []
120
+
121
+ post_install_message:
122
+ rdoc_options:
123
+ - --title
124
+ - fusegen
125
+ - --main
126
+ - README.rdoc
127
+ - -ri
128
+ require_paths:
129
+ - lib
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ none: false
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ hash: 3
137
+ segments:
138
+ - 0
139
+ version: "0"
140
+ required_rubygems_version: !ruby/object:Gem::Requirement
141
+ none: false
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ hash: 3
146
+ segments:
147
+ - 0
148
+ version: "0"
149
+ requirements: []
150
+
151
+ rubyforge_project:
152
+ rubygems_version: 1.8.24
153
+ signing_key:
154
+ specification_version: 3
155
+ summary: JBoss Fuse Code Generator
156
+ test_files: []
157
+