rails_4_backports 0.1.1 → 0.2.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 +4 -4
- data/CHANGELOG.md +11 -0
- data/lib/rails_4_backports.rb +13 -7
- data/lib/rails_4_backports/file_fixtures.rb +38 -0
- data/lib/rails_4_backports/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e122f7523c46c42c1a8c1e30415f8851eafb6175
|
4
|
+
data.tar.gz: 726a74ea5f2faaca8ac0aa77838943fc03fdd7ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5ebc934324880bb7b4080cf68398a259491504dc7319405f62871e9554c391f86cefbefdc1ed99455d996852a023ed556c74d65f8cef169d03a5bfb08caa3bb
|
7
|
+
data.tar.gz: c53045afb6bcf1a7fb490ae6313c987d9b32b7178f19a617d26d6ce5602865a02b51d5de0370df3e0c9610da53154f96a51d5b3dea626271251f0cb6f2fa9bc1
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Change Log
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
|
+
This changelog adheres to [Keep a CHANGELOG](http://keepachangelog.com/).
|
5
|
+
|
6
|
+
## Unreleased
|
7
|
+
|
8
|
+
## 0.2.0
|
9
|
+
### Added
|
10
|
+
- [TT-1392] Changelog file
|
11
|
+
- [TT-2759] Backport rails file_fixture method
|
data/lib/rails_4_backports.rb
CHANGED
@@ -1,15 +1,21 @@
|
|
1
1
|
require "rails_4_backports/version"
|
2
2
|
|
3
3
|
module Rails4Backports
|
4
|
-
|
5
|
-
|
6
|
-
ActiveRecord::
|
4
|
+
if defined?(ActiveRecord)
|
5
|
+
require 'rails_4_backports/active_record_dynamic_finders'
|
6
|
+
if ::ActiveRecord::VERSION::MAJOR == 3
|
7
|
+
ActiveRecord::Base.send(:extend, ActiveRecordDynamicFinders)
|
8
|
+
end
|
7
9
|
end
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
require 'rails_4_backports/file_fixtures'
|
12
|
+
|
13
|
+
if defined?(Rails)
|
14
|
+
class Railtie < ::Rails::Railtie
|
15
|
+
config.before_initialize do |app|
|
16
|
+
require 'rails-secrets'
|
17
|
+
app.config.secret_token ||= app.secrets.secret_key_base
|
18
|
+
end
|
13
19
|
end
|
14
20
|
end
|
15
21
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# Methods backported from Rails 5:
|
2
|
+
# http://api.rubyonrails.org/classes/ActiveSupport/Testing/FileFixtures.html
|
3
|
+
module Rails4Backports
|
4
|
+
module Testing
|
5
|
+
# Adds simple access to sample files called file fixtures.
|
6
|
+
# File fixtures are normal files stored in
|
7
|
+
# <tt>ActiveSupport::TestCase.file_fixture_path</tt>.
|
8
|
+
#
|
9
|
+
# File fixtures are represented as +Pathname+ objects.
|
10
|
+
# This makes it easy to extract specific information:
|
11
|
+
#
|
12
|
+
# file_fixture("example.txt").read # get the file's content
|
13
|
+
# file_fixture("example.mp3").size # get the file size
|
14
|
+
module FileFixtures
|
15
|
+
def self.file_fixture_path=(path)
|
16
|
+
@path = path
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.file_fixture_path
|
20
|
+
@path
|
21
|
+
end
|
22
|
+
|
23
|
+
# Returns a +Pathname+ to the fixture file named +fixture_name+.
|
24
|
+
#
|
25
|
+
# Raises +ArgumentError+ if +fixture_name+ can't be found.
|
26
|
+
def self.file_fixture(fixture_name)
|
27
|
+
path = Pathname.new(File.join(file_fixture_path, fixture_name))
|
28
|
+
|
29
|
+
if path.exist?
|
30
|
+
path
|
31
|
+
else
|
32
|
+
msg = "the directory '%s' does not contain a file named '%s'"
|
33
|
+
raise ArgumentError, msg % [file_fixture_path, fixture_name]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_4_backports
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Noack
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails-secrets
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- ".gitignore"
|
77
77
|
- ".rspec"
|
78
78
|
- ".travis.yml"
|
79
|
+
- CHANGELOG.md
|
79
80
|
- Gemfile
|
80
81
|
- LICENSE.txt
|
81
82
|
- README.md
|
@@ -84,6 +85,7 @@ files:
|
|
84
85
|
- bin/setup
|
85
86
|
- lib/rails_4_backports.rb
|
86
87
|
- lib/rails_4_backports/active_record_dynamic_finders.rb
|
88
|
+
- lib/rails_4_backports/file_fixtures.rb
|
87
89
|
- lib/rails_4_backports/version.rb
|
88
90
|
- rails_4_backports.gemspec
|
89
91
|
homepage: https://github.com/sealink/rails_4_backports
|
@@ -106,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
108
|
version: '0'
|
107
109
|
requirements: []
|
108
110
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.
|
111
|
+
rubygems_version: 2.5.1
|
110
112
|
signing_key:
|
111
113
|
specification_version: 4
|
112
114
|
summary: Backports of rails 4 functionality, such as find_by and secrets.
|