roll-amp 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b3558881ad7ec6ca95fa5bd9dec9311fa2365512
4
+ data.tar.gz: 05c3fb716d8c0c2352b939ec99b16da903e87e71
5
+ SHA512:
6
+ metadata.gz: eba77f753dd2bfff50e22aa43f2b1f9f94e426d1959b8f6265e5c4843d0a1e759b0fd9e37360fd8f1766229e091e0f14465d9a6f631e92053923c7f33431f936
7
+ data.tar.gz: e2b07d19382183c53fcc8cc62a59722c6b6fa7c240d5f601acb74f71c601f4d2409fc0dc64c43306f57c4c4fbd9e63838394baa8267e8566e5bd8423da48dfc1
data/.codeclimate.yml ADDED
@@ -0,0 +1,20 @@
1
+ ---
2
+ engines:
3
+ duplication:
4
+ enabled: true
5
+ config:
6
+ languages:
7
+ - ruby
8
+
9
+ fixme:
10
+ enabled: true
11
+
12
+ rubocop:
13
+ enabled: true
14
+
15
+ ratings:
16
+ paths:
17
+ - "**.rb"
18
+
19
+ exclude_paths:
20
+ - spec/
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
13
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,15 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.6
5
+ - 2.3.3
6
+ - 2.4.0
7
+ - ruby-head
8
+ before_install: gem install bundler -v 1.14.5
9
+
10
+ addons:
11
+ code_climate:
12
+ repo_token: d0e6e8620fdb35c857f1b874fe18a1a11e13560f35b5ea46e23f93e72089abec
13
+
14
+ after_success:
15
+ - bundle exec codeclimate-test-reporter
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at shinkarenko.vi@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in roll-amp.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'reek'
8
+ gem 'rubocop'
9
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Viacheslav Shynkarenko
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # AMP in Rails apps
2
+ Utilities to simplify Accelerated Mobile Pages (AMP) implementation in Rails apps.
3
+
4
+ [![Travis Build Status](https://travis-ci.org/roll-rails/roll-amp.svg?branch=master)](https://travis-ci.org/roll-rails/roll-amp)
5
+ [![Appveyor Build Status](https://ci.appveyor.com/api/projects/status/4i4t22ggmecnkg6k?svg=true)](https://ci.appveyor.com/project/slavikdev/roll-amp)
6
+ [![Test Coverage](https://codeclimate.com/github/roll-rails/roll-amp/badges/coverage.svg)](https://codeclimate.com/github/roll-rails/roll-amp/coverage)
7
+ [![Code Climate](https://codeclimate.com/github/roll-rails/roll-amp/badges/gpa.svg)](https://codeclimate.com/github/roll-rails/roll-amp)
8
+ [![Issue Count](https://codeclimate.com/github/roll-rails/roll-amp/badges/issue_count.svg)](https://codeclimate.com/github/roll-rails/roll-amp)
9
+
10
+ ## Features
11
+ Implemented:
12
+ * Tag to include AMP boilerplate CSS.
13
+ * Tag to include AMP base JS.
14
+ * Tag to include custom CSS.
15
+
16
+ Todo:
17
+ * Google Analytics integration.
18
+ * AMP validation via Ruby tests.
19
+ * ...
20
+
21
+ ## Platforms
22
+ Minimum supported MRI version is `2.2.6`. JRuby is not supported.
23
+ The gem should work on Mac, Linux and Windows, however testing
24
+ is limited as follows:
25
+ * Mac OS X (development machine)
26
+ * `2.4.0`
27
+ * Windows (via appveyor)
28
+ * `2.3.3`
29
+ * `2.2.6`
30
+ * Ubuntu (via travis-ci)
31
+ * `2.4.0`
32
+ * `2.3.3`
33
+ * `2.2.6`
34
+ * `Head`
35
+
36
+ ## Installation
37
+
38
+ Add this line to your application's Gemfile:
39
+
40
+ ```ruby
41
+ gem 'roll-amp'
42
+ ```
43
+
44
+ And then execute:
45
+
46
+ $ bundle
47
+
48
+ Or install it yourself as:
49
+
50
+ $ gem install roll-amp
51
+
52
+ ## Usage
53
+ * [How to setup AMP layout for Rails app pages](https://github.com/roll-rails/roll-amp/wiki/How-to-setup-AMP-layout-for-Rails-app-pages)
54
+
55
+ Layout example:
56
+ ```html
57
+ <!doctype html>
58
+ <html ⚡>
59
+ <head>
60
+ <%= amp_js %>
61
+ <%= csrf_meta_tags %>
62
+ <%= amp_boilerplate %>
63
+ <%= amp_custom_style('amp/application') %>
64
+ </head>
65
+ <body>
66
+ <%= yield %>
67
+ </body>
68
+ </html>
69
+ ```
70
+
71
+ ## Development
72
+
73
+ After checking out the repo, run `bin/setup` to install dependencies.
74
+ Then, run `rake spec` to run the tests. You can also run `bin/console`
75
+ for an interactive prompt that will allow you to experiment.
76
+
77
+ To install this gem onto your local machine, run `bundle exec rake install`.
78
+ To release a new version, update the version number in `version.rb`,
79
+ and then run `bundle exec rake release`, which will create a git tag for
80
+ the version, push git commits and tags, and push the `.gem`
81
+ file to [rubygems.org](https://rubygems.org).
82
+
83
+ ## Contributing
84
+
85
+ Bug reports and pull requests are welcome on GitHub
86
+ at https://github.com/roll-rails/roll-amp. This project is intended to be
87
+ a safe, welcoming space for collaboration, and contributors are expected
88
+ to adhere to the [Contributor Covenant](http://contributor-covenant.org)
89
+ code of conduct.
90
+
91
+
92
+ ## License
93
+
94
+ The gem is available as open source under the terms of the
95
+ [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/appveyor.yml ADDED
@@ -0,0 +1,18 @@
1
+ version: "{build}"
2
+
3
+ environment:
4
+ matrix:
5
+ - RUBY_VERSION: 23
6
+ - RUBY_VERSION: 22
7
+
8
+ install:
9
+ - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
10
+ - ruby -v
11
+ - gem -v
12
+ - bundle -v
13
+ - bundle install
14
+
15
+ build: off
16
+
17
+ test_script:
18
+ - bundle exec rake
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "roll/amp"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,9 @@
1
+ # Patching of the standard Module class.
2
+ class Module
3
+ # Calls `autoload`, prefixing file_name with common prefix.
4
+ # @param klass [Symbol] the class or module to load.
5
+ # @param file_name [String] the file name containing the class or module.
6
+ def use(klass, file_name)
7
+ autoload(klass, "roll/amp/#{file_name}")
8
+ end
9
+ end
@@ -0,0 +1,2 @@
1
+ UtilityFunction:
2
+ enabled: false
@@ -0,0 +1,35 @@
1
+ require 'rails'
2
+
3
+ module Roll
4
+ module Amp
5
+ module Helpers
6
+ # Implements tags to be used in Rails templates.
7
+ module Tags
8
+ # Renders AMP boilerplate stylesheet.
9
+ # @return [String] HTML containing style tags with boilerplate CSS.
10
+ def amp_boilerplate
11
+ Style::BoilerplateStyleTagsSet.new.to_html
12
+ end
13
+
14
+ # Renders custom stylesheet.
15
+ # @return [String] HTML containing style tag with
16
+ # content of the file specified.
17
+ def amp_custom_style(file_name)
18
+ Style::CustomStyleTag.new(
19
+ Style::Stylesheet.new(
20
+ ::Rails.root,
21
+ ::Rails.application.assets,
22
+ file_name
23
+ ).read
24
+ ).to_html
25
+ end
26
+
27
+ # Renders script tag with link to AMP main JS.
28
+ # @return [String] HTML containing script tag.
29
+ def amp_js
30
+ Script::AmpJsTag.new.to_html
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,18 @@
1
+ require 'action_view'
2
+
3
+ module Roll
4
+ module Amp
5
+ module Script
6
+ # The script tag with AMP utilities.
7
+ class AmpJsTag
8
+ include ActionView::Helpers::OutputSafetyHelper
9
+
10
+ # Prints this tag as HTML.
11
+ # @return [String] HTML-safe string containing the tag's HTML view.
12
+ def to_html
13
+ raw('<script async src="https://cdn.ampproject.org/v0.js"></script>')
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ module Roll
2
+ module Amp
3
+ module Style
4
+ # The boilerplate style tag. Provides base CSS for AMP pages.
5
+ class BoilerplateStyleTag < StyleTag
6
+ # Initializes new instance of the boilerplate style tag.
7
+ # @param css_file_name [String] the file name of the CSS file to take
8
+ # boilerplate CSS content from.
9
+ def initialize(css_file_name)
10
+ super(
11
+ 'amp-boilerplate',
12
+ InternalCssFile.new(css_file_name).read
13
+ )
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,26 @@
1
+ require 'action_view'
2
+
3
+ module Roll
4
+ module Amp
5
+ module Style
6
+ # The boilerplate style tags set. There are two boilerplate styles:
7
+ # the main style and the additional style which disables animations
8
+ # and is put into <noscript> tag.
9
+ # This class represents all that structure.
10
+ class BoilerplateStyleTagsSet
11
+ include ActionView::Helpers::OutputSafetyHelper
12
+
13
+ # Builds HTML set of style tags.
14
+ # @return [String] safe HTML string, containing
15
+ # the boilerplate style structure.
16
+ def to_html
17
+ content = BoilerplateStyleTag.new('boilerplate-main.css').to_html
18
+ content << NoScriptTag.new(
19
+ BoilerplateStyleTag.new('boilerplate-animation.css').to_html
20
+ ).to_html
21
+ raw(content)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,28 @@
1
+ module Roll
2
+ module Amp
3
+ module Style
4
+ # The stylesheet file, compiled into Rails app public directory.
5
+ class CompiledStylesheetFile
6
+ # Initializes new instance of the compiled stylesheet file.
7
+ # @param app_path [String] the Rails application root path.
8
+ # @param stylesheet_name [String] the stylesheet file name.
9
+ def initialize(app_path, stylesheet_name)
10
+ @path = CompiledStylesheetPath.new(app_path, stylesheet_name)
11
+ end
12
+
13
+ # Reads content of the file.
14
+ # @return [String] the file content or empty string
15
+ # if file doesn't exist.
16
+ def read
17
+ full_stylesheet_path = @path.full
18
+ if File.file?(full_stylesheet_path) &&
19
+ File.exist?(full_stylesheet_path)
20
+ File.read(full_stylesheet_path)
21
+ else
22
+ ''
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,29 @@
1
+ require 'action_view'
2
+
3
+ module Roll
4
+ module Amp
5
+ module Style
6
+ # The path of a stylesheet file, compiled into
7
+ # Rails app `public` directory.
8
+ class CompiledStylesheetPath
9
+ # Initializes new instance of the path of a compiled stylesheet file.
10
+ # @param app_path [String] the Rails application root path.
11
+ # @param stylesheet_name [String] the stylesheet file name.
12
+ def initialize(app_path, stylesheet_name)
13
+ @app_path = app_path
14
+ @stylesheet_name = stylesheet_name
15
+ end
16
+
17
+ # Uses ActionView to obtain full stylesheet path in `public` directory.
18
+ # @return [String] the full path string. Always has value.
19
+ def full
20
+ stylesheet_file = ActionView::Base.new.stylesheet_path(
21
+ @stylesheet_name,
22
+ host: nil
23
+ )
24
+ "#{@app_path}/public#{stylesheet_file}"
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1 @@
1
+ body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}
@@ -0,0 +1 @@
1
+ body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}
@@ -0,0 +1,14 @@
1
+ module Roll
2
+ module Amp
3
+ module Style
4
+ # The custom style tag.
5
+ class CustomStyleTag < StyleTag
6
+ # Initializes new instance of the custom style tag.
7
+ # @param [String] the content of the tag.
8
+ def initialize(content)
9
+ super('amp-custom', content)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,30 @@
1
+ module Roll
2
+ module Amp
3
+ module Style
4
+ # The internal CSS file. Provides API to access preset
5
+ # CSS files of this library.
6
+ class InternalCssFile
7
+ # Initializes new instance of the internal CSS file.
8
+ # @param css_file_name [String] the file name of the CSS file.
9
+ def initialize(css_file_name)
10
+ @css_file_name = css_file_name
11
+ end
12
+
13
+ # Reads content of the file.
14
+ # @return [String] the file content.
15
+ def read
16
+ File.read(full_path)
17
+ end
18
+
19
+ private
20
+
21
+ def full_path
22
+ File.expand_path(
23
+ "../style/css/#{@css_file_name}",
24
+ File.dirname(__FILE__)
25
+ )
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,24 @@
1
+ require 'action_view'
2
+
3
+ module Roll
4
+ module Amp
5
+ module Style
6
+ # The <nosript> tag.
7
+ class NoScriptTag
8
+ include ActionView::Helpers::TagHelper
9
+
10
+ # Initializes new instance of the noscript tag.
11
+ # @param [String] the content of the tag.
12
+ def initialize(content)
13
+ @content = content
14
+ end
15
+
16
+ # Prints this tag as HTML.
17
+ # @return [String] HTML-safe string containing the tag's HTML view.
18
+ def to_html
19
+ content_tag('noscript', @content)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,27 @@
1
+ require 'action_view'
2
+
3
+ module Roll
4
+ module Amp
5
+ module Style
6
+ # The style tag.
7
+ class StyleTag
8
+ include ActionView::Helpers::TagHelper
9
+
10
+ # Initializes new instance of the style tag.
11
+ # @param amp_attr [String] the AMP-specific attribute of the tag
12
+ # to indicate its purpose.
13
+ # @param [String] the content of the tag.
14
+ def initialize(amp_attr, content)
15
+ @amp_attr = amp_attr
16
+ @content = content
17
+ end
18
+
19
+ # Prints this tag as HTML.
20
+ # @return [String] HTML-safe string containing the tag's HTML view.
21
+ def to_html
22
+ content_tag('style', @content, @amp_attr => '')
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,54 @@
1
+ require 'action_view'
2
+
3
+ module Roll
4
+ module Amp
5
+ module Style
6
+ # The AMP stylesheet which can be loaded from file or assets pipeline
7
+ # and injected into HTML body.
8
+ class Stylesheet
9
+ include ActionView::Helpers::OutputSafetyHelper
10
+
11
+ # Initializes new instance of the AML stylesheet.
12
+ # @param app_path [String] the Rails application root path.
13
+ # @param assets [Sprockets::Environment] the Rails.application.assets
14
+ # @param stylesheet_name [String] the stylesheet file name.
15
+ def initialize(app_path, assets, stylesheet_name)
16
+ @app_path = app_path
17
+ @assets = assets
18
+ @stylesheet_name = stylesheet_name
19
+ end
20
+
21
+ # Reads stylesheet content from file or assets pipeline.
22
+ # Usually the pipeline is used in dev/test mode, while on production
23
+ # the stylesheet would be read from file.
24
+ # @return [String] CSS content as HTML-safe unescaped string or empty
25
+ # string if content couldn't be retreived.
26
+ def read
27
+ raw(stylesheet_content)
28
+ end
29
+
30
+ private
31
+
32
+ def stylesheet_content
33
+ if available_in_pipeline?
34
+ read_from_pipeline
35
+ else
36
+ read_from_compiled_file
37
+ end
38
+ end
39
+
40
+ def available_in_pipeline?
41
+ @assets && @assets[@stylesheet_name]
42
+ end
43
+
44
+ def read_from_pipeline
45
+ @assets[@stylesheet_name]
46
+ end
47
+
48
+ def read_from_compiled_file
49
+ CompiledStylesheetFile.new(@app_path, @stylesheet_name).read
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,5 @@
1
+ module Roll
2
+ module Amp
3
+ VERSION = '0.1.0'.freeze
4
+ end
5
+ end
data/lib/roll/amp.rb ADDED
@@ -0,0 +1,34 @@
1
+ require 'roll/amp/version'
2
+ require 'roll/amp/autoload'
3
+ require 'action_view'
4
+
5
+ module Roll
6
+ # AMP in Rails apps.
7
+ module Amp
8
+ # CSS in AMP.
9
+ module Style
10
+ use :BoilerplateStyleTag, 'style/boilerplate_style_tag'
11
+ use :BoilerplateStyleTagsSet, 'style/boilerplate_style_tags_set'
12
+ use :CompiledStylesheetFile, 'style/compiled_stylesheet_file'
13
+ use :CompiledStylesheetPath, 'style/compiled_stylesheet_path'
14
+ use :CustomStyleTag, 'style/custom_style_tag'
15
+ use :InternalCssFile, 'style/internal_css_file'
16
+ use :NoScriptTag, 'style/noscript_tag'
17
+ use :StyleTag, 'style/style_tag'
18
+ use :Stylesheet, 'style/stylesheet'
19
+ end
20
+
21
+ # JS in AMP.
22
+ module Script
23
+ use :AmpJsTag, 'script/amp_js_tag'
24
+ end
25
+
26
+ # Modules with utility functions to use in Rails helpers.
27
+ module Helpers
28
+ use :Tags, 'helpers/tags'
29
+ end
30
+ end
31
+ end
32
+
33
+ # Automatically extend Rails views with AMP tags.
34
+ ActionView::Base.send :include, Roll::Amp::Helpers::Tags
data/roll-amp.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'roll/amp/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'roll-amp'
8
+ spec.version = Roll::Amp::VERSION
9
+ spec.authors = ['Viacheslav Shynkarenko']
10
+ spec.email = ['shinkarenko.vi@gmail.com']
11
+
12
+ spec.summary = 'AMP in Rails apps'
13
+ spec.description = 'Utilities to simplify Accelerated Mobile Pages (AMP)'\
14
+ 'implementation in Rails apps'
15
+ spec.homepage = 'https://github.com/roll-rails/roll-amp'
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test|spec|features)/})
20
+ end
21
+ spec.bindir = 'exe'
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ['lib']
24
+
25
+ spec.required_ruby_version = '>= 2.2.6'
26
+ spec.required_rubygems_version = '>= 1.8.11'
27
+
28
+ spec.add_dependency 'actionview', '>= 3.2.0', '<= 5.1.0'
29
+ spec.add_dependency 'railties', '>= 3.2.0', '<= 5.1.0'
30
+
31
+ spec.add_development_dependency 'bundler', '~> 1.14'
32
+ spec.add_development_dependency 'rake', '~> 10.0'
33
+ spec.add_development_dependency 'rspec', '~> 3.0'
34
+ spec.add_development_dependency 'simplecov'
35
+ spec.add_development_dependency 'codeclimate-test-reporter', '~> 1.0.0'
36
+ spec.add_development_dependency 'rspec-html-matchers', '~> 0.9.1'
37
+ end
metadata ADDED
@@ -0,0 +1,199 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: roll-amp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Viacheslav Shynkarenko
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-03-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: actionview
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 3.2.0
20
+ - - "<="
21
+ - !ruby/object:Gem::Version
22
+ version: 5.1.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 3.2.0
30
+ - - "<="
31
+ - !ruby/object:Gem::Version
32
+ version: 5.1.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: railties
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 3.2.0
40
+ - - "<="
41
+ - !ruby/object:Gem::Version
42
+ version: 5.1.0
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 3.2.0
50
+ - - "<="
51
+ - !ruby/object:Gem::Version
52
+ version: 5.1.0
53
+ - !ruby/object:Gem::Dependency
54
+ name: bundler
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '1.14'
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '1.14'
67
+ - !ruby/object:Gem::Dependency
68
+ name: rake
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '10.0'
74
+ type: :development
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: '10.0'
81
+ - !ruby/object:Gem::Dependency
82
+ name: rspec
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '3.0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - "~>"
93
+ - !ruby/object:Gem::Version
94
+ version: '3.0'
95
+ - !ruby/object:Gem::Dependency
96
+ name: simplecov
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ - !ruby/object:Gem::Dependency
110
+ name: codeclimate-test-reporter
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - "~>"
114
+ - !ruby/object:Gem::Version
115
+ version: 1.0.0
116
+ type: :development
117
+ prerelease: false
118
+ version_requirements: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - "~>"
121
+ - !ruby/object:Gem::Version
122
+ version: 1.0.0
123
+ - !ruby/object:Gem::Dependency
124
+ name: rspec-html-matchers
125
+ requirement: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: 0.9.1
130
+ type: :development
131
+ prerelease: false
132
+ version_requirements: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - "~>"
135
+ - !ruby/object:Gem::Version
136
+ version: 0.9.1
137
+ description: Utilities to simplify Accelerated Mobile Pages (AMP)implementation in
138
+ Rails apps
139
+ email:
140
+ - shinkarenko.vi@gmail.com
141
+ executables: []
142
+ extensions: []
143
+ extra_rdoc_files: []
144
+ files:
145
+ - ".codeclimate.yml"
146
+ - ".gitignore"
147
+ - ".rspec"
148
+ - ".travis.yml"
149
+ - CODE_OF_CONDUCT.md
150
+ - Gemfile
151
+ - LICENSE.txt
152
+ - README.md
153
+ - Rakefile
154
+ - appveyor.yml
155
+ - bin/console
156
+ - bin/setup
157
+ - lib/roll/amp.rb
158
+ - lib/roll/amp/autoload.rb
159
+ - lib/roll/amp/helpers/config.reek
160
+ - lib/roll/amp/helpers/tags.rb
161
+ - lib/roll/amp/script/amp_js_tag.rb
162
+ - lib/roll/amp/style/boilerplate_style_tag.rb
163
+ - lib/roll/amp/style/boilerplate_style_tags_set.rb
164
+ - lib/roll/amp/style/compiled_stylesheet_file.rb
165
+ - lib/roll/amp/style/compiled_stylesheet_path.rb
166
+ - lib/roll/amp/style/css/boilerplate-animation.css
167
+ - lib/roll/amp/style/css/boilerplate-main.css
168
+ - lib/roll/amp/style/custom_style_tag.rb
169
+ - lib/roll/amp/style/internal_css_file.rb
170
+ - lib/roll/amp/style/noscript_tag.rb
171
+ - lib/roll/amp/style/style_tag.rb
172
+ - lib/roll/amp/style/stylesheet.rb
173
+ - lib/roll/amp/version.rb
174
+ - roll-amp.gemspec
175
+ homepage: https://github.com/roll-rails/roll-amp
176
+ licenses:
177
+ - MIT
178
+ metadata: {}
179
+ post_install_message:
180
+ rdoc_options: []
181
+ require_paths:
182
+ - lib
183
+ required_ruby_version: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: 2.2.6
188
+ required_rubygems_version: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ version: 1.8.11
193
+ requirements: []
194
+ rubyforge_project:
195
+ rubygems_version: 2.6.10
196
+ signing_key:
197
+ specification_version: 4
198
+ summary: AMP in Rails apps
199
+ test_files: []