data_provider 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.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/Gemfile +2 -0
  4. data/Gemfile.lock +113 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.md +29 -0
  7. data/README.rdoc +3 -0
  8. data/Rakefile +34 -0
  9. data/app/assets/.keep +0 -0
  10. data/bin/rails +12 -0
  11. data/data_provider.gemspec +27 -0
  12. data/lib/data_provider.rb +6 -0
  13. data/lib/data_provider/base.rb +42 -0
  14. data/lib/data_provider/engine.rb +5 -0
  15. data/lib/data_provider/version.rb +3 -0
  16. data/lib/generators/data_provider/USAGE +8 -0
  17. data/lib/generators/data_provider/data_provider_generator.rb +18 -0
  18. data/lib/generators/data_provider/install_generator.rb +14 -0
  19. data/lib/generators/data_provider/templates/.keep +0 -0
  20. data/lib/generators/data_provider/templates/provider.rb +0 -0
  21. data/lib/tasks/data_provider_tasks.rake +4 -0
  22. data/test/data_provider_test.rb +7 -0
  23. data/test/dummy/README.rdoc +28 -0
  24. data/test/dummy/Rakefile +6 -0
  25. data/test/dummy/app/assets/images/.keep +0 -0
  26. data/test/dummy/app/assets/javascripts/application.js +13 -0
  27. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  28. data/test/dummy/app/controllers/application_controller.rb +5 -0
  29. data/test/dummy/app/controllers/concerns/.keep +0 -0
  30. data/test/dummy/app/helpers/application_helper.rb +2 -0
  31. data/test/dummy/app/mailers/.keep +0 -0
  32. data/test/dummy/app/models/.keep +0 -0
  33. data/test/dummy/app/models/concerns/.keep +0 -0
  34. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  35. data/test/dummy/bin/bundle +3 -0
  36. data/test/dummy/bin/rails +4 -0
  37. data/test/dummy/bin/rake +4 -0
  38. data/test/dummy/config.ru +4 -0
  39. data/test/dummy/config/application.rb +23 -0
  40. data/test/dummy/config/boot.rb +5 -0
  41. data/test/dummy/config/database.yml +25 -0
  42. data/test/dummy/config/environment.rb +5 -0
  43. data/test/dummy/config/environments/development.rb +37 -0
  44. data/test/dummy/config/environments/production.rb +82 -0
  45. data/test/dummy/config/environments/test.rb +39 -0
  46. data/test/dummy/config/initializers/assets.rb +8 -0
  47. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  48. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  49. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  50. data/test/dummy/config/initializers/inflections.rb +16 -0
  51. data/test/dummy/config/initializers/mime_types.rb +4 -0
  52. data/test/dummy/config/initializers/session_store.rb +3 -0
  53. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  54. data/test/dummy/config/locales/en.yml +23 -0
  55. data/test/dummy/config/routes.rb +4 -0
  56. data/test/dummy/config/secrets.yml +22 -0
  57. data/test/dummy/lib/assets/.keep +0 -0
  58. data/test/dummy/log/.keep +0 -0
  59. data/test/dummy/public/404.html +67 -0
  60. data/test/dummy/public/422.html +67 -0
  61. data/test/dummy/public/500.html +66 -0
  62. data/test/dummy/public/favicon.ico +0 -0
  63. data/test/integration/navigation_test.rb +10 -0
  64. data/test/lib/generators/uber_presenter/install_generator_test.rb +16 -0
  65. data/test/lib/generators/uber_presenter/presenter_generator_test.rb +16 -0
  66. data/test/test_helper.rb +15 -0
  67. 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
@@ -0,0 +1,12 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ test/dummy/db/*.sqlite3
5
+ test/dummy/db/*.sqlite3-journal
6
+ test/dummy/log/*.log
7
+ test/dummy/tmp/
8
+ test/dummy/.sass-cache
9
+ .idea
10
+ .idea/*
11
+ .idea/**/*
12
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
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
@@ -0,0 +1,3 @@
1
+ = DataProvider
2
+
3
+ This project rocks and uses MIT-LICENSE.
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,6 @@
1
+ require 'data_provider/engine'
2
+
3
+ module DataProvider
4
+ autoload :Base, 'data_provider/base'
5
+ require 'memoist'
6
+ 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,5 @@
1
+ module DataProvider
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace DataProvider
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module DataProvider
2
+ VERSION = '0.1.3'
3
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ rails generate data_provider Thing
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -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
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :data_provider do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class DataProviderTest < ActiveSupport::TestCase
4
+ test 'truth' do
5
+ assert_kind_of Module, DataProvider
6
+ end
7
+ end
@@ -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>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks