lurry 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -0,0 +1,12 @@
1
+ .idea/
2
+ .bundle/
3
+ _yardoc/
4
+ coverage/
5
+ doc/
6
+ pkg/
7
+ spec/reports/
8
+ tmp/
9
+
10
+ .yardoc
11
+ Gemfile.lock
12
+ README.md
@@ -0,0 +1,7 @@
1
+ image: ruby:2.3.1
2
+
3
+ testing:
4
+ before_script:
5
+ - gem install bundler
6
+ - bundle install
7
+ script: rspec
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in lurry.gemspec
4
+ gemspec
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,2 @@
1
+ require 'lurry/version'
2
+ require 'lurry/lurry'
@@ -0,0 +1,12 @@
1
+ class Attribute
2
+ def initialize(name, block)
3
+ @name = name
4
+ @block = block
5
+ end
6
+
7
+ attr_reader :name, :block
8
+
9
+ def block_given?
10
+ !@block.nil?
11
+ end
12
+ end
@@ -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
@@ -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
@@ -0,0 +1,3 @@
1
+ class Lurry
2
+ VERSION = "0.1.0"
3
+ end
@@ -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: []