rails_extras 0.0.1 → 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.
@@ -0,0 +1,36 @@
1
+ class RailsExtras
2
+ module Helpers
3
+ module Tag
4
+ def add_tag(name=nil, options={}, &block)
5
+ if block_given?
6
+ if block.arity == 1
7
+ result = ActiveSupport::SafeBuffer.new
8
+ def result.space(text)
9
+ self << text
10
+ self << ' '
11
+ end
12
+ def result.add(text)
13
+ self << text
14
+ end
15
+ block.call(result)
16
+ if name
17
+ content_tag(name, options) do
18
+ result
19
+ end
20
+ else
21
+ result
22
+ end
23
+ else
24
+ if name
25
+ content_tag(name, options) do
26
+ block.call
27
+ end
28
+ else
29
+ block.call
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -1,3 +1,3 @@
1
- module RailsExtras
2
- VERSION = "0.0.1"
1
+ class RailsExtras
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/rails_extras.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require "rails_extras/version"
2
- require "application_helper"
3
2
 
4
- module RailsExtras
3
+ class RailsExtras
5
4
 
6
5
  end
data/rails_extras.gemspec CHANGED
@@ -20,5 +20,6 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency 'bundler', '~> 1.3'
22
22
  spec.add_development_dependency 'rake'
23
+ spec.add_development_dependency 'rspec-rails', '>= 2.0.0'
23
24
  spec.add_dependency 'rails', '>= 3.0.0'
