rails_amp 0.1.4 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 41090d7cbfa0a001a9e1648ae23cd8597f10f571
4
- data.tar.gz: 93b900a423f87244c74ac738b4cff363638858c8
3
+ metadata.gz: 0ad444c3a645c549cba96965c0ab6c46c93e80a4
4
+ data.tar.gz: 87e3891260c56b7034b8918815ec99e792a53efe
5
5
  SHA512:
6
- metadata.gz: 42eeb0062a86bb316413c3fd9ab6ecef11ca34ba6d7f21fe4b47bfe6932f4db24dfa13ecfd3726f732ec4b3d05270ca4314675aede6fb529dc758037d2afeced
7
- data.tar.gz: c08fe3e59be882193b4e9f6ba6b3be994aeb54607e34173dff1248294ca5a7f0e390348a0750c57e3813160b0a58d8cb1d2cced47a9318c4ac833e84949c0c3c
6
+ metadata.gz: 36f2877b2a096be0eb2a5cc83f7eaf1c77e90c8efa6a711f516df2f0a578f9e84bbe1bcffaa53e835e0ab9762749a1eaf715280a2396261bb7b4354f4c52a59e
7
+ data.tar.gz: 28f6848404a59db9e7f6fcdc8798bdcb7652b935b7430798a52743bf2531352a53aa01bf44a158e320aeabb813010d632b8985f0e9f39f2d8b8af25e5b11e8aa
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ sudo: false
3
+ rvm:
4
+ - 2.3.1
5
+ - 2.2.3
6
+ gemfile:
7
+ - Gemfile
8
+ - gemfiles/Gemfile-rails.4.2.x
9
+ - gemfiles/Gemfile-rails.4.1.x
10
+ script:
11
+ - bundle exec rspec spec
12
+ notifications:
13
+ email: false
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # RailsAmp
1
+ # RailsAmp [![Build Status](https://travis-ci.org/takafumir/rails_amp.svg?branch=master)](https://travis-ci.org/takafumir/rails_amp)
2
2
 
3
3
  RailsAmp is a Ruby on Rails plugin that makes it easy to build views for AMP(Accelerated Mobile Pages).
4
4
 
@@ -1,4 +1,4 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem 'rails', '~> 4.1.0'
4
3
  gemspec path: '../'
4
+ gem 'rails', '~> 4.1.0'
@@ -1,4 +1,4 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem 'rails', '~> 4.2.0'
4
3
  gemspec path: '../'
4
+ gem 'rails', '~> 4.2.0'
@@ -1,3 +1,5 @@
1
+ require 'yaml'
2
+
1
3
  module RailsAmp
2
4
  class Config
3
5
  # Return the current format, default is ''. The only configuration value that is not global.
@@ -1,3 +1,3 @@
1
1
  module RailsAmp
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
@@ -62,14 +62,14 @@ describe UsersController do
62
62
  it 'has normal image tag' do
63
63
  get 'index'
64
64
  expect(image_tag('rails.png', {size: '30x20', border: '0'})).to match(
65
- %r(<img border="0" src="/(images|assets)/rails-?\w*?.jpg" alt="Rails" width="30" height="20" />)
65
+ %r{(<img border="0" src="/(images|assets)/rails-?\w*?.png" alt="Rails" width="30" height="20" />)|(<img alt="Rails" border="0" height="20" src="/(images|assets)/rails-?\w*?.png" width="30" />)}
66
66
  )
67
67
  expect(image_tag('rails.png')).to match(
68
- %r(<img src="/(images|assets)/rails-?\w*?.jpg" alt="Rails" />)
68
+ %r{(<img src="/(images|assets)/rails-?\w*?.png" alt="Rails" />)|(<img alt="Rails" src="/(images|assets)/rails-?\w*?.png" />)}
69
69
  )
70
70
  # According to dummy app default view `home/_amp_info`
71
71
  expect(response.body).to match(
72
- %r(<img border="0" src="/(images|assets)/rails-?\w*?.jpg" alt="Rails" width="30" height="20" />)
72
+ %r{(<img border="0" src="/(images|assets)/rails-?\w*?.png" alt="Rails" width="30" height="20" />)|(<img alt="Rails" border="0" height="20" src="/(images|assets)/rails-?\w*?.png" width="30" />)}
73
73
  )
74
74
  end
75
75
  end
