we_bridge-auto_view_helper 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: cfd341b8a712521bfd68d0bbae7abe44aa24c38f
4
+ data.tar.gz: 1b6b547a9d195ba6abea5aa83fe2a003c65dd1c4
5
+ SHA512:
6
+ metadata.gz: 8a9450eba414c0154fd14e2791cdc35f45a289758fe9131f9e0b46d7a6d33ba43dd4871441fdf61e392c0815cdb12e762b752ca79d042e575f253816327186a3
7
+ data.tar.gz: 77d7a5aa1944ecaca405516e2c684e53aa6d04349522ad36df2c26f4f6ce17b44204f3100241eca1170f02ef32d161480ee1a0d37f956cb87bbbccdf6e2dc517
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /vendor
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
4
+ before_install: gem install bundler -v 1.10.3
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in we_bridge-auto_view_helper.gemspec
4
+ gemspec
5
+
6
+ gem 'actionview'
7
+ gem 'actionview-helpers-auto_tag_helper'
data/Gemfile.lock ADDED
@@ -0,0 +1,75 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ we_bridge-auto_view_helper (0.1.0)
5
+ actionview
6
+ actionview-helpers-auto_tag_helper
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actionview (4.2.3)
12
+ activesupport (= 4.2.3)
13
+ builder (~> 3.1)
14
+ erubis (~> 2.7.0)
15
+ rails-dom-testing (~> 1.0, >= 1.0.5)
16
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
17
+ actionview-helpers-auto_tag_helper (0.1.1)
18
+ actionview
19
+ activesupport (>= 4.2.3)
20
+ activesupport (4.2.3)
21
+ i18n (~> 0.7)
22
+ json (~> 1.7, >= 1.7.7)
23
+ minitest (~> 5.1)
24
+ thread_safe (~> 0.3, >= 0.3.4)
25
+ tzinfo (~> 1.1)
26
+ builder (3.2.2)
27
+ diff-lcs (1.2.5)
28
+ erubis (2.7.0)
29
+ i18n (0.7.0)
30
+ json (1.8.3)
31
+ loofah (2.0.2)
32
+ nokogiri (>= 1.5.9)
33
+ mini_portile (0.6.2)
34
+ minitest (5.7.0)
35
+ nokogiri (1.6.6.2)
36
+ mini_portile (~> 0.6.0)
37
+ rails-deprecated_sanitizer (1.0.3)
38
+ activesupport (>= 4.2.0.alpha)
39
+ rails-dom-testing (1.0.6)
40
+ activesupport (>= 4.2.0.beta, < 5.0)
41
+ nokogiri (~> 1.6.0)
42
+ rails-deprecated_sanitizer (>= 1.0.1)
43
+ rails-html-sanitizer (1.0.2)
44
+ loofah (~> 2.0)
45
+ rake (10.4.2)
46
+ rspec (3.3.0)
47
+ rspec-core (~> 3.3.0)
48
+ rspec-expectations (~> 3.3.0)
49
+ rspec-mocks (~> 3.3.0)
50
+ rspec-core (3.3.2)
51
+ rspec-support (~> 3.3.0)
52
+ rspec-expectations (3.3.1)
53
+ diff-lcs (>= 1.2.0, < 2.0)
54
+ rspec-support (~> 3.3.0)
55
+ rspec-mocks (3.3.2)
56
+ diff-lcs (>= 1.2.0, < 2.0)
57
+ rspec-support (~> 3.3.0)
58
+ rspec-support (3.3.0)
59
+ thread_safe (0.3.5)
60
+ tzinfo (1.2.2)
61
+ thread_safe (~> 0.1)
62
+
63
+ PLATFORMS
64
+ ruby
65
+
66
+ DEPENDENCIES
67
+ actionview
68
+ actionview-helpers-auto_tag_helper
69
+ bundler (~> 1.10)
70
+ rake (~> 10.0)
71
+ rspec
72
+ we_bridge-auto_view_helper!
73
+
74
+ BUNDLED WITH
75
+ 1.10.3
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Shinjiro Itagaki
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # WeBridge::AutoViewHelper
2
+
3
+ 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/we_bridge/auto_view_helper`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'we_bridge-auto_view_helper'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install we_bridge-auto_view_helper
22
+
23
+ ## Usage
24
+
25
+ Call helper method in view template
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/we_bridge-auto_view_helper. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "we_bridge/auto_view_helper"
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/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,140 @@
1
+ require "we_bridge/auto_view_helper/version"
2
+ require "actionview/helpers/auto_tag_helper"
3
+
4
+ module WeBridge
5
+ module AutoViewHelper
6
+ include ActionView::Helpers::AutoTagHelper
7
+ def t_xxx(xxx,k)
8
+ ::I18n.t("db.#{xxx}.#{k}",default: ::I18n.t("db._common_.#{k}",default: k.to_s))
9
+ end
10
+
11
+ def self.default_options
12
+ @default_options ? @default_options.dup : {show_path: nil, edit_path: nil, new_path: nil, root_path: '/', locale: ::I18n.default_locale}
13
+ end
14
+
15
+ def self.default_options=(options)
16
+ @default_options = options
17
+ end
18
+
19
+ def edit_common(record,url,options={})
20
+ options = WeBridge::AutoViewHelper.default_options.merge options.symbolize_keys
21
+
22
+ show_path = options[:show_path]
23
+ root_path = options[:root_path]
24
+ locale = options[:locale]
25
+
26
+ title ||= "Edit " + record.class.name
27
+ method ||= nil
28
+ markup do |m|
29
+ m.section do
30
+ m.h2 title
31
+ m << form_tag(url, method: method || :patch, multipart: true) do
32
+ markup do |m2|
33
+ m2.dl do
34
+ klass = record.class
35
+ syms = []
36
+ if klass.respond_to? :editable_columns
37
+ syms = klass.editable_columns
38
+ else
39
+ syms = klass.content_columns.map(&:name)
40
+ end
41
+
42
+ syms.each do |sym|
43
+ m2.dt t_xxx(record.class.table_name,sym)
44
+ m2.dd { m2 << auto_input_tag(sym,record.class,"#{record.class.table_name}[#{sym}]",record.__send__(sym)) }
45
+ end
46
+
47
+ m2.div class: locale do
48
+ if record.respond_to?(:text) && (text = record.text(lang.code))
49
+ syms = []
50
+ if text.respond_to? :editable_columns
51
+ syms = text.editable_columns
52
+ else
53
+ syms = text.content_columns.map(&:name)
54
+ end
55
+ syms.each do |sym|
56
+ column = text.class.columns_hash[sym.to_s]
57
+ m2.dt t_xxx(text.class.table_name,sym)
58
+ m2.dd { m2 << text_tag(column.type,"#{text.class.table_name}[#{text.lang.code}][#{sym}]",text.__send__(sym)) }
59
+ end
60
+ end
61
+ end
62
+ end
63
+ m2 << submit_tag("Save")
64
+ end
65
+ end
66
+ end
67
+
68
+ if show_path
69
+ m.div do
70
+ m.a "Show", href: show_path
71
+ end
72
+ end
73
+
74
+ if root_path
75
+ m.div do
76
+ m.a "Top", href: root_path
77
+ end
78
+ end
79
+ end
80
+ end
81
+
82
+ def show_common(record,options={})
83
+ options = WeBridge::Common::Layouts.default_options.merge options.symbolize_keys
84
+
85
+ edit_path = options[:edit_path]
86
+ root_path = options[:root_path]
87
+
88
+ markup do |m|
89
+ m.section do
90
+ m.h2 "show "
91
+ m << self.show_record(record)
92
+ if edit_path
93
+ m.div do
94
+ m.a "Edit", href: edit_path
95
+ end
96
+ end
97
+
98
+ if root_path
99
+ m.div do
100
+ m.a "Top", href: root_path
101
+ end
102
+ end
103
+ end
104
+ end
105
+ end
106
+
107
+ def show_record(record)
108
+ model = record.class
109
+ markup do |m|
110
+ m.dl class: :table do
111
+ method_names = model.respond_to?(:showable_methods) ? model.showable_methods : model.content_columns.map(&:name)
112
+ method_names.each do |mn|
113
+ m.dt t_xxx(record.class.table_name,mn)
114
+ m.dd { m << display_tag(mn,record) }
115
+ end
116
+
117
+ if record.respond_to?(:text) && model.respond_to?(:text)
118
+ text_model = model.text
119
+ if text_model.respond_to? :showable_methods
120
+ mns = text_model.showable_methods
121
+ lang_model = defined?(::Lang) ? ::Lang : ActiveRecord::Mlang::Lang
122
+ langs = lang_model.all.to_a
123
+ langs.each do |lang|
124
+ text = record.text(lang.code)
125
+ mns.each do |mn|
126
+ m.div class: lang.code do
127
+ m.dt t_xxx(record.class.text.table_name,mn)
128
+ m.dd { m << (show_tag(mn,text) || "N/A") }
129
+ end
130
+ end
131
+ end
132
+ end
133
+ end
134
+ end
135
+ end
136
+ end
137
+ end
138
+ end
139
+
140
+ ActionView::Base.__send__(:include,WeBridge::AutoViewHelper)
@@ -0,0 +1,5 @@
1
+ module WeBridge
2
+ module AutoViewHelper
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'we_bridge/auto_view_helper/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "we_bridge-auto_view_helper"
8
+ spec.version = WeBridge::AutoViewHelper::VERSION
9
+ spec.authors = ["Shinjiro Itagaki"]
10
+ spec.email = ["ishinjiroster@gmail.com"]
11
+
12
+ spec.summary = "helper used in we-bridge"
13
+ spec.description = "helper used in we-bridge"
14
+ spec.homepage = "https://github.com/baseball-bridge/we_bridge-auto_view_helper"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_dependency 'actionview'
31
+ spec.add_dependency 'actionview-helpers-auto_tag_helper'
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.10"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rspec"
36
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: we_bridge-auto_view_helper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Shinjiro Itagaki
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-08-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: actionview
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: actionview-helpers-auto_tag_helper
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.10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.10'
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
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: helper used in we-bridge
84
+ email:
85
+ - ishinjiroster@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - CODE_OF_CONDUCT.md
94
+ - Gemfile
95
+ - Gemfile.lock
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - bin/console
100
+ - bin/setup
101
+ - lib/we_bridge/auto_view_helper.rb
102
+ - lib/we_bridge/auto_view_helper/version.rb
103
+ - we_bridge-auto_view_helper.gemspec
104
+ homepage: https://github.com/baseball-bridge/we_bridge-auto_view_helper
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.4.5
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: helper used in we-bridge
128
+ test_files: []