adva-static 0.0.1

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.
@@ -0,0 +1,85 @@
1
+ Given /^an empty import directory "([^"]+)"$/ do |name|
2
+ @import_dir = Pathname.new("/tmp/adva-static-test/import/#{name}")
3
+ import_dir.mkpath
4
+ end
5
+
6
+ Given /^an empty export directory$/ do
7
+ @export_dir = Pathname.new("/tmp/adva-static-test/export")
8
+ export_dir.mkpath
9
+ end
10
+
11
+ Given /^a source file "([^\"]*)"$/ do |filename|
12
+ setup_files([filename, '']) unless filename.blank?
13
+ end
14
+
15
+ Given /^a source file "([^\"]*)" with the following values:$/ do |filename, table|
16
+ setup_files([filename, YAML.dump(table.rows_hash)]) unless filename.blank?
17
+ end
18
+
19
+ Given /^the following source files:$/ do |table|
20
+ table.hashes.each do |hash|
21
+ setup_files([hash.delete('file'), YAML.dump(hash)])
22
+ end
23
+ end
24
+
25
+ Given /^a watcher has started$/ do
26
+ @watch ||= begin
27
+ Adva::Static::Rack::Watch.any_instance.stubs(:run!)
28
+ Adva::Static::Rack::Watch.new(Adva::Static::Rack::Export.new(Rails.application, :target => export_dir), :dir => import_dir)
29
+ end
30
+ end
31
+
32
+ When /^I run the import task$/ do
33
+ Adva::Static::Import.new(:source => import_dir).run
34
+ end
35
+
36
+ When /^I create the file "([^"]*)" with the following values triggering the watcher:$/ do |filename, table|
37
+ setup_files([filename, YAML.dump(table.rows_hash)]) unless filename.blank?
38
+ @watch.send(:handler).trigger
39
+ end
40
+
41
+ When /^I update the file "([^"]*)" with the following values triggering the watcher:$/ do |filename, table|
42
+ setup_files([filename, YAML.dump(table.rows_hash)])
43
+ file = import_dir.join(filename)
44
+ file.utime(file.atime, future)
45
+ @watch.send(:handler).trigger
46
+ end
47
+
48
+ When /^I delete the file "([^"]*)" triggering the watcher$/ do |filename|
49
+ import_dir.join(filename).unlink
50
+ @watch.send(:handler).trigger
51
+ end
52
+
53
+ Then /^the watcher should "([^\"]*)" the following "([^\"]*)" params for the file "([^\"]*)":$/ do |method, key, file, table|
54
+ import = Adva::Static::Import.new(:source => import_dir)
55
+ request = import.request_for(file)
56
+ params = request.params
57
+ method.downcase!
58
+
59
+ # model = import.send(:recognize, file).first
60
+ # debugger
61
+
62
+ case method
63
+ when 'put', 'delete'
64
+ assert_equal method, params['_method'].try(:downcase)
65
+ when 'post'
66
+ assert !params.key?('_method')
67
+ end
68
+
69
+ expected = table.rows_hash.symbolize_keys
70
+ actual = request.params[key.to_sym].slice(*expected.keys)
71
+ assert_equal expected, actual
72
+ end
73
+
74
+ Then /^there should be an export file "([^"]*)" containing "([^"]*)"$/ do |filename, text|
75
+ file = export_dir.join(filename)
76
+ assert file.exist?, "expected #{file.to_s.inspect} to exist"
77
+ file = File.read(file)
78
+ assert file.include?(text), "expected #{file.inspect} to include #{text.inspect} "
79
+ end
80
+
81
+ Then /^there should not be an export file "([^"]*)"$/ do |filename|
82
+ file = export_dir.join(filename)
83
+ assert !file.exist?, "expected #{file.to_s.inspect} not to exist"
84
+ end
85
+
@@ -0,0 +1,133 @@
1
+ module TestHelper
2
+ module Static
3
+ def setup
4
+ setup_import_directory
5
+ super
6
+ end
7
+
8
+ def teardown_import_directory
9
+ import_dir.rmtree rescue nil
10
+ end
11
+
12
+ def teardown_export_directory
13
+ export_dir.rmtree rescue nil
14
+ end
15
+
16
+ def import_dir
17
+ @import_dir ||= Pathname.new('/tmp/adva-static-test/import/ruby-i18n.org')
18
+ end
19
+
20
+ def export_dir
21
+ @export_dir ||= Pathname.new('/tmp/adva-static-test/export')
22
+ end
23
+
24
+ def teardown
25
+ teardown_import_directory
26
+ super
27
+ end
28
+
29
+ def request(path)
30
+ Adva::Static::Import.new(:source => import_dir).request_for(path)
31
+ end
32
+
33
+ def source(path)
34
+ Adva::Static::Import::Source.new(path, import_dir)
35
+ end
36
+
37
+ def setup_site_record
38
+ Factory(:site, :host => 'ruby-i18n.org')
39
+ end
40
+
41
+ def setup_root_page_record
42
+ setup_site_record
43
+ end
44
+
45
+ def setup_non_root_page_record
46
+ site = setup_site_record
47
+ site.pages.create!(:name => 'Contact')
48
+ end
49
+
50
+ def setup_root_blog_record
51
+ site = setup_site_record
52
+ site.pages.first.destroy
53
+
54
+ site.blogs.create!(:name => 'Home', :posts_attributes => [
55
+ { :title => 'Welcome to the future of I18n in Ruby on Rails', :body => 'Welcome to the future!', :created_at => '2008-07-31' }
56
+ ])
57
+ end
58
+
59
+ def setup_non_root_blog_record
60
+ site = setup_site_record
61
+ site.blogs.create!(:name => 'Blog', :posts_attributes => [
62
+ { :title => 'Welcome to the future of I18n in Ruby on Rails', :body => 'Welcome to the future!', :created_at => '2008-07-31' }
63
+ ])
64
+ end
65
+
66
+ def setup_import_directory
67
+ import_dir.mkpath
68
+ setup_dirs(%w(images javascripts stylesheets))
69
+ setup_files(['config.ru', 'foo'], ['site.yml', YAML.dump(:host => 'ruby-i18n.org', :name => 'Ruby I18n', :title => 'Ruby I18n')])
70
+ end
71
+
72
+ def setup_root_blog
73
+ setup_files(
74
+ ['2008/07/31/welcome-to-the-future-of-i18n-in-ruby-on-rails.yml', YAML.dump(:body => 'Welcome to the future')],
75
+ ['2009/07/12/ruby-i18n-gem-hits-0-2-0.yml', YAML.dump(:body => 'Ruby I18n hits 0.2.0')]
76
+ )
77
+ end
78
+
79
+ def setup_non_root_blog
80
+ setup_files(
81
+ ['blog/2008/07/31/welcome-to-the-future-of-i18n-in-ruby-on-rails.yml', YAML.dump(:body => 'Welcome to the future')],
82
+ ['blog/2009/07/12/ruby-i18n-gem-hits-0-2-0.yml', YAML.dump(:body => 'Ruby I18n hits 0.2.0')]
83
+ )
84
+ end
85
+
86
+ def setup_root_page
87
+ setup_files(
88
+ ['index.yml', YAML.dump(:name => 'Home', :body => 'home')]
89
+ )
90
+ end
91
+
92
+ def setup_root_nested_page
93
+ setup_files(
94
+ ['home/nested.yml', YAML.dump(:body => 'nested under home')]
95
+ )
96
+ end
97
+
98
+ def setup_non_root_page
99
+ setup_files(
100
+ ['contact.yml', YAML.dump(:body => 'contact')]
101
+ )
102
+ end
103
+
104
+ def setup_non_root_nested_page
105
+ setup_files(
106
+ ['contact/nested.yml', YAML.dump(:body => 'nested under contact')]
107
+ )
108
+ end
109
+
110
+ def setup_nested_page
111
+ setup_files(
112
+ ['contact/mailer.yml', YAML.dump(:body => 'contact mailer')]
113
+ )
114
+ end
115
+
116
+ def setup_dirs(paths)
117
+ paths.each do |path|
118
+ FileUtils.mkdir_p(import_dir.join(path))
119
+ end
120
+ end
121
+
122
+ def setup_files(*files)
123
+ files.each do |path, content|
124
+ import_dir.join(File.dirname(path)).mkpath
125
+ File.open(import_dir.join(path), 'w') { |f| f.write(content) }
126
+ end
127
+ end
128
+
129
+ def future
130
+ Time.local(Time.now.year + 1, Time.now.month, Time.now.day)
131
+ end
132
+ end
133
+ end
metadata ADDED
@@ -0,0 +1,151 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: adva-static
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Sven Fuchs
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-10-29 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: adva-core
23
+ prerelease: false
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: nokogiri
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: rack-cache
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ type: :runtime
62
+ version_requirements: *id003
63
+ - !ruby/object:Gem::Dependency
64
+ name: watchr
65
+ prerelease: false
66
+ requirement: &id004 !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ hash: 3
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ type: :runtime
76
+ version_requirements: *id004
77
+ description: "[description]"
78
+ email: nobody@adva-cms.org
79
+ executables: []
80
+
81
+ extensions: []
82
+
83
+ extra_rdoc_files: []
84
+
85
+ files:
86
+ - lib/adva-static.rb
87
+ - lib/adva/tasks/static.rb
88
+ - lib/adva/static/setup.rb
89
+ - lib/adva/static/export.rb
90
+ - lib/adva/static/import/format.rb
91
+ - lib/adva/static/import/source.rb
92
+ - lib/adva/static/import/model.rb
93
+ - lib/adva/static/import/model/page.rb
94
+ - lib/adva/static/import/model/site.rb
95
+ - lib/adva/static/import/model/post.rb
96
+ - lib/adva/static/import/model/section.rb
97
+ - lib/adva/static/import/model/base.rb
98
+ - lib/adva/static/import/model/blog.rb
99
+ - lib/adva/static/import/request.rb
100
+ - lib/adva/static/watch.rb
101
+ - lib/adva/static/export/page.rb
102
+ - lib/adva/static/export/templates/config.ru
103
+ - lib/adva/static/export/path.rb
104
+ - lib/adva/static/export/store.rb
105
+ - lib/adva/static/export/queue.rb
106
+ - lib/adva/static/rack/export.rb
107
+ - lib/adva/static/rack/watch.rb
108
+ - lib/adva/static/rack/static.rb
109
+ - lib/adva/static/rack/request.rb
110
+ - lib/adva/static/rack.rb
111
+ - lib/adva/static/watch/handler.rb
112
+ - lib/adva/static/import.rb
113
+ - lib/adva/static.rb
114
+ - lib/testing/test_helper.rb
115
+ - lib/testing/step_definitions.rb
116
+ has_rdoc: true
117
+ homepage: http://github.com/svenfuchs/adva-cms2
118
+ licenses: []
119
+
120
+ post_install_message:
121
+ rdoc_options: []
122
+
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ none: false
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ hash: 3
131
+ segments:
132
+ - 0
133
+ version: "0"
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ none: false
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ hash: 3
140
+ segments:
141
+ - 0
142
+ version: "0"
143
+ requirements: []
144
+
145
+ rubyforge_project: "[none]"
146
+ rubygems_version: 1.3.7
147
+ signing_key:
148
+ specification_version: 3
149
+ summary: "[summary]"
150
+ test_files: []
151
+