template_builder 0.2.0 → 0.3.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.
data/History.txt CHANGED
@@ -1,4 +1,5 @@
1
-
1
+ == 0.3.0
2
+ * add action
2
3
  == 0.2.0 / 2010-12-21
3
4
  * show action
4
5
  == 0.1.0 / 2010-11-21
data/README.txt CHANGED
@@ -18,6 +18,7 @@ project that you want.
18
18
 
19
19
  template_builder new your_template
20
20
  template_builder show
21
+ template_builder add framework plugin
21
22
 
22
23
 
23
24
  == INSTALL:
data/Rakefile CHANGED
@@ -14,5 +14,6 @@ Bones {
14
14
  email 'anthony.laibe@gmail.com'
15
15
  url 'https://github.com/alaibe/template_builder'
16
16
  ignore_file '.gitignore'
17
+ gem.dependencies 'little-plugger'
17
18
  }
18
19
 
@@ -1,26 +1,26 @@
1
1
  database :
2
- help : set the database you want to use
2
+ help : set the database you want use
3
3
  priority : 1
4
4
  orm :
5
- help : set the orm framework you want to use
5
+ help : set the orm framework you want use
6
6
  priority : 2
7
7
  javascript :
8
- help : set the javascript framework you want to use
8
+ help : set the javascript framework you want use
9
9
  priority : 2
10
10
  templating :
11
- help : set the templating framework you want to use
11
+ help : set the templating framework you want use
12
12
  priority : 2
13
13
  css :
14
- help : set the css framework you want to use
14
+ help : set the css framework you want use
15
15
  priority : 2
16
16
  unit_testing :
17
- help : set the unit testing framework you want to use
17
+ help : set the unit testing framework you want use
18
18
  priority : 3
19
19
  integration_testing :
20
- help : set the integration testing framework you want to use
20
+ help : set the integration testing framework you want use
21
21
  priority : 3
22
22
  authentication :
23
- help : set the authentication framework you want to use
23
+ help : set the authentication framework you want use
24
24
  priority : 4
25
25
 
26
26
 
@@ -4,7 +4,7 @@ require 'uri'
4
4
  module TemplateBuilder::App
5
5
  extend LittlePlugger(:path => 'template_builder/app', :module => TemplateBuilder::App)
6
6
 
7
- disregard_plugins :command, :file_manager, :file_analyzer
7
+ disregard_plugins :command, :file_manager, :file_analyzer; :conf_writer
8
8
 
9
9
  Error = Class.new(StandardError)
10
10
 
@@ -57,14 +57,18 @@ module TemplateBuilder::App
57
57
  cmd.run
58
58
  end
59
59
 
60
- # rescue TemplateBuilder::App::Error => err
61
- # stderr.puts "ERROR: While executing template builder ..."
62
- # stderr.puts " #{err.message}"
63
- # exit 1
64
- # rescue StandardError => err
65
- # stderr.puts "ERROR: While executing template builder ... (#{err.class})"
66
- # stderr.puts " #{err.to_s}"
67
- # exit 1
60
+ rescue TemplateBuilder::App::Error => err
61
+ stderr.puts "ERROR: While executing template builder ..."
62
+ stderr.puts " #{err.message}"
63
+ exit 1
64
+ rescue StandardError => err
65
+ stderr.puts "ERROR: While executing template builder ... (#{err.class})"
66
+ stderr.puts " #{err.to_s}"
67
+ exit 1
68
+ rescue Exception => err
69
+ stderr.puts "ERROR: While executing template builder ... (#{err.class})"
70
+ stderr.puts " #{err.to_s}"
71
+ exit 1
68
72
  end
69
73
 
70
74
  # Show the toplevel Template builder help message.
@@ -96,7 +100,7 @@ DESCRIPTION
96
100
  puts msg
97
101
  end
98
102
  }
99
- ary = [:new, :show]
103
+ ary = [:new, :show, :add]
100
104
  ary.each(&fmt)
101
105
  (@all_commands.keys - ary).each(&fmt)
102
106
  msg.concat <<-MSG
