BxMS 0.0.18 → 0.0.22

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.
@@ -19,13 +19,10 @@ module BxMS
19
19
  end
20
20
 
21
21
  def load_file( file_name )
22
- local_file = state.get_local_file( file_name )
23
- return IO.read( local_file ) if File.exists? local_file
24
-
25
- root_file = state.get_root_file( file_name )
26
- return IO.read( root_file ) if File.exists? root_file
27
-
28
- raise "Unable to find #{file_name}"
22
+ file_path = state.get_file file_name
23
+ raise "Unable to find #{file_name}" unless file_path
24
+ state.remembered_files << file_path
25
+ IO.read file_path
29
26
  end
30
27
 
31
28
  def run_erb_on( template, file_name )
@@ -15,6 +15,8 @@ module BxMS
15
15
  attr_reader :rules
16
16
  attr_reader :tags
17
17
 
18
+ attr_reader :remembered_files
19
+
18
20
  def initialize( parent, directory = nil )
19
21
  @parent = parent
20
22
 
@@ -29,6 +31,8 @@ module BxMS
29
31
  @rules = Rules.new parent.rules
30
32
  @tags = Tags.new parent.tags
31
33
 
34
+ @remembered_files = []
35
+
32
36
  load_local @functions, '.functions/*.{rb}'
33
37
  load_local @tags, '.tags/*'
34
38
  load_local @rules, '.rules'
@@ -44,6 +48,14 @@ module BxMS
44
48
  @parent.target_dir
45
49
  end
46
50
 
51
+ def get_file( file_name )
52
+ local_file = get_local_file file_name
53
+ return local_file if File.exist?(local_file)
54
+ root_file = get_root_file file_name
55
+ return root_file if File.exist?(root_file)
56
+ nil
57
+ end
58
+
47
59
  def get_root_file( file_name )
48
60
  File.join source_dir, file_name
49
61
  end
@@ -0,0 +1,46 @@
1
+ require 'net/transport_wrapper'
2
+
3
+ module Net
4
+
5
+ class Transport
6
+
7
+ def self.create(deploy_config_path, &block)
8
+ require 'yaml'
9
+ deploy_config = YAML::load(File.read('deploy.yml'))
10
+ Transport.new(deploy_config).open &block
11
+ end
12
+
13
+ def initialize(config_hash)
14
+ @configuration = config_hash
15
+ end
16
+
17
+ def open(&block)
18
+ require 'net/ftp'
19
+ Net::FTP.open(host) do |ftp|
20
+ ftp.login user, password
21
+ ftp.chdir folder
22
+ yield TransportWrapper.new(folder, ftp)
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def host
29
+ @configuration['host']
30
+ end
31
+
32
+ def user
33
+ @configuration['user']
34
+ end
35
+
36
+ def password
37
+ @configuration['password']
38
+ end
39
+
40
+ def folder
41
+ @configuration['folder']
42
+ end
43
+
44
+ end
45
+
46
+ end
@@ -0,0 +1,36 @@
1
+ module Net
2
+
3
+ class TransportWrapper
4
+
5
+ def initialize(folder, ftp)
6
+ @folder = folder
7
+ @ftp = ftp
8
+ end
9
+
10
+ def chdir(subfolder)
11
+ remote_folder = File.join @folder, subfolder
12
+ puts "chdir #{remote_folder}"
13
+ @ftp.chdir remote_folder
14
+ end
15
+
16
+ def update(localfile, remotefile)
17
+ puts "update #{localfile} to #{remotefile}"
18
+ localtime = File.mtime(localfile).getutc
19
+ remotetime = mtime(remotefile).getutc
20
+ changed = localtime > remotetime
21
+ @ftp.putbinaryfile localfile, remotefile if changed
22
+ return changed
23
+ end
24
+
25
+ def mtime(remotefile)
26
+ @ftp.mtime remotefile, MTIME_UTC
27
+ rescue
28
+ nil
29
+ end
30
+
31
+ private
32
+
33
+ MTIME_UTC = false # see Net::FTP#mtime
34
+ end
35
+
36
+ end
@@ -1,3 +1,4 @@
1
+ require 'fileutils'
1
2
 
2
3
  module Rules
3
4
 
