erbside 0.1.0 → 0.2.0

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.
Files changed (67) hide show
  1. data/.gemspec +152 -0
  2. data/.gitignore +8 -0
  3. data/.ruby +48 -0
  4. data/.yardopts +6 -0
  5. data/{HISTORY → HISTORY.rdoc} +0 -0
  6. data/MANIFEST +33 -0
  7. data/NOTICE.rdoc +32 -0
  8. data/PROFILE +6 -3
  9. data/README.rdoc +76 -0
  10. data/VERSION +1 -1
  11. data/lib/erbside.rb +6 -2
  12. data/lib/erbside/context.rb +3 -3
  13. data/lib/erbside/gemspec.rb +19 -0
  14. data/lib/erbside/inline.rb +8 -5
  15. data/lib/erbside/inline/cpp.rb +7 -0
  16. data/lib/erbside/inline/css.rb +7 -0
  17. data/lib/erbside/inline/js.rb +7 -0
  18. data/lib/erbside/metadata.rb +86 -50
  19. data/lib/erbside/runner.rb +14 -5
  20. data/main.assembly +56 -0
  21. data/{test/functional → qed}/applique/env.rb +0 -0
  22. data/{test/functional → qed}/bash.rdoc +0 -0
  23. data/{test/functional → qed}/cli.rdoc +0 -0
  24. data/{test/functional → qed}/cpp.rdoc +0 -0
  25. data/{test/functional → qed}/css.rdoc +0 -0
  26. data/{test/functional → qed}/javascript.rdoc +0 -0
  27. data/{test/functional → qed}/ruby.rdoc +0 -0
  28. data/{test/functional → qed}/sgml.rdoc +0 -0
  29. data/site/.htaccess +2 -0
  30. data/site/.rsync-filter +7 -0
  31. data/site/assets/css/highlight.css +96 -0
  32. data/site/assets/css/reset.css +19 -0
  33. data/site/assets/css/site.css +52 -0
  34. data/site/assets/img/curb.jpg +0 -0
  35. data/site/assets/img/emeraled.png +0 -0
  36. data/site/assets/img/fade.png +0 -0
  37. data/site/assets/img/fork-me.png +0 -0
  38. data/site/assets/img/icon.jpg +0 -0
  39. data/site/assets/js/highlight.js +1 -0
  40. data/site/assets/js/jquery.js +19 -0
  41. data/site/assets/js/jquery.tabs.js +1 -0
  42. data/site/index.html +229 -0
  43. data/test/{unit/fixture → fixture}/inline.rb +3 -3
  44. data/test/{unit/fixture → fixture}/inline_complex.rb +0 -0
  45. data/test/inline_test.rb +15 -0
  46. data/work/defunct/css/color.css +45 -0
  47. data/work/defunct/css/font.css +39 -0
  48. data/work/defunct/css/struct.css +51 -0
  49. data/work/defunct/inline-old/bash.rb +36 -0
  50. data/work/defunct/inline-old/cpp.rb +39 -0
  51. data/work/defunct/inline-old/css.rb +32 -0
  52. data/work/defunct/inline-old/html.rb +32 -0
  53. data/work/defunct/inline-old/js.rb +85 -0
  54. data/work/defunct/inline-old/ruby.rb +147 -0
  55. data/work/defunct/inline-old/type.rb +91 -0
  56. data/work/defunct/inline.rb +202 -0
  57. data/work/defunct/plan.rb +37 -0
  58. data/work/defunct/tiller.rb +200 -0
  59. data/work/defunct/webme/options.yml +4 -0
  60. data/work/defunct/whole.rb +221 -0
  61. data/{lib → work}/plugins/syckle/erbside.rb +0 -0
  62. data/work/radio_earth.jpg +0 -0
  63. data/yard.watchr +12 -0
  64. metadata +94 -50
  65. data/LICENSE +0 -206
  66. data/README +0 -88
  67. data/test/unit/inline_test.rb +0 -14