24
25
  end
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
File without changes
@@ -0,0 +1,4 @@
1
+ module ApplicationHelper
2
+ include RailsExtras::Helpers::Tag
3
+
4
+ end
@@ -0,0 +1,3 @@
1
+ module DummyHelper
2
+ # extend ApplicationHelper
3
+ end
File without changes
File without changes
@@ -0,0 +1,9 @@
1
+ class DummyModel
2
+ def name
3
+ "example name"
4
+ end
5
+
6
+ def id
7
+ 123
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
6
+ <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,12 @@
1
+ #require 'rails/all'
2
+ require "action_controller/railtie"
3
+ require "action_mailer/railtie"
4
+ require "sprockets/railtie"
5
+ # Require the gems listed in Gemfile, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Bundler.require(:default, Rails.env)
8
+
9
+ module Dummy
10
+ class Application < Rails::Application
11
+ end
12
+ end
@@ -0,0 +1,4 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the Rails application.
5
+ Dummy::Application.initialize!
@@ -0,0 +1,29 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Do not eager load code on boot.
10
+ config.eager_load = false
11
+
12
+ # Show full error reports and disable caching.
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send.
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ # Print deprecation notices to the Rails logger.
20
+ config.active_support.deprecation = :log
21
+
22
+ # Raise an error on page load if there are pending migrations
23
+ config.active_record.migration_error = :page_load
24
+
25
+ # Debug mode disables concatenation and preprocessing of assets.
26
+ # This option may cause significant delays in view rendering with a large
27
+ # number of complex assets.
28
+ config.assets.debug = true
29
+ end
@@ -0,0 +1,80 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # Code is not reloaded between requests.
5
+ config.cache_classes = true
6
+
7
+ # Eager load code on boot. This eager loads most of Rails and
8
+ # your application in memory, allowing both thread web servers
9
+ # and those relying on copy on write to perform better.
10
+ # Rake tasks automatically ignore this option for performance.
11
+ config.eager_load = true
12
+
13
+ # Full error reports are disabled and caching is turned on.
14
+ config.consider_all_requests_local = false
15
+ config.action_controller.perform_caching = true
16
+
17
+ # Enable Rack::Cache to put a simple HTTP cache in front of your application
18
+ # Add `rack-cache` to your Gemfile before enabling this.
19
+ # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
20
+ # config.action_dispatch.rack_cache = true
21
+
22
+ # Disable Rails's static asset server (Apache or nginx will already do this).
23
+ config.serve_static_assets = false
24
+
25
+ # Compress JavaScripts and CSS.
26
+ config.assets.js_compressor = :uglifier
27
+ # config.assets.css_compressor = :sass
28
+
29
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
30
+ config.assets.compile = false
31
+
32
+ # Generate digests for assets URLs.
33
+ config.assets.digest = true
34
+
35
+ # Version of your assets, change this if you want to expire all your assets.
36
+ config.assets.version = '1.0'
37
+
38
+ # Specifies the header that your server uses for sending files.
39
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
40
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
41
+
42
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
43
+ # config.force_ssl = true
44
+
45
+ # Set to :debug to see everything in the log.
46
+ config.log_level = :info
47
+
48
+ # Prepend all log lines with the following tags.
49
+ # config.log_tags = [ :subdomain, :uuid ]
50
+
51
+ # Use a different logger for distributed setups.
52
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
53
+
54
+ # Use a different cache store in production.
55
+ # config.cache_store = :mem_cache_store
56
+
57
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
58
+ # config.action_controller.asset_host = "http://assets.example.com"
59
+
60
+ # Precompile additional assets.
61
+ # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
62
+ # config.assets.precompile += %w( search.js )
63
+
64
+ # Ignore bad email addresses and do not raise email delivery errors.
65
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
66
+ # config.action_mailer.raise_delivery_errors = false
67
+
68
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
69
+ # the I18n.default_locale when a translation can not be found).
70
+ config.i18n.fallbacks = true
71
+
72
+ # Send deprecation notices to registered listeners.
73
+ config.active_support.deprecation = :notify
74
+
75
+ # Disable automatic flushing of the log to improve performance.
76
+ # config.autoflush_log = false
77
+
78
+ # Use default logging formatter so that PID and timestamp are not suppressed.
79
+ config.log_formatter = ::Logger::Formatter.new
80
+ end
@@ -0,0 +1,36 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Do not eager load code on boot. This avoids loading your whole application
11
+ # just for the purpose of running a single test. If you are using a tool that
12
+ # preloads Rails for running tests, you may have to set it to true.
13
+ config.eager_load = false
14
+
15
+ # Configure static asset server for tests with Cache-Control for performance.
16
+ config.serve_static_assets = true
17
+ config.static_cache_control = "public, max-age=3600"
18
+
19
+ # Show full error reports and disable caching.
20
+ config.consider_all_requests_local = true
21
+ config.action_controller.perform_caching = false
22
+
23
+ # Raise exceptions instead of rendering exception templates.
24
+ config.action_dispatch.show_exceptions = false
25
+
26
+ # Disable request forgery protection in test environment.
27
+ config.action_controller.allow_forgery_protection = false
28
+
29
+ # Tell Action Mailer not to deliver emails to the real world.
30
+ # The :test delivery method accumulates sent emails in the
31
+ # ActionMailer::Base.deliveries array.
32
+ config.action_mailer.delivery_method = :test
33
+
34
+ # Print deprecation notices to the stderr.
35
+ config.active_support.deprecation = :stderr
36
+ end
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Configure sensitive parameters which will be filtered from the log file.
4
+ Rails.application.config.filter_parameters += [:password]
@@ -0,0 +1,12 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure your secret_key_base is kept private
11
+ # if you're sharing your code publicly.
12
+ Dummy::Application.config.secret_key_base = '11655f0443b81ff7895b50d41240a00cee3ecdc65f268ccadffd341722e50c87d099467d0f8265edec7ac9993a0f826f1b2532bb68919d5c61646ff88ec26288'
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9
+ end
10
+
11
+ # To enable root element in JSON for ActiveRecord objects.
12
+ # ActiveSupport.on_load(:active_record) do
13
+ # self.include_root_in_json = true
14
+ # end
@@ -0,0 +1,56 @@
1
+ Dummy::Application.routes.draw do
2
+ # The priority is based upon order of creation: first created -> highest priority.
3
+ # See how all your routes lay out with "rake routes".
4
+
5
+ # You can have the root of your site routed with "root"
6
+ # root 'welcome#index'
7
+
8
+ # Example of regular route:
9
+ # get 'products/:id' => 'catalog#view'
10
+
11
+ # Example of named route that can be invoked with purchase_url(id: product.id)
12
+ # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
13
+
14
+ # Example resource route (maps HTTP verbs to controller actions automatically):
15
+ # resources :products
16
+
17
+ # Example resource route with options:
18
+ # resources :products do
19
+ # member do
20
+ # get 'short'
21
+ # post 'toggle'
22
+ # end
23
+ #
24
+ # collection do
25
+ # get 'sold'
26
+ # end
27
+ # end
28
+
29
+ # Example resource route with sub-resources:
30
+ # resources :products do
31
+ # resources :comments, :sales
32
+ # resource :seller
33
+ # end
34
+
35
+ # Example resource route with more complex sub-resources:
36
+ # resources :products do
37
+ # resources :comments
38
+ # resources :sales do
39
+ # get 'recent', on: :collection
40
+ # end
41
+ # end
42
+
43
+ # Example resource route with concerns:
44
+ # concern :toggleable do
45
+ # post 'toggle'
46
+ # end
47
+ # resources :posts, concerns: :toggleable
48
+ # resources :photos, concerns: :toggleable
49
+
50
+ # Example resource route within a namespace:
51
+ # namespace :admin do
52
+ # # Directs /admin/products/* to Admin::ProductsController
53
+ # # (app/controllers/admin/products_controller.rb)
54
+ # resources :products
55
+ # end
56
+ end
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Rails.application
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7
+ # Mayor.create(name: 'Emanuel', city: cities.first)
File without changes
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe ApplicationHelper do
4
+ describe ".add_tag" do
5
+ it "should generate content for div tag" do
6
+ helper.add_tag(:div, class: 'example') { }.should eq("<div class=\"example\"></div>")
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,38 @@
1
+ require "rspec/core/formatters/base_text_formatter"
2
+
3
+ class NumericProgress < RSpec::Core::Formatters::BaseTextFormatter
4
+ def initialize(output)
5
+ @actual_example_count = 0
6
+ super(output)
7
+ end
8
+
9
+ def example_passed(example)
10
+ super(example)
11
+ print_numeric_progress
12
+ end
13
+
14
+ def example_pending(example)
15
+ super(example)
16
+ print_numeric_progress
17
+ end
18
+
19
+ def example_failed(example)
20
+ super(example)
21
+ print_numeric_progress
22
+ end
23
+
24
+ def start_dump
25
+ super()
26
+ output.puts
27
+ end
28
+
29
+ private
30
+
31
+ def print_numeric_progress
32
+ @actual_example_count += 1
33
+ output.print success_color(" Success: #{@actual_example_count - @failure_count - @pending_count}")
34
+ output.print failure_color(" Failure: #{@failure_count}")
35
+ output.print pending_color(" Pending: #{@pending_count}")
36
+ output.print default_color(" Total: #{@actual_example_count} / #{@example_count}\r")
37
+ end
38
+ end
@@ -0,0 +1,14 @@
1
+ ENV["RAILS_ENV"] ||= 'test'
2
+
3
+ require 'rails_extras'
4
+ require 'rails_extras/helpers/tag'
5
+ require ::File.expand_path('../dummy/config/environment', __FILE__)
6
+ require 'rspec/rails'
7
+
8
+ #require 'coveralls'
9
+ #Coveralls.wear!
10
+
11
+ RSpec.configure do |config|
12
+ config.color_enabled = true
13
+ config.tty = true
14
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_extras
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-05 00:00:00.000000000 Z
12
+ date: 2014-02-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -43,6 +43,22 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec-rails
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 2.0.0
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: 2.0.0
46
62
  - !ruby/object:Gem::Dependency