@@ -11,6 +12,34 @@ module Rules
11
12
  name.sub! /Rule\Z/, ''
12
13
  end
13
14
 
15
+ def update(data, to_file, from_file_list)
16
+ uptodate = uptodate? to_file, from_file_list
17
+ content_matches = compare data, to_file if uptodate and data
18
+ unless uptodate and content_matches
19
+ store data, to_file if data
20
+ copy from_file_list.first, to_file unless data
21
+ else
22
+ puts "skipped unchanged #{to_file}" if @verbose
23
+ end
24
+ end
25
+
26
+ def store(data, to_file)
27
+ File.open(to_file, 'w' ) { |file| file.write data }
28
+ end
29
+
30
+ def copy(from_file, to_file)
31
+ FileUtils.cp from_file, to_file, :preserve => true
32
+ end
33
+
34
+ def uptodate?(target_file, source_file_list)
35
+ FileUtils.uptodate? target_file, source_file_list
36
+ end
37
+
38
+ def compare(data, target_file)
39
+ target = IO.read target_file
40
+ data == target
41
+ end
42
+
14
43
  end
15
44
 
16
45
  end
@@ -7,9 +7,9 @@ module Rules
7
7
  class CopyRule < BaseRule
8
8
 
9
9
  def apply_to( file, state )
10
- puts "copy #{file} to #{state.output_dir}" if @verbose
11
10
  FileUtils.mkdir_p state.output_dir unless File.directory? state.output_dir
12
- FileUtils.cp file, state.output_dir
11
+ target_file = File.join state.output_dir, File.basename(file)
12
+ update nil, target_file, [file]
13
13
  end
14
14
 
15
15
  end
@@ -15,7 +15,8 @@ module Rules
15
15
  output = context.run_erb_on file_contents, input_file
16
16
 
17
17
  output_file = state.get_output_file_for input_file
18
- File.open( output_file, 'w' ) { |file| file.write output }
18
+
19
+ update output, output_file, [input_file]
19
20
  end
20
21
 
21
22
  end
@@ -10,6 +10,9 @@ module Rules
10
10
  def apply_to( input_file, state )
11
11
  puts "process page #{input_file} to #{state.output_dir}" if @verbose
12
12
 
13
+ state.remembered_files.clear
14
+ state.remembered_files << input_file
15
+
13
16
  collector = PartCollector.new input_file
14
17
  parts = collector.load_and_scan input_file
15
18
 
@@ -36,9 +39,7 @@ module Rules
36
39
  output_file = state.get_output_file_for input_file
37
40
  output_file.sub! /\.page$/, '.html'
38
41
 
39
- File.open( output_file, 'w' ) do |file|
40
- file.write output
41
- end
42
+ update output, output_file, state.remembered_files
42
43
  end
43
44
 
44
45
  end
@@ -0,0 +1,46 @@
1
+ module Util
2
+
3
+ class FolderScanner
4
+
5
+ def self.traverse(folderpath, &block)
6
+ FolderScanner.new(folderpath).list &block
7
+ end
8
+
9
+ def initialize(rootpath, currentpath = nil)
10
+ @rootpath = rootpath
11
+ @currentpath = currentpath
12
+ end
13
+
14
+ def list(&block)
15
+ Dir.entries(current_folder).sort.each do |filename|
16
+ next if filename == '.' or filename == '..'
17
+ filepath = path_to filename
18
+ is_folder = File.directory? File.join(rootpath, filepath)
19
+ if is_folder
20
+ yield filepath, :folder
21
+ FolderScanner.new(rootpath, filepath).list &block
22
+ yield path_to('.'), :folder
23
+ else
24
+ yield filepath, :file
25
+ end
26
+ end
27
+ end
28
+
29
+ def path_to(filename)
30
+ return filename unless currentpath
31
+ File.join currentpath, filename
32
+ end
33
+
34
+ def current_folder
35
+ return rootpath unless currentpath
36
+ File.join rootpath, currentpath
37
+ end
38
+
39
+ private
40
+
41
+ attr_reader :rootpath
42
+ attr_reader :currentpath
43
+
44
+ end
45
+
46
+ end
metadata CHANGED
@@ -1,116 +1,128 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
3
- specification_version: 1
4
2
  name: BxMS
5
3
  version: !ruby/object:Gem::Version