@@ -83,37 +83,18 @@ describe UsersController do
83
83
  it 'has amp-img tag' do
84
84
  get 'index', format: RailsAmp.default_format.to_s
85
85
  expect(image_tag('rails.png', {size: '30x20', border: '0'})).to match(
86
- %r(<amp-img src="/(images|assets)/rails-?\w*?.jpg" alt="Rails" layout="fixed" width="30" height="20" /></amp-img>)
86
+ %r{(<amp-img src="/(images|assets)/rails-?\w*?.png" alt="Rails" width="30" height="20" layout="fixed" /></amp-img>)|(<amp-img alt="Rails" height="20" layout="fixed" src="/(images|assets)/rails-?\w*?.png" width="30" /></amp-img>)}
87
87
  )
88
- # `width="400" height="400"` is removed because request.base_url returns dummy url for test.
89
88
  expect(image_tag('rails.png')).to match(
90
- %r(<amp-img src="/(images|assets)/rails-?\w*?.jpg" alt="Rails" layout="fixed" /></amp-img>)
89
+ %r{(<amp-img src="/(images|assets)/rails-?\w*?.png" alt="Rails" width="50" height="64" layout="fixed" /></amp-img>)|(<amp-img alt="Rails" height="64" layout="fixed" src="/(images|assets)/rails-?\w*?.png" width="50" /></amp-img>)}
91
90
  )
92
91
  # According to dummy app default view `home/_amp_info`
93
92
  expect(response.body).to match(
94
- %r(<amp-img src="/(images|assets)/rails-?\w*?.jpg" alt="Rails" layout="fixed" width="30" height="20" /></amp-img>)
93
+ %r{(<amp-img src="/(images|assets)/rails-?\w*?.png" alt="Rails" width="30" height="20" layout="fixed" /></amp-img>)|(<amp-img alt="Rails" height="20" layout="fixed" src="/(images|assets)/rails-?\w*?.png" width="30" /></amp-img>)}
95
94
  )
96
95
  end
97
96
  end
98
97
  end
99
-
100
- context '#show GET' do
101
- let(:user) { User.create(name: 'Taro', email: 'taro@example.com') }
102
-
103
- context 'with html format' do
104
- it 'is not renderable by amp' do
105
- get 'show', params: {id: user.id}
106
- expect(amp_renderable?).to eq false
107
- end
108
- end
109
-
110
- context 'with amp format' do
111
- it 'is renderable by amp' do
112
- get 'show', format: RailsAmp.default_format.to_s, params: {id: user.id}
113
- expect(amp_renderable?).to eq true
114
- end
115
- end
116
- end
117
98
  end
118
99
 
119
100
  describe HomeController do
@@ -135,7 +116,7 @@ describe HomeController do
135
116
  it 'is not renderable by amp' do
136
117
  expect do
137
118
  get 'help', format: RailsAmp.default_format.to_s
138
- end.to raise_error(ActionController::UnknownFormat)
119
+ end.to raise_error(StandardError) # ActionView::MissingTemplate or ActionController::UnknownFormat
139
120
  end
140
121
  end
141
122
  end
@@ -1,7 +1,6 @@
1
1
  // Action Cable provides the framework to deal with WebSockets in Rails.
2
2
  // You can generate new channels where WebSocket features live using the rails generate channel command.
3
3
  //
4
- //= require action_cable
5
4
  //= require_self
6
5
  //= require_tree ./channels
7
6
 
@@ -1,11 +1,9 @@
1
1
  # Just for test.
2
2
  class UsersController < ApplicationController
3
3
  def index
4
- @users = User.all
5
4
  end
6
5
 
7
6
  def show
8
- @user = User.find(params[:id])
9
7
  end
10
8
 
11
9
  def new
@@ -1,11 +1,5 @@
1
1
  <%# Just for test. %>
2
2
  <h1>Users List</h1>
3
- <% @users.each do |user| %>
4
- <p>id: <%= user.id %></p>
5
- <p>name: <%= user.name %></p>
6
- <p>email: <%= user.email %></p>
7
- <hr />
8
- <% end %>
9
3
 
10
4
  <%# Just for test. %>
11
5
  <%= render 'home/amp_info' %>
@@ -1,7 +1,4 @@
1
1
  <%# Just for test. %>
2
2
  <h1>User Profile</h1>
3
- <p>id: <%= @user.id %></p>
4
- <p>name: <%= @user.name %></p>
5
- <p>email: <%= @user.email %></p>
6
3
 
