Skip to content

Commit 54d40be

Browse files
authored
Merge pull request apotonick#7 from apotonick/ruby27
test ruby 2.7
2 parents 927ecf5 + 78b7dfc commit 54d40be

File tree

15 files changed

+98
-69
lines changed

15 files changed

+98
-69
lines changed

.travis.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
language: ruby
2+
before_install: gem install bundler
3+
cache: bundler
24
rvm:
3-
- 2.3.1
4-
- 1.9.3
5-
gemfile:
6-
- Gemfile
7-
before_install:
8-
- gem install bundler
5+
- ruby-head
6+
- 2.7
7+
- 2.6
8+
- 2.5
9+
- 2.4
10+
jobs:
11+
allow_failures:
12+
- rvm: ruby-head

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2015 Nick Sutterer
1+
Copyright (c) 2015-2020 Nick Sutterer
22

33
MIT License
44

declarative.gemspec

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ Gem::Specification.new do |spec|
1212
spec.homepage = "https://github.com/apotonick/declarative"
1313
spec.license = "MIT"
1414

15-
spec.files = `git ls-files -z`.split("\x0")
16-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
16+
f.match(%r{^(test)/})
17+
end
18+
spec.test_files = spec.files.grep(%r{^(test)/})
1819
spec.require_paths = ["lib"]
1920

20-
spec.add_development_dependency "rake", "~> 10.0"
21+
spec.add_development_dependency "rake"
2122
spec.add_development_dependency "minitest"
2223
spec.add_development_dependency "minitest-line"
2324
end

lib/declarative/deep_dup.rb

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1+
# frozen_string_literal: true
2+
13
module Declarative
2-
class DeepDup
4+
module DeepDup
35
def self.call(args)
4-
return Array[*dup_items(args)] if args.is_a?(Array)
5-
return ::Hash[dup_items(args)] if args.is_a?(::Hash)
6-
args
6+
case args
7+
when Array
8+
Array[*dup_items(args)]
9+
when ::Hash
10+
::Hash[dup_items(args)]
11+
else
12+
args
13+
14+
end
715
end
816

9-
private
1017
def self.dup_items(arr)
1118
arr.to_a.collect { |v| call(v) }
1219
end

lib/declarative/defaults.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def call(name, given_options)
2222
evaluated_options = @dynamic_options.(name, given_options)
2323

2424
options = Variables.merge( @static_options, handle_array_and_deprecate(evaluated_options) )
25-
options = Variables.merge( options, handle_array_and_deprecate(given_options) ) # FIXME: given_options is not tested!
25+
Variables.merge( options, handle_array_and_deprecate(given_options) ) # FIXME: given_options is not tested!
2626
end
2727

2828
def handle_array_and_deprecate(variables)

lib/declarative/definitions.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Declarative
22
class Definitions < ::Hash
33
class Definition
4-
def initialize(name, options={}, &block)
4+
def initialize(name, options={})
55
@options = options.dup
66
@options[:name] = name.to_s
77
end
@@ -40,7 +40,7 @@ def add(name, options={}, &block)
4040
options = options[:_defaults].(name, options) if options[:_defaults] # FIXME: pipeline?
4141
base = options[:_base]
4242

43-
if options.delete(:inherit) and parent_property = get(name)
43+
if options.delete(:inherit) and (parent_property = get(name))
4444
base = parent_property[:nested]
4545
options = parent_property.merge(options) # TODO: Definition#merge
4646
end

lib/declarative/heritage.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ def call(inheritor, &block)
1313
each { |cfg| call!(inheritor, cfg, &block) }
1414
end
1515

16-
private
17-
def call!(inheritor, cfg)
18-
yield cfg if block_given? # allow messing around with recorded arguments.
19-
20-
inheritor.send(cfg[:method], *cfg[:args], &cfg[:block])
21-
end
22-
2316
module DSL
2417
def heritage
2518
@heritage ||= Heritage.new
@@ -41,5 +34,12 @@ def included(mod)
4134
heritage.(mod)
4235
end
4336
end
37+
38+
private
39+
def call!(inheritor, cfg)
40+
yield cfg if block_given? # allow messing around with recorded arguments.
41+
42+
inheritor.send(cfg[:method], *cfg[:args], &cfg[:block])
43+
end
4444
end
4545
end

lib/declarative/schema.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ def definition_class # TODO: test me.
4545

4646
private
4747
def build_definition(name, options={}, &block)
48-
default_options = {}
49-
default_options[:_base] = default_nested_class
50-
default_options[:_defaults] = _defaults
48+
default_options = {
49+
_base: default_nested_class,
50+
_defaults: _defaults
51+
}
5152
default_options[:_nested_builder] = nested_builder if block
5253

5354
# options = options.merge( Defaults.wrap_arrays(options) )

lib/declarative/testing.rb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1+
# frozen_string_literal: true
2+
13
module Declarative
24
def self.Inspect(obj)
35
string = obj.inspect
46

57
if obj.is_a?(Proc)
6-
elements = string.split("/")
8+
elements = string.split('/')
79
string = "#{elements.first}#{elements.last}"
810
end
9-
string.gsub(/0x\w+/, "")
11+
string.gsub(/0x\w+/, '')
1012
end
1113

1214
module Inspect
1315
def inspect
1416
string = super
1517
if is_a?(Proc)
16-
elements = string.split("/")
18+
elements = string.split('/')
1719
string = "#{elements.first}#{elements.last}"
1820
end
19-
string.gsub(/0x\w+/, "")
21+
string.gsub(/0x\w+/, '')
2022
end
2123

2224
module Schema
@@ -29,15 +31,15 @@ def inspect
2931

3032
module Definitions::Inspect
3133
def inspect
32-
each { |dfn|
34+
each do |dfn|
3335
dfn.extend(Declarative::Inspect)
3436

35-
if dfn[:nested] && dfn[:nested].is_a?(Declarative::Schema::DSL)
37+
if dfn[:nested]&.is_a?(Declarative::Schema::DSL)
3638
dfn[:nested].extend(Declarative::Inspect::Schema)
3739
else
38-
dfn[:nested].extend(Declarative::Definitions::Inspect) if dfn[:nested]
40+
dfn[:nested]&.extend(Declarative::Definitions::Inspect)
3941
end
40-
}
42+
end
4143
super
4244
end
4345

lib/declarative/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Declarative
2-
VERSION = "0.0.10"
2+
VERSION = "0.0.20"
33
end

0 commit comments

Comments
 (0)