refinerycms-convertor 0.0.2 → 0.0.3

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/.gitignore CHANGED
@@ -13,6 +13,10 @@ tmtags
13
13
  ## VIM
14
14
  *.swp
15
15
 
16
+ ## REDCAR
17
+ tags
18
+ .redcar
19
+
16
20
  ## PROJECT::GENERAL
17
21
  coverage
18
22
  rdoc
data/README.rdoc CHANGED
@@ -1,6 +1,8 @@
1
1
  = refinerycms-convertor
2
2
 
3
- Description goes here.
3
+ Add this line to your rakefile above the last require line:
4
+
5
+ $refinery_gem_plugin_lib_paths << "#{Gem.searcher.find('refinerycms-convertor').full_gem_path}/lib" rescue nil
4
6
 
5
7
  == Note on Patches/Pull Requests
6
8
 
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ begin
11
11
  gem.homepage = "http://github.com/stevenheidel/refinerycms-convertor"
12
12
  gem.authors = ["stevenheidel"]
13
13
  gem.add_development_dependency "rspec", ">= 1.2.9"
14
- gem.add_dependency "refinerycms", ">= 0.9.6.34"
14
+ gem.add_dependency "refinerycms", ">= 0.9.7"
15
15
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
16
  end
17
17
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -0,0 +1,22 @@
1
+ require 'convertor-tags'
2
+
3
+ class ConvertorFile
4
+
5
+ attr_reader :original_dir, :original_file, :current_dir, :current_file
6
+
7
+ def initialize(path)
8
+ @file = File.new(path)
9
+
10
+ @original_dir = @current_dir = File.dirname(path)
11
+ @original_file = @current_file = path
12
+ end
13
+
14
+ def copy(path)
15
+ FileUtils.mkdir_p(File.dirname(path))
16
+ FileUtils.copy(@current_file, path)
17
+
18
+ @current_dir = File.dirname(path)
19
+ @current_file = path
20
+ end
21
+
22
+ end
@@ -0,0 +1,8 @@
1
+ class ConvertorLayout < ConvertorFile
2
+
3
+ def initialize(original_file)
4
+ super(Rails.root.join('themes', 'theme', 'original', original_file))
5
+ copy(Rails.root.join('themes', 'theme', 'layouts', 'application.html.erb'))
6
+ end
7
+
8
+ end
@@ -0,0 +1,19 @@
1
+ class ConvertorTag
2
+
3
+ def initialize(text)
4
+ @text = text
5
+ end
6
+
7
+ def tags
8
+ @text.scan(/{@\s*(.*)\s*@}.*{@ \/\1 @}/m).flatten!
9
+ end
10
+
11
+ def text_inside_tag(tag)
12
+ @text.match(/{@\s*#{tag}\s*@}\n(.*){@ \/#{tag} @}/m)[1] rescue nil
13
+ end
14
+
15
+ def text_with_tag(tag)
16
+ @text.match(/{@\s*#{tag}\s*@}\n(.*){@ \/#{tag} @}/m)[0] rescue nil
17
+ end
18
+
19
+ end
@@ -1,8 +1,10 @@
1
+ require 'fileutils'
2
+
3
+ require 'convertor-file'
4
+ require 'convertor-layout'
5
+
1
6
  class RefinerycmsConvertor
2
7
 
3
- require 'fileutils'
4
- include FileUtils
5
-
6
8
  attr_reader :theme_dir, :original_dir
7
9
 
8
10
  def initialize(theme)
@@ -15,7 +17,7 @@ class RefinerycmsConvertor
15
17
 
16
18
  def convert!
17
19
  ['images', 'javascripts', 'stylesheets', 'views/layouts', 'views/pages', 'views/shared'].each do |dir|
18
- mkdir_p @theme_dir + dir
20
+ FileUtils.mkdir_p(@theme_dir + dir)
19
21
  end
20
22
  end
21
23
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{refinerycms-convertor}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["stevenheidel"]
12
- s.date = %q{2010-06-27}
12
+ s.date = %q{2010-07-24}
13
13
  s.description = %q{This gem makes it very easy to create beautiful looking websites with refinerycms by taking out all of the repetition of making refinerycms themes.}
14
14
  s.email = %q{steven@livingskyweb.ca}
15
15
  s.extra_rdoc_files = [
@@ -23,9 +23,15 @@ Gem::Specification.new do |s|
23
23
  "README.rdoc",
24
24
  "Rakefile",
25
25
  "VERSION",
26
+ "lib/convertor-file.rb",
27
+ "lib/convertor-layout.rb",
28
+ "lib/convertor-tags.rb",
26
29
  "lib/refinerycms-convertor.rb",
27
30
  "lib/tasks/refinerycms-convertor.rake",
28
31
  "refinerycms-convertor.gemspec",
32
+ "spec/convertor-file_spec.rb",
33
+ "spec/convertor-layout_spec.rb",
34
+ "spec/convertor-tags_spec.rb",
29
35
  "spec/fixtures/themes/theme/original/index.html",
30
36
  "spec/fixtures/themes/unindexed/original/.gitinclude",
31
37
  "spec/fixtures/themes/unoriginal/.gitinclude",
@@ -39,8 +45,11 @@ Gem::Specification.new do |s|
39
45
  s.rubygems_version = %q{1.3.7}
40
46
  s.summary = %q{Converts simple html templates into refinerycms themes.}
41
47
  s.test_files = [
42
- "spec/refinerycms-convertor_spec.rb",
43
- "spec/spec_helper.rb"
48
+ "spec/convertor-tags_spec.rb",
49
+ "spec/convertor-layout_spec.rb",
50
+ "spec/spec_helper.rb",
51
+ "spec/refinerycms-convertor_spec.rb",
52
+ "spec/convertor-file_spec.rb"
44
53
  ]
45
54
 
46
55
  if s.respond_to? :specification_version then
@@ -49,14 +58,14 @@ Gem::Specification.new do |s|
49
58
 
50
59
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
51
60
  s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
52
- s.add_runtime_dependency(%q<refinerycms>, [">= 0.9.6.34"])
61
+ s.add_runtime_dependency(%q<refinerycms>, [">= 0.9.7"])
53
62
  else
54
63
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
55
- s.add_dependency(%q<refinerycms>, [">= 0.9.6.34"])
64
+ s.add_dependency(%q<refinerycms>, [">= 0.9.7"])
56
65
  end
57
66
  else
58
67
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
59
- s.add_dependency(%q<refinerycms>, [">= 0.9.6.34"])
68
+ s.add_dependency(%q<refinerycms>, [">= 0.9.7"])
60
69
  end
61
70
  end
62
71
 
@@ -0,0 +1,47 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe ConvertorFile do
4
+
5
+ context "#copy" do
6
+
7
+ before(:each) do
8
+ @index_html = ConvertorFile.new(Rails.root.join('themes', 'theme', 'original', 'index.html'))
9
+ end
10
+
11
+ it "should know locations" do
12
+ @index_html.original_file.should == @index_html.current_file
13
+
14
+ @index_html.copy(Rails.root.join('themes', 'theme', 'test', 'copied.html'))
15
+
16
+ @index_html.original_file.should_not == @index_html.current_file
17
+ @index_html.current_file.should == Rails.root.join('themes', 'theme', 'test', 'copied.html')
18
+ end
19
+
20
+ it "should be able to copy to a new location" do
21
+ @index_html.copy(Rails.root.join('themes', 'theme', 'test', 'copied.html'))
22
+
23
+ File.should be_exist(Rails.root.join('themes', 'theme', 'original', 'index.html'))
24
+ File.should be_exist(Rails.root.join('themes', 'theme', 'test', 'copied.html'))
25
+ FileUtils::compare_file(Rails.root.join('themes', 'theme', 'original', 'index.html'), Rails.root.join('themes', 'theme', 'test', 'copied.html')).should be_true
26
+ end
27
+
28
+ after(:each) do
29
+ File.delete(@index_html.current_file)
30
+ Dir.delete(@index_html.current_dir)
31
+ end
32
+
33
+ end
34
+
35
+ context "#extract_to_partials" do
36
+
37
+ it "should take out all tags to respective shared files" do
38
+
39
+ end
40
+
41
+ it "should take the <head> to shared/_head.html.erb" do
42
+ pending
43
+ end
44
+
45
+ end
46
+
47
+ end
@@ -0,0 +1,17 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe ConvertorLayout do
4
+
5
+ it "should move files from original to layouts folder" do
6
+ @layout = ConvertorLayout.new('index.html')
7
+
8
+ File.should be_exist(Rails.root.join('themes', 'theme', 'layouts', 'application.html.erb'))
9
+ FileUtils::compare_file(Rails.root.join('themes', 'theme', 'original', 'index.html'), Rails.root.join('themes', 'theme', 'layouts', 'application.html.erb')).should be_true
10
+ end
11
+
12
+ after(:each) do
13
+ File.delete(@layout.current_file)
14
+ Dir.delete(@layout.current_dir)
15
+ end
16
+
17
+ end
@@ -0,0 +1,104 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe ConvertorTag do
4
+
5
+ before(:each) do
6
+ # non-nested tags should get both
7
+ @content = ConvertorTag.new <<-EOF
8
+ <head>
9
+ <title>Test</title>
10
+ </head>
11
+ <body>
12
+ {@ header @}
13
+ <div id="header">
14
+ <p>Header Content!</p>
15
+ </div>
16
+ {@ /header @}
17
+ {@ menu @}
18
+ <ul id='menu'>
19
+ <li>Item 1</li>
20
+ <li>Item 2</li>
21
+ </ul>
22
+ {@ /menu @}
23
+ </body>
24
+ EOF
25
+
26
+ # nested tags should only get outside
27
+ @content2 = ConvertorTag.new <<-EOF
28
+ <head>
29
+ <title>Test</title>
30
+ </head>
31
+ <body>
32
+ {@ header @}
33
+ <div id="nav">
34
+ {@ menu @}
35
+ <ul id='menu'>
36
+ <li>Item 1</li>
37
+ <li>Item 2</li>
38
+ </ul>
39
+ {@ /menu @}
40
+ </div>
41
+ {@ /header @}
42
+ </div>
43
+ </body>
44
+ EOF
45
+ end
46
+
47
+ it "should find eye tags" do
48
+ @content.tags.should == ['header', 'menu']
49
+ @content2.tags.should == ['header']
50
+ end
51
+
52
+ it "should get what's in the eye tags" do
53
+ header_content = <<-EOF
54
+ <div id="header">
55
+ <p>Header Content!</p>
56
+ </div>
57
+ EOF
58
+
59
+ header_content2 = <<-EOF
60
+ <div id="nav">
61
+ {@ menu @}
62
+ <ul id='menu'>
63
+ <li>Item 1</li>
64
+ <li>Item 2</li>
65
+ </ul>
66
+ {@ /menu @}
67
+ </div>
68
+ EOF
69
+
70
+ @content.text_inside_tag('header').strip.should == header_content.strip
71
+ @content2.text_inside_tag('header').strip.should == header_content2.strip
72
+
73
+ @content.text_inside_tag('fake').should == nil
74
+ end
75
+
76
+ it "should get what's in and the eye tags" do
77
+ header_content = <<-EOF
78
+ {@ header @}
79
+ <div id="header">
80
+ <p>Header Content!</p>
81
+ </div>
82
+ {@ /header @}
83
+ EOF
84
+
85
+ header_content2 = <<-EOF
86
+ {@ header @}
87
+ <div id="nav">
88
+ {@ menu @}
89
+ <ul id='menu'>
90
+ <li>Item 1</li>
91
+ <li>Item 2</li>
92
+ </ul>
93
+ {@ /menu @}
94
+ </div>
95
+ {@ /header @}
96
+ EOF
97
+
98
+ @content.text_with_tag('header').strip.should == header_content.strip
99
+ @content2.text_with_tag('header').strip.should == header_content2.strip
100
+
101
+ @content.text_inside_tag('fake').should == nil
102
+ end
103
+
104
+ end
@@ -0,0 +1,6 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <body>
4
+ <p>Hello World!</p>
5
+ </body>
6
+ </html>
@@ -36,6 +36,17 @@ describe RefinerycmsConvertor do
36
36
  end
37
37
  end
38
38
 
39
+ after(:all) do
40
+ # Deletes the directories created, comment out if debugging
41
+ Dir.glob(@theme.theme_dir + '**/**').reverse.each do |f|
42
+ begin
43
+ File.delete(f) unless f =~ /original/
44
+ rescue
45
+ Dir.delete(f)
46
+ end if f.include?(@theme.theme_dir.to_s)
47
+ end
48
+ end
49
+
39
50
  end
40
51
 
41
52
  end
data/spec/spec_helper.rb CHANGED
@@ -8,6 +8,8 @@ Spec::Runner.configure do |config|
8
8
 
9
9
  end
10
10
 
11
+ require 'fileutils'
12
+
11
13
  # Pretend we're in a rails app
12
14
  class Rails
13
15
 
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms-convertor
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 0
9
- - 2
10
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
11
10
  platform: ruby
12
11
  authors:
13
12
  - stevenheidel
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-06-27 00:00:00 -06:00
17
+ date: 2010-07-24 00:00:00 -06:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -26,7 +25,6 @@ dependencies:
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- hash: 13
30
28
  segments:
31
29
  - 1
32
30
  - 2
@@ -42,13 +40,11 @@ dependencies:
42
40
  requirements:
43
41
  - - ">="
44
42
  - !ruby/object:Gem::Version
45
- hash: 91
46
43
  segments:
47
44
  - 0
48
45
  - 9
49
- - 6
50
- - 34
51
- version: 0.9.6.34
46
+ - 7
47
+ version: 0.9.7
52
48
  type: :runtime
53
49
  version_requirements: *id002
54
50
  description: This gem makes it very easy to create beautiful looking websites with refinerycms by taking out all of the repetition of making refinerycms themes.
@@ -67,9 +63,15 @@ files:
67
63
  - README.rdoc
68
64
  - Rakefile
69
65
  - VERSION
66
+ - lib/convertor-file.rb
67
+ - lib/convertor-layout.rb
68
+ - lib/convertor-tags.rb
70
69
  - lib/refinerycms-convertor.rb
71
70
  - lib/tasks/refinerycms-convertor.rake
72
71
  - refinerycms-convertor.gemspec
72
+ - spec/convertor-file_spec.rb
73
+ - spec/convertor-layout_spec.rb
74
+ - spec/convertor-tags_spec.rb
73
75
  - spec/fixtures/themes/theme/original/index.html
74
76
  - spec/fixtures/themes/unindexed/original/.gitinclude
75
77
  - spec/fixtures/themes/unoriginal/.gitinclude
@@ -90,7 +92,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
90
92
  requirements:
91
93
  - - ">="
92
94
  - !ruby/object:Gem::Version
93
- hash: 3
94
95
  segments:
95
96
  - 0
96
97
  version: "0"
@@ -99,7 +100,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
100
  requirements:
100
101
  - - ">="
101
102
  - !ruby/object:Gem::Version
102
- hash: 3
103
103
  segments:
104
104
  - 0
105
105
  version: "0"
@@ -111,5 +111,8 @@ signing_key:
111
111
  specification_version: 3
112
112
  summary: Converts simple html templates into refinerycms themes.
113
113
  test_files:
114
- - spec/refinerycms-convertor_spec.rb
114
+ - spec/convertor-tags_spec.rb
115
+ - spec/convertor-layout_spec.rb
115
116
  - spec/spec_helper.rb
117
+ - spec/refinerycms-convertor_spec.rb
118
+ - spec/convertor-file_spec.rb