47
63
  name: rails
48
64
  requirement: !ruby/object:Gem::Requirement
@@ -71,10 +87,35 @@ files:
71
87
  - LICENSE.txt
72
88
  - README.md
73
89
  - Rakefile
74
- - lib/application_helper.rb
75
90
  - lib/rails_extras.rb
91
+ - lib/rails_extras/helpers/tag.rb
76
92
  - lib/rails_extras/version.rb
77
93
  - rails_extras.gemspec
94
+ - spec/dummy/app/controllers/application_controller.rb
95
+ - spec/dummy/app/controllers/concerns/.keep
96
+ - spec/dummy/app/helpers/application_helper.rb
97
+ - spec/dummy/app/helpers/dummy_helper.rb
98
+ - spec/dummy/app/models/.keep
99
+ - spec/dummy/app/models/concerns/.keep
100
+ - spec/dummy/app/models/dummy_model.rb
101
+ - spec/dummy/app/views/layouts/application.html.erb
102
+ - spec/dummy/config.ru
103
+ - spec/dummy/config/application.rb
104
+ - spec/dummy/config/boot.rb
105
+ - spec/dummy/config/environment.rb
106
+ - spec/dummy/config/environments/development.rb
107
+ - spec/dummy/config/environments/production.rb
108
+ - spec/dummy/config/environments/test.rb
109
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
110
+ - spec/dummy/config/initializers/secret_token.rb
111
+ - spec/dummy/config/initializers/session_store.rb
112
+ - spec/dummy/config/initializers/wrap_parameters.rb
113
+ - spec/dummy/config/routes.rb
114
+ - spec/dummy/db/seeds.rb
115
+ - spec/dummy/log/test.log
116
+ - spec/helpers/application_helper_spec.rb
117
+ - spec/numeric_progress.rb
118
+ - spec/spec_helper.rb
78
119
  homepage: https://github.com/raglub/rails_extras