6
- version: 0.0.18
7
- date: 2006-05-04 00:00:00 +02:00
8
- summary: Simple offline CMS framework based on ERB, 'tags' and 'functions'.
9
- require_paths:
10
- - src
11
- email: bxms {AT} intensicode {DOT} com
12
- homepage: bxms.rubyforge.org.
13
- rubyforge_project: bxms
14
- description: "Please see the Wiki found at: http://bxms.rubyforge.org/wiki/wiki.pl"
15
- autorequire:
16
- default_executable: bxms
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 0.0.22
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
6
  authors:
29
7
  - The.French.DJ
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-07-17 00:00:00 +02:00
13
+ default_executable: bxms
14
+ dependencies: []
15
+
16
+ description: "Please see the Wiki found at: http://bxms.rubyforge.org/wiki/wiki.pl"
17
+ email: bxms {AT} intensicode {DOT} com
18
+ executables:
19
+ - bxms
20
+ - bxms.rb
21
+ - bxms.bat
22
+ - bxms.sh
23
+ extensions: []
24
+
25
+ extra_rdoc_files: []
26
+
30
27
  files:
31
28
  - bin/bxms
32
- - bin/bxms.bat
33
29
  - bin/bxms.rb
30
+ - bin/bxms.bat
34
31
  - bin/bxms.sh
35
32
  - examples/www.berlinfactor.com
33
+ - examples/www.berlinfactor.com/Section.Bx
34
+ - examples/www.berlinfactor.com/Section.Bx/index.page
36
35
  - examples/www.berlinfactor.com/Bx.css
37
- - examples/www.berlinfactor.com/Bx.js
38
36
  - examples/www.berlinfactor.com/favicon.ico
39
- - examples/www.berlinfactor.com/images
40
- - examples/www.berlinfactor.com/index.page
37
+ - examples/www.berlinfactor.com/Section.Contact
38
+ - examples/www.berlinfactor.com/Section.Contact/index.page
41
39
  - examples/www.berlinfactor.com/news.page
40
+ - examples/www.berlinfactor.com/index.page
41
+ - examples/www.berlinfactor.com/Bx.js
42
42
  - examples/www.berlinfactor.com/news.txt
43
- - examples/www.berlinfactor.com/Section.Books
44
- - examples/www.berlinfactor.com/Section.Bx
45
- - examples/www.berlinfactor.com/Section.Contact
46
- - examples/www.berlinfactor.com/Section.Links
47
- - examples/www.berlinfactor.com/images/background.png
48
- - examples/www.berlinfactor.com/images/logo_above.gif
49
- - examples/www.berlinfactor.com/images/logo_below.gif
50
- - examples/www.berlinfactor.com/images/logo_clickable.gif
51
- - examples/www.berlinfactor.com/images/no_section_name.gif
52
- - examples/www.berlinfactor.com/images/section_books.gif
53
- - examples/www.berlinfactor.com/images/section_books_hover.gif
54
- - examples/www.berlinfactor.com/images/section_books_name.gif
55
- - examples/www.berlinfactor.com/images/section_bx.gif
56
- - examples/www.berlinfactor.com/images/section_bx_hover.gif
43
+ - examples/www.berlinfactor.com/images
57
44
  - examples/www.berlinfactor.com/images/section_bx_name.gif
58
- - examples/www.berlinfactor.com/images/section_contact.gif
59
45
  - examples/www.berlinfactor.com/images/section_contact_hover.gif
46
+ - examples/www.berlinfactor.com/images/section_books_name.gif
47
+ - examples/www.berlinfactor.com/images/no_section_name.gif
48
+ - examples/www.berlinfactor.com/images/logo_below.gif
49
+ - examples/www.berlinfactor.com/images/section_bx_hover.gif
60
50
  - examples/www.berlinfactor.com/images/section_contact_name.gif
61
- - examples/www.berlinfactor.com/images/section_links.gif
62
- - examples/www.berlinfactor.com/images/section_links_hover.gif
63
- - examples/www.berlinfactor.com/images/section_links_name.gif
51
+ - examples/www.berlinfactor.com/images/logo_clickable.gif
52
+ - examples/www.berlinfactor.com/images/background.png
64
53
  - examples/www.berlinfactor.com/images/section_tfdj.gif
