view_model-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dd3afc860e0238825e05f729a1985375e8bcc692
4
+ data.tar.gz: b954b58375a5d36f465bfa94a96e542cbc8275c5
5
+ SHA512:
6
+ metadata.gz: e202da2c368afeca11bf07056309afd48ec874083c47641456382f0a2609290be278934bf4f002da02c5d8f2b12d0488f80049a76caa1ef8ae9b393a4895b08e
7
+ data.tar.gz: 3255836bf9128b9b441e4e4c938bb6f9292b6a3db104f998ed970279d67783f43155901cfa9242525a96f5a0d1c2e11f3eed97bd1b3f3e3d99ccb953e81781fc
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ view_model-rails
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # ViewModel::Rails
2
+
3
+ Rails engine providing view models.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'view_model-rails'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ ## Usage
18
+
19
+ Generate a base class for your view models with
20
+
21
+ $ rake view_model:setup
22
+
23
+ ### Generator
24
+ Create files and tests...
25
+
26
+ Example 'RegisterForm':
27
+
28
+ ```ruby
29
+ rails g view_model RegisterForm
30
+ ```
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ begin
2
+ require 'bundler/gem_tasks'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rake/testtask'
8
+
9
+ Rake::TestTask.new do |t|
10
+ t.libs << 'spec'
11
+ t.test_files = FileList['spec/**/*_spec.rb']
12
+ t.verbose = true
13
+ end
14
+
15
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "view_model-rails"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
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/view_model/rails/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'
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,2 @@
1
+ class -classname- < ViewModel
2
+ end
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ class -classname-ViewModelTest < ActiveSupport::TestCase
4
+
5
+ test 'the truth' do
6
+ assert true
7
+ end
8
+
9
+ end
@@ -0,0 +1,36 @@
1
+ require 'rails/generators'
2
+
3
+ class ViewModelGenerator < Rails::Generators::NamedBase
4
+
5
+ source_root File.expand_path('../templates', __FILE__)
6
+
7
+ def create_view_model_file
8
+ path = "app/view_model/#{file_name}.rb"
9
+
10
+ if FileTest.exists? path
11
+ raise FileExistError, "This filename ist used by another view-model:#{path}"
12
+ end
13
+
14
+ copy_file 'view_model_template.rb', path
15
+ replace_class_name path
16
+ end
17
+
18
+ def create_presenter_test_file
19
+ path = "test/view_model/#{file_name}_view_model_test.rb"
20
+ if FileTest.exists?path
21
+ raise FileExistError, "This filename ist used by another view-model test:#{path}"
22
+ end
23
+
24
+ copy_file "view_model_test_template.rb", path
25
+ replace_class_name path
26
+ end
27
+
28
+ private
29
+
30
+ def replace_class_name path
31
+ gsub_file path, '-classname-' , "#{class_name}"
32
+ end
33
+
34
+ end
35
+
36
+ class FileExistError < StandardError; end
@@ -0,0 +1,6 @@
1
+ # Base class for view models in this application
2
+
3
+ require 'view_model'
4
+
5
+ class ViewModel < ViewModel::Base
6
+ end
@@ -0,0 +1,14 @@
1
+ namespace :'view_model' do
2
+
3
+ def copy_from_template(path)
4
+ templates = File.expand_path('../share/', __FILE__)
5
+ rails = Rails.root.to_s
6
+ sh "mkdir -p #{rails}/#{File.dirname path}"
7
+ cp "#{templates}/#{path}", "#{rails}/#{path}"
8
+ end
9
+
10
+ desc 'Build application base view model'
11
+ task :setup do
12
+ copy_from_template 'app/view_model/view_model.rb'
13
+ end
14
+ end
@@ -0,0 +1,8 @@
1
+ require 'rails/engine'
2
+
3
+ module ViewModel
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ module ViewModel
2
+ module Rails
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require 'view_model/rails/version'
2
+ require 'view_model/rails/engine'
3
+
4
+ module ViewModel
5
+ module Rails
6
+ end
7
+ end
@@ -0,0 +1,29 @@
1
+ $:.push File.expand_path('../lib', __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require 'view_model/rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'view_model-rails'
8
+ spec.version = ViewModel::Rails::VERSION
9
+ spec.authors = ['Andreas Busold']
10
+ spec.email = ['ab@neopoly.de']
11
+
12
+ if spec.respond_to?(:metadata)
13
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
14
+ end
15
+
16
+ spec.summary = %q{Rails engine providing view models}
17
+ spec.homepage = ''
18
+ spec.license = ''
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_dependency 'view_model'
25
+ spec.add_dependency 'rails'
26
+
27
+ spec.add_development_dependency 'bundler', '~> 1.8'
28
+ spec.add_development_dependency 'rake', '~> 10.0'
29
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: view_model-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Andreas Busold
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: view_model
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.8'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.8'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description:
70
+ email:
71
+ - ab@neopoly.de
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".ruby-gemset"
78
+ - ".ruby-version"
79
+ - Gemfile
80
+ - README.md
81
+ - Rakefile
82
+ - bin/console
83
+ - bin/rails
84
+ - bin/setup
85
+ - lib/generators/templates/view_model_template.rb
86
+ - lib/generators/templates/view_model_test_template.rb
87
+ - lib/generators/view_model_generator.rb
88
+ - lib/tasks/share/app/view_model/view_model.rb
89
+ - lib/tasks/view_model_tasks.rake
90
+ - lib/view_model-rails.rb
91
+ - lib/view_model/rails/engine.rb
92
+ - lib/view_model/rails/version.rb
93
+ - view_model-rails.gemspec
94
+ homepage: ''
95
+ licenses:
96
+ - ''
97
+ metadata:
98
+ allowed_push_host: https://rubygems.org
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubyforge_project:
115
+ rubygems_version: 2.4.6
116
+ signing_key:
117
+ specification_version: 4
118
+ summary: Rails engine providing view models
119
+ test_files: []