axtags 0.1.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.
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ # AWEXOME LABS AX TAGS
2
+ # Gemfile
3
+
4
+ source "http://rubygems.org"
5
+
6
+ # Runtime dependencies:
7
+
8
+ # The gem builds a different API to Radius:
9
+ gem "radius", "~> 0.7.3"
10
+
11
+ # Development dependencies:
12
+ group :development do
13
+ gem "bundler", "~> 1.2.1"
14
+ gem "jeweler", "~> 1.8.4"
15
+ gem "rdoc", "~> 3.12"
16
+ gem "rspec", ">= 2.11.0"
17
+ end
@@ -0,0 +1,33 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.3)
5
+ git (1.2.5)
6
+ jeweler (1.8.4)
7
+ bundler (~> 1.0)
8
+ git (>= 1.2.5)
9
+ rake
10
+ rdoc
11
+ json (1.7.5)
12
+ radius (0.7.3)
13
+ rake (10.0.3)
14
+ rdoc (3.12)
15
+ json (~> 1.4)
16
+ rspec (2.11.0)
17
+ rspec-core (~> 2.11.0)
18
+ rspec-expectations (~> 2.11.0)
19
+ rspec-mocks (~> 2.11.0)
20
+ rspec-core (2.11.1)
21
+ rspec-expectations (2.11.3)
22
+ diff-lcs (~> 1.1.3)
23
+ rspec-mocks (2.11.2)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ bundler (~> 1.2.1)
30
+ jeweler (~> 1.8.4)
31
+ radius (~> 0.7.3)
32
+ rdoc (~> 3.12)
33
+ rspec (>= 2.11.0)
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Awexome Labs, LLC
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,9 @@
1
+
2
+ == Ax Tags
3
+
4
+ Flexible, extensible custom tag and template-parsing framework built around the
5
+ {Radius templating framework}[https://github.com/jlong/radius].
6
+
7
+
8
+
9
+ Copyright (C) 2013 Awexome Labs, LLC
@@ -0,0 +1,65 @@
1
+ # encoding: utf-8
2
+
3
+ require "rubygems"
4
+ require "bundler"
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require "rake"
13
+
14
+ require "jeweler"
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "axtags"
18
+ gem.homepage = "http://github.com/mccolin/axtags"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Flexible, extensible custom tag and template framework with safe execution and HTML-like style}
21
+ gem.description = %Q{Flexible, extensible custom tag and template framework with safe execution and HTML-like style. Wraps a cleaner API around the Radius templating framework.}
22
+ gem.email = "engineering@awexomelabs.com"
23
+ gem.authors = ["Awexome Labs"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require "rspec/core"
29
+ require "rspec/core/rake_task"
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ end
32
+
33
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
34
+ spec.rcov = true
35
+ end
36
+
37
+ task :default => :spec
38
+
39
+ # require "rake/testtask"
40
+ # Rake::TestTask.new(:test) do |test|
41
+ # test.libs << "lib" << "test"
42
+ # test.pattern = "test/**/test_*.rb"
43
+ # test.verbose = true
44
+ # end
45
+
46
+ # require "rcov/rcovtask"
47
+ # Rcov::RcovTask.new do |test|
48
+ # test.libs << "test"
49
+ # test.pattern = "test/**/test_*.rb"
50
+ # test.verbose = true
51
+ # test.rcov_opts << "--exclude "gems/*""
52
+ # end
53
+
54
+ # task :default => :test
55
+
56
+ require "rdoc/task"
57
+ Rake::RDocTask.new do |rdoc|
58
+ version = File.exist?("VERSION") ? File.read("VERSION") : ""
59
+
60
+ rdoc.rdoc_dir = "rdoc"
61
+ rdoc.title = "AxTags #{version}"
62
+ rdoc.rdoc_files.include("README*")
63
+ rdoc.rdoc_files.include("LICENSE*")
64
+ rdoc.rdoc_files.include("lib/**/*.rb")
65
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,63 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "axtags"
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Awexome Labs"]
12
+ s.date = "2013-01-16"
13
+ s.description = "Flexible, extensible custom tag and template framework with safe execution and HTML-like style. Wraps a cleaner API around the Radius templating framework."
14
+ s.email = "engineering@awexomelabs.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ "Gemfile",
21
+ "Gemfile.lock",
22
+ "LICENSE.txt",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "axtags.gemspec",
27
+ "lib/axtags.rb",
28
+ "lib/axtags/ax_context.rb",
29
+ "lib/axtags/ax_parser.rb",
30
+ "lib/axtags/tag_library.rb",
31
+ "spec/axtags_spec.rb"
32
+ ]
33
+ s.homepage = "http://github.com/mccolin/axtags"
34
+ s.licenses = ["MIT"]
35
+ s.require_paths = ["lib"]
36
+ s.rubygems_version = "1.8.24"
37
+ s.summary = "Flexible, extensible custom tag and template framework with safe execution and HTML-like style"
38
+
39
+ if s.respond_to? :specification_version then
40
+ s.specification_version = 3
41
+
42
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
43
+ s.add_runtime_dependency(%q<radius>, ["~> 0.7.3"])
44
+ s.add_development_dependency(%q<bundler>, ["~> 1.2.1"])
45
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
46
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
47
+ s.add_development_dependency(%q<rspec>, [">= 2.11.0"])
48
+ else
49
+ s.add_dependency(%q<radius>, ["~> 0.7.3"])
50
+ s.add_dependency(%q<bundler>, ["~> 1.2.1"])
51
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
52
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
53
+ s.add_dependency(%q<rspec>, [">= 2.11.0"])
54
+ end
55
+ else
56
+ s.add_dependency(%q<radius>, ["~> 0.7.3"])
57
+ s.add_dependency(%q<bundler>, ["~> 1.2.1"])
58
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
59
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
60
+ s.add_dependency(%q<rspec>, [">= 2.11.0"])
61
+ end
62
+ end
63
+
@@ -0,0 +1,19 @@
1
+ # AWEXOME LABS
2
+ # AxTags
3
+ #
4
+ # A flexible, extensible custom tag and template framework with safe execution of user
5
+ # submitting templating.
6
+
7
+ require "radius"
8
+
9
+ require "axtags/ax_context"
10
+ require "axtags/ax_parser"
11
+ require "axtags/tag_library"
12
+
13
+ module AxTags
14
+
15
+ def self.version
16
+ Gem.loaded_specs["axtags"].version.to_s
17
+ end
18
+
19
+ end # AxTags
@@ -0,0 +1,24 @@
1
+ # AX TAGS
2
+ # Flexible, extensible custom tag and template-parsing framework built
3
+ # around the Radius templating framework.
4
+ #
5
+ # AxContext - A context contains a dictionary of tags that can be used
6
+ # in template parsing. Context objects are passed to parsers alongside
7
+ # templates to enable parsing.
8
+ #
9
+
10
+ module AxTags
11
+ class AxContext < Radius::Context
12
+
13
+ # A catch-call for handling an unsupported tag included in a template:
14
+ def tag_missing(tag, attr, &block)
15
+ %{<span class="error parse-error ui-state-error">Tag "#{tag}" is unknown. Attributes provided: #{attr.inspect}</span>}
16
+ end
17
+
18
+ # A method in-reserve for generic error-reporting to the end-user:
19
+ def tag_error(tag, error_text)
20
+ %{<span class="error parse-error ui-state-error">Error in rendering tag \"#{tag}\"; #{error_text}</span>}
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,13 @@
1
+ # AX TAGS
2
+ # Flexible, extensible custom tag and template-parsing framework built
3
+ # around the Radius templating framework.
4
+ #
5
+ # AxParser - Does the heavy lifting of sifting tags out of template
6
+ # documents and leverages the contents of a context object to build an
7
+ # output result document
8
+ #
9
+
10
+ module AxTags
11
+ class AxParser < Radius::Parser
12
+ end # AxParser
13
+ end # AxTags
@@ -0,0 +1,68 @@
1
+ # AX TAGS
2
+ # Flexible, extensible custom tag and template-parsing framework built
3
+ # around the Radius templating framework.
4
+ #
5
+ # TagLibrary - Composed of an AxContext and an AxParser, each library
6
+ # class provides the direct interface for defining tags in a given context,
7
+ # passing local variables to the parser, and managing the parsing process. Best
8
+ # use calls for the application to create any number of descendant classes of
9
+ # this class in which they define tags and call parsing actions upon. For
10
+ # example:
11
+ #
12
+ # class MyTagLibrary < AxTags::TagLibrary
13
+ # tag "myanchor" do |t|
14
+ # "<a class='awesome_anchor' href='http://awesometown.com/'>I am Awesome!</a>"
15
+ # end
16
+ # end
17
+ #
18
+ # MyTagLibrary.parse("Here is an awesome link: <ax:myanchor/>")
19
+ # => "Here is an awesome link: <a class='awesome_anchor' href='http://awesometown.com/'>I am awesome!</a>"
20
+ #
21
+ # Because tags are defined at a class level, it's not generally recommended to
22
+ # use the parent class as your API to tag definition and parsing, though it is
23
+ # possible to access the context and parsers directly and define tags and call
24
+ # parsing on them. That would look some like this:
25
+ #
26
+ # AxTags::TagLibrary.context.with do |c|
27
+ # c.define_tag "myanchor" do |t|
28
+ # "<a class='awesome_anchor' href='http://awesometown.com/'>I am Awesome!</a>"
29
+ # end
30
+ # end
31
+ # AxTags::TagLibrary.parse("Here is an awesome link: <ax:myanchor/>")
32
+ # => "Here is an awesome link: <a class='awesome_anchor' href='http://awesometown.com/'>I am awesome!</a>"
33
+ #
34
+ # This introduces the complication of having only one global tag library in which
35
+ # all tags in your system would exist, which is why the first example is the preferred
36
+ # method for optimal extensibility and namespacing.
37
+ #
38
+
39
+ module AxTags
40
+ class TagLibrary
41
+
42
+ def self.context
43
+ @@context ||= AxContext.new
44
+ end
45
+
46
+ def self.parser
47
+ @@parser ||= AxParser.new(context, :tag_prefix=>"ax")
48
+ end
49
+
50
+ def self.parse(document, options={})
51
+ if locals = options.delete(:locals)
52
+ locals.each {|arg, value| context.globals.send("#{arg}=", value) }
53
+ end
54
+ parser.parse(document)
55
+ end
56
+
57
+ def self.build_tags(&block)
58
+ yield context
59
+ end
60
+
61
+ def self.tag(name, options={}, &block)
62
+ build_tags do |c|
63
+ c.define_tag(name, options, &block)
64
+ end
65
+ end
66
+
67
+ end
68
+ end
@@ -0,0 +1,59 @@
1
+ # AWEXOME LABS
2
+ # AxTags Test Suite
3
+
4
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
6
+
7
+ require "rubygems"
8
+ require "bundler"
9
+ Bundler.setup(:default, :development)
10
+
11
+ require "axtags"
12
+ require "rspec"
13
+ require "rspec/autorun"
14
+
15
+ root = File.expand_path(File.join(File.dirname(__FILE__), ".."))
16
+
17
+ RSpec.configure do |config|
18
+ end
19
+
20
+
21
+ # Create a testable tag library:
22
+ class TestLibrary < AxTags::TagLibrary
23
+ tag "anchor" do |t|
24
+ %{<a class="awesome_anchor" href="http://awesometown.com/">I am Awesome!</a>}
25
+ end
26
+ end
27
+
28
+ # Test AxTags parsing and management:
29
+ describe "axtags" do
30
+
31
+ before(:each) do
32
+ end
33
+
34
+ after(:each) do
35
+ end
36
+
37
+
38
+ it "defines simple tags" do
39
+ end
40
+
41
+ it "defines content tags" do
42
+ end
43
+
44
+ it "defines nested tags" do
45
+ end
46
+
47
+ it "properly renders simple tag content" do
48
+ tmpl = %{<ax:anchor/>}
49
+ TestLibrary.parse(tmpl) == %{<a class="awesome_anchor" href="http://awesometown.com/">I am Awesome!</a>}
50
+ end
51
+
52
+ it "properly renders content tags" do
53
+ end
54
+
55
+ it "properly renders nested tag content" do
56
+ end
57
+
58
+
59
+ end # axtags
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: axtags
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Awexome Labs
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: radius
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.7.3
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.7.3
30
+ - !ruby/object:Gem::Dependency
31
+ name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 1.2.1
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.2.1
46
+ - !ruby/object:Gem::Dependency
47
+ name: jeweler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.8.4
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.8.4
62
+ - !ruby/object:Gem::Dependency
63
+ name: rdoc
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '3.12'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '3.12'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rspec
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: 2.11.0
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: 2.11.0
94
+ description: Flexible, extensible custom tag and template framework with safe execution
95
+ and HTML-like style. Wraps a cleaner API around the Radius templating framework.
96
+ email: engineering@awexomelabs.com
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files:
100
+ - LICENSE.txt
101
+ - README.rdoc
102
+ files:
103
+ - Gemfile
104
+ - Gemfile.lock
105
+ - LICENSE.txt
106
+ - README.rdoc
107
+ - Rakefile
108
+ - VERSION
109
+ - axtags.gemspec
110
+ - lib/axtags.rb
111
+ - lib/axtags/ax_context.rb
112
+ - lib/axtags/ax_parser.rb
113
+ - lib/axtags/tag_library.rb
114
+ - spec/axtags_spec.rb
115
+ homepage: http://github.com/mccolin/axtags
116
+ licenses:
117
+ - MIT
118
+ post_install_message:
119
+ rdoc_options: []
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ segments:
129
+ - 0
130
+ hash: -2603607807429614524
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ none: false
133
+ requirements:
134
+ - - ! '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 1.8.24
140
+ signing_key:
141
+ specification_version: 3
142
+ summary: Flexible, extensible custom tag and template framework with safe execution
143
+ and HTML-like style
144
+ test_files: []