normalize_line_endings 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 111500040a787c75f435a4815c10c724217e5bd616eccbfed0cd57f55dabcf54
4
+ data.tar.gz: e4724b49e12cec206123697d5f3384324a8a4405b07f2dd8ac77f394c5f8ac5d
5
+ SHA512:
6
+ metadata.gz: 0c25b1cf2efbe484a3d7168c0f6da28e5c3c00189962d04d5d81c77d1bc07687c2b0fb59c9880d6c54c6f2e604dabc85eaaf26364d3e44b5d7e49a833910bf71
7
+ data.tar.gz: d392596f8bed83b093226d473d3d583b872ce0bf5bfd2880d06791bf3e2f3490dce70aff6513e59cbfa5b5b3b3d47fbe839462288d90d8f42e775d4d36b3964c
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -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 alistairm@nulogy.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,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in normalize_line_endings.gemspec
6
+ gemspec
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # NormalizeLineEndings
2
+
3
+ Converts \r\n characters to \n for attributes on ActiveModel-like entities.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'normalize_line_endings'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install normalize_line_endings
20
+
21
+ ## Usage
22
+
23
+ Run tests by cd'ing to the root of the gem directory and running `rake test`
24
+
25
+ ```
26
+ class Post < ApplicationRecord
27
+ normalize_line_endings :only => [:foo, :bar, :biz]
28
+ end
29
+ ```
30
+
31
+ See the tests for more example usages.
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require "rake"
4
+ require "rake/testtask"
5
+ require "rdoc/task"
6
+
7
+ desc "Default: run unit tests."
8
+ task default: :test
9
+
10
+ desc "Test the stripattributes plugin."
11
+ Rake::TestTask.new(:test) do |t|
12
+ t.libs << "lib"
13
+ t.pattern = "test/**/*_test.rb"
14
+ end
15
+
16
+ desc "Generate documentation for the stripattributes plugin."
17
+ Rake::RDocTask.new(:rdoc) do |rdoc|
18
+ rdoc.rdoc_dir = "rdoc"
19
+ rdoc.title = "Stripattributes"
20
+ rdoc.options << "--line-numbers" << "--inline-source"
21
+ rdoc.rdoc_files.include("README.rdoc")
22
+ rdoc.rdoc_files.include("lib/**/*.rb")
23
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "normalize_line_endings"
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,40 @@
1
+ require "normalize_line_endings/version"
2
+
3
+ require "active_support"
4
+
5
+ module NormalizeLineEndings
6
+ extend ActiveSupport::Concern
7
+
8
+ module ClassMethods
9
+ def normalize_line_endings(*opts)
10
+ @normalize_line_endings_options = opts.first.is_a?(Hash) ? opts.first : { only: opts } unless opts.empty?
11
+
12
+ class << self; attr_reader :normalize_line_endings_options; end
13
+
14
+ before_validation { |record| record.normalize_line_endings }
15
+ end
16
+ alias_method :normalize_line_endings_for, :normalize_line_endings
17
+ end
18
+
19
+ def normalize_line_endings
20
+ attrs_for_normalized_line_endings.each do |attr, value|
21
+ send("#{attr}=", value.gsub(/\r\n/, "\n")) if value.respond_to?(:gsub)
22
+ end
23
+ end
24
+
25
+ def attrs_for_normalized_line_endings
26
+ options = self.class.normalize_line_endings_options
27
+
28
+ return attributes if options.blank?
29
+
30
+ if options[:except]
31
+ except = Array(options[:except]).flatten.map(&:to_s)
32
+
33
+ attributes.stringify_keys.except(*except)
34
+ elsif options[:only]
35
+ only = Array(options[:only]).flatten.map(&:to_s)
36
+
37
+ attributes.stringify_keys.slice(*only)
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,3 @@
1
+ module NormalizeLineEndings
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,31 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "normalize_line_endings/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "normalize_line_endings"
8
+ spec.version = NormalizeLineEndings::VERSION
9
+ spec.authors = ["Matt Briggs","Alistair McKinnell"]
10
+ spec.email = ["alistairm@nulogy.com"]
11
+
12
+ spec.summary = %q(Converts \r\n characters to \n for attributes on ActiveModel-like entities.)
13
+ spec.description = %q(Converts \r\n characters to \n for attributes on ActiveModel-like entities.)
14
+ spec.homepage = "https://github.com/nulogy/normalize_line_endings"
15
+ spec.license = "MIT"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(/^spec/) }
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_dependency "activesupport", ">= 5.0", "< 6.0"
27
+
28
+ spec.add_development_dependency "activemodel", ">= 5.0", "< 6.0"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency "rspec", "~> 3.0"
31
+ end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: normalize_line_endings
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Matt Briggs
8
+ - Alistair McKinnell
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2019-01-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '5.0'
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: '6.0'
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ version: '5.0'
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '6.0'
34
+ - !ruby/object:Gem::Dependency
35
+ name: activemodel
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '5.0'
41
+ - - "<"
42
+ - !ruby/object:Gem::Version
43
+ version: '6.0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '5.0'
51
+ - - "<"
52
+ - !ruby/object:Gem::Version
53
+ version: '6.0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: rake
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '10.0'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '10.0'
68
+ - !ruby/object:Gem::Dependency
69
+ name: rspec
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '3.0'
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.0'
82
+ description: Converts \r\n characters to \n for attributes on ActiveModel-like entities.
83
+ email:
84
+ - alistairm@nulogy.com
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - ".gitignore"
90
+ - ".rspec"
91
+ - CODE_OF_CONDUCT.md
92
+ - Gemfile
93
+ - README.md
94
+ - Rakefile
95
+ - bin/console
96
+ - bin/setup
97
+ - lib/normalize_line_endings.rb
98
+ - lib/normalize_line_endings/version.rb
99
+ - normalize_line_endings.gemspec
100
+ homepage: https://github.com/nulogy/normalize_line_endings
101
+ licenses:
102
+ - MIT
103
+ metadata: {}
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 2.7.7
121
+ signing_key:
122
+ specification_version: 4
123
+ summary: Converts \r\n characters to \n for attributes on ActiveModel-like entities.
124
+ test_files: []