@@ -0,0 +1,79 @@
1
+ module TemplateBuilder::App
2
+ class Add < Command
3
+ def self.initialize_add
4
+ synopsis 'template_builder add [framework] [plugin]'
5
+
6
+ summary 'Add new available framework or plugin at your template_builder .'
7
+
8
+ description <<-__
9
+ Add new framework (plugin) at your template_builder gem. You can add a new framework
10
+ type and new plugin for this framework.
11
+ __
12
+
13
+ option(standard_options[:force])
14
+ option(standard_options[:verbose])
15
+ end
16
+
17
+ def run
18
+ case @param.length
19
+ when 1
20
+ create_framework @param.shift
21
+ when 2
22
+ create_plugin @param.shift, @param.shift
23
+ else
24
+ Raise Exception, "Bad number of argument, see -h for more information"
25
+ end
26
+ end
27
+
28
+ def parse( args )
29
+ opts = super args
30
+ config[:name] = args.empty? ? nil : args.join('_')
31
+ if name.nil?
32
+ stdout.puts opts
33
+ exit 1
34
+ end
35
+ @param = args
36
+ end
37
+
38
+ def create_framework(name)
39
+ priority = ask_for_priority
40
+ ConfWriter.write_new_framework name, priority
41
+ end
42
+
43
+ def create_plugin(framework_name,plugin_name)
44
+ raise Exception, "Framework #{name} doesn't exists." unless test ?e, TemplateBuilder::PATH+"/conf/"+framework_name+".yml"
45
+ write = "\n#{plugin_name} :\n"
46
+ answer = "Would you add a gem at your plugin? (y/yes)"
47
+ puts answer
48
+ while ["y\n","yes\n"].include? STDIN.gets
49
+ write += build_new_gem
50
+ puts answer
51
+ end
52
+ puts "plugin command ="
53
+ write += "\tcommand :"+STDIN.gets
54
+ puts "plugin action ="
55
+ write += "\taction :["+STDIN.gets+"]"
56
+ ConfWriter.write_new_plugin framework_name, write
57
+ end
58
+
59
+ def build_new_gem
60
+ puts "gem name = "
61
+ msg = "\t"+STDIN.gets
62
+ puts "gem version = "
63
+ msg += "\t\tversion : "+STDIN.gets
64
+ puts "gem source = "
65
+ msg += "\t\tsource : "+STDIN.gets
66
+ puts "gem action = "
67
+ msg += "\t\taction : "+STDIN.gets
68
+ puts "gem command = "
69
+ msg += "\t\tcommand : "+STDIN.gets
70
+ msg
71
+ end
72
+
73
+ def ask_for_priority
74
+ puts "Choose the priority of your framework ? (1 <=> hight et 5 <=> less)"
75
+ answer = STDIN.gets until (1..5).include? answer.to_i
76
+ answer
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,15 @@
1
+ module TemplateBuilder::App::ConfWriter
2
+ def self.write_new_framework(name,priority)
3
+ #raise Exception, "Framework #{name} already exists." if test ?e, TemplateBuilder::PATH+"/conf/"+name+".yml"
4
+ File.open(File.join(TemplateBuilder::PATH+"/conf/",name+".yml"),"w")
5
+ File.open(File.join(TemplateBuilder::PATH+"/conf/","param.yml"),"a+") do |out|
6
+ out.write "\n#{name} : \n\t help : set the #{name} framework you want use\n\tpriority : #{priority}"
7
+ end
8
+ end
9
+
10
+ def self.write_new_plugin(framework_name, plugin)
11
+ File.open(File.join(TemplateBuilder::PATH+"/conf/",framework_name+".yml"),"a+") do |out|
12
+ out.write plugin
13
+ end
14
+ end
15
+ end
@@ -72,7 +72,6 @@ module TemplateBuilder::App::FileAnalyzer
72
72
 
73
73
  def load_framework(name)
74
74
  opts = {:name => name, :gems =>[]}
75
- puts name
76
75
  @config_file[name].each do |key, value|
77
76
  if ["command","action"].include? key
78
77
  opts[key.to_sym] = value
@@ -32,9 +32,7 @@ of option as the database, the javascript framework etc ..
32
32
  sorted_param.each{ |k,v| ask_for k unless v.name }
33
33
 
34
34
  file_manager.start_file sorted_param
35
-
36
35
  sorted_param.each{ |k,v| run_framework file_manager, :type=>k, :name=>v.name unless v.name == "none"}
37
-
38
36
  file_manager.end_file name, @command
39
37
 
40
38
  end
@@ -1,7 +1,7 @@
1
1
  module TemplateBuilder::App
2
2
  class Show < Command
3
3
  def self.initialize_show
4
- synopsis 'template_builder show [parameter]'
4
+ synopsis 'template_builder show [framework] [plugin]'
5
5
 
6
6
  summary 'Show all kind of awesome framework available .'
7
7
 
data/version.txt CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: template_builder
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 2
8
+ - 3
9
9
  - 0
10
- version: 0.2.0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Anthony
@@ -15,13 +15,27 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-21 00:00:00 +01:00
18
+ date: 2010-12-23 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: bones
22
+ name: little-plugger
23
23
  prerelease: false
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: bones
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
25
39
  none: false
26
40
  requirements:
27
41
  - - ">="
@@ -33,7 +47,7 @@ dependencies:
33
47
  - 1
34
48
  version: 3.5.1
35
49
  type: :development
36
- version_requirements: *id001
50
+ version_requirements: *id002
37
51
  description: |-
38
52
  Template-builder is a handy tool that builds a template for your new Ruby
39
53
  on Rails projects. The template contains all you need to build the RoR
@@ -65,6 +79,8 @@ files:
65
79
  - lib/template_builder.rb
66
80
  - lib/template_builder/app.rb
67
81
  - lib/template_builder/app/command.rb
82
+ - lib/template_builder/app/command_add.rb
83
+ - lib/template_builder/app/conf_writer.rb
68
84
  - lib/template_builder/app/file_analyzer.rb
69
85
  - lib/template_builder/app/file_manager.rb
70
86
  - lib/template_builder/app/helper/framework.rb