faat 0.1.2 → 0.1.3
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 +8 -8
- data/README.md +8 -20
- data/faat.gemspec +1 -0
- data/lib/faat.rb +1 -0
- data/lib/faat/version.rb +1 -1
- data/lib/generators/faat.rb +28 -0
- data/lib/{faat/generators → generators/faat/forms}/templates/form_tamplate.rb +0 -0
- data/lib/generators/faat/resources/resources_generator.rb +28 -0
- data/lib/generators/faat/resources/templates/resource_template.rb +11 -0
- metadata +20 -5
- data/lib/faat/generators/resources/resources_generator.rb +0 -12
- data/lib/faat/generators/templates/resource_template.rb +0 -0
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZWZjNTk2YTIwNzRmZWIyMTlkZWU0NzQ3M2EyZDFmN2UxM2IzNjkwYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODFmMzg4ODQ0MzI1ZmE4YTAyYTNjZjFmYWYyMzlhMGEyODI4MjNmMg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDA0YzZhODIzYzYxMDZlZjU5YmI5OTFlYjgyMjZkMzBmMzFhMDY1NjZkOTk4
|
10
|
+
ZDhlM2Y2Yjc0MjQ4ZTI0Nzk3MGMwYzVkNzIzZjhiY2M4MTlkZmQyZDFhMGFi
|
11
|
+
YWYzYThhMTA5ZjQxODVkZTZiNTg3MTI3YjU1ZGJjNzQzZDUxZTg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YWQzYzg1MzgwYTk3NGMzOTc1NTU4Y2U2YmNkNGEwZGI0Y2NkNTYzMzkyZDli
|
14
|
+
ZTk0YzhiMWUzMjYxMWUyODUwZWRmMWIwMGQwM2ZjZWUxOTllNThkMTgwYzkx
|
15
|
+
N2M1YmRiOTZjODQ3ODQyMWQ5YzczMjBiMDI4NzEzMzkzZTQyMjQ=
|
data/README.md
CHANGED
@@ -2,9 +2,7 @@
|
|
2
2
|
|
3
3
|
[](https://gitter.im/xo8bit/faat?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [](https://badge.fury.io/rb/faat) [](https://codeclimate.com/repos/5683d90ecbc0bf2f17002347/feed) [](https://codeclimate.com/repos/5683d90ecbc0bf2f17002347/coverage) [](https://travis-ci.org/xo8bit/faat)
|
4
4
|
|
5
|
-
Welcome to
|
6
|
-
|
7
|
-
TODO: Delete this and the text above, and describe your gem
|
5
|
+
Welcome to `faat` gem!
|
8
6
|
|
9
7
|
## Installation
|
10
8
|
|
@@ -24,21 +22,17 @@ Or install it yourself as:
|
|
24
22
|
|
25
23
|
## Usage
|
26
24
|
|
27
|
-
|
28
|
-
|
29
|
-
```ruby
|
30
|
-
class PostResources < Faat::Resources::Base
|
31
|
-
# your business logic put here
|
32
|
-
end
|
33
|
-
```
|
25
|
+
Run ```rails generate faat:resources {model_name}```,
|
26
|
+
generator will create folder ```resource``` in ```app``` directory, and file ```{model_name}_resource.rb```
|
34
27
|
|
35
|
-
|
28
|
+
|
29
|
+
###Initialize:
|
36
30
|
```ruby
|
37
31
|
@post = Post.new
|
38
32
|
@post_resource = PostResource.new(@post)
|
39
33
|
```
|
40
34
|
|
41
|
-
Usage:
|
35
|
+
###Usage:
|
42
36
|
```ruby
|
43
37
|
@post_resource.destroy => destroy @post
|
44
38
|
@post_resource.update => update @post
|
@@ -48,20 +42,14 @@ PostResource.all => Post.all
|
|
48
42
|
PostResource.where(title: "First Test Title") => Post.where(...)
|
49
43
|
```
|
50
44
|
|
51
|
-
|
52
|
-
## Development
|
53
|
-
|
54
|
-
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
55
|
-
|
56
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
57
|
-
|
58
45
|
## TODO
|
59
46
|
|
60
47
|
Add resource and form generators
|
61
48
|
|
49
|
+
|
62
50
|
## Contributing
|
63
51
|
|
64
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
52
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/xo8bit/faat. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
65
53
|
|
66
54
|
|
67
55
|
## License
|
data/faat.gemspec
CHANGED
@@ -34,6 +34,7 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_runtime_dependency 'virtus', '~> 1.0.5'
|
35
35
|
spec.add_runtime_dependency 'activemodel', '~> 4.2.5'
|
36
36
|
spec.add_runtime_dependency 'activesupport', '~> 4.2.5'
|
37
|
+
spec.add_runtime_dependency 'rails', '~> 4.2.5'
|
37
38
|
|
38
39
|
spec.add_development_dependency 'bundler', '>= 1.6'
|
39
40
|
spec.add_development_dependency 'rake', '~> 10.0'
|
data/lib/faat.rb
CHANGED
data/lib/faat/version.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
|
3
|
+
module Faat
|
4
|
+
module Generators
|
5
|
+
class Base < Rails::Generators::Base
|
6
|
+
def self.source_root
|
7
|
+
@_faat_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'faat', generator_name, 'templates'))
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.banner
|
11
|
+
"rails generate faat:#{generator_name} #{self.arguments.map{ |a| a.usage }.join(' ')} [options]"
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def add_gem(name, options = {})
|
17
|
+
gemfile_content = File.read(destination_path("Gemfile"))
|
18
|
+
File.open(destination_path("Gemfile"), 'a') { |f| f.write("\n") } unless gemfile_content =~ /\n\Z/
|
19
|
+
gem name, options unless gemfile_content.include? name
|
20
|
+
end
|
21
|
+
|
22
|
+
def print_usage
|
23
|
+
self.class.help(Thor::Base.shell.new)
|
24
|
+
exit
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
File without changes
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'generators/faat'
|
2
|
+
require 'rails/generators/base'
|
3
|
+
|
4
|
+
module Faat
|
5
|
+
module Generators
|
6
|
+
class ResourcesGenerator < Base
|
7
|
+
argument :resource_name, type: :string, default: 'app', banner: 'resource_name'
|
8
|
+
|
9
|
+
def create_resources
|
10
|
+
template "resource_template.rb", "app/resources/#{file_name}_resources.rb"
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def file_name
|
16
|
+
resource_name.underscore
|
17
|
+
end
|
18
|
+
|
19
|
+
def constant_name
|
20
|
+
resource_name.underscore.upcase
|
21
|
+
end
|
22
|
+
|
23
|
+
def class_name
|
24
|
+
resource_name.downcase.capitalize
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<%= '# default generated template' %>
|
2
|
+
|
3
|
+
<%= "# for using with model resource, initialize #{resource_name}Resource" %>
|
4
|
+
<%= "# #{resource_name}Resource.new( ModelClassName.new )" %>
|
5
|
+
<%= "# or with instance variable #{resource_name}Resource.new(@model_class_name)" %>
|
6
|
+
|
7
|
+
class <%= resource_name %>Resource < Faat::Resources::Base
|
8
|
+
|
9
|
+
# add your business logic here
|
10
|
+
|
11
|
+
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.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nazarii Sheremet
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: virtus
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 4.2.5
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 4.2.5
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 4.2.5
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,12 +126,13 @@ files:
|
|
112
126
|
- bin/setup
|
113
127
|
- faat.gemspec
|
114
128
|
- lib/faat.rb
|
115
|
-
- lib/faat/generators/resources/resources_generator.rb
|
116
|
-
- lib/faat/generators/templates/form_tamplate.rb
|
117
|
-
- lib/faat/generators/templates/resource_template.rb
|
118
129
|
- lib/faat/helpers/string.rb
|
119
130
|
- lib/faat/resources/base.rb
|
120
131
|
- lib/faat/version.rb
|
132
|
+
- lib/generators/faat.rb
|
133
|
+
- lib/generators/faat/forms/templates/form_tamplate.rb
|
134
|
+
- lib/generators/faat/resources/resources_generator.rb
|
135
|
+
- lib/generators/faat/resources/templates/resource_template.rb
|
121
136
|
homepage: https://github.com/xo8bit/faat
|
122
137
|
licenses:
|
123
138
|
- MIT
|
@@ -1,12 +0,0 @@
|
|
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
|