tvml 0.0.1.pre → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/MIT-LICENSE +20 -0
- data/README.md +26 -6
- data/Rakefile +6 -1
- data/lib/TVML/document.rb +30 -0
- data/lib/TVML/element/background.rb +7 -0
- data/lib/TVML/element/banner.rb +7 -0
- data/lib/TVML/element/base.rb +2 -1
- data/lib/TVML/element/button.rb +7 -0
- data/lib/TVML/template/alert.rb +1 -3
- data/lib/TVML/version.rb +1 -1
- data/lib/tvml.rb +2 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7561a4cabf06eb87058b550005cdb2375659f156
|
4
|
+
data.tar.gz: 50f3fe1f5ca879c6b3353e5bfcf4edf6523bed36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9db07405eaaa52b322f6e356b9fe9330121905c0c0b78826d97bf36c3022f592f3f89d920ae1a691fa73e428db350d47fba06354b3d3784bfa5329429283d32f
|
7
|
+
data.tar.gz: af82ce86e647a038426cf4ee9bdccf86c3cfbd68259558ac6e3281fc2b30215323e4fcb3c05e210132e2767478ee352d9e1f9907ce4bb6158d6d58ebf55df1a0
|
data/Gemfile
CHANGED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2015-2016 Chris Bielinski (chris@shadow.io)
|
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.
|
data/README.md
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
# TVML
|
2
2
|
|
3
|
-
|
3
|
+
[![Build Status](https://img.shields.io/travis/chrisb/tvml/master.svg?style=flat-square)](https://travis-ci.org/chrisb/tvml)
|
4
|
+
[![Gemnasium](https://img.shields.io/gemnasium/chrisb/tvml.svg?style=flat-square)](https://gemnasium.com/chrisb/tvml)
|
5
|
+
[![Code Climate](https://img.shields.io/codeclimate/github/chrisb/tvml.svg?style=flat-square)](https://codeclimate.com/github/chrisb/tvml)
|
6
|
+
[![Coverage](https://img.shields.io/coveralls/chrisb/tvml.svg?style=flat-square)](https://coveralls.io/r/chrisb/tvml)
|
7
|
+
[![Security](https://hakiri.io/github/chrisb/tvml/master.svg)](https://hakiri.io/github/chrisb/tvml/master/shield)
|
4
8
|
|
5
|
-
|
9
|
+
[![Join the chat at https://gitter.im/chrisb/tvml](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/chrisb/tvml)
|
10
|
+
|
11
|
+
Provides a way of working with Apple's TVML documents, templates, and elements in an elegant and friendly Ruby-style DSL.
|
12
|
+
|
13
|
+
The TVML gem is based on [Builder](https://github.com/jimweirich/builder). For an example of how to integrate TVML with Sinatra, check out the [tvml-example repo](https://github.com/chrisb/tvml-example).
|
6
14
|
|
7
15
|
## Installation
|
8
16
|
|
@@ -18,18 +26,30 @@ And then execute:
|
|
18
26
|
|
19
27
|
Or install it yourself as:
|
20
28
|
|
21
|
-
$ gem install
|
29
|
+
$ gem install tvml
|
22
30
|
|
23
31
|
## Usage
|
24
32
|
|
25
|
-
|
33
|
+
```ruby
|
34
|
+
doc = TVML::Document.new
|
35
|
+
doc.template = TVML::Template::Alert.new.tap do |alert|
|
36
|
+
alert.title = "Hello World"
|
37
|
+
alert.description = "How are things?"
|
38
|
+
end
|
39
|
+
|
40
|
+
doc.build # => "<?xml version=\"1.0\" encoding=\"UTF-8\"?><document><alertTemplate><description>How are things?</description><title>Hello World</title></alertTemplate></document>"
|
41
|
+
```
|
26
42
|
|
27
43
|
## Development
|
28
44
|
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `
|
45
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rspec spec/` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
46
|
|
31
47
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
48
|
|
33
49
|
## Contributing
|
34
50
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
51
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/chrisb/tvml.
|
52
|
+
|
53
|
+
## Copyright
|
54
|
+
|
55
|
+
Copyright (c) 2015-2016 Chris Bielinski. See `MIT-LICENSE` for details.
|
data/Rakefile
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
module TVML
|
2
|
+
class Document
|
3
|
+
attr_accessor :builder, :template
|
4
|
+
|
5
|
+
JS_ESCAPE_MAP = { '\\' => '\\\\', '</' => '<\/', "\r\n" => '\n',
|
6
|
+
"\n" => '\n', "\r" => '\n', '"' => '\\"', "'" => "\\'" }
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@builder = Builder::XmlMarkup.new
|
10
|
+
@builder.instruct!
|
11
|
+
end
|
12
|
+
|
13
|
+
def build
|
14
|
+
@builder.document do |doc|
|
15
|
+
doc << @template.build if @template
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def build_escaped
|
20
|
+
escape_javascript(build)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def escape_javascript(javascript)
|
26
|
+
return '' unless javascript
|
27
|
+
javascript.gsub(%r{(\|<\/|\r\n|\342\200\250|\342\200\251|[\n\r"'])}) { |match| JS_ESCAPE_MAP[match] }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/TVML/element/base.rb
CHANGED
@@ -41,7 +41,8 @@ module TVML
|
|
41
41
|
def marshal_elements(node, *element_list)
|
42
42
|
element_list = self.class.elements if element_list.empty?
|
43
43
|
element_list.each do |ele|
|
44
|
-
|
44
|
+
next unless send(ele).present?
|
45
|
+
node.__send__ ele.to_s.camelize(:lower), send(ele)
|
45
46
|
end
|
46
47
|
end
|
47
48
|
end
|
data/lib/TVML/element/button.rb
CHANGED
data/lib/TVML/template/alert.rb
CHANGED
data/lib/TVML/version.rb
CHANGED
data/lib/tvml.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tvml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Bielinski
|
@@ -104,10 +104,14 @@ files:
|
|
104
104
|
- ".gitignore"
|
105
105
|
- ".travis.yml"
|
106
106
|
- Gemfile
|
107
|
+
- MIT-LICENSE
|
107
108
|
- README.md
|
108
109
|
- Rakefile
|
109
110
|
- bin/console
|
110
111
|
- bin/setup
|
112
|
+
- lib/TVML/document.rb
|
113
|
+
- lib/TVML/element/background.rb
|
114
|
+
- lib/TVML/element/banner.rb
|
111
115
|
- lib/TVML/element/base.rb
|
112
116
|
- lib/TVML/element/button.rb
|
113
117
|
- lib/TVML/template/alert.rb
|
@@ -144,9 +148,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
144
148
|
version: '0'
|
145
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
150
|
requirements:
|
147
|
-
- - "
|
151
|
+
- - ">="
|
148
152
|
- !ruby/object:Gem::Version
|
149
|
-
version:
|
153
|
+
version: '0'
|
150
154
|
requirements: []
|
151
155
|
rubyforge_project:
|
152
156
|
rubygems_version: 2.4.5.1
|