79
120
  licenses:
80
121
  - MIT
@@ -100,4 +141,29 @@ rubygems_version: 1.8.25
100
141
  signing_key:
101
142
  specification_version: 3
102
143
  summary: This gem provides extras methods for Rails application.
103
- test_files: []
144
+ test_files:
145
+ - spec/dummy/app/controllers/application_controller.rb
146
+ - spec/dummy/app/controllers/concerns/.keep
147
+ - spec/dummy/app/helpers/application_helper.rb
148
+ - spec/dummy/app/helpers/dummy_helper.rb
149
+ - spec/dummy/app/models/.keep
150
+ - spec/dummy/app/models/concerns/.keep
151
+ - spec/dummy/app/models/dummy_model.rb
152
+ - spec/dummy/app/views/layouts/application.html.erb
153
+ - spec/dummy/config.ru
154
+ - spec/dummy/config/application.rb
155
+ - spec/dummy/config/boot.rb
156
+ - spec/dummy/config/environment.rb
157
+ - spec/dummy/config/environments/development.rb
158
+ - spec/dummy/config/environments/production.rb
159
+ - spec/dummy/config/environments/test.rb
160
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
161
+ - spec/dummy/config/initializers/secret_token.rb
162
+ - spec/dummy/config/initializers/session_store.rb
163
+ - spec/dummy/config/initializers/wrap_parameters.rb
164
+ - spec/dummy/config/routes.rb
165
+ - spec/dummy/db/seeds.rb
166
+ - spec/dummy/log/test.log
167
+ - spec/helpers/application_helper_spec.rb
168
+ - spec/numeric_progress.rb
169
+ - spec/spec_helper.rb
@@ -1,32 +0,0 @@
1
- module ApplicationHelper
2
- def add_tag(name=nil, options={}, &block)
3
- if block_given?
4
- if block.arity == 1
5
- result = ActiveSupport::SafeBuffer.new
6
- def result.space(text)
7
- self << text
8
- self << ' '
9
- end
10
- def result.add(text)
11
- self << text
12
- end
13
- block.call(result)
14
- if name
15
- content_tag(name, options) do
16
- result
17
- end
18
- else
19
- result
20
- end
21
- else
22
- if name
23
- content_tag(name, options) do
24
- block.call
25
- end
26
- else
27
- block.call
28
- end
29
- end
30
- end
31
- end
32
- end