takes_macro 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ceca3174dc7ada14ebe8b672d54baac69876ae042efc298659ae682d925db71a
4
- data.tar.gz: fe5078f816994e5642038b09e27669d082637117004ade1c2e6293b2233709f3
3
+ metadata.gz: 4e316a40e16340852e1d13e80e76981c2d9904722894ce48eb2af2b85378d8df
4
+ data.tar.gz: 314c10bb6f31dae580b9d99b8365ac60403bba2a87d4eb7b514000755fc18b0c
5
5
  SHA512:
6
- metadata.gz: 3e6a8e3b1ebd32088aa71fa0e35db6c5c1a4bd4ecdba2257e35800f21149446c55551e82e3bfb39f54d7a4be4a6d8939138bbcf337b2f8e6c3e47767f92a8b1e
7
- data.tar.gz: cd686948db014474ef17c5146ce0f8d65096f208c514f16e97ff08c3c8e4e7bb9790c2f2ad7dd16bde2440509cdc6f8c06608809e6daa6ad20a996faee5b24e5
6
+ metadata.gz: 691d558719fe4bbd72c7105e6ceb6fa56138fd3c1f6e14eb0a39385d0e00d7f9c1b4e3fefd00d9956238ad745661c5cd3e4fb5cc3f7b641ed9eaad8ff83f6c9a
7
+ data.tar.gz: 3a816029d1e337d2613bf7b8b83f617a7e02ebc98c50ef4fb9751d3a6b3e606c7680dd847369fa07b6a1d00b58e05e589763dc84b54b5cbde650fc9ebf6518f4
@@ -0,0 +1,20 @@
1
+ name: Ruby
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ build:
7
+
8
+ runs-on: ubuntu-latest
9
+
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+ - name: Set up Ruby 2.6
13
+ uses: actions/setup-ruby@v1
14
+ with:
15
+ ruby-version: 2.6.x
16
+ - name: Build and test with Rake
17
+ run: |
18
+ gem install bundler
19
+ bundle install --jobs 4 --retry 3
20
+ bundle exec rake
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # TakesMacro
2
2
 
3
+ ![ci badge](https://github.com/tonsser/takes_macro/workflows/Ruby/badge.svg "ci badge")
4
+
5
+
3
6
  [attr_extras][] is a **great** gem that lets you remove most of the boilerplate needed for creating different types of initializers in Ruby.
4
7
 
5
8
  This gem contains a reimplementation of `pattr_initialize` from attr_extras that is much faster. If you're using attr_extras, but the only feature of it you're using is `pattr_initialize` then this gem is for you.
@@ -23,9 +26,11 @@ Run `bundle exec ruby benchmarks/takes_macro_vs_attr_extras.rb` to see how much
23
26
  875.721k (± 5.8%) i/s - 4.424M in 5.071249s
24
27
 
25
28
  Comparison:
26
- takes_macro: 1208748.5 i/s
27
- hand written initializer: 875721.1 i/s - 1.38x slower
28
- attr_extras: 169352.8 i/s - 7.14x slower
29
+ takes_macro: 1208748.5 i/s
30
+ hand written initializer: 875721.1 i/s - 1.38x slower
31
+ attr_extras: 169352.8 i/s - 7.14x slower
32
+
33
+ The initializer generated by `takes` is faster than the hand written version because the `takes` version uses an options hash, and the hand written version uses keyword arguments, which are a bit slower. You can see the exact code for the benchmark [here](https://github.com/tonsser/takes_macro/blob/master/benchmarks/takes_macro_vs_attr_extras.rb).
29
34
 
30
35
  ## How it works
31
36
 
data/lib/takes_macro.rb CHANGED
@@ -20,10 +20,11 @@ module TakesMacro
20
20
  positional_args,
21
21
  ]
22
22
 
23
- if keyword_args.any?
23
+ if keyword_args.one? && !keyword_args.first.include?("!")
24
+ args_code << "options = {}"
25
+ elsif keyword_args.any?
24
26
  args_code << "options"
25
27
  end
26
-
27
28
  args_code = args_code.flatten.compact.join(", ")
28
29
 
29
30
  bind_positional_args_code = positional_args.map do |arg|
@@ -1,3 +1,3 @@
1
1
  module TakesMacro
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: takes_macro
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Pedersen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-10 00:00:00.000000000 Z
11
+ date: 2020-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -87,6 +87,7 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
+ - ".github/workflows/ruby.yml"
90
91
  - ".gitignore"
91
92
  - ".travis.yml"
92
93
  - Gemfile
@@ -117,8 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
118
  - !ruby/object:Gem::Version
118
119
  version: '0'
119
120
  requirements: []
120
- rubyforge_project:
121
- rubygems_version: 2.7.3
121
+ rubygems_version: 3.0.3
122
122
  signing_key:
123
123
  specification_version: 4
124
124
  summary: Remove boilerplate for writing initializers