7
4
  <%= render 'home/amp_info' %>
@@ -5,8 +5,8 @@ require "active_record/railtie"
5
5
  require "action_controller/railtie"
6
6
  require "action_view/railtie"
7
7
  require "action_mailer/railtie"
8
- require "active_job/railtie"
9
- require "action_cable/engine"
8
+ # require "active_job/railtie"
9
+ # require "action_cable/engine"
10
10
  # require "rails/test_unit/railtie"
11
11
  require "sprockets/railtie"
12
12
 
@@ -13,10 +13,10 @@ Rails.application.configure do
13
13
  config.eager_load = false
14
14
 
15
15
  # Configure public file server for tests with Cache-Control for performance.
16
- config.public_file_server.enabled = true
17
- config.public_file_server.headers = {
18
- 'Cache-Control' => 'public, max-age=3600'
19
- }
16
+ # config.public_file_server.enabled = true
17
+ # config.public_file_server.headers = {
18
+ # 'Cache-Control' => 'public, max-age=3600'
19
+ # }
20
20
 
21
21
  # Show full error reports and disable caching.
22
22
  config.consider_all_requests_local = true
@@ -27,7 +27,7 @@ Rails.application.configure do
27
27
 
28
28
  # Disable request forgery protection in test environment.
29
29
  config.action_controller.allow_forgery_protection = false
30
- config.action_mailer.perform_caching = false
30
+ # config.action_mailer.perform_caching = false
31
31
 
32
32
  # Tell Action Mailer not to deliver emails to the real world.
33
33
  # The :test delivery method accumulates sent emails in the
@@ -5,20 +5,20 @@
5
5
  # Read the Guide for Upgrading Ruby on Rails for more info on each option.
6
6
 
7
7
  # Enable per-form CSRF tokens. Previous versions had false.
8
- Rails.application.config.action_controller.per_form_csrf_tokens = true
8
+ # Rails.application.config.action_controller.per_form_csrf_tokens = true
9
9
 
10
10
  # Enable origin-checking CSRF mitigation. Previous versions had false.
11
- Rails.application.config.action_controller.forgery_protection_origin_check = true
11
+ # Rails.application.config.action_controller.forgery_protection_origin_check = true
12
12
 
13
13
  # Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
14
14
  # Previous versions had false.
15
- ActiveSupport.to_time_preserves_timezone = true
15
+ # ActiveSupport.to_time_preserves_timezone = true
16
16
 
17
17
  # Require `belongs_to` associations by default. Previous versions had false.
18
- Rails.application.config.active_record.belongs_to_required_by_default = true
18
+ # Rails.application.config.active_record.belongs_to_required_by_default = true
19
19
 
20
20
  # Do not halt callback chains when a callback returns false. Previous versions had true.
21
- ActiveSupport.halt_callback_chains_on_return_false = false
21
+ # ActiveSupport.halt_callback_chains_on_return_false = false
22
22
 
23
23
  # Configure SSL options to enable HSTS with subdomains. Previous versions had false.
24
- Rails.application.config.ssl_options = { hsts: { subdomains: true } }
24
+ # Rails.application.config.ssl_options = { hsts: { subdomains: true } }
@@ -5,7 +5,7 @@
5
5
 
6
6
  # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
7
  ActiveSupport.on_load(:action_controller) do
8
- wrap_parameters format: [:json]
8
+ wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9
9
  end
10
10
 
11
11
  # To enable root element in JSON for ActiveRecord objects.
@@ -1,4 +1,4 @@
1
- class CreateUsers < ActiveRecord::Migration[5.0]
1
+ class CreateUsers < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :users do |t|
4
4
  t.string :name
@@ -15,8 +15,8 @@ ActiveRecord::Schema.define(version: 20170130074559) do
15
15
  create_table "users", force: :cascade do |t|
16
16
  t.string "name"
17
17
  t.string "email"
18
- t.datetime "created_at", null: false
19
- t.datetime "updated_at", null: false
18
+ t.datetime "created_at"
19
+ t.datetime "updated_at"
20
20
  end
21
21
 
22
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_amp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takafumi Yamano
@@ -75,6 +75,7 @@ extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
77
  - ".gitignore"
78
+ - ".travis.yml"
78
79
  - Gemfile
79
80
  - MIT-LICENSE
80
81
  - README.md