nevermind 0.0.1

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: 801d69d84b3ad05b15dba9d8d321c8618ab6b2ef
4
+ data.tar.gz: faf22b0eb6e66da9f35c797785fa30c9d0f90b15
5
+ SHA512:
6
+ metadata.gz: 9cb18bf0a46718c59af0cb3d26e427b71fb1bcdd409ed3b58008f94680e96fa0d7fb22c70f391a8834ea109692ea8ccee46ca1f9d891c8f103b4988e645e4175
7
+ data.tar.gz: 5ec0cbe2a1cbf2c0e1650e7ad0cf27be4d301a0946779ca3cf1fcd16d049e226eb6c74215220ebc266caef2cc8b3716c4f70c5b93ffa73490ebe158159eb9457
@@ -0,0 +1,39 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Documentation cache and generated files:
13
+ /.yardoc/
14
+ /_yardoc/
15
+ /doc/
16
+ /rdoc/
17
+
18
+ ## Environment normalisation:
19
+ /.bundle/
20
+ /lib/bundler/man/
21
+
22
+ # for a library or gem, you might want to ignore these files since the code is
23
+ # intended to run in multiple environments; otherwise, check them in:
24
+ Gemfile.lock
25
+ .ruby-version
26
+ .ruby-gemset
27
+
28
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
29
+ .rvmrc
30
+
31
+ # packages
32
+ *.bundle
33
+ *.so
34
+ *.o
35
+ *.a
36
+
37
+ # other
38
+ .idea
39
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in nevermind.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Roman Exempliarov
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # Nevermind
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'nevermind'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install nevermind
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/appelsin/nevermind/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,6 @@
1
+ require 'nevermind/version'
2
+ require 'nevermind/proto'
3
+
4
+ module Nevermind
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,41 @@
1
+ module Nevermind
2
+ class Proto
3
+ def initialize(first, second)
4
+ @first, @second = first, second
5
+ end
6
+
7
+ def where(*args)
8
+ @first.where(*args)
9
+ @second.where(*args)
10
+ end
11
+
12
+ def method_missing(method, *args, &block)
13
+ if '!' == method.to_s.last
14
+ forced_method_missing(method, *args, &block)
15
+ else
16
+ regular_method_missing(method, *args, &block)
17
+ end
18
+ end
19
+
20
+ private
21
+ # find_by, first, etc
22
+ def regular_method_missing(method, *args, &block)
23
+ found = @first.send method, *args, &block
24
+ if found.nil?
25
+ found = @second.send method, *args, &block
26
+ end
27
+ return found
28
+ end
29
+
30
+ # find_by!, first!, etc
31
+ def forced_method_missing(method, *args, &block)
32
+ begin
33
+ found = @first.send method, *args, &block
34
+ rescue
35
+ found = @second.send method, *args, &block
36
+ ensure
37
+ return found
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,5 @@
1
+ module Nevermind
2
+ class Relation
3
+
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module Nevermind
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'nevermind/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "nevermind"
8
+ spec.version = Nevermind::VERSION
9
+ spec.authors = ["Roman Exempliarov"]
10
+ spec.email = ["urvala@gmail.com"]
11
+ spec.summary = %q{Abstraction layer that allows to work with multiple models just like with one.}
12
+ spec.description = %q{In development now. Next milestone: 1. Handling a pair of models with find_by. }
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec", "~> 3.1"
24
+ spec.add_development_dependency "activerecord", "~> 4.0"
25
+ spec.add_development_dependency "sqlite3"
26
+ end
@@ -0,0 +1,7 @@
1
+ class Article < ActiveRecord::Base
2
+
3
+ end
4
+
5
+ class Video < ActiveRecord::Base
6
+
7
+ end
@@ -0,0 +1,31 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe Nevermind::Proto do
4
+ it 'passes find_by' do
5
+ posts = Nevermind::Proto.new(Article, Video)
6
+ post = posts.find_by(content: 'article')
7
+ expect(post.class).to eq Article
8
+ post = posts.find_by(content: 'video')
9
+ expect(post.class).to eq Video
10
+ end
11
+
12
+ it 'passes find_by!' do
13
+ posts = Nevermind::Proto.new(Article, Video)
14
+ post = posts.find_by!(content: 'article')
15
+ expect(post.class).to eq Article
16
+ post = posts.find_by!(content: 'video')
17
+ expect(post.class).to eq Video
18
+ end
19
+
20
+ it 'passes first' do
21
+ posts = Nevermind::Proto.new(Article, Video)
22
+ post = posts.first
23
+ expect(post.class).to satisfy { |klass| [Article, Video].include? klass }
24
+ end
25
+
26
+ it 'passes first!' do
27
+ posts = Nevermind::Proto.new(Article, Video)
28
+ post = posts.first
29
+ expect(post.class).to satisfy { |klass| [Article, Video].include? klass }
30
+ end
31
+ end
@@ -0,0 +1,18 @@
1
+ ActiveRecord::Schema.define do
2
+ self.verbose = false
3
+
4
+ create_table :articles, :force => true do |t|
5
+ t.integer :vid
6
+ t.string :content
7
+
8
+ t.timestamps
9
+ end
10
+
11
+ create_table :videos, :force => true do |t|
12
+ t.integer :vid
13
+ t.string :content
14
+
15
+ t.timestamps
16
+ end
17
+
18
+ end
@@ -0,0 +1,4 @@
1
+ 5.times do |i|
2
+ Article.create vid: i*2, content: 'article'
3
+ Video.create vid: i*2+1, content: 'video'
4
+ end
@@ -0,0 +1,8 @@
1
+ require 'active_record'
2
+ require 'nevermind'
3
+
4
+ ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
5
+
6
+ load File.dirname(__FILE__) + '/schema.rb'
7
+ require File.dirname(__FILE__) + '/models.rb'
8
+ require File.dirname(__FILE__) + '/seed.rb'
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nevermind
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Roman Exempliarov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-17 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.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '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.1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activerecord
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '4.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sqlite3
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: 'In development now. Next milestone: 1. Handling a pair of models with
84
+ find_by. '
85
+ email:
86
+ - urvala@gmail.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - lib/nevermind.rb
97
+ - lib/nevermind/proto.rb
98
+ - lib/nevermind/relation.rb
99
+ - lib/nevermind/version.rb
100
+ - nevermind.gemspec
101
+ - spec/models.rb
102
+ - spec/nevermind_proto_spec.rb
103
+ - spec/schema.rb
104
+ - spec/seed.rb
105
+ - spec/spec_helper.rb
106
+ homepage: ''
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.4.1
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Abstraction layer that allows to work with multiple models just like with
130
+ one.
131
+ test_files:
132
+ - spec/models.rb
133
+ - spec/nevermind_proto_spec.rb
134
+ - spec/schema.rb
135
+ - spec/seed.rb
136
+ - spec/spec_helper.rb