morph 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG +2 -0
  3. data/LICENSE +1 -1
  4. data/README.md +1 -1
  5. data/lib/morph.rb +10 -28
  6. metadata +6 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f2b8819bada6d3885cdc74db61abc8e7b71b3e15
4
- data.tar.gz: ed1a490e45a8e6a3e89019cd3d549f5b086e9c83
2
+ SHA256:
3
+ metadata.gz: e0a6b2a59ef3ddad777af1427b8156a15ebde94a8ac5d7f00ab8d53afa1ed7eb
4
+ data.tar.gz: e7405190734cd1fd61dbd8f6a8af3cc3387e9c587f3a03cbaaab520cd2eb49b5
5
5
  SHA512:
6
- metadata.gz: f629a91770fb3342b34bc11d259a3eb1a952ca3c88e3853d6ff75fbabca40abe3dcd4da4e1b5ece50bd6f61d1553c6d4e1a2feb91270d1d39b7c7480809ffce9
7
- data.tar.gz: dba929059e40edbed9f1c682b5387d85db75b85c1ea3b43e386aff253b4849042056f12c60f4fd3766c033a11cb5256f55149f3c4684b4466353bff793faba74
6
+ metadata.gz: 3d24c2be5594671ef4402e4b4d08dc9210ce9080444d4f43f111ef3de77b58004a236af71821a210fbddcefda726ff85ef69259f3661b3f2b81df4c383927741
7
+ data.tar.gz: d8d1aa076c05ad4bc74df0cd210a4c1e2cf622bf04081f277dfa7ede30594964877a5e55ff39a9f2bfbc1b0fb608f6b02c22f51a284fa1fed58dd3778de52aa1
data/CHANGELOG CHANGED
@@ -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
+
1
3
  v0.5.1. replace Fixnum with Integer to prevent deprecation warning in Ruby 2.4
2
4
 
3
5
  v0.5.0. set accessor methods when attribute value is blank, instead of ignoring
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016 Rob McKinnon
3
+ Copyright (c) 2019 Rob McKinnon
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -14,7 +14,7 @@ To use Morph:
14
14
  require 'morph'
15
15
  ```
16
16
 
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.
18
18
 
19
19
  ## Morph creating classes `from_json`
20
20
 
@@ -1,8 +1,6 @@
1
- if RUBY_VERSION >= "1.9"
2
- require 'csv'
3
- end
1
+ require 'csv'
2
+
4
3
  begin
5
- # require 'active_support'
6
4
  require 'active_support/core_ext/object/blank'
7
5
  require 'active_support/inflector'
8
6
  require 'active_support/core_ext/string/inflections'
@@ -63,11 +61,7 @@ module Chas
63
61
  end
64
62
 
65
63
  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
71
65
 
72
66
  if klass.superclass.respond_to?(:morph_attributes)
73
67
  methods += klass.superclass.morph_methods
@@ -97,9 +91,7 @@ module Chas
97
91
 
98
92
  def self.morph_method_missing object, symbol, *args
99
93
  attribute = symbol.to_s.chomp '='
100
- if RUBY_VERSION >= "1.9"
101
- attribute = attribute.to_sym
102
- end
94
+ attribute = attribute.to_sym
103
95
 
104
96
  if Object.instance_methods.include?(attribute)
105
97
  raise "'#{attribute}' is an instance_method on Object, cannot create accessor methods for '#{attribute}'"
@@ -132,7 +124,7 @@ module Chas
132
124
  end
133
125
 
134
126
  module Morph
135
- VERSION = '0.5.1' unless defined? Morph::VERSION
127
+ VERSION = '0.6.0' unless defined? Morph::VERSION
136
128
 
137
129
  class << self
138
130
  def classes
@@ -157,23 +149,13 @@ module Morph
157
149
 
158
150
  def from_csv csv, class_name, namespace=Morph
159
151
  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)
166
156
  end
157
+ objects << object
167
158
  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
177
159
  objects
178
160
  end
179
161
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: morph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob McKinnon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-20 00:00:00.000000000 Z
11
+ date: 2019-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.2
19
+ version: 4.1.11
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 2.0.2
26
+ version: 4.1.11
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description:
42
- email: rob ~@nospam@~ rubyforge.org
42
+ email: rob ~@nospam@~ movingflow
43
43
  executables: []
44
44
  extensions: []
45
45
  extra_rdoc_files:
@@ -70,8 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
72
  requirements: []
73
- rubyforge_project:
74
- rubygems_version: 2.6.4
73
+ rubygems_version: 3.0.3
75
74
  signing_key:
76
75
  specification_version: 4
77
76
  summary: Morph allows you to emerge Ruby class definitions from data or by calling