@@ -0,0 +1,152 @@
1
+ # encoding: utf-8
2
+
3
+ require 'yaml'
4
+
5
+ Gem::Specification.new do |gemspec|
6
+
7
+ manifest = Dir.glob('manifest{,.txt)', File::FNM_CASEFOLD).first
8
+
9
+ scm = case
10
+ when File.directory?('.git')
11
+ :git
12
+ end
13
+
14
+ files = case
15
+ when manifest
16
+ File.readlines(manifest).
17
+ map{ |line| line.srtip }.
18
+ reject{ |line| line.empty? || line[0,1] == '#' }
19
+ when scm == :git
20
+ `git ls-files -z`.split("\0")
21
+ else
22
+ Dir.glob('{**/}{.*,*}') # TODO: be more specific using standard locations ?
23
+ end.select{ |path| File.file?(path) }
24
+
25
+ patterns = {
26
+ :bin_files => 'bin/*',
27
+ :lib_files => 'lib/{**/}*.rb',
28
+ :ext_files => 'ext/{**/}extconf.rb',
29
+ :doc_files => '*.{txt,rdoc,md,markdown,tt,textile}',
30
+ :test_files => '{test/{**/}*_test.rb,spec/{**/}*_spec.rb}'
31
+ }
32
+
33
+ glob_files = lambda { |pattern|
34
+ Dir.glob(pattern).select { |path|
35
+ File.file?(path) && files.include?(path)
36
+ }
37
+ }
38
+
39
+ #files = glob_files[patterns[:files]]
40
+
41
+ executables = glob_files[patterns[:bin_files]].map do |path|
42
+ File.basename(path)
43
+ end
44
+
45
+ extensions = glob_files[patterns[:ext_files]].map do |path|
46
+ File.basename(path)
47
+ end
48
+
49
+ metadata = YAML.load_file('.ruby')
50
+
51
+ # build-out the gemspec
52
+
53
+ case metadata['revision']
54
+ when 0
55
+ gemspec.name = metadata['name']
56
+ gemspec.version = metadata['version']
57
+ gemspec.summary = metadata['summary']
58
+ gemspec.description = metadata['description']
59
+
60
+ metadata['authors'].each do |author|
61
+ gemspec.authors << author['name']
62
+
63
+ if author.has_key?('email')
64
+ if gemspec.email
65
+ gemspec.email << author['email']
66
+ else
67
+ gemspec.email = [author['email']]
68
+ end
69
+ end
70
+ end
71
+
72
+ gemspec.licenses = metadata['licenses']
73
+
74
+ metadata['requirements'].each do |req|
75
+ name = req['name']
76
+ version = req['version']
77
+ groups = req['groups'] || []
78
+
79
+ if md = /^(.*?)([+-~])$/.match(version)
80
+ version = case md[2]
81
+ when '+' then ">= #{$1}"
82
+ when '-' then "< #{$1}"
83
+ when '~' then "~> #{$1}"
84
+ else version
85
+ end
86
+ end
87
+
88
+ #development = req['development']
89
+ #if development
90
+ # # populate development dependencies
91
+ # if gemspec.respond_to?(:add_development_dependency)
92
+ # gemspec.add_development_dependency(name,*version)
93
+ # else
94
+ # gemspec.add_dependency(name,*version)
95
+ # end
96
+ #else
97
+ # # populate runtime dependencies
98
+ # if gemspec.respond_to?(:add_runtime_dependency)
99
+ # gemspec.add_runtime_dependency(name,*version)
100
+ # else
101
+ # gemspec.add_dependency(name,*version)
102
+ # end
103
+ #end
104
+
105
+ if groups.empty? or groups.include?('runtime')
106
+ # populate runtime dependencies
107
+ if gemspec.respond_to?(:add_runtime_dependency)
108
+ gemspec.add_runtime_dependency(name,*version)
109
+ else
110
+ gemspec.add_dependency(name,*version)
111
+ end
112
+ else
113
+ # populate development dependencies
114
+ if gemspec.respond_to?(:add_development_dependency)
115
+ gemspec.add_development_dependency(name,*version)
116
+ else
117
+ gemspec.add_dependency(name,*version)
118
+ end
119
+ end
120
+ end
121
+
122
+ # convert external dependencies into a requirements
123
+ if metadata['external_dependencies']
124
+ ##gemspec.requirements = [] unless metadata['external_dependencies'].empty?
125
+ metadata['external_dependencies'].each do |req|
126
+ gemspec.requirements << req.to_s
127
+ end
128
+ end
129
+
130
+ # determine homepage from resources
131
+ homepage = metadata['resources'].find{ |key, url| key =~ /^home/ }
132
+ gemspec.homepage = homepage.last if homepage
133
+
134
+ gemspec.require_paths = metadata['load_path'] || ['lib']
135
+ gemspec.post_install_message = metadata['install_message']
136
+
137
+ # RubyGems specific metadata
138
+ gemspec.files = files
139
+ gemspec.extensions = extensions
140
+ gemspec.executables = executables
141
+
142
+ if Gem::VERSION < '1.7.'
143
+ gemspec.default_executable = gemspec.executables.first
144
+ end
145
+
146
+ gemspec.test_files = glob_files[patterns[:test_files]]
147
+
148
+ unless gemspec.files.include?('.document')
149
+ gemspec.extra_rdoc_files = glob_files[patterns[:doc_files]]
150
+ end
151
+ end
152
+ end
@@ -0,0 +1,8 @@
1
+ .yardoc
2
+ pkg
3
+ log
4
+ tmp
5
+ site/doc
6
+ site/qed
7
+ work/sandbox
8
+ DEMOS.rdoc
data/.ruby ADDED
@@ -0,0 +1,48 @@
1
+ ---
2
+ authors:
3
+ - name: Thomas Sawyer
4
+ email: transfire@gmail.com
5
+ copyrights:
6
+ - holder: Thomas Sawyer
7
+ year: "2010"
8
+ license: Apache 2.0
9
+ replacements: []
10
+
11
+ conflicts: []
12
+
13
+ requirements:
14
+ - name: facets
15
+ - name: pom
16
+ - name: ko
17
+ groups:
18
+ - test
19
+ development: true
20
+ dependencies: []
21
+
22
+ repositories:
23
+ - uri: git://github.com/proutils/till.git
24
+ scm: git
25
+ name: public
26
+ resources:
27
+ home: http://rubyworks.github.com/erbside
28
+ code: http://github.com/rubyworks/erbside
29
+ docs: http://rubydoc.info/gems/erbside/frames
30
+ mail: http://googlegroups.com/group/rubyworks-mailinglist
31
+ load_path:
32
+ - lib
33
+ extra:
34
+ contact: trans <transfire@gmail.com>
35
+ manifest: MANIFEST
36
+ source: []
37
+
38
+ alternatives: []
39
+
40
+ revision: 0
41
+ title: Erbside
42
+ summary: ERB-based Inline Templating
43
+ suite: rubyworks
44
+ created: "2009-07-15"
45
+ description: Erbside is a simple project-oriented erb-based inline template system. Inline templates make it easy to do basic code generation without the need for duplicate files.
46
+ version: 0.2.0
47
+ name: erbside
48
+ date: "2011-08-22"
@@ -0,0 +1,6 @@
1
+ --output-dir site/doc
2
+ --title Erbside
3
+ --readme README.rdoc
4
+ lib
5
+ -
6
+ [A-Z]*.*
File without changes
@@ -0,0 +1,33 @@
1
+ #!mast .ruby .yardopts bin lib qed test [A-Z][A-Z]*
2
+ .ruby
3
+ .yardopts
4
+ bin/erbside
5
+ lib/erbside/context.rb
6
+ lib/erbside/gemspec.rb
7
+ lib/erbside/inline/bash.rb
8
+ lib/erbside/inline/cpp.rb
9
+ lib/erbside/inline/css.rb
10
+ lib/erbside/inline/js.rb
11
+ lib/erbside/inline/ruby.rb
12
+ lib/erbside/inline/sgml.rb
13
+ lib/erbside/inline.rb
14
+ lib/erbside/metadata.rb
15
+ lib/erbside/runner.rb
16
+ lib/erbside.rb
17
+ qed/applique/env.rb
18
+ qed/bash.rdoc
19
+ qed/cli.rdoc
20
+ qed/cpp.rdoc
21
+ qed/css.rdoc
22
+ qed/javascript.rdoc
23
+ qed/ruby.rdoc
24
+ qed/sgml.rdoc
25
+ test/fixture/inline.rb
26
+ test/fixture/inline_complex.rb
27
+ test/inline_test.rb
28
+ HISTORY.rdoc
29
+ PROFILE
30
+ DEMOS.rdoc
31
+ README.rdoc
32
+ VERSION
33
+ NOTICE.rdoc
@@ -0,0 +1,32 @@
1
+ = COPYRIGHT NOTICES
2
+
3
+ == Erbside
4
+
5
+ Copyright:: (c) 2009 Thomas Sawyer, Rubyworks
6
+ License:: BSD-2-Clause
7
+ Website:: http://rubyworks.github.com/erbside
8
+
9
+ Copyright 2009 Thomas Sawyer. All rights reserved.
10
+
11
+ Redistribution and use in source and binary forms, with or without modification, are
12
+ permitted provided that the following conditions are met:
13
+
14
+ 1. Redistributions of source code must retain the above copyright notice, this list of
15
+ conditions and the following disclaimer.
16
+
17
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list
18
+ of conditions and the following disclaimer in the documentation and/or other materials
19
+ provided with the distribution.
20
+
21
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESS OR IMPLIED
22
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
23
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
24
+ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
27
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+
31
+ (http://spdx.org/licenses/BSD-2-Clause)
32
+
data/PROFILE CHANGED
@@ -1,10 +1,9 @@
1
1
  ---
2
2
  title : Erbside
3
3
  summary: ERB-based Inline Templating
4
- license: Apache 2.0
5
4
  contact: trans <transfire@gmail.com>
6
5
  suite : rubyworks
7
- authors: Thomas Sawyer
6
+ authors: Thomas Sawyer <transfire@gmail.com>
8
7
  created: 2009-07-15
9
8
 
10
9
  description:
@@ -14,14 +13,18 @@ description:
14
13
 
15
14
  requires:
16
15
  - facets
16
+ - pom
17
+ - ko (test)
17
18
 
18
19
  resources:
19
20
  home: http://rubyworks.github.com/erbside
20
21
  code: http://github.com/rubyworks/erbside
22
+ docs: http://rubydoc.info/gems/erbside/frames
23
+ mail: http://googlegroups.com/group/rubyworks-mailinglist
21
24
 
22
25
  repositories:
23
26
  public: git://github.com/proutils/till.git
24
27
 
25
28
  copyright:
26
29
  Copyright (c) 2010 Thomas Sawyer
27
-
30
+ license: Apache 2.0
@@ -0,0 +1,76 @@
1
+ = Erbside
2
+
3
+ {Homepage}[http://rubyworks.github.com/erbside] |
4
+ {Documentation}[http://rubydoc.info/gems/erbside/frames] |
5
+ {Source Code}[http://github.com/rubyworks/erbside] |
6
+ {Mailing List}[http://googlegroups.com/group/rubyworks-mailinglist]
7
+
8
+
9
+ == DESCRIPTION
10
+
11
+ Erbside is a simple in-line project-oriented ERB-based template system.
12
+ With Erbside it is very easy to do basic templating without the need
13
+ for file duplication.
14
+
15
+ Erbside also provides direct access to project metadata. It does this
16
+ automatically via {DotRuby}[http://dotruby.github.com/dotruby], or it
17
+ can be instructed to use other resources, including a project's gemspec.
18
+
19
+
20
+ == FEATURES
21
+
22
+ * Easy to use.
23
+ * Uses ERB. Easy.
24
+ * Uses .ruby and .gemspec. Easy.
25
+ * The file is the template. Easy.
26
+ * Did I mention it was easy?
27
+
28
+
29
+ == SYNOPSIS
30
+
31
+ In a Ruby script add an ERB comment.
32
+
33
+ module YourLibrary
34
+ VERSION = "1.0.0" #:erb: VERSION="<%= version %>"
35
+ end
36
+
37
+ Then run:
38
+
39
+ $ erbside myscript.rb
40
+
41
+ Unless you use the --force option, Erbside will ask you if
42
+ want to overwrite the file. Type y<Enter> and all of the #:erb:
43
+ in-line templating will be filled in.
44
+
45
+ To see what erbside would do without actually writing to the file,
46
+ use the `-o/--stdout` option.
47
+
48
+ $ erbside -o myscript.rb
49
+
50
+
51
+ == HOW TO INSTALL
52
+
53
+ Describe your installation procedure here.
54
+
55
+ To install with RubyGems simply open a console and type:
56
+
57
+ $ gem install erb
58
+
59
+ Local installation requires Setup.rb (gem install setup),
60
+ then download the tarball package and type:
61
+
62
+ $ tar -xvzf erb-1.0.0.tgz
63
+ $ cd erb-1.0.0.tgz
64
+ $ sudo setup.rb all
65
+
66
+ Windows users use 'ruby setup.rb all'.
67
+
68
+
69
+ == COPYRIGHT & LICENSE
70
+
71
+ Copyright (c) 2009 Thomas Sawyer
72
+
73
+ Erbside is made available according to the terms of the *FreeBSD* license.
74
+
75
+ See NOTICE.rdoc for details.
76
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -3,14 +3,14 @@ module Erbside
3
3
  require 'erbside/runner'
4
4
 
5
5
  #
6
- VERSION="0.1.0" #:erb: VERSION="<%= version %>"
6
+ VERSION="0.2.0" #:erb: VERSION="<%= version %>"
7
7
 
8
8
  #
9
9
  def self.cli(argv=ARGV)
10
10
  require 'optparse'
11
11
  require 'erbside/runner'
12
12
 
13
- options = {}
13
+ options = {:resources=>[]}
14
14
 
15
15
  usage = OptionParser.new do |use|
16
16
  use.banner = 'Usage: erbside [OPTIONS] [FILE1 FILE2 ...]'
@@ -19,6 +19,10 @@ module Erbside
19
19
  # options[:delete] = true
20
20
  #end
21
21
 
22
+ use.on('-r', '--resource FILE', 'get metadata from file') do |file|
23
+ options[:resources] << file
24
+ end
25
+
22
26
  use.on('-f', '--force', 'automatically make overwrites') do
23
27
  options[:force] = true
24
28
  end
@@ -10,10 +10,10 @@ module Erbside
10
10
  attr :metadata
11
11
 
12
12
  #
13
- def initialize(file=nil)
13
+ def initialize(file, resources=[])
14
14
  @filename = file
15
15
  @directory = File.dirname(file)
16
- @metadata = Metadata.new(@directory)
16
+ @metadata = Metadata.new(resources)
17
17
  end
18
18
 
19
19
  #
@@ -35,7 +35,7 @@ module Erbside
35
35
  def render(text)
36
36
  Dir.chdir(@directory) do
37
37
  erb = ERB.new(text)
38
- erb.filename = @filename
38
+ erb.filename = @filename.to_s
39
39
  erb.result(binding)
40
40
  end
41
41
  end