faat 0.1.0 → 0.1.1.beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/README.md +2 -0
- data/Rakefile +4 -4
- data/bin/console +6 -6
- data/faat.gemspec +21 -17
- data/lib/faat.rb +29 -2
- data/lib/faat/generators/resources/resources_generator.rb +12 -0
- data/lib/faat/generators/templates/form_tamplate.rb +0 -0
- data/lib/faat/generators/templates/resource_template.rb +0 -0
- data/lib/faat/resources/base.rb +50 -9
- data/lib/faat/support/string.rb +13 -0
- data/lib/faat/version.rb +2 -1
- metadata +22 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b87850a8cf58a690582d2874da503bf1d2da8b2
|
4
|
+
data.tar.gz: 761d631d6a825121ab253f5d0dce8369417aff6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5ee4bb997610deb801ffde6a7cec6f37b697dca3719a9041f2de6fecdad1774c6cd7a1196666253d7b155c26eee704e6ba1366a2e765caf7fdd0d9b47130f23
|
7
|
+
data.tar.gz: b5a973dced412eca58f67bd19d4faee5a8ef9729009039394dac1c861eca15981cf3c0a254e9ec4649d8327aec86aec8e702984bc54058321a3b140f07c71bb8
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Faat
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/faat)
|
4
|
+
|
3
5
|
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/faat`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
6
|
|
5
7
|
TODO: Delete this and the text above, and describe your gem
|
data/Rakefile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
3
|
|
4
|
-
task :
|
5
|
-
task :
|
4
|
+
task default: :spec
|
5
|
+
task test: :spec
|
data/bin/console
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'faat'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
8
8
|
|
9
9
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
|
11
|
-
|
10
|
+
require 'pry'
|
11
|
+
Pry.start
|
12
12
|
|
13
|
-
require
|
14
|
-
IRB.start
|
13
|
+
# require 'irb'
|
14
|
+
# IRB.start
|
data/faat.gemspec
CHANGED
@@ -4,33 +4,37 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'faat/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'faat'
|
8
8
|
spec.version = Faat::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Nazarii Sheremet']
|
10
|
+
spec.email = ['xo8bit@gmail.com']
|
11
11
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
12
|
+
spec.summary = 'Faat kills your fat models.'
|
13
|
+
spec.description = 'Gem Faat kills your fat models.'
|
14
|
+
spec.homepage = 'https://github.com/xo8bit/faat'
|
15
|
+
spec.license = 'MIT'
|
16
16
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
18
|
# delete this section to allow pushing this gem to any host.
|
19
19
|
if spec.respond_to?(:metadata)
|
20
|
-
spec.metadata['allowed_push_host'] =
|
20
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
21
21
|
else
|
22
|
-
|
22
|
+
fail 'RubyGems 2.0 or newer is required to protect against
|
23
|
+
public gem pushes.'
|
23
24
|
end
|
24
25
|
|
25
|
-
spec.files
|
26
|
-
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = 'exe'
|
27
30
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
-
spec.require_paths = [
|
31
|
+
spec.require_paths = ['lib']
|
29
32
|
|
30
|
-
spec.add_runtime_dependency
|
31
|
-
spec.add_runtime_dependency
|
33
|
+
spec.add_runtime_dependency 'virtus', '~> 1.0.5'
|
34
|
+
spec.add_runtime_dependency 'activemodel', '~> 4.2.5'
|
35
|
+
spec.add_runtime_dependency 'activesupport'
|
32
36
|
|
33
|
-
spec.add_development_dependency
|
34
|
-
spec.add_development_dependency
|
35
|
-
spec.add_development_dependency
|
37
|
+
spec.add_development_dependency 'bundler', '~> 1.11'
|
38
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
39
|
+
spec.add_development_dependency 'rspec'
|
36
40
|
end
|
data/lib/faat.rb
CHANGED
@@ -1,5 +1,32 @@
|
|
1
|
-
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2015 Nazarii Sheremet
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
2
23
|
|
24
|
+
require 'faat/version'
|
25
|
+
require 'faat/resources/base'
|
26
|
+
require 'faat/support/string'
|
27
|
+
require 'active_support/inflector'
|
28
|
+
|
29
|
+
# root gem module
|
3
30
|
module Faat
|
4
|
-
|
31
|
+
autoload :Resources, 'faat/resources/base'
|
5
32
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
namespace 'faat'
|
2
|
+
|
3
|
+
# creating resources_generator
|
4
|
+
class ResourcesGenerator < Rails::Generators::Base
|
5
|
+
def create_resources_file
|
6
|
+
create_file "app/resources/#{file_name}_resource.rb", <<-FILE
|
7
|
+
class #{class_name}Resources < Faat::Resources::Base
|
8
|
+
attr_reader #{plural_name}, :#{plural_name.singularize}
|
9
|
+
end
|
10
|
+
FILE
|
11
|
+
end
|
12
|
+
end
|
File without changes
|
File without changes
|
data/lib/faat/resources/base.rb
CHANGED
@@ -1,21 +1,62 @@
|
|
1
|
+
# root module Faat
|
1
2
|
module Faat
|
2
|
-
|
3
3
|
# Faat::Resources resources module
|
4
4
|
module Resources
|
5
|
-
|
6
5
|
# Faat::Resources::Base default resource class
|
7
6
|
class Base
|
7
|
+
# Your classes must inherited from this Base class
|
8
|
+
# for removing all business logic from models classes,
|
9
|
+
# and controllers
|
10
|
+
# Right now you can use one resources for one model,
|
11
|
+
|
12
|
+
# TODO: implement resources logic for working with coup of models
|
13
|
+
|
14
|
+
def initialize(resource)
|
15
|
+
# setup resource name for accessing from other methods
|
16
|
+
@resource_name = resource.class.name.underscore
|
17
|
+
|
18
|
+
# setup :attr_accessor for resource attributes
|
19
|
+
self.class.send(:attr_accessor, resource.class.name.underscore)
|
20
|
+
# setup :class_name for resource class
|
21
|
+
self.class.class_eval { @class_name = resource.class.name }
|
22
|
+
instance_variable_set("@#{resource.class.name.underscore}", resource)
|
23
|
+
end
|
24
|
+
|
25
|
+
# initialize :method_missing for ActiveRecord methods
|
26
|
+
# like :save, :valid?, :destroy and others
|
8
27
|
|
9
|
-
# attr_accessor
|
10
28
|
def method_missing(name, *attr, &block)
|
11
|
-
|
12
|
-
|
13
|
-
|
29
|
+
# getting resource by instance variable :resource_name
|
30
|
+
instance_variable_get("@#{@resource_name}").send(name, *attr, &block) || super
|
31
|
+
end
|
32
|
+
|
33
|
+
# initialize :respond_to_missing? method for working with
|
34
|
+
# ActiveRecord instance methods
|
35
|
+
|
36
|
+
def respond_to_missing?(name, include_private = false)
|
37
|
+
# getting resource by instance variable :resource_name,
|
38
|
+
# for :respond_to? method
|
39
|
+
instance_variable_get("@#{@resource_name}").respond_to?(name) || super
|
14
40
|
end
|
15
41
|
|
16
|
-
|
17
|
-
|
42
|
+
# add class methods form resource class
|
43
|
+
class << self
|
44
|
+
# singleton method :method_missing
|
45
|
+
def method_missing(name, *attr, &block)
|
46
|
+
# initialize :method_missing for accessing for
|
47
|
+
# ActiveRecord model class_methods
|
48
|
+
class_eval do
|
49
|
+
@class_name.constantize.send(name, *attr, &block) || super
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def respond_to_missing?(name, include_private = false)
|
54
|
+
# getting respond_to? access to ActiveRecord model class_methods
|
55
|
+
class_eval do
|
56
|
+
@class_name.constantize.respond_to?(name) || super
|
57
|
+
end
|
58
|
+
end
|
18
59
|
end
|
19
60
|
end
|
20
61
|
end
|
21
|
-
end
|
62
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# add method to String class
|
2
|
+
class String
|
3
|
+
# add method :underscore for String class to convert Class name in camelcase
|
4
|
+
def underscore
|
5
|
+
word = dup
|
6
|
+
word.gsub!(/::/, '/')
|
7
|
+
word.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
8
|
+
word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
|
9
|
+
word.tr!('-', '_')
|
10
|
+
word.downcase!
|
11
|
+
word
|
12
|
+
end
|
13
|
+
end
|
data/lib/faat/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1.beta
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nazarii Sheremet
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: virtus
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 4.2.5
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -97,7 +111,11 @@ files:
|
|
97
111
|
- bin/setup
|
98
112
|
- faat.gemspec
|
99
113
|
- lib/faat.rb
|
114
|
+
- lib/faat/generators/resources/resources_generator.rb
|
115
|
+
- lib/faat/generators/templates/form_tamplate.rb
|
116
|
+
- lib/faat/generators/templates/resource_template.rb
|
100
117
|
- lib/faat/resources/base.rb
|
118
|
+
- lib/faat/support/string.rb
|
101
119
|
- lib/faat/version.rb
|
102
120
|
homepage: https://github.com/xo8bit/faat
|
103
121
|
licenses:
|
@@ -115,9 +133,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
115
133
|
version: '0'
|
116
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
135
|
requirements:
|
118
|
-
- - "
|
136
|
+
- - ">"
|
119
137
|
- !ruby/object:Gem::Version
|
120
|
-
version:
|
138
|
+
version: 1.3.1
|
121
139
|
requirements: []
|
122
140
|
rubyforge_project:
|
123
141
|
rubygems_version: 2.4.8
|