moonshine 0.0.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.ruby-version +1 -0
- data/.travis.yml +12 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +9 -0
- data/lib/moonshine.rb +7 -0
- data/lib/moonshine/base.rb +24 -0
- data/lib/moonshine/filter.rb +4 -0
- data/lib/moonshine/version.rb +3 -0
- data/moonshine.gemspec +28 -0
- data/spec/lib/moonshine/base_spec.rb +49 -0
- data/spec/lib/moonshine/version_spec.rb +8 -0
- data/spec/test_helper.rb +9 -0
- metadata +132 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0c67b01e14a12bfb081d480144382ff66bd92390
|
4
|
+
data.tar.gz: c80bc255a367700bf3b8882cb6bf27330a70d190
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fab4fd9c04bfc441540a94e006249d45a8d88f4ea92b6b12a5b04536d5f2670a048b0d6f8a0bb6df0ff83217d7102de998a82997cc4d3f74418333cf21646aae
|
7
|
+
data.tar.gz: 8fabac3d0efeaa17d3b345446a19b27aee434d69b56ab0cd0050ed24cb86c4a02812247acbfd05ce8674875684d0e967ed1b1f56e71ec7674c00fed025e4a56e
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Alessio Rocco
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Moonshine [![Build Status](https://travis-ci.org/nebulab/moonshine.png?branch=master)](https://travis-ci.org/nebulab/moonshine) [![Coverage Status](https://coveralls.io/repos/nebulab/moonshine/badge.png?branch=master)](https://coveralls.io/r/nebulab/moonshine?branch=master) [![Code Climate](https://codeclimate.com/github/nebulab/moonshine.png)](https://codeclimate.com/github/nebulab/moonshine)
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'moonshine'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install moonshine
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
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 new Pull Request
|
data/Rakefile
ADDED
data/lib/moonshine.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
module Moonshine
|
2
|
+
class Base
|
3
|
+
|
4
|
+
attr_accessor :filters
|
5
|
+
attr_accessor :subject
|
6
|
+
|
7
|
+
def initialize(filters, subject = nil)
|
8
|
+
@filters = filters
|
9
|
+
@subject = subject || default_subject.new
|
10
|
+
end
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def subject(klass)
|
14
|
+
define_method :default_subject do
|
15
|
+
klass
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def filter name, scope, transform: nil, default: nil
|
20
|
+
Moonshine::Filter.new(self, name, scope, transform: transform, default: default)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/moonshine.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'moonshine/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "moonshine"
|
8
|
+
spec.version = Moonshine::VERSION
|
9
|
+
spec.authors = ["Alessio Rocco"]
|
10
|
+
spec.email = ["alessio.rocco.lt@gmail.com"]
|
11
|
+
spec.summary = %q{Conditional method chaining}
|
12
|
+
spec.description = %q{Conditional method chaining}
|
13
|
+
spec.homepage = "https://github.com/nebulab/moonshine"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
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.required_ruby_version = '>= 2.0'
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
24
|
+
spec.add_development_dependency "minitest", "~> 5.2"
|
25
|
+
spec.add_development_dependency "mocha", "~> 1.0"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency "coveralls", "~> 0.7"
|
28
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe Moonshine::Base do
|
4
|
+
|
5
|
+
describe '.subject' do
|
6
|
+
let(:mock_class){ MockClass.new({}) }
|
7
|
+
|
8
|
+
it 'defines default_subject method on instance' do
|
9
|
+
mock_class.must_respond_to(:default_subject)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'sets default_subject' do
|
13
|
+
mock_class.default_subject.must_equal DefaultSubject
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'when it is initialized without a subject' do
|
17
|
+
it 'sets subject as default subject' do
|
18
|
+
mock_class.subject.must_be_instance_of DefaultSubject
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'when it is initialized with a subject' do
|
23
|
+
let(:mock_class){ MockClass.new({}, Subject.new) }
|
24
|
+
|
25
|
+
it 'sets subject as requested' do
|
26
|
+
mock_class.subject.must_be_instance_of Subject
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '.filter' do
|
32
|
+
it 'instantiates a Moonshine::Filter class' do
|
33
|
+
Moonshine::Filter.expects(:new).with(MockClass, :filter_name, :scope, transform: nil, default: nil)
|
34
|
+
MockClass.filter :filter_name, :scope
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
class Subject
|
42
|
+
end
|
43
|
+
|
44
|
+
class DefaultSubject
|
45
|
+
end
|
46
|
+
|
47
|
+
class MockClass < Moonshine::Base
|
48
|
+
subject DefaultSubject
|
49
|
+
end
|
data/spec/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: moonshine
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.pre
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alessio Rocco
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-20 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.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.2'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mocha
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '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'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: coveralls
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.7'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.7'
|
83
|
+
description: Conditional method chaining
|
84
|
+
email:
|
85
|
+
- alessio.rocco.lt@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- .ruby-version
|
92
|
+
- .travis.yml
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- lib/moonshine.rb
|
98
|
+
- lib/moonshine/base.rb
|
99
|
+
- lib/moonshine/filter.rb
|
100
|
+
- lib/moonshine/version.rb
|
101
|
+
- moonshine.gemspec
|
102
|
+
- spec/lib/moonshine/base_spec.rb
|
103
|
+
- spec/lib/moonshine/version_spec.rb
|
104
|
+
- spec/test_helper.rb
|
105
|
+
homepage: https://github.com/nebulab/moonshine
|
106
|
+
licenses:
|
107
|
+
- MIT
|
108
|
+
metadata: {}
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '2.0'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - '>'
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 1.3.1
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 2.0.14
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: Conditional method chaining
|
129
|
+
test_files:
|
130
|
+
- spec/lib/moonshine/base_spec.rb
|
131
|
+
- spec/lib/moonshine/version_spec.rb
|
132
|
+
- spec/test_helper.rb
|