bivouac 0.2.5 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -20,6 +20,15 @@ Bivouac is a simple generator for camping[http://code.whytheluckystiff.net/campi
20
20
 
21
21
  == FEATURES/PROBLEMS:
22
22
 
23
+ === 0.3.0:
24
+
25
+ * script/plugin improvements
26
+ * Add before_filter
27
+ * Move console.rc from script to config (Bug)
28
+ * Rename :session_type to :session in environment.rb
29
+ * Add rake tasks bivouac:update, bivouac:update:all, bivouac:update:app, bivouac:update:configs, bivouac:update:public and bivouac:update:scripts. Use FORCE=1 (or true) to force update
30
+ * Bivouac::Template#copyTemplate has been modified
31
+
23
32
  === 0.2.5:
24
33
 
25
34
  * Bugs corrections for DB sessions
data/bin/bivouac CHANGED
@@ -27,7 +27,8 @@ database_configuration = {
27
27
  :orgtype => "GOH",
28
28
  :port => 3301,
29
29
  :address => "0.0.0.0",
30
- :session => :cookie
30
+ :session => :cookie,
31
+ :versions => "{ :scripts => '#{@BIVOUAC_VERSION}', :public => '#{@BIVOUAC_VERSION}', :configs => '#{@BIVOUAC_VERSION}', :app => '#{@BIVOUAC_VERSION}' }"
31
32
  )
32
33
 
33
34
  opts = OptionParser.new do |opts|
@@ -142,6 +143,7 @@ createDir( "#{@conf.appdir}/log" )
142
143
  createDir( "#{@conf.appdir}/script" )
143
144
  createDir( "#{@conf.appdir}/test" )
144
145
  createDir( "#{@conf.appdir}/lib" )
146
+ createDir( "#{@conf.appdir}/lib/tasks" )
145
147
  createDir( "#{@conf.appdir}/plugins" )
146
148
 
147
149
  # Create Application Environment file
@@ -185,7 +187,7 @@ createFile( "#{@conf.appdir}/script/console", true ) { |io|
185
187
  }
186
188
 
187
189
  # Create console.rc view
188
- createFile( "#{@conf.appdir}/script/console.rc" ) { |io|
190
+ createFile( "#{@conf.appdir}/config/console.rc" ) { |io|
189
191
  io.puts template( "static/console_rc" )
190
192
  }
191
193
 
@@ -195,7 +197,7 @@ createFile( "#{@conf.appdir}/script/plugin", true ) { |io|
195
197
  }
196
198
 
197
199
  # Create Rakefile
198
- createFile( "#{@conf.appdir}/Rakefile", true ) { |io|
200
+ createFile( "#{@conf.appdir}/Rakefile" ) { |io|
199
201
  io.puts template( "Rakefile" )
200
202
  }
201
203
 
data/doc/rdoc/created.rid CHANGED
@@ -1 +1 @@
1
- Sun, 29 Jun 2008 18:53:32 +0200
1
+ Thu, 17 Jul 2008 14:49:01 +0200
@@ -87,7 +87,7 @@ end</strong>
87
87
  <div id="README" class="page_shade">
88
88
  <div class="page">
89
89
  <div class="header">
90
- <div class="path">README / Sun Jun 29 18:52:22 +0200 2008</div>
90
+ <div class="path">README / Fri Jul 04 15:13:15 +0200 2008</div>
91
91
  </div>
92
92
 
93
93
  <h1>Bivouac</h1>
@@ -130,6 +130,29 @@ href="http://code.whytheluckystiff.net/camping">camping</a>.
130
130
  </li>
131
131
  </ul>
132
132
  <h2>FEATURES/PROBLEMS:</h2>
133
+ <h3>0.3.0:</h3>
134
+ <ul>
135
+ <li>script/plugin improvements
136
+
137
+ </li>
138
+ <li>Add before_filter
139
+
140
+ </li>
141
+ <li>Move console.rc from script to config (Bug)
142
+
143
+ </li>
144
+ <li>Rename :session_type to :session in environment.rb
145
+
146
+ </li>
147
+ <li>Add rake tasks bivouac:update, bivouac:update:all, bivouac:update:app,
148
+ bivouac:update:configs, bivouac:update:public and bivouac:update:scripts.
149
+ Use FORCE=1 (or true) to force update
150
+
151
+ </li>
152
+ <li>Bivouac::Template#copyTemplate has been modified
153
+
154
+ </li>
155
+ </ul>
133
156
  <h3>0.2.5:</h3>
134
157
  <ul>
135
158
  <li>Bugs corrections for DB sessions
@@ -55,18 +55,48 @@ module Bivouac
55
55
 
56
56
  r = system "svn", "co", "#{BASE_URL}#{@script_arguments}"
57
57
  if r == false
58
- raise $?
58
+ get_with_http( BASE_URL, @script_arguments )
59
59
  end
60
60
  end
61
61
 
62
62
  def list(desc = false)
63
63
  return "List available plugins" if desc
64
+
65
+ plugins_path = File.dirname($0) + "/../plugins/"
66
+ installed_plugins = Dir.glob( plugins_path + "*" ).map { |p| p.gsub!( plugins_path, "" ) }
64
67
 
65
68
  open(BASE_URL).read.each do |l|
66
69
  if m = /<li><a href="([^"]*)">(\1)<\/a><\/li>/.match( l )
67
- puts " - " + m[1].gsub( /\//, '' )
70
+ p_name = m[1].gsub( /\//, '' )
71
+ print " - " + p_name
72
+ print " (installed)" if installed_plugins.include?( p_name )
73
+ puts
74
+ end
75
+ end
76
+ end
77
+
78
+ private
79
+ def get_with_http( root, dir_name )
80
+ FileUtils::mkdir( dir_name )
81
+ FileUtils::cd( dir_name )
82
+
83
+ open( root + dir_name ).read.each do |l|
84
+ if m = /<li><a href="([^"]*)">(\1)<\/a><\/li>/.match( l )
85
+ file_name = m[1]
86
+ if file_name[-1].chr == "/"
87
+ get_with_http( root + dir_name + "/", file_name.gsub( /\//, '' ) )
88
+ else
89
+ puts "A #{root.gsub( BASE_URL, "" )}#{dir_name}/#{file_name}"
90
+ open( file_name, "w" ) do |fhd|
91
+ open( "#{root}#{dir_name}/#{file_name}" ).read.each do |lc|
92
+ fhd.print( lc )
93
+ end
94
+ end
95
+ end
68
96
  end
69
97
  end
98
+
99
+ FileUtils::cd( ".." )
70
100
  end
71
101
  end
72
102
  end
@@ -0,0 +1,39 @@
1
+ $__filters__ = {}
2
+ def before_filter( action, opts = {} )
3
+ $__filters__[action] = opts
4
+ end
5
+
6
+ module Bivouac::Filters
7
+ def service(*a)
8
+ current_class_name = self.class.name #.to_s.gsub( /.*::/, '' )
9
+ apply_filter = nil
10
+
11
+ $__filters__.each do |k, v|
12
+ if v.size > 0
13
+
14
+ v.each do |only_or_except, klasses|
15
+ kklasses = klasses.map{|_| _.name}
16
+ if only_or_except == :only and kklasses.include?( current_class_name )
17
+ apply_filter = k
18
+ end
19
+
20
+ if only_or_except == :except and not kklasses.include?( current_class_name )
21
+ apply_filter = k
22
+ end
23
+ end
24
+
25
+ else
26
+ apply_filter = k
27
+ end
28
+ end
29
+
30
+ s = super(*a)
31
+ unless apply_filter.nil?
32
+ r = apply_filter.filter( @state )
33
+ unless r.nil?
34
+ redirect r
35
+ end
36
+ end
37
+ s
38
+ end
39
+ end
@@ -0,0 +1,35 @@
1
+ include Bivouac
2
+ include Bivouac::Template
3
+
4
+ class Hash
5
+ def <<(h)
6
+ h.each {|k,v| self[k]=v}
7
+ end
8
+ alias :to_str :to_s
9
+ def to_s
10
+ "{"+self.map{|k,v|k.inspect+" => "+v.inspect}.join(', ')+"}"
11
+ end
12
+ end
13
+
14
+ class << Gem; attr_accessor :loaded_specs; end
15
+ BIVOUAC_VERSION = Gem.loaded_specs['bivouac'].version.to_s
16
+ CAMPING_VERSION = Gem.loaded_specs['camping'].version.to_s
17
+
18
+ # Load environment
19
+ require "#{BIVOUAC_ROOT}/config/environment.rb"
20
+ config = Bivouac::Environment.new( )
21
+ @app_versions = config.environment.versions || { :scripts => '(unknown)', :public => '(unknown)', :configs => '(unknown)', :app => '(unknown)' }
22
+ @conf = config.environment
23
+ @conf.versions = @app_versions
24
+ @conf.session = config.environment.session_type if config.environment.session_type
25
+
26
+ def update_version( opts )
27
+ @conf.versions << opts
28
+ end
29
+
30
+ # Load Bivouac rakefile extensions
31
+ Dir["#{File.dirname(__FILE__)}/*.rake"].each { |ext| load ext }
32
+
33
+ # Load any custom rakefile extensions
34
+ Dir["#{BIVOUAC_ROOT}/lib/tasks/**/*.rake"].sort.each { |ext| load ext }
35
+
@@ -0,0 +1,105 @@
1
+ namespace :bivouac do
2
+ @force = false
3
+ desc "Update both configs, scripts and public"
4
+ task :update => [ "update:do_scripts", "update:do_public", "update:configs" ]
5
+
6
+ namespace :update do
7
+ desc "Update both configs, scripts, public and app/#{@conf.appfile}.rb"
8
+ task :all => [ "do_scripts", "do_public", "do_app", "configs" ]
9
+
10
+ desc "Update config/environment.rb"
11
+ task :configs do
12
+ if @app_versions[:scripts] != BIVOUAC_VERSION or ["true", "1"].include?(ENV['FORCE']) or @force
13
+ puts "* Update configs from Bivouac #{@app_versions[:configs]} -> #{BIVOUAC_VERSION}"
14
+ @conf.versions << { :configs => BIVOUAC_VERSION }
15
+
16
+ # Create Application Environment file
17
+ createFile( "config/environment.rb", false, true ) { |io|
18
+ io.puts template( "environment" )
19
+ }
20
+ end
21
+ end
22
+
23
+ desc "Update scripts to the application script/ directory, and Rakefile"
24
+ task :scripts => [ "do_scripts", "configs" ]
25
+ task :do_scripts do
26
+ if @app_versions[:scripts] != BIVOUAC_VERSION or ["true", "1"].include?(ENV['FORCE'])
27
+ puts "* Update scripts from Bivouac #{@app_versions[:scripts]} -> #{BIVOUAC_VERSION}"
28
+ @conf.versions << { :scripts => BIVOUAC_VERSION }
29
+ @force = true
30
+
31
+ # Create generate script
32
+ createFile( "script/generate", true, true ) { |io|
33
+ io.puts template( "generate" )
34
+ }
35
+
36
+ # Create server script
37
+ createFile( "script/server", true, true ) { |io|
38
+ io.puts template( "server" )
39
+ }
40
+
41
+ # Create console script
42
+ createFile( "script/console", true, true ) { |io|
43
+ io.puts template( "console" )
44
+ }
45
+
46
+ # Create console.rc view
47
+ createFile( "config/console.rc", false, true ) { |io|
48
+ io.puts template( "static/console_rc" )
49
+ }
50
+
51
+ # Create plugin script
52
+ createFile( "script/plugin", true, true ) { |io|
53
+ io.puts template( "plugin" )
54
+ }
55
+
56
+ # Create Rakefile
57
+ createFile( "Rakefile", false, true ) { |io|
58
+ io.puts template( "Rakefile" )
59
+ }
60
+ end
61
+ end
62
+
63
+ desc "Update files to public/* directories"
64
+ task :public => [ "do_public", "configs" ]
65
+ task :do_public do
66
+ if @app_versions[:public] != BIVOUAC_VERSION or ["true", "1"].include?(ENV['FORCE'])
67
+ puts "* Update javascripts from Bivouac #{@app_versions[:public]} -> #{BIVOUAC_VERSION}"
68
+ @conf.versions << { :public => BIVOUAC_VERSION }
69
+ @force = true
70
+
71
+ # Copy statics files
72
+ %w{builder.js dragdrop.js prototype.js slider.js unittest.js controls.js effects.js sound.js scriptaculous.js}.each do |f|
73
+ copyTemplate( "static/#{f}", "public/javascripts", :force => true )
74
+ end
75
+ copyTemplate( "static/autocomplete.css", "public/stylesheets", :force => true )
76
+ end
77
+ end
78
+
79
+ desc "Update app/#{@conf.appfile}.rb, config/postamble.rb and helpers/_helpers.rb"
80
+ task :app => [ "do_app", "configs" ]
81
+ task :do_app do
82
+ if @app_versions[:app] != BIVOUAC_VERSION or ["true", "1"].include?(ENV['FORCE'])
83
+ puts "* Update #{@conf.appfile}.rb from Bivouac #{@app_versions[:bivouac]} -> #{BIVOUAC_VERSION}"
84
+ @conf.versions << { :app => BIVOUAC_VERSION }
85
+ @force = true
86
+
87
+ # Create Application Postamble file
88
+ createFile( "config/postamble.rb", false, true ) { |io|
89
+ io.puts template( "application/postamble" )
90
+ }
91
+
92
+ # Create Application file
93
+ createFile( "app/#{@conf.appfile}.rb", false, true ) { |io|
94
+ io.puts template( "application_#{@conf.orgtype.downcase}" )
95
+ }
96
+
97
+ # Create Application Helpers Loader file
98
+ createFile( "app/helpers/_helpers.rb", false, true ) { |io|
99
+ io.puts template( "application/helpers_#{@conf.orgtype.downcase}" )
100
+ }
101
+ end
102
+ end
103
+ end
104
+ end
105
+
@@ -0,0 +1,12 @@
1
+ namespace :plugin do
2
+ desc "List installed plugins"
3
+ task :list do
4
+ Dir.glob( BIVOUAC_ROOT + '/plugins/**' ).each do |p|
5
+ pn = p.gsub( /.*\//, "" )
6
+ print " - #{pn} : "
7
+ Rake::Task["plugin:#{pn}:desc"].invoke
8
+ end
9
+ end
10
+
11
+ Dir.glob( BIVOUAC_ROOT + '/plugins/**/tasks/**.rake' ).each { |p| load p }
12
+ end
@@ -4,14 +4,20 @@
4
4
  # Created using bivouac on <%= Time.now %>.
5
5
  # Copyright (c) <%= Time.now.year %> __My__. All rights reserved.
6
6
  #
7
+ # DO NOT EDIT THIS FILE OR YOU REALLY KNOW WHAT YOU ARE DOING
8
+ # Add your tasks in lib/tasks
9
+ #
7
10
  require 'rubygems'
8
11
  require 'rake/rdoctask'
9
12
  require 'camping'
10
13
  require 'camping/session'
11
14
  require 'bivouac'
15
+ require 'bivouac/template'
16
+
17
+ BIVOUAC_ROOT = File.expand_path( File.dirname(__FILE__) )
18
+ ENV['BIVOUAC_ROOT'] = BIVOUAC_ROOT
12
19
 
13
- include Bivouac
14
- ENV['BIVOUAC_ROOT'] = File.expand_path( File.dirname(__FILE__) )
20
+ require 'bivouac/tasks/bivouac'
15
21
 
16
22
  task :environment do
17
23
  Camping.goes :<%= @conf.appname %>
@@ -22,11 +28,9 @@ task :environment do
22
28
  # Load create and database schema
23
29
  files( '../db' ) { |file| require( file ) }
24
30
 
25
- require "#{ENV['BIVOUAC_ROOT']}/config/environment.rb"
26
- config = Bivouac::Environment.new( )
27
- database_connection = config.environment.db
31
+ database_connection = @conf.db
28
32
  if database_connection[:adapter] =~ /sqlite/
29
- database_connection[:database] = ENV['BIVOUAC_ROOT'] + "/" + database_connection[:database]
33
+ database_connection[:database] = BIVOUAC_ROOT + "/" + database_connection[:database]
30
34
  end
31
35
  <%= @conf.appname %>::Models::Base.establish_connection database_connection
32
36
  end
@@ -37,7 +41,7 @@ namespace :db do
37
41
  if <%= @conf.appname %>.respond_to? :create
38
42
  <%= @conf.appname %>.create
39
43
  else
40
- puts "Nothing to do!"
44
+ puts "* Nothing to do!"
41
45
  end
42
46
  end
43
47
 
@@ -50,16 +54,3 @@ namespace :db do
50
54
  end
51
55
  end
52
56
  end
53
-
54
- namespace :plugin do
55
- desc "List plugins"
56
- task :list do
57
- Dir.glob( filePath( __FILE__, 'plugins/**' ) ).each do |p|
58
- pn = p.gsub( /.*\//, "" )
59
- print " - #{pn} : "
60
- Rake::Task["plugin:#{pn}:desc"].invoke
61
- end
62
- end
63
-
64
- Dir.glob( filePath( __FILE__, 'plugins/**/tasks/**.rake' ) ).each { |p| load p }
65
- end
@@ -13,15 +13,18 @@ require 'rubygems'
13
13
  require 'camping'
14
14
  require 'mime/types'
15
15
  require 'bivouac'
16
+ require 'bivouac/filter'
16
17
 
17
18
  <% if @conf.session == :db %>
18
19
  require 'camping/session'
19
20
  module <%= @conf.appname %>
21
+ include Bivouac::Filters
20
22
  include Camping::Session
21
23
  end
22
24
  <% else %>
23
25
  require 'camping/cookies_sessions'
24
26
  module <%= @conf.appname %>
27
+ include Bivouac::Filters
25
28
  include Camping::CookieSessions
26
29
  @@state_secret = "You want a really really long string of rubbish nobody could ever ever guess! Don't tell anyone! Not even your girlfriend or dog!"
27
30
  end
@@ -1,4 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
+ #
3
+ # Project <%= @conf.appname %>
4
+ #
5
+ # Created using bivouac on <%= Time.now %>.
6
+ # Copyright (c) <%= Time.now.year %> __My__. All rights reserved.
7
+ #
8
+ # DO NOT EDIT THIS FILE OR YOU REALLY KNOW WHAT YOU ARE DOING
9
+ #
2
10
  require 'rubygems'
3
11
  app = File.dirname(__FILE__) + "/../app/<%= @conf.appfile %>.rb"
4
12
 
@@ -47,7 +47,11 @@ module Bivouac
47
47
 
48
48
  # Session type
49
49
  # DO NOT CHANGE IT, OR YOU REALLY KNOW WHAT YOU ARE DOING!
50
- :session_type => "<%= @conf.session %>"
50
+ :session => "<%= @conf.session %>",
51
+
52
+ # Session type
53
+ # DO NOT CHANGE IT, OR YOU REALLY KNOW WHAT YOU ARE DOING!
54
+ :versions => <%= @conf.versions %>
51
55
  )
52
56
  end
53
57
  end
@@ -6,7 +6,7 @@
6
6
  #
7
7
 
8
8
  def <%= @app.environment.appname %>.create
9
- <% if @app.environment.session_type.to_s == "db" %>
9
+ <% if @app.environment.session.to_s == "db" %>
10
10
  Camping::Models::Session.create_schema
11
11
  <% end %>
12
12
  <%= @app.environment.appname %>::Models.create_schema
@@ -1,4 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
+ #
3
+ # Project <%= @conf.appname %>
4
+ #
5
+ # Created using bivouac on <%= Time.now %>.
6
+ # Copyright (c) <%= Time.now.year %> __My__. All rights reserved.
7
+ #
8
+ # DO NOT EDIT THIS FILE OR YOU REALLY KNOW WHAT YOU ARE DOING
9
+ #
2
10
  require 'rubygems'
3
11
 
4
12
  def filePath( from, *data )
@@ -1,3 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
+ #
3
+ # Project <%= @conf.appname %>
4
+ #
5
+ # Created using bivouac on <%= Time.now %>.
6
+ # Copyright (c) <%= Time.now.year %> __My__. All rights reserved.
7
+ #
8
+ # DO NOT EDIT THIS FILE OR YOU REALLY KNOW WHAT YOU ARE DOING
9
+ #
2
10
  require 'rubygems'
3
11
  require 'bivouac/commands/plugin'
@@ -1,4 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
+ #
3
+ # Project <%= @conf.appname %>
4
+ #
5
+ # Created using bivouac on <%= Time.now %>.
6
+ # Copyright (c) <%= Time.now.year %> __My__. All rights reserved.
7
+ #
8
+ # DO NOT EDIT THIS FILE OR YOU REALLY KNOW WHAT YOU ARE DOING
9
+ #
2
10
  require 'rubygems'
3
11
  app = File.dirname(__FILE__) + "/../app/<%= @conf.appfile %>.rb"
4
12
 
@@ -55,11 +55,18 @@ module Bivouac
55
55
  end
56
56
  end
57
57
 
58
- def copyTemplate( file, dest, from = File.dirname(__FILE__) )
59
- if File.exist?( dest + "/" + File.basename( file ) )
58
+ def copyTemplate( file, dest, opts = {} )
59
+ force = opts[:force] || false
60
+ from = opts[:from] || File.dirname(__FILE__)
61
+
62
+ if File.exist?( dest + "/" + File.basename( file ) ) and force == false
60
63
  puts "\tskip #{File.expand_path( dest + "/" + File.basename( file ) )}: already exist"
61
64
  else
62
- puts "\tcreate #{File.expand_path( dest ) + "/" + File.basename( file )}"
65
+ if force
66
+ puts "\tforce #{File.expand_path( dest ) + "/" + File.basename( file )}"
67
+ else
68
+ puts "\tcreate #{File.expand_path( dest ) + "/" + File.basename( file )}"
69
+ end
63
70
  src = from + "/template/" + file
64
71
  FileUtils::cp( src, dest )
65
72
  end
data/lib/bivouac.rb CHANGED
@@ -7,7 +7,7 @@ module Bivouac
7
7
  if ENV['BIVOUAC_ROOT']
8
8
  path = ENV['BIVOUAC_ROOT'] + "/app/" + xPath.to_s
9
9
  end
10
-
10
+
11
11
  Dir.glob("#{path}/**/*.rb").each do |file|
12
12
  if options[0]
13
13
  if options[0].keys.include?( :except )
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bivouac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Gr\xC3\xA9goire Lejeune"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-06-29 00:00:00 +02:00
12
+ date: 2008-07-23 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -121,6 +121,7 @@ files:
121
121
  - lib/bivouac/commands
122
122
  - lib/bivouac/commands/generate.rb
123
123
  - lib/bivouac/commands/plugin.rb
124
+ - lib/bivouac/filter.rb
124
125
  - lib/bivouac/helpers
125
126
  - lib/bivouac/helpers/view
126
127
  - lib/bivouac/helpers/view/goh
@@ -130,6 +131,10 @@ files:
130
131
  - lib/bivouac/helpers/view/goh/javascript.rb
131
132
  - lib/bivouac/helpers/view/goh/scriptaculous.rb
132
133
  - lib/bivouac/helpers/view/goh/sound.rb
134
+ - lib/bivouac/tasks
135
+ - lib/bivouac/tasks/bivouac.rb
136
+ - lib/bivouac/tasks/framework.rake
137
+ - lib/bivouac/tasks/plugins.rake
133
138
  - lib/bivouac/template
134
139
  - lib/bivouac/template/application
135
140
  - lib/bivouac/template/application/helpers_goh.rb