65
- - examples/www.berlinfactor.com/images/section_tfdj_hover.gif
66
54
  - examples/www.berlinfactor.com/images/section_tfdj_name.gif
55
+ - examples/www.berlinfactor.com/images/section_books_hover.gif
56
+ - examples/www.berlinfactor.com/images/section_links.gif
57
+ - examples/www.berlinfactor.com/images/section_tfdj_hover.gif
58
+ - examples/www.berlinfactor.com/images/section_contact.gif
59
+ - examples/www.berlinfactor.com/images/section_books.gif
60
+ - examples/www.berlinfactor.com/images/section_bx.gif
61
+ - examples/www.berlinfactor.com/images/section_links_name.gif
62
+ - examples/www.berlinfactor.com/images/section_links_hover.gif
63
+ - examples/www.berlinfactor.com/images/logo_above.gif
64
+ - examples/www.berlinfactor.com/Section.Books
67
65
  - examples/www.berlinfactor.com/Section.Books/books.txt
68
66
  - examples/www.berlinfactor.com/Section.Books/index.page
69
- - examples/www.berlinfactor.com/Section.Bx/index.page
70
- - examples/www.berlinfactor.com/Section.Contact/index.page
67
+ - examples/www.berlinfactor.com/Section.Links
68
+ - examples/www.berlinfactor.com/Section.Links/Tools.and.Utilities.txt
71
69
  - examples/www.berlinfactor.com/Section.Links/Game.Development.txt
70
+ - examples/www.berlinfactor.com/Section.Links/Software.Development.txt
72
71
  - examples/www.berlinfactor.com/Section.Links/index.page
73
72
  - examples/www.berlinfactor.com/Section.Links/News.and.Stuff.txt
74
- - examples/www.berlinfactor.com/Section.Links/Software.Development.txt
75
73
  - examples/www.berlinfactor.com/Section.Links/Symbian.Development.txt
76
- - examples/www.berlinfactor.com/Section.Links/Tools.and.Utilities.txt
77
74
  - src/bxms
78
- - src/bxms.rb
79
- - src/page
80
- - src/rules
81
- - src/util
82
75
  - src/bxms/context.rb
83
- - src/bxms/functions.rb
84
76
  - src/bxms/processor.rb
77
+ - src/bxms/variables.rb
85
78
  - src/bxms/root_state.rb
86
- - src/bxms/rules.rb
87
79
  - src/bxms/state.rb
88
80
  - src/bxms/tags.rb
89
- - src/bxms/variables.rb
90
- - src/page/part.rb
81
+ - src/bxms/rules.rb
82
+ - src/bxms/functions.rb
83
+ - src/net
84
+ - src/net/transport_wrapper.rb
85
+ - src/net/transport.rb
86
+ - src/page
91
87
  - src/page/part_collector.rb
88
+ - src/page/part.rb
89
+ - src/bxms.rb
90
+ - src/rules
92
91
  - src/rules/base.rb
93
- - src/rules/copy.rb
94
- - src/rules/ignore.rb
95
92
  - src/rules/process.rb
96
93
  - src/rules/process_page.rb
94
+ - src/rules/copy.rb
95
+ - src/rules/ignore.rb
96
+ - src/util
97
+ - src/util/folder_scanner.rb
97
98
  - src/util/chained_hash.rb
98
- - src/util/logger.rb
99
99
  - src/util/system_logger.rb
100
- test_files: []
101
-
100
+ - src/util/logger.rb
101
+ has_rdoc: true
102
+ homepage: bxms.rubyforge.org.
103
+ post_install_message:
102
104
  rdoc_options: []
103
105
 
104
- extra_rdoc_files: []
105
-
106
- executables:
107
- - bxms
108
- - bxms.bat
109
- - bxms.rb
110
- - bxms.sh
111
- extensions: []
112
-
106
+ require_paths:
107
+ - src
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: "0"
113
+ version:
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: "0"
119
+ version:
113
120
  requirements: []
114
121
 
115
- dependencies: []
122
+ rubyforge_project: bxms
123
+ rubygems_version: 1.3.1
124
+ signing_key:
125
+ specification_version: 2
126
+ summary: Simple offline CMS framework based on ERB, 'tags' and 'functions'.
127
+ test_files: []
116
128