data_provider 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +113 -0
- data/MIT-LICENSE +20 -0
- data/README.md +29 -0
- data/README.rdoc +3 -0
- data/Rakefile +34 -0
- data/app/assets/.keep +0 -0
- data/bin/rails +12 -0
- data/data_provider.gemspec +27 -0
- data/lib/data_provider.rb +6 -0
- data/lib/data_provider/base.rb +42 -0
- data/lib/data_provider/engine.rb +5 -0
- data/lib/data_provider/version.rb +3 -0
- data/lib/generators/data_provider/USAGE +8 -0
- data/lib/generators/data_provider/data_provider_generator.rb +18 -0
- data/lib/generators/data_provider/install_generator.rb +14 -0
- data/lib/generators/data_provider/templates/.keep +0 -0
- data/lib/generators/data_provider/templates/provider.rb +0 -0
- data/lib/tasks/data_provider_tasks.rake +4 -0
- data/test/data_provider_test.rb +7 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/mailers/.keep +0 -0
- data/test/dummy/app/models/.keep +0 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +82 -0
- data/test/dummy/config/environments/test.rb +39 -0
- data/test/dummy/config/initializers/assets.rb +8 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/lib/generators/uber_presenter/install_generator_test.rb +16 -0
- data/test/lib/generators/uber_presenter/presenter_generator_test.rb +16 -0
- data/test/test_helper.rb +15 -0
- metadata +196 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e489c9257b2c8cbc6cd03720e371dae7eada854c
|
4
|
+
data.tar.gz: d886c54bb478bfabe41ebbb8e1079d0a01854cff
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 79111d7a2fe801ec79fa441a2c71358d70bf6aa23db2ee0e99bc3aaa17cb4c469b12b05ff4a9bd3a293afa2a96713501bce2e9029dc83724a8e253fba9ec4270
|
7
|
+
data.tar.gz: 20428edfb01835b62d3724c11f24b6dae5debd117cef0bfd81a42033918e3271947dbe77742e58743edcbadce22503022222b0ea2eb090f5d0a52b448bff39b5
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
data_provider (0.1.2)
|
5
|
+
memoist (>= 0.9.3)
|
6
|
+
rails (>= 3.2.12)
|
7
|
+
railties (>= 3.2.6)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
actionmailer (4.2.0)
|
13
|
+
actionpack (= 4.2.0)
|
14
|
+
actionview (= 4.2.0)
|
15
|
+
activejob (= 4.2.0)
|
16
|
+
mail (~> 2.5, >= 2.5.4)
|
17
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
18
|
+
actionpack (4.2.0)
|
19
|
+
actionview (= 4.2.0)
|
20
|
+
activesupport (= 4.2.0)
|
21
|
+
rack (~> 1.6.0)
|
22
|
+
rack-test (~> 0.6.2)
|
23
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
24
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
25
|
+
actionview (4.2.0)
|
26
|
+
activesupport (= 4.2.0)
|
27
|
+
builder (~> 3.1)
|
28
|
+
erubis (~> 2.7.0)
|
29
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
30
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
31
|
+
activejob (4.2.0)
|
32
|
+
activesupport (= 4.2.0)
|
33
|
+
globalid (>= 0.3.0)
|
34
|
+
activemodel (4.2.0)
|
35
|
+
activesupport (= 4.2.0)
|
36
|
+
builder (~> 3.1)
|
37
|
+
activerecord (4.2.0)
|
38
|
+
activemodel (= 4.2.0)
|
39
|
+
activesupport (= 4.2.0)
|
40
|
+
arel (~> 6.0)
|
41
|
+
activesupport (4.2.0)
|
42
|
+
i18n (~> 0.7)
|
43
|
+
json (~> 1.7, >= 1.7.7)
|
44
|
+
minitest (~> 5.1)
|
45
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
46
|
+
tzinfo (~> 1.1)
|
47
|
+
arel (6.0.0)
|
48
|
+
builder (3.2.2)
|
49
|
+
erubis (2.7.0)
|
50
|
+
globalid (0.3.3)
|
51
|
+
activesupport (>= 4.1.0)
|
52
|
+
hike (1.2.3)
|
53
|
+
i18n (0.7.0)
|
54
|
+
json (1.8.2)
|
55
|
+
loofah (2.0.1)
|
56
|
+
nokogiri (>= 1.5.9)
|
57
|
+
mail (2.6.3)
|
58
|
+
mime-types (>= 1.16, < 3)
|
59
|
+
memoist (0.11.0)
|
60
|
+
mime-types (2.4.3)
|
61
|
+
mini_portile (0.6.2)
|
62
|
+
minitest (5.5.1)
|
63
|
+
multi_json (1.11.0)
|
64
|
+
nokogiri (1.6.6.2)
|
65
|
+
mini_portile (~> 0.6.0)
|
66
|
+
rack (1.6.0)
|
67
|
+
rack-test (0.6.3)
|
68
|
+
rack (>= 1.0)
|
69
|
+
rails (4.2.0)
|
70
|
+
actionmailer (= 4.2.0)
|
71
|
+
actionpack (= 4.2.0)
|
72
|
+
actionview (= 4.2.0)
|
73
|
+
activejob (= 4.2.0)
|
74
|
+
activemodel (= 4.2.0)
|
75
|
+
activerecord (= 4.2.0)
|
76
|
+
activesupport (= 4.2.0)
|
77
|
+
bundler (>= 1.3.0, < 2.0)
|
78
|
+
railties (= 4.2.0)
|
79
|
+
sprockets-rails
|
80
|
+
rails-deprecated_sanitizer (1.0.3)
|
81
|
+
activesupport (>= 4.2.0.alpha)
|
82
|
+
rails-dom-testing (1.0.5)
|
83
|
+
activesupport (>= 4.2.0.beta, < 5.0)
|
84
|
+
nokogiri (~> 1.6.0)
|
85
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
86
|
+
rails-html-sanitizer (1.0.1)
|
87
|
+
loofah (~> 2.0)
|
88
|
+
railties (4.2.0)
|
89
|
+
actionpack (= 4.2.0)
|
90
|
+
activesupport (= 4.2.0)
|
91
|
+
rake (>= 0.8.7)
|
92
|
+
thor (>= 0.18.1, < 2.0)
|
93
|
+
rake (10.4.2)
|
94
|
+
sprockets (2.12.3)
|
95
|
+
hike (~> 1.2)
|
96
|
+
multi_json (~> 1.0)
|
97
|
+
rack (~> 1.0)
|
98
|
+
tilt (~> 1.1, != 1.3.0)
|
99
|
+
sprockets-rails (2.2.4)
|
100
|
+
actionpack (>= 3.0)
|
101
|
+
activesupport (>= 3.0)
|
102
|
+
sprockets (>= 2.8, < 4.0)
|
103
|
+
thor (0.19.1)
|
104
|
+
thread_safe (0.3.4)
|
105
|
+
tilt (1.4.1)
|
106
|
+
tzinfo (1.2.2)
|
107
|
+
thread_safe (~> 0.1)
|
108
|
+
|
109
|
+
PLATFORMS
|
110
|
+
ruby
|
111
|
+
|
112
|
+
DEPENDENCIES
|
113
|
+
data_provider!
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2014 Alexander Gorbunov
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# DataProvider
|
2
|
+
|
3
|
+
DataProvider - библиотека для огранизации провайдеров данных в проектах на Ruby On Rails
|
4
|
+
|
5
|
+
## Установка (Installation)
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'data_provider'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Run:
|
16
|
+
|
17
|
+
$ rails generate data_provider:install
|
18
|
+
|
19
|
+
For generate providers, do:
|
20
|
+
|
21
|
+
$ rails generate data_provider MyProvider
|
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/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'DataProvider'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path('../test/dummy/Rakefile', __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
Bundler::GemHelper.install_tasks
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'lib'
|
28
|
+
t.libs << 'test'
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
30
|
+
t.verbose = false
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
task default: :test
|
data/app/assets/.keep
ADDED
File without changes
|
data/bin/rails
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
|
3
|
+
|
4
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
5
|
+
ENGINE_PATH = File.expand_path('../../lib/data_provider/engine', __FILE__)
|
6
|
+
|
7
|
+
# Set up gems listed in the Gemfile.
|
8
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
9
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
10
|
+
|
11
|
+
require 'rails/all'
|
12
|
+
require 'rails/engine/commands'
|
@@ -0,0 +1,27 @@
|
|
1
|
+
$:.push File.expand_path('../lib', __FILE__)
|
2
|
+
|
3
|
+
# Maintain your gem's version:
|
4
|
+
require 'data_provider/version'
|
5
|
+
|
6
|
+
# Describe your gem and declare its dependencies:
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = 'data_provider'
|
9
|
+
s.version = DataProvider::VERSION
|
10
|
+
s.platform = Gem::Platform::RUBY
|
11
|
+
s.authors = ['Alexander Gorbunov']
|
12
|
+
s.email = ['lexgorbunov@gmail.com']
|
13
|
+
s.homepage = 'https://github.com/lexgorbunov/data_provider'
|
14
|
+
s.summary = 'Gem to add data providers to RoR projects'
|
15
|
+
s.description = 'DataProvider is a gem to add data providers to Ruby on Rails projects'
|
16
|
+
s.license = 'MIT'
|
17
|
+
|
18
|
+
# s.files = Dir['{app,config,db,lib}/**/*', 'MIT-LICENSE', 'Rakefile', 'README.rdoc']
|
19
|
+
# s.test_files = Dir['test/**/*']
|
20
|
+
s.files = `git ls-files`.split("\n")
|
21
|
+
s.test_files = `git ls-files -- test/*`.split("\n")
|
22
|
+
s.require_paths = ['lib']
|
23
|
+
|
24
|
+
s.add_dependency 'rails', '>= 3.2.12'
|
25
|
+
s.add_dependency 'railties', '>= 3.2.6'
|
26
|
+
s.add_dependency 'memoist', '>= 0.9.3'
|
27
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class DataProvider::Base
|
2
|
+
extend Memoist
|
3
|
+
|
4
|
+
# Доступ к объекту контроллера
|
5
|
+
attr_reader :controller
|
6
|
+
delegate :params, :action_name, :controller_name, :session, :render, to: :controller
|
7
|
+
|
8
|
+
class << self
|
9
|
+
# Создаем экземпляр презенера, уникальный для объекта controller
|
10
|
+
#
|
11
|
+
# @param [Object] controller
|
12
|
+
# @param [Object] args Набор аргументов для презентора
|
13
|
+
# @return [Object] Экземпляр провайдера
|
14
|
+
#
|
15
|
+
def new(controller, *args)
|
16
|
+
storage = storage_from(controller)
|
17
|
+
(instance = storage[self.name]).present? ? instance : (storage[self.name] = super(*args)).tap { |inst| inst.instance_variable_set(:@controller, controller) }
|
18
|
+
end
|
19
|
+
|
20
|
+
# Получаем хранилище презенторов из контроллера controller
|
21
|
+
#
|
22
|
+
# @param [Object] controller
|
23
|
+
# @return [Hash]
|
24
|
+
#
|
25
|
+
def storage_from(controller)
|
26
|
+
controller.instance_variable_set(:@data_providers, {}) unless controller.instance_variable_names.include?('@data_providers')
|
27
|
+
controller.instance_variable_get(:@data_providers)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Получаем хранилище провайдеров
|
32
|
+
#
|
33
|
+
# @return [Hash]
|
34
|
+
#
|
35
|
+
def data_providers
|
36
|
+
@data_providers.present? ? @data_providers : self.class.storage_from(controller)
|
37
|
+
end
|
38
|
+
|
39
|
+
def inspect
|
40
|
+
"#<#{self.class.name}:#{self.object_id} @controller=#<#{controller.class.name}:#{controller.object_id}>>"
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class DataProviderGenerator < Rails::Generators::Base
|
2
|
+
source_root File.expand_path('../templates', __FILE__)
|
3
|
+
argument :provider_name, type: :string
|
4
|
+
|
5
|
+
def generate
|
6
|
+
name = provider_name.singularize
|
7
|
+
create_file "app/data_providers/#{name.underscore}.rb", <<-FILE
|
8
|
+
class #{name.classify} < DataProvider::Base
|
9
|
+
# def posts
|
10
|
+
# # ...
|
11
|
+
# end
|
12
|
+
|
13
|
+
# Кэширование результатов
|
14
|
+
# memoize :method
|
15
|
+
end
|
16
|
+
FILE
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module DataProvider
|
2
|
+
class InstallGenerator < Rails::Generators::Base
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
4
|
+
|
5
|
+
desc 'Включает поддержку провайдеров'
|
6
|
+
|
7
|
+
def install
|
8
|
+
copy_file '.keep', 'app/data_providers/.keep'
|
9
|
+
inject_into_file('config/application.rb', after: "class Application < Rails::Application\n") do
|
10
|
+
" config.autoload_paths << Rails.root.join('app', 'data_providers').to_s\n"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
ADDED