lurry 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.gitlab-ci.yml +7 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/lurry.rb +2 -0
- data/lib/lurry/attribute.rb +12 -0
- data/lib/lurry/attributes.rb +23 -0
- data/lib/lurry/lurry.rb +50 -0
- data/lib/lurry/version.rb +3 -0
- data/lurry.gemspec +35 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 79d6294c46c7e48361c433f0757b2f369548d6b0
|
4
|
+
data.tar.gz: 376e25f13e4e9729e519d486bcde420f63f98860
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 438a3505b7d995813c80e7e89fac3fa72b1c91e38ba1a82871f5bba4a29df59b52d24bfa8198bd23f77f524064d9719640df96f68494b90a268eab8acad9a9d2
|
7
|
+
data.tar.gz: b69eafc51ec7a9a0ebb52e799a2cf0f83da222ba37ca0bebb5fbc31f4e6648398e06436fad21fb282713f29c2d553199dfcd6690c75bed399cb51798556e41a2
|
data/.gitignore
ADDED
data/.gitlab-ci.yml
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "lurry"
|
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
|
data/bin/setup
ADDED
data/lib/lurry.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
class Attributes
|
2
|
+
def initialize
|
3
|
+
@attributes = Array.new
|
4
|
+
end
|
5
|
+
|
6
|
+
def add(name, block)
|
7
|
+
attribute = Attribute.new(name, block)
|
8
|
+
if @attributes.map{ |attr| attr.name }.include? name
|
9
|
+
raise ArgumentError.new("Double #{name} attribute")
|
10
|
+
else
|
11
|
+
@attributes << attribute
|
12
|
+
end
|
13
|
+
self
|
14
|
+
end
|
15
|
+
|
16
|
+
def all
|
17
|
+
@attributes
|
18
|
+
end
|
19
|
+
|
20
|
+
def print
|
21
|
+
@attributes.map { |attribute| attribute.name }
|
22
|
+
end
|
23
|
+
end
|
data/lib/lurry/lurry.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
class Lurry
|
2
|
+
require 'lurry/attribute'
|
3
|
+
require 'lurry/attributes'
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def hash(object)
|
8
|
+
execute object
|
9
|
+
end
|
10
|
+
|
11
|
+
def object
|
12
|
+
@object
|
13
|
+
end
|
14
|
+
|
15
|
+
def attribute(name, &block)
|
16
|
+
add_attr name, block
|
17
|
+
end
|
18
|
+
|
19
|
+
def attributes(*names, &block)
|
20
|
+
names.each { |name| add_attr name, block }
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def attrs
|
26
|
+
@attributes ? @attributes.all : []
|
27
|
+
end
|
28
|
+
|
29
|
+
def add_attr(name, block)
|
30
|
+
@attributes = Attributes.new unless @attributes
|
31
|
+
@attributes.add name, block
|
32
|
+
end
|
33
|
+
|
34
|
+
def execute(object)
|
35
|
+
@object = object
|
36
|
+
result = Hash.new
|
37
|
+
attrs.each { |attr| result[attr.name] = eval_value attr }
|
38
|
+
result
|
39
|
+
end
|
40
|
+
|
41
|
+
def eval_value( attr )
|
42
|
+
if attr.block_given?
|
43
|
+
attr.block.call
|
44
|
+
else
|
45
|
+
object[ attr.name ]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
data/lurry.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'lurry/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'lurry'
|
8
|
+
spec.version = Lurry::VERSION
|
9
|
+
spec.authors = ['Eugene Yak']
|
10
|
+
spec.email = ['GeneAYak@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'Fast and easy hash mutation'
|
13
|
+
spec.description = 'Fast and easy hash mutation'
|
14
|
+
spec.homepage = 'https://gitlab.com/yak/lurry'
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
# if spec.respond_to?(:metadata)
|
19
|
+
# spec.metadata['allowed_push_host'] = 'https://gitlab.com/'
|
20
|
+
# else
|
21
|
+
# raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
|
22
|
+
# end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
25
|
+
f.match(%r{^(test|spec|features)/})
|
26
|
+
end
|
27
|
+
spec.bindir = "exe"
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ['lib']
|
30
|
+
|
31
|
+
spec.add_development_dependency 'bundler', '~> 1.13'
|
32
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
33
|
+
spec.add_development_dependency 'rspec', '~> 3.5'
|
34
|
+
spec.add_development_dependency 'simplecov', '~> 0.12.0'
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lurry
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Eugene Yak
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-11-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.12.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.12.0
|
69
|
+
description: Fast and easy hash mutation
|
70
|
+
email:
|
71
|
+
- GeneAYak@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".gitlab-ci.yml"
|
78
|
+
- ".rspec"
|
79
|
+
- Gemfile
|
80
|
+
- Rakefile
|
81
|
+
- bin/console
|
82
|
+
- bin/setup
|
83
|
+
- lib/lurry.rb
|
84
|
+
- lib/lurry/attribute.rb
|
85
|
+
- lib/lurry/attributes.rb
|
86
|
+
- lib/lurry/lurry.rb
|
87
|
+
- lib/lurry/version.rb
|
88
|
+
- lurry.gemspec
|
89
|
+
homepage: https://gitlab.com/yak/lurry
|
90
|
+
licenses: []
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.5.1
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: Fast and easy hash mutation
|
112
|
+
test_files: []
|