Skip to content

Commit f48d762

Browse files
authored
Merge pull request #6 from robmckinnon/ruby-2.6-update
Drop Ruby < 1.9 support
2 parents 7cfb9ce + 3ff9243 commit f48d762

7 files changed

Lines changed: 23 additions & 45 deletions

File tree

.travis.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
language: ruby
22
rvm:
3-
- 2.4.0
4-
- 2.3.1
5-
- 2.2.5
3+
- 2.6.2
4+
- 2.5.5
5+
- 2.4.5
6+
- 2.3.8
7+
- 2.2.10
68
- ruby-head
79
bundler_args: --without test
810
script: bundle exec rspec spec

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
v0.6.0. drop Ruby < 1.9 support, test against Ruby 2.5/2.6, require activesupport >= 4.1.11
2+
13
v0.5.1. replace Fixnum with Integer to prevent deprecation warning in Ruby 2.4
24

35
v0.5.0. set accessor methods when attribute value is blank, instead of ignoring

Gemfile

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,7 @@ end
66

77
group :development do
88
gem 'rspec'
9-
end
10-
11-
if RUBY_VERSION < '1.9'
12-
gem 'i18n', '0.6.11'
13-
gem 'activesupport', '~> 3.2.0'
14-
gem 'fastercsv'
15-
gem 'rake', '~> 0.9.2.2' # required for travis builds
16-
gem 'json'
17-
else
18-
gem 'activesupport'
199
gem 'rake'
2010
end
11+
12+
gem 'activesupport', ">= 4.1.11"

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2016 Rob McKinnon
3+
Copyright (c) 2019 Rob McKinnon
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ To use Morph:
1414
require 'morph'
1515
```
1616

17-
Tested to work with Ruby 1.8 - 2.3, JRuby 9, and Rubinius 3.
17+
Tested to work with Ruby 2.2 - 2.6.
1818

1919
## Morph creating classes `from_json`
2020

Rakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ spec = Gem::Specification.new do |s|
1616
s.version = Morph::VERSION
1717
s.summary = 'Morph allows you to emerge Ruby class definitions from data or by calling assignment methods.'
1818
s.author = 'Rob McKinnon'
19-
s.email = 'rob ~@nospam@~ rubyforge.org'
19+
s.email = 'rob ~@nospam@~ movingflow'
2020
s.homepage = 'https://github.com/robmckinnon/morph'
2121

2222
s.has_rdoc = true
@@ -27,7 +27,7 @@ spec = Gem::Specification.new do |s|
2727
s.files = %w(CHANGELOG LICENSE) + Dir.glob('{lib}/**/*')
2828
s.require_paths = ['lib']
2929

30-
s.add_runtime_dependency('activesupport', '>= 2.0.2')
30+
s.add_runtime_dependency('activesupport', '>= 4.1.11')
3131
s.add_development_dependency('rspec')
3232
end
3333

lib/morph.rb

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
if RUBY_VERSION >= "1.9"
2-
require 'csv'
3-
end
1+
require 'csv'
2+
43
begin
5-
# require 'active_support'
64
require 'active_support/core_ext/object/blank'
75
require 'active_support/inflector'
86
require 'active_support/core_ext/string/inflections'
@@ -63,11 +61,7 @@ def self.morph_attributes klass
6361
end
6462

6563
def self.morph_methods klass
66-
methods = if RUBY_VERSION >= "1.9"
67-
@morph_methods[klass].keys.sort
68-
else
69-
@morph_methods[klass].keys.map(&:to_s).sort
70-
end
64+
methods = @morph_methods[klass].keys.sort
7165

7266
if klass.superclass.respond_to?(:morph_attributes)
7367
methods += klass.superclass.morph_methods
@@ -97,9 +91,7 @@ def self.add_morph_attribute klass, attribute
9791

9892
def self.morph_method_missing object, symbol, *args
9993
attribute = symbol.to_s.chomp '='
100-
if RUBY_VERSION >= "1.9"
101-
attribute = attribute.to_sym
102-
end
94+
attribute = attribute.to_sym
10395

10496
if Object.instance_methods.include?(attribute)
10597
raise "'#{attribute}' is an instance_method on Object, cannot create accessor methods for '#{attribute}'"
@@ -132,7 +124,7 @@ def self.convert_to_morph_method_name label
132124
end
133125

134126
module Morph
135-
VERSION = '0.5.1' unless defined? Morph::VERSION
127+
VERSION = '0.6.0' unless defined? Morph::VERSION
136128

137129
class << self
138130
def classes
@@ -157,23 +149,13 @@ def generate_migrations object, options={}
157149

158150
def from_csv csv, class_name, namespace=Morph
159151
objects = []
160-
if !(RUBY_VERSION >= "1.9")
161-
begin
162-
require 'fastercsv'
163-
rescue LoadError
164-
puts "\nYou need to install the fastercsv gem to use Morph.from_csv() with Ruby 1.8"
165-
puts " gem install fastercsv\n"
152+
CSV.parse(csv, { :headers => true }) do |row|
153+
object = object_from_name class_name, namespace
154+
row.each do |key, value|
155+
object.morph(key, value)
166156
end
157+
objects << object
167158
end
168-
169-
csv_utility = (RUBY_VERSION >= "1.9") ? CSV : 'FasterCSV'.constantize
170-
csv_utility.parse(csv, { :headers => true }) do |row|
171-
object = object_from_name class_name, namespace
172-
row.each do |key, value|
173-
object.morph(key, value)
174-
end
175-
objects << object
176-
end
177159
objects
178160
end
179161

0 commit comments

Comments
 (0)