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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bcc5d95080c5d7e824afe48fb1c24300b45499da
4
- data.tar.gz: 10578518c2ab1be538bf37bb0e08b27087bae2f3
3
+ metadata.gz: 3b87850a8cf58a690582d2874da503bf1d2da8b2
4
+ data.tar.gz: 761d631d6a825121ab253f5d0dce8369417aff6a
5
5
  SHA512:
6
- metadata.gz: 9e9f653b7b11b6002e1a348254b1f51a5db3bac3f6aff521629b5c105b404f31d530db837d07b2bdbbd160e91e1c789ac9bd53ae9b7975807a76b98c8c231391
7
- data.tar.gz: 9800bb09ec4a753a2e4f5fd578e1f7660b430479a7182de61926eb61f5fa02a0db624f44eafef56bea3204a12954a84360a0e7c53fd132962d2598c640bf11b6
6
+ metadata.gz: d5ee4bb997610deb801ffde6a7cec6f37b697dca3719a9041f2de6fecdad1774c6cd7a1196666253d7b155c26eee704e6ba1366a2e765caf7fdd0d9b47130f23
7
+ data.tar.gz: b5a973dced412eca58f67bd19d4faee5a8ef9729009039394dac1c861eca15981cf3c0a254e9ec4649d8327aec86aec8e702984bc54058321a3b140f07c71bb8
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gem 'pry'
3
4
  # Specify your gem's dependencies in faat.gemspec
4
5
  gemspec
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Faat
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/faat.svg)](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 "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
- task :default => :spec
5
- task :test => :spec
4
+ task default: :spec
5
+ task test: :spec
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "faat"
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
- # require "pry"
11
- # Pry.start
10
+ require 'pry'
11
+ Pry.start
12
12
 
13
- require "irb"
14
- IRB.start
13
+ # require 'irb'
14
+ # IRB.start
@@ -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 = "faat"
7
+ spec.name = 'faat'
8
8
  spec.version = Faat::VERSION
9
- spec.authors = ["Nazarii Sheremet"]
10
- spec.email = ["xo8bit@gmail.com"]
9
+ spec.authors = ['Nazarii Sheremet']
10
+ spec.email = ['xo8bit@gmail.com']
11
11
 
12
- spec.summary = %q{Faat kills your fat models.}
13
- spec.description = %q{Gem Faat kills your fat models.}
14
- spec.homepage = "https://github.com/xo8bit/faat"
15
- spec.license = "MIT"
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'] = "https://rubygems.org"
20
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
21
21
  else
22
- raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
22
+ fail 'RubyGems 2.0 or newer is required to protect against
23
+ public gem pushes.'
23
24
  end
24
25
 
25
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
- spec.bindir = "exe"
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 = ["lib"]
31
+ spec.require_paths = ['lib']
29
32
 
30
- spec.add_runtime_dependency "virtus", "~> 1.0.5"
31
- spec.add_runtime_dependency "activemodel", "~> 4.2.5"
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 "bundler", "~> 1.11"
34
- spec.add_development_dependency "rake", "~> 10.0"
35
- spec.add_development_dependency "rspec"
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
@@ -1,5 +1,32 @@
1
- require "faat/version"
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
- # Your code goes here...
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
@@ -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
- if name == ""
12
- attribute_model.send :name
13
- end
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
- def respond_to?(name)
17
- true
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
@@ -1,3 +1,4 @@
1
+ # root gem module with version constant
1
2
  module Faat
2
- VERSION = "0.1.0"
3
+ VERSION = '0.1.1.beta'
3
4
  end
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.0
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-25 00:00:00.000000000 Z
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: '0'
138
+ version: 1.3.1
121
139
  requirements: []
122
140
  rubyforge_project:
123
141
  rubygems_version: 2.4.8