sitefuel 0.1.0a → 0.1.0b

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/bin/sitefuel CHANGED
@@ -15,13 +15,17 @@
15
15
  #
16
16
  # == Usage
17
17
  #
18
- # sitefuel <command> [--driver=file|svn|git] <source> [<output>]
19
- # [--debug] [--verbose] [--help] [--license]
18
+ # sitefuel <command> [--scm=file|svn|git] <source> [<output>] [--debug] \
19
+ # [--verbose]
20
+ # [--help]
21
+ # [--license]
20
22
  #
21
23
  # === <command>
22
24
  # Possible commands are:
25
+ # pull: Pulls a website from an SCM into a temporary directory.
23
26
  # stage:: Simulate a deployment of a site.
24
27
  # deploy:: Deploy a site using SiteFuel.
28
+ # process:: Deploy a website in-place. Not recommended.
25
29
  # help:: Show this message.
26
30
  #
27
31
  # === <driver>
@@ -29,8 +33,8 @@
29
33
  # specify:
30
34
  #
31
35
  # filesystem:: deploy a directory
32
- # svn:: use with Subversion repositories
33
- # git:: use with Git repositories
36
+ # svn:: use with Subversion repositories
37
+ # git:: use with Git repositories
34
38
  #
35
39
  # === <source>
36
40
  # Specify the source SiteFuel is deploying from. This should accept all
@@ -16,6 +16,7 @@ module SiteFuel
16
16
  require 'optparse'
17
17
 
18
18
  require 'term/ansicolor'
19
+ require 'fileutils'
19
20
 
20
21
  include Term::ANSIColor
21
22
 
@@ -34,7 +35,7 @@ module SiteFuel
34
35
  require 'sitefuel/external/GIT'
35
36
 
36
37
  # version of SiteFuel
37
- VERSION = [0, 1, '0a'].freeze
38
+ VERSION = [0, 1, '0b'].freeze
38
39
 
39
40
  # a human readable version
40
41
  VERSION_TEXT = VERSION.join('.').freeze
@@ -247,6 +248,8 @@ module SiteFuel
247
248
 
248
249
  # pulls files out of a given repository or file system
249
250
  def pull
251
+ section_divider 'Pulling'
252
+
250
253
  if @scm_system == nil
251
254
  @scm_system = classify_repository_system!(@deploy_from)
252
255
  info "Using #{@scm_system} version control to access #{@deploy_from}"
@@ -279,6 +282,22 @@ module SiteFuel
279
282
  end
280
283
 
281
284
 
285
+
286
+ # given a file name will remove the staging directory from it and give
287
+ # just the base name for the resource
288
+ def get_base_resource_name(filename)
289
+ filename.gsub(Regexp.new('^'+Regexp.escape(@staging_directory)), '')
290
+ end
291
+
292
+
293
+ # given a source file name will remove the staging directory and give the
294
+ # fully qualified fully qualified name to which this resource is being
295
+ # deployed
296
+ def get_full_deployed_name(filename)
297
+ File.join(@deploy_to, get_base_resource_name(filename))
298
+ end
299
+
300
+
282
301
  # implements the stage command. Staging, by itself, will give statistics on
283
302
  # the deployment; how many bytes were saved by minification; etc.
284
303
  #
@@ -304,7 +323,8 @@ module SiteFuel
304
323
  if processor == nil
305
324
  @resource_processors[filename] = nil
306
325
  else
307
- @resource_processors[filename] = processor.process_file(filename)
326
+ resource_name = get_base_resource_name(filename)
327
+ @resource_processors[filename] = processor.process_file(filename, :resource_name => resource_name)
308
328
  end
309
329
 
310
330
  processor = @resource_processors[filename]
@@ -404,6 +424,11 @@ module SiteFuel
404
424
  results = @resource_processors[filename]
405
425
  if results == nil
406
426
  putc '.'
427
+
428
+ # copy the file over
429
+ file_destination = get_full_deployed_name(filename)
430
+ info("Copying #{filename} to #{file_destination}")
431
+ FileUtils.copy(filename, file_destination)
407
432
  else
408
433
  putc results.processor_symbol
409
434
  results.save(file_tree)
@@ -418,7 +443,7 @@ module SiteFuel
418
443
  def finish
419
444
  puts ''
420
445
  puts ''
421
- section_divider('Finishing')
446
+ section_divider('Finished')
422
447
  end
423
448
 
424
449
 
@@ -463,4 +488,4 @@ module SiteFuel
463
488
 
464
489
  # load the various processors
465
490
  SiteFuelRuntime.load_processors
466
- end
491
+ end
@@ -10,8 +10,9 @@
10
10
 
11
11
  class FileTree
12
12
 
13
- def initialize(base_path = :automatic)
14
- if base_path == :automatic
13
+ # creates a new FileTree data structure for a given path
14
+ def initialize(base_path = nil)
15
+ if base_path == nil
15
16
  @base_path = Dir.pwd
16
17
  else
17
18
  @base_path = base_path
@@ -27,6 +28,7 @@ class FileTree
27
28
  end
28
29
 
29
30
 
31
+ # rebuilds the FileTree given the #base_path
30
32
  def refresh_tree
31
33
  @directory_hash = {}
32
34
  @file_hash = {}
@@ -52,6 +54,10 @@ class FileTree
52
54
  # creates the given directory if it doesn't exist and returns a
53
55
  # FileTree for it
54
56
  def create_directory(name)
57
+ return if name == nil
58
+ return if name == '.'
59
+ return if name == '..'
60
+
55
61
  full_name = File.join(@base_path, name)
56
62
  res = @directory_hash[full_name]
57
63
  if res != nil
@@ -48,8 +48,18 @@ module SiteFuel
48
48
  end
49
49
 
50
50
  # sets the file used by this processor
51
- def set_file(filename)
52
- self.resource_name = filename
51
+ def set_file(filename, resource_name=nil)
52
+ case
53
+ when (resource_name == nil and @resource_name == nil)
54
+ @resource_name = filename
55
+
56
+ when @resource_name != nil
57
+ # just leave @resource_name be
58
+
59
+ else
60
+ @resource_name = resource_name
61
+ end
62
+
53
63
  self.original_size = File.size(filename)
54
64
 
55
65
  return self
@@ -84,6 +84,8 @@ module SiteFuel
84
84
  self.logger = SiteFuelLogger.instance
85
85
  @execution_list = []
86
86
  @filters = []
87
+
88
+ @resource_name = nil
87
89
  end
88
90
 
89
91
 
@@ -317,7 +319,7 @@ module SiteFuel
317
319
  def execute
318
320
  setup_filters
319
321
  @execution_list.uniq.each do |filter|
320
- info " Running filter: #{filter}"
322
+ info "\t\tRunning filter: #{filter}"
321
323
  run_filter(filter)
322
324
  end
323
325
  finish_filters
@@ -53,12 +53,24 @@ module SiteFuel
53
53
  end
54
54
 
55
55
  # opens a resource from a file
56
- def open_file(filename)
56
+ def open_file(filename, resource_name = nil)
57
57
  info "#{self.class} opening #{filename}"
58
58
 
59
59
  self.document = File.read(filename)
60
60
  self.original_size = File.size(filename)
61
- self.resource_name = filename
61
+
62
+ case
63
+ when (resource_name == nil and @resource_name == nil)
64
+ @resource_name = filename
65
+
66
+ when @resource_name != nil
67
+ # just leave @resource_name be
68
+
69
+ else
70
+ @resource_name = resource_name
71
+ end
72
+
73
+ debug "\t\tOpened with resource name: '#{@resource_name}'"
62
74
 
63
75
  return self
64
76
  end
@@ -92,7 +104,7 @@ module SiteFuel
92
104
  file << @document
93
105
  end
94
106
 
95
- info "Wrote document into #{file}"
107
+ info "Wrote document into #{file_name}"
96
108
  end
97
109
 
98
110
  attr_reader :document
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sitefuel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0a
4
+ version: 0.1.0b
5
5
  platform: ruby
6
6
  authors:
7
7
  - wkm
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-30 00:00:00 -06:00
12
+ date: 2010-01-01 00:00:00 -06:00
13
13
  default_executable: sitefuel
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -75,9 +75,6 @@ files:
75
75
  - test/test_RHTMLProcessor.rb
76
76
  - test/processor_listing.rb
77
77
  - test/test_HAMLProcessor.rb
78
- - test/repositories/git/few_files/style.css
79
- - test/repositories/git/few_files/deployment.yml
80
- - test/repositories/git/few_files/index.html
81
78
  - test/repositories/svn/testrepo1/conf/svnserve.conf
82
79
  - test/repositories/svn/testrepo1/conf/passwd
83
80
  - test/repositories/svn/testrepo1/conf/authz
File without changes
@@ -1,10 +0,0 @@
1
- <html>
2
- <head>
3
- <title>Just a little test</title>
4
- <link rel="stylesheet" type="text/css" href="style.css" />
5
- </head>
6
- <body>
7
- <h1>Git Repository Test</h1>
8
- <p>Ta da....</p>
9
- </body>
10
- </html>
@@ -1,2 +0,0 @@
1
- body { font-family: sans-serif; font-size: 16pt; }
2
-