kitestrings 1.0.2 → 1.0.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 +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +10 -0
- data/kitestrings.gemspec +0 -2
- data/lib/generators/kitestrings/install_generator.rb +26 -6
- data/lib/generators/kitestrings/message_templates/default.text.erb +7 -0
- data/lib/generators/kitestrings/message_templates/index.html.haml +26 -0
- data/lib/generators/kitestrings/{templates → message_templates}/message.rb.erb +19 -2
- data/lib/generators/kitestrings/message_templates/message_mailer.rb +19 -0
- data/lib/generators/kitestrings/message_templates/message_migration.rb +20 -0
- data/lib/generators/kitestrings/message_templates/message_spec.rb +73 -0
- data/lib/generators/kitestrings/message_templates/messages.rb +11 -0
- data/lib/generators/kitestrings/message_templates/messages_controller.rb +41 -0
- data/lib/generators/kitestrings/message_templates/messages_controller_spec.rb +86 -0
- data/lib/generators/kitestrings/message_templates/show.html.haml +32 -0
- data/lib/generators/kitestrings/messages_generator.rb +64 -1
- data/lib/generators/templates/{deploy.rb → config/deploy.rb} +19 -16
- data/lib/generators/templates/config/deploy/integ.rb +3 -0
- data/lib/generators/templates/config/deploy/production.rb +12 -0
- data/lib/generators/templates/config/deploy/uat.rb +3 -0
- data/lib/generators/templates/config/environments/integ.rb +21 -0
- data/lib/generators/templates/config/environments/uat.rb +21 -0
- data/lib/generators/templates/views/public/403.html +30 -0
- data/lib/kitestrings/menu.rb +10 -0
- data/lib/kitestrings/menu/admin_controller.rb +21 -0
- data/lib/kitestrings/menu/controller.rb +24 -0
- data/lib/kitestrings/menu/item.rb +94 -0
- data/lib/kitestrings/menu/item_collection.rb +29 -0
- data/lib/kitestrings/menu/model.rb +29 -0
- data/lib/kitestrings/menu/view_helper.rb +68 -0
- data/lib/kitestrings/version.rb +1 -1
- data/spec/lib/generators/kitestrings/install_generator_spec.rb +17 -13
- data/spec/lib/generators/kitestrings/messages_generator_spec.rb +31 -3
- data/spec/lib/kitestrings/menu/model_spec.rb +33 -0
- data/spec/support/active_record.rb +0 -1
- data/spec/support/generator_support.rb +15 -0
- metadata +30 -35
- data/lib/generators/templates/deploy/integ.rb +0 -21
- data/lib/generators/templates/deploy/production.rb +0 -26
- data/lib/generators/templates/deploy/uat.rb +0 -23
@@ -0,0 +1,68 @@
|
|
1
|
+
module Kitestrings
|
2
|
+
module Menu::ViewHelper
|
3
|
+
|
4
|
+
# Generate a <li><a href="path">name</li> html string.
|
5
|
+
#
|
6
|
+
# This is done from a Menu::Item object that fetches the path and display name from a resource(model, or any
|
7
|
+
# object with Menu::Model included in it.), or an array that would be passed to polymorphic_path
|
8
|
+
#
|
9
|
+
# All other options are passed to +link_to+
|
10
|
+
#
|
11
|
+
# Examples:
|
12
|
+
# menu_link_to(current_menu_item)
|
13
|
+
# menu_link_to(current_menu_item.sub_item(OtherModel)) # link to nested index page of OtherModel under current path
|
14
|
+
# menu_link_to(:name => "Explicit", :path => path_method()) # specify name and path explicitly
|
15
|
+
# menu_link_to("Explicit", :path => path_method()) # specify name and path explicitly
|
16
|
+
# menu_link_to(@resource) # will link to resource_path(@resource)
|
17
|
+
# menu_link_to([@user, @mail]) # will link to user_mail_path(@user, @mail)
|
18
|
+
# menu_link_to([@user, Message]) # will link to user_messages_path(@user)
|
19
|
+
# menu_link_to(@user, :id => :user_link, :class => "me") # pass options to link_to
|
20
|
+
#
|
21
|
+
def menu_link_to(item, options={})
|
22
|
+
case
|
23
|
+
when item.is_a?(Hash)
|
24
|
+
# for use like: menu_item(name: "Selections", path: selections_path())
|
25
|
+
options = item
|
26
|
+
item = Menu::Item.new([])
|
27
|
+
when item.is_a?(Array)
|
28
|
+
item = Menu::Item.new(item)
|
29
|
+
when item.is_a?(String)
|
30
|
+
options[:name] = item
|
31
|
+
item = Menu::Item.new([])
|
32
|
+
when !item.is_a?(Menu::Item)
|
33
|
+
item = Menu::Item.new([item])
|
34
|
+
end
|
35
|
+
|
36
|
+
# use explicitly given path, or calculate using polymorphic_path:
|
37
|
+
path = options.delete(:path) ||
|
38
|
+
begin
|
39
|
+
if item.object.respond_to?(:new_record?) && item.object.new_record?
|
40
|
+
polymorphic_path item.resources[0..-2] + [item.object.class]
|
41
|
+
else
|
42
|
+
item.path
|
43
|
+
end
|
44
|
+
rescue NoMethodError, ActionController::RoutingError
|
45
|
+
Rails.logger.error("Menu item has no path: #{item.inspect}")
|
46
|
+
nil
|
47
|
+
end
|
48
|
+
|
49
|
+
if path && !item.hidden?
|
50
|
+
active = path == request.path # need to check request action perhaps? eg: GET, PUT, POST, etc.
|
51
|
+
|
52
|
+
name = options.delete(:name) || item.name || ''
|
53
|
+
|
54
|
+
# truncate long plain strings with an elipsis
|
55
|
+
if name.length > 30 && !name.html_safe?
|
56
|
+
name = name[0..30] + "…"
|
57
|
+
end
|
58
|
+
options[:id] ||= item.link_id
|
59
|
+
li_class = active ? 'active' : ''
|
60
|
+
|
61
|
+
# only generate the <li> tag if we have a name to display and a path to go to.
|
62
|
+
if name.present?
|
63
|
+
content_tag(:li, link_to(name, path, options), :class => li_class)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/lib/kitestrings/version.rb
CHANGED
@@ -4,20 +4,15 @@ require 'generator_spec'
|
|
4
4
|
require 'generators/kitestrings/install_generator'
|
5
5
|
|
6
6
|
describe Kitestrings::Generators::InstallGenerator do
|
7
|
-
|
7
|
+
|
8
|
+
include GeneratorSupport
|
9
|
+
|
10
|
+
destination File.expand_path("../../../../../tmp", __FILE__)
|
8
11
|
|
9
12
|
before :all do
|
10
13
|
prepare_destination
|
14
|
+
run_rails_new_generator(destination_root)
|
11
15
|
run_generator
|
12
|
-
@dir = self.class.test_case.destination_root
|
13
|
-
end
|
14
|
-
|
15
|
-
def file_path(path)
|
16
|
-
File.join(@dir, path)
|
17
|
-
end
|
18
|
-
|
19
|
-
def file_contents(path)
|
20
|
-
File.read(file_path(path))
|
21
16
|
end
|
22
17
|
|
23
18
|
context "check files" do
|
@@ -28,6 +23,8 @@ describe Kitestrings::Generators::InstallGenerator do
|
|
28
23
|
config/deploy/integ.rb
|
29
24
|
config/deploy/uat.rb
|
30
25
|
config/deploy/production.rb
|
26
|
+
config/environments/integ.rb
|
27
|
+
config/environments/uat.rb
|
31
28
|
lib/templates/haml/scaffold/_form.html.haml
|
32
29
|
lib/templates/haml/scaffold/edit.html.haml
|
33
30
|
lib/templates/haml/scaffold/index.html.haml
|
@@ -39,15 +36,22 @@ describe Kitestrings::Generators::InstallGenerator do
|
|
39
36
|
lib/templates/rspec/model/model_spec.rb
|
40
37
|
lib/templates/rspec/scaffold/controller_spec.rb
|
41
38
|
lib/templates/rspec/scaffold/routing_spec.rb
|
39
|
+
app/views/public/403.html
|
40
|
+
app/views/layouts/application.html.haml
|
41
|
+
app/views/application/_navigation.html.haml
|
42
|
+
lib/capistrano/.keep
|
42
43
|
].each do |file|
|
43
44
|
it "created #{file}" do
|
44
|
-
path =
|
45
|
+
path = file_path(file)
|
45
46
|
expect(File.exist?(path)).to be_truthy
|
46
47
|
end
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
50
|
-
|
51
|
-
|
51
|
+
it "inserted into application_controller" do
|
52
|
+
file_contents("app/controllers/application_controller.rb").should match(/rescue_from CanCan::AccessDenied/)
|
53
|
+
end
|
52
54
|
|
55
|
+
# otherwise it wants to run the specs in the tmp/spec directory
|
56
|
+
after(:all) { rm_rf(destination_root) }
|
53
57
|
end
|
@@ -5,15 +5,43 @@ require 'generators/kitestrings/messages_generator'
|
|
5
5
|
require 'rails'
|
6
6
|
|
7
7
|
describe Kitestrings::Generators::MessagesGenerator do
|
8
|
-
|
8
|
+
|
9
|
+
include GeneratorSupport
|
10
|
+
|
11
|
+
destination File.expand_path("../../../../../tmp", __FILE__)
|
9
12
|
|
10
13
|
before :all do
|
11
14
|
prepare_destination
|
15
|
+
run_rails_new_generator(destination_root)
|
12
16
|
run_generator
|
13
17
|
@dir = self.class.test_case.destination_root
|
14
18
|
end
|
15
19
|
|
16
|
-
|
17
|
-
|
20
|
+
context "check files" do
|
21
|
+
%w[
|
22
|
+
app/controllers/messages_controller.rb
|
23
|
+
app/models/message.rb
|
24
|
+
app/mailers/message_mailer.rb
|
25
|
+
app/views/message_mailer/default.text.erb
|
26
|
+
app/views/messages/index.html.haml
|
27
|
+
app/views/messages/show.html.haml
|
28
|
+
spec/controllers/messages_controller_spec.rb
|
29
|
+
spec/models/message_spec.rb
|
30
|
+
spec/factories/messages.rb
|
31
|
+
].each do |file|
|
32
|
+
it "created #{file}" do
|
33
|
+
path = file_path(file)
|
34
|
+
expect(File.exist?(path)).to be_truthy
|
35
|
+
end
|
36
|
+
|
37
|
+
it "created a migration" do
|
38
|
+
files = Dir.glob(file_path("/db/migrate/*.rb"))
|
39
|
+
expect(files.select { |name| File.basename(name) =~ /create_messages/ }.count).to eq(1)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "updated the routes" do
|
43
|
+
expect(file_contents("config/routes.rb")).to include('resources :messages, only: [:index, :show]')
|
44
|
+
end
|
45
|
+
end
|
18
46
|
end
|
19
47
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'kitestrings/menu'
|
3
|
+
require 'kitestrings/menu/model'
|
4
|
+
|
5
|
+
describe Kitestrings::Menu::Model do
|
6
|
+
let(:klass) { Class.new { include Kitestrings::Menu::Model } }
|
7
|
+
subject { klass.new }
|
8
|
+
|
9
|
+
context "Class" do
|
10
|
+
it "uses activemodel::naming" do
|
11
|
+
klass.class_eval do
|
12
|
+
self.extend ActiveModel::Naming
|
13
|
+
def self.name
|
14
|
+
"example"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
expect(klass.menu_display_name).to eq("Examples")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "Instance" do
|
22
|
+
it "default name method" do
|
23
|
+
subject.stub(:name => "some example")
|
24
|
+
expect(subject.menu_display_name).to eq("some example")
|
25
|
+
end
|
26
|
+
|
27
|
+
it "explicit name method" do
|
28
|
+
klass.menu_name_method = :full_name
|
29
|
+
subject.stub(:full_name => "full name example")
|
30
|
+
expect(subject.menu_display_name).to eq("full name example")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module GeneratorSupport
|
2
|
+
def file_path(path)
|
3
|
+
File.join(destination_root, path)
|
4
|
+
end
|
5
|
+
|
6
|
+
def file_contents(path)
|
7
|
+
File.read(file_path(path))
|
8
|
+
end
|
9
|
+
|
10
|
+
def run_rails_new_generator(path)
|
11
|
+
# inherit whatever GEMFILE is specified by our environment. This should allow the test to inherit
|
12
|
+
# specific versions of rails from a gemfile, eg when using appraisals (to come soon)
|
13
|
+
%x[bundle exec rails new -T -B -G #{path}] # skip test, bundle and git.
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitestrings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ridget
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-07-
|
12
|
+
date: 2014-07-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -25,20 +25,6 @@ dependencies:
|
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '3.2'
|
28
|
-
- !ruby/object:Gem::Dependency
|
29
|
-
name: activemodel
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
31
|
-
requirements:
|
32
|
-
- - ">="
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: '3.2'
|
35
|
-
type: :runtime
|
36
|
-
prerelease: false
|
37
|
-
version_requirements: !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - ">="
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: '3.2'
|
42
28
|
- !ruby/object:Gem::Dependency
|
43
29
|
name: bundler
|
44
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,20 +95,6 @@ dependencies:
|
|
109
95
|
- - ">="
|
110
96
|
- !ruby/object:Gem::Version
|
111
97
|
version: '0'
|
112
|
-
- !ruby/object:Gem::Dependency
|
113
|
-
name: activerecord
|
114
|
-
requirement: !ruby/object:Gem::Requirement
|
115
|
-
requirements:
|
116
|
-
- - ">="
|
117
|
-
- !ruby/object:Gem::Version
|
118
|
-
version: '3.2'
|
119
|
-
type: :development
|
120
|
-
prerelease: false
|
121
|
-
version_requirements: !ruby/object:Gem::Requirement
|
122
|
-
requirements:
|
123
|
-
- - ">="
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: '3.2'
|
126
98
|
description: ''
|
127
99
|
email:
|
128
100
|
- tom.ridge@tworedkites.com
|
@@ -143,12 +115,23 @@ files:
|
|
143
115
|
- lib/async.rb
|
144
116
|
- lib/form_object.rb
|
145
117
|
- lib/generators/kitestrings/install_generator.rb
|
118
|
+
- lib/generators/kitestrings/message_templates/default.text.erb
|
119
|
+
- lib/generators/kitestrings/message_templates/index.html.haml
|
120
|
+
- lib/generators/kitestrings/message_templates/message.rb.erb
|
121
|
+
- lib/generators/kitestrings/message_templates/message_mailer.rb
|
122
|
+
- lib/generators/kitestrings/message_templates/message_migration.rb
|
123
|
+
- lib/generators/kitestrings/message_templates/message_spec.rb
|
124
|
+
- lib/generators/kitestrings/message_templates/messages.rb
|
125
|
+
- lib/generators/kitestrings/message_templates/messages_controller.rb
|
126
|
+
- lib/generators/kitestrings/message_templates/messages_controller_spec.rb
|
127
|
+
- lib/generators/kitestrings/message_templates/show.html.haml
|
146
128
|
- lib/generators/kitestrings/messages_generator.rb
|
147
|
-
- lib/generators/
|
148
|
-
- lib/generators/templates/deploy.rb
|
149
|
-
- lib/generators/templates/deploy/
|
150
|
-
- lib/generators/templates/deploy/
|
151
|
-
- lib/generators/templates/
|
129
|
+
- lib/generators/templates/config/deploy.rb
|
130
|
+
- lib/generators/templates/config/deploy/integ.rb
|
131
|
+
- lib/generators/templates/config/deploy/production.rb
|
132
|
+
- lib/generators/templates/config/deploy/uat.rb
|
133
|
+
- lib/generators/templates/config/environments/integ.rb
|
134
|
+
- lib/generators/templates/config/environments/uat.rb
|
152
135
|
- lib/generators/templates/haml/scaffold/_form.html.haml
|
153
136
|
- lib/generators/templates/haml/scaffold/edit.html.haml
|
154
137
|
- lib/generators/templates/haml/scaffold/index.html.haml
|
@@ -164,7 +147,15 @@ files:
|
|
164
147
|
- lib/generators/templates/spec_ext/spec_helper_ext.rb
|
165
148
|
- lib/generators/templates/views/application/_navigation.html.haml
|
166
149
|
- lib/generators/templates/views/layouts/application.html.haml
|
150
|
+
- lib/generators/templates/views/public/403.html
|
167
151
|
- lib/kitestrings.rb
|
152
|
+
- lib/kitestrings/menu.rb
|
153
|
+
- lib/kitestrings/menu/admin_controller.rb
|
154
|
+
- lib/kitestrings/menu/controller.rb
|
155
|
+
- lib/kitestrings/menu/item.rb
|
156
|
+
- lib/kitestrings/menu/item_collection.rb
|
157
|
+
- lib/kitestrings/menu/model.rb
|
158
|
+
- lib/kitestrings/menu/view_helper.rb
|
168
159
|
- lib/kitestrings/railtie.rb
|
169
160
|
- lib/kitestrings/version.rb
|
170
161
|
- lib/page_and_sort_helper.rb
|
@@ -175,10 +166,12 @@ files:
|
|
175
166
|
- spec/lib/async_spec.rb
|
176
167
|
- spec/lib/generators/kitestrings/install_generator_spec.rb
|
177
168
|
- spec/lib/generators/kitestrings/messages_generator_spec.rb
|
169
|
+
- spec/lib/kitestrings/menu/model_spec.rb
|
178
170
|
- spec/lib/page_and_sort_helper_spec.rb
|
179
171
|
- spec/lib/size_validator_spec.rb
|
180
172
|
- spec/spec_helper.rb
|
181
173
|
- spec/support/active_record.rb
|
174
|
+
- spec/support/generator_support.rb
|
182
175
|
homepage: ''
|
183
176
|
licenses:
|
184
177
|
- MIT
|
@@ -208,7 +201,9 @@ test_files:
|
|
208
201
|
- spec/lib/async_spec.rb
|
209
202
|
- spec/lib/generators/kitestrings/install_generator_spec.rb
|
210
203
|
- spec/lib/generators/kitestrings/messages_generator_spec.rb
|
204
|
+
- spec/lib/kitestrings/menu/model_spec.rb
|
211
205
|
- spec/lib/page_and_sort_helper_spec.rb
|
212
206
|
- spec/lib/size_validator_spec.rb
|
213
207
|
- spec/spec_helper.rb
|
214
208
|
- spec/support/active_record.rb
|
209
|
+
- spec/support/generator_support.rb
|
@@ -1,21 +0,0 @@
|
|
1
|
-
set :rails_env, 'integ'
|
2
|
-
|
3
|
-
set :rvm_ruby_string, "2.1.1"
|
4
|
-
|
5
|
-
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
|
6
|
-
|
7
|
-
set :rvm_install_ruby_params, '--verify-downloads 1'
|
8
|
-
set :rvm_type, :user
|
9
|
-
set :branch, 'develop'
|
10
|
-
|
11
|
-
|
12
|
-
#default_run_option[:pty] = true
|
13
|
-
ssh_options[:forward_agent] = true
|
14
|
-
|
15
|
-
|
16
|
-
# set :scm, :git # You can set :scm explicitly or Capistrano will make an intelligent guess based on known version control directory names
|
17
|
-
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
|
18
|
-
|
19
|
-
|
20
|
-
before 'deploy:setup', 'rvm:install_rvm' # update RVM
|
21
|
-
before 'deploy:setup', 'rvm:install_ruby'
|
@@ -1,26 +0,0 @@
|
|
1
|
-
set :rails_env, 'production'
|
2
|
-
|
3
|
-
#set :rvm_ruby_string, "1.9.3-p125@pwi_#{rails_env}"
|
4
|
-
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
|
5
|
-
|
6
|
-
set :rvm_install_ruby_params, '--verify-downloads 1'
|
7
|
-
set :rvm_type, :user
|
8
|
-
set :branch, 'master'
|
9
|
-
|
10
|
-
#default_run_option[:pty] = true
|
11
|
-
ssh_options[:forward_agent] = true
|
12
|
-
|
13
|
-
|
14
|
-
# set :scm, :git # You can set :scm explicitly or Capistrano will make an intelligent guess based on known version control directory names
|
15
|
-
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
|
16
|
-
|
17
|
-
|
18
|
-
#server 'standby.unitedsynergies.com.au', :web, :app, :db, primary: true
|
19
|
-
|
20
|
-
|
21
|
-
before 'deploy:setup', 'rvm:install_rvm' # update RVM
|
22
|
-
before 'deploy:setup', 'rvm:install_ruby'
|
23
|
-
|
24
|
-
after 'deploy:update_code' do
|
25
|
-
run "cd #{release_path}; RAILS_ENV=#{rails_env} bundle exec rake assets:precompile"
|
26
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
set :rails_env, 'uat'
|
2
|
-
|
3
|
-
#set :rvm_ruby_string, "1.9.3-p125@pwi_#{rails_env}"
|
4
|
-
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
|
5
|
-
|
6
|
-
set :rvm_install_ruby_params, '--verify-downloads 1'
|
7
|
-
set :rvm_type, :user
|
8
|
-
set :branch, 'develop'
|
9
|
-
|
10
|
-
|
11
|
-
#default_run_option[:pty] = true
|
12
|
-
ssh_options[:forward_agent] = true
|
13
|
-
|
14
|
-
|
15
|
-
# set :scm, :git # You can set :scm explicitly or Capistrano will make an intelligent guess based on known version control directory names
|
16
|
-
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
|
17
|
-
|
18
|
-
|
19
|
-
#server 'standby.unitedsynergies.com.au', :web, :app, :db, primary: true
|
20
|
-
|
21
|
-
|
22
|
-
before 'deploy:setup', 'rvm:install_rvm' # update RVM
|
23
|
-
before 'deploy:setup', 'rvm:install_ruby'
|