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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 697968941bc21b59c1a4ccf04ce9ee006549cfb3
4
- data.tar.gz: 11a94e8193d2ae1f55a9ee5d5c6c162ac378dbd9
3
+ metadata.gz: 7561a4cabf06eb87058b550005cdb2375659f156
4
+ data.tar.gz: 50f3fe1f5ca879c6b3353e5bfcf4edf6523bed36
5
5
  SHA512:
6
- metadata.gz: 8fdc9797028daf0cc4bce4fc46f99611fc289d593d4dc2b24763f89f2f18a24b347afb64422804ef0cbd3589a1c10651900dc6bc1bf46d60afe282b8c7d6df55
7
- data.tar.gz: 9c374ce2f82335b570b0ef9bc79ed0f6f34985b7b88ade0321be57f6481eb5ea821412c2c5f17b14817c442c45174e397db734cbd134f003734be4872c797c2c
6
+ metadata.gz: 9db07405eaaa52b322f6e356b9fe9330121905c0c0b78826d97bf36c3022f592f3f89d920ae1a691fa73e428db350d47fba06354b3d3784bfa5329429283d32f
7
+ data.tar.gz: af82ce86e647a038426cf4ee9bdccf86c3cfbd68259558ac6e3281fc2b30215323e4fcb3c05e210132e2767478ee352d9e1f9907ce4bb6158d6d58ebf55df1a0
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gem 'coveralls', require: false
4
+
3
5
  # Specify your gem's dependencies in TVML.gemspec
4
6
  gemspec
@@ -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
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/TVML`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- TODO: Delete this and the text above, and describe your gem
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 TVML
29
+ $ gem install tvml
22
30
 
23
31
  ## Usage
24
32
 
25
- TODO: Write usage instructions here
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 `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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/[USERNAME]/TVML.
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
@@ -1 +1,6 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new :spec
5
+
6
+ task default: :spec
@@ -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
@@ -0,0 +1,7 @@
1
+ module TVML
2
+ module Element
3
+ class Background < Base
4
+ element :audio
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module TVML
2
+ module Element
3
+ class Banner < Base
4
+ element :background, :button, :hero_img, :info_list, :row, :stack, :title
5
+ end
6
+ end
7
+ end
@@ -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
- node.__send__ ele, send(ele) if send(ele).present?
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
@@ -2,6 +2,13 @@ module TVML
2
2
  module Element
3
3
  class Button < Base
4
4
  element :text
5
+
6
+ def self.from_value(str)
7
+ btn = new
8
+ btn.text = str
9
+ btn
10
+ end
11
+
5
12
  end
6
13
  end
7
14
  end
@@ -12,9 +12,7 @@ module TVML
12
12
  def collapse_button_list
13
13
  @buttons = buttons.map do |button|
14
14
  next button if button.is_a?(TVML::Element::Button)
15
- btn = TVML::Element::Button.new
16
- btn.text = button
17
- btn
15
+ TVML::Element::Button.from_value(button)
18
16
  end
19
17
  end
20
18
 
@@ -1,3 +1,3 @@
1
1
  module TVML
2
- VERSION = "0.0.1.pre"
2
+ VERSION = "0.0.1"
3
3
  end
@@ -5,6 +5,8 @@ require 'builder'
5
5
  module TVML
6
6
  extend ActiveSupport::Autoload
7
7
 
8
+ autoload :Document, 'TVML/document'
9
+
8
10
  module Element
9
11
  autoload :Base, 'TVML/element/base'
10
12
  autoload :Button, 'TVML/element/button'
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.pre
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: 1.3.1
153
+ version: '0'
150
154
  requirements: []
151
155
  rubyforge_project:
152
156
  rubygems_version: 2.4.5.1