active_admin_menu 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d57449bdcecd4cac16edaaf94377ea49a90d7b47
4
- data.tar.gz: fe1faf28ad26ec69a66f31f41120380c12ea6c01
3
+ metadata.gz: c2ee76827d02be8882582bf722b6309093fba1d2
4
+ data.tar.gz: 84211e63ae516eaf7d9e3a950b2b91c23ac268f1
5
5
  SHA512:
6
- metadata.gz: 4c4c11dd16b27ed8148c2a3e8795136ea1770927ff73e5d866823c10f5719c313af60f97c684031cb4eddd5a902940cb903d80f47661626499e40ca3e626ca59
7
- data.tar.gz: 9e60a1712247606a71c04a245ecba1175898e673b74e5c28e97ff848539f86a726a7392b0f4c079eb68db073c9be5ad85717fc0e0442913da5bba9c5766c4c3d
6
+ metadata.gz: e1db122eb6331313f88f2e96afff387215bd11bb7b3916fe9a7f97b3bc74e72e504a2d80cbccaa10d37b3a3dadf36a3bf9a51619aeb3c3e3ff50cc10b9205ce5
7
+ data.tar.gz: d27a232fc350d5a24c6e23b48b56daa5d6c9c5f16fcbb0a8d9ae9e8402745b80e296d9d7f122ff7c026a4b809a75d04bae38d1c2c8dbad1c767c3e99a154473b
data/.gitignore CHANGED
@@ -5,5 +5,8 @@
5
5
  /coverage/
6
6
  /doc/
7
7
  /pkg/
8
+ /spec/rails/
8
9
  /spec/reports/
9
10
  /tmp/
11
+ /gemfiles/*.gemfile.lock
12
+ /gemfiles/vendor/
data/.rubocop.yml CHANGED
@@ -5,6 +5,8 @@ AllCops:
5
5
  Exclude:
6
6
  - "bin/*"
7
7
  - "vendor/**/*"
8
+ - "gemfiles/**/*"
9
+ - "spec/rails/**/*"
8
10
  - Gemfile
9
11
  - Rakefile
10
12
  DisplayCopNames: true
data/Appraisals ADDED
@@ -0,0 +1,10 @@
1
+ appraise 'rails42' do
2
+ gem 'rails', '~> 4.2.0'
3
+ gem 'activeadmin', '1.0.0.pre4'
4
+ end
5
+
6
+ appraise 'rails50' do
7
+ gem 'rails', '~> 5.0.0'
8
+ gem 'inherited_resources', github: 'activeadmin/inherited_resources'
9
+ gem 'activeadmin', github: 'activeadmin/activeadmin'
10
+ end
data/Gemfile CHANGED
@@ -1,4 +1,21 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in active_admin_menu.gemspec
4
3
  gemspec
4
+
5
+ gem 'rails', '~> 4.2.0'
6
+ gem 'activeadmin', '1.0.0.pre4'
7
+ gem "pry"
8
+ gem 'appraisal'
9
+
10
+ group :development do
11
+ gem "rubocop", "~> 0.40.0"
12
+ end
13
+
14
+ group :test do
15
+ gem "capybara"
16
+ gem "rspec-rails"
17
+ gem "database_cleaner"
18
+ gem 'shoulda-matchers'
19
+ gem "sqlite3", platforms: :mri
20
+ gem "poltergeist"
21
+ end
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ActiveAdminMenu
2
2
 
3
- Manage menu with YAML for [Active Admin](https://github.com/activeadmin/activeadmin)
3
+ Manageable menu with YAML for [Active Admin](https://github.com/activeadmin/activeadmin)
4
4
 
5
5
  ## Installation
6
6
 
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler'
2
+ require 'rake'
3
3
 
4
- RSpec::Core::RakeTask.new(:spec)
4
+ Bundler.setup
5
+ Bundler::GemHelper.install_tasks
5
6
 
6
- task :default => :spec
7
+ FileList['tasks/**/*.rake'].each { |task| import task }
@@ -1,7 +1,4 @@
1
- # -*- encoding: utf-8 -*-
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "active_admin_menu/version"
1
+ require File.join(File.dirname(__FILE__), "lib", "active_admin_menu", "version")
5
2
 
6
3
  Gem::Specification.new do |gem|
7
4
  gem.name = "active_admin_menu"
@@ -20,11 +17,9 @@ Gem::Specification.new do |gem|
20
17
  gem.require_paths = ["lib"]
21
18
 
22
19
  gem.required_ruby_version = ">= 2.1.0"
23
- gem.add_runtime_dependency "activeadmin", "~> 1.0.0.pre4"
20
+
21
+ gem.add_dependency "activeadmin", ">= 1.0.0.pre4"
24
22
 
25
23
  gem.add_development_dependency "bundler", "~> 1.13"
26
24
  gem.add_development_dependency "rake", "~> 10.0"
27
- gem.add_development_dependency "rspec", "~> 3.0"
28
- gem.add_development_dependency "pry", "~> 0.10.0"
29
- gem.add_development_dependency "rubocop", "~> 0.40.0"
30
25
  end
@@ -0,0 +1,23 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 4.2.0"
6
+ gem "activeadmin", "1.0.0.pre4"
7
+ gem "pry"
8
+ gem "appraisal"
9
+
10
+ group :development do
11
+ gem "rubocop", "~> 0.40.0"
12
+ end
13
+
14
+ group :test do
15
+ gem "capybara"
16
+ gem "rspec-rails"
17
+ gem "database_cleaner"
18
+ gem "shoulda-matchers"
19
+ gem "sqlite3", :platforms => :mri
20
+ gem "poltergeist"
21
+ end
22
+
23
+ gemspec :path => "../"
@@ -0,0 +1,24 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 5.0.0"
6
+ gem "activeadmin", :github => "activeadmin/activeadmin"
7
+ gem "pry"
8
+ gem "appraisal"
9
+ gem "inherited_resources", :github => "activeadmin/inherited_resources"
10
+
11
+ group :development do
12
+ gem "rubocop", "~> 0.40.0"
13
+ end
14
+
15
+ group :test do
16
+ gem "capybara"
17
+ gem "rspec-rails"
18
+ gem "database_cleaner"
19
+ gem "shoulda-matchers"
20
+ gem "sqlite3", :platforms => :mri
21
+ gem "poltergeist"
22
+ end
23
+
24
+ gemspec :path => "../"
@@ -0,0 +1,19 @@
1
+ module ActiveAdminMenu
2
+ module ActiveAdmin
3
+ module Application
4
+ def register(*arg, &block)
5
+ super(*arg) do
6
+ allocate_to_menu
7
+ instance_eval(&block)
8
+ end
9
+ end
10
+
11
+ def register_page(*args, &block)
12
+ super(*args) do
13
+ allocate_to_menu(is_page: true)
14
+ instance_eval(&block)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,20 @@
1
+ module ActiveAdminMenu
2
+ module ActiveAdmin
3
+ module DSL
4
+ def allocate_to_menu(is_page: false)
5
+ if item = active_admin_menu.find_item_by(resource_name: config.resource_name.name)
6
+ item.is_page = is_page
7
+ menu(item.to_options)
8
+ else
9
+ menu(if: -> { false })
10
+ end
11
+ end
12
+
13
+ private
14
+
15
+ def active_admin_menu
16
+ @_active_admin_menu ||= ::ActiveAdminMenu::Menu.build
17
+ end
18
+ end
19
+ end
20
+ end
@@ -4,8 +4,6 @@ module ActiveAdminMenu
4
4
  class << self
5
5
  def configure
6
6
  yield(config)
7
- rescue NoMethodError => e
8
- raise Config::InvalidAttribute, ":#{e.name.to_s.chop} is invalid attribute"
9
7
  end
10
8
 
11
9
  def config
@@ -14,9 +12,6 @@ module ActiveAdminMenu
14
12
  end
15
13
 
16
14
  class Config
17
- class InvalidAttribute < StandardError; end
18
- class FileNotFound < StandardError; end
19
-
20
15
  attr_reader :source
21
16
  attr_accessor :namespace, :uncategorize_key_name, :i18n_scope_prefix
22
17
 
@@ -28,8 +23,6 @@ module ActiveAdminMenu
28
23
 
29
24
  def source=(value)
30
25
  @source = value.is_a?(Hash) ? value : YAML.load_file(value.to_s)
31
- rescue => e
32
- raise FileNotFound, e.message
33
26
  end
34
27
 
35
28
  def namespaced_source
@@ -10,20 +10,21 @@ module ActiveAdminMenu
10
10
  end
11
11
 
12
12
  def to_options
13
- { priority: priority }.tap do |options|
14
- options.store(:parent, I18n.t(parent_i18n_scope, default: parent)) if parent
15
- options.store(:label, I18n.t(label_i18n_scope, default: resource_name)) if is_page
16
- end
13
+ { parent: parent_i18n, label: label_i18n, priority: priority }.reject { |_, v| v.nil? }
17
14
  end
18
15
 
19
16
  private
20
17
 
21
- def parent_i18n_scope
22
- [config.i18n_scope_prefix[:parent], parent.downcase].join(".")
18
+ def parent_i18n
19
+ return unless parent
20
+
21
+ I18n.t([config.i18n_scope_prefix[:parent], parent.downcase].join("."), default: parent)
23
22
  end
24
23
 
25
- def label_i18n_scope
26
- [config.i18n_scope_prefix[:label], resource_name.downcase].join(".")
24
+ def label_i18n
25
+ return unless is_page
26
+
27
+ I18n.t([config.i18n_scope_prefix[:label], resource_name.downcase].join("."), default: resource_name)
27
28
  end
28
29
 
29
30
  def config
@@ -1,3 +1,3 @@
1
1
  module ActiveAdminMenu
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.1.1".freeze
3
3
  end
@@ -1,7 +1,9 @@
1
- require "active_admin_menu/allocator"
1
+ require "active_admin"
2
2
  require "active_admin_menu/config"
3
- require "active_admin_menu/dsl"
4
3
  require "active_admin_menu/item"
5
4
  require "active_admin_menu/menu"
6
- require "active_admin_menu/railtie"
7
- require "active_admin_menu/version"
5
+ require "active_admin_menu/active_admin/application"
6
+ require "active_admin_menu/active_admin/dsl"
7
+
8
+ ::ActiveAdmin::DSL.send :include, ActiveAdminMenu::ActiveAdmin::DSL
9
+ ::ActiveAdmin::Application.send :prepend, ActiveAdminMenu::ActiveAdmin::Application
data/tasks/test.rake ADDED
@@ -0,0 +1,10 @@
1
+ desc "Creates a test rails app for the specs to run against"
2
+ task :setup do
3
+ require "rails/version"
4
+ system("mkdir spec/rails") unless File.exist?("spec/rails")
5
+ system "bundle exec rails new spec/rails/rails-#{Rails::VERSION::STRING} -m spec/support/rails_template.rb --skip-spring --skip-turbolinks"
6
+ end
7
+
8
+ require "rspec/core/rake_task"
9
+ RSpec::Core::RakeTask.new(:spec)
10
+ task default: :spec
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_admin_menu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoshiyuki Hirano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-22 00:00:00.000000000 Z
11
+ date: 2016-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeadmin
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.0.0.pre4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.0.0.pre4
27
27
  - !ruby/object:Gem::Dependency
@@ -52,48 +52,6 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '10.0'
55
- - !ruby/object:Gem::Dependency
56
- name: rspec
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '3.0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '3.0'
69
- - !ruby/object:Gem::Dependency
70
- name: pry
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 0.10.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.10.0
83
- - !ruby/object:Gem::Dependency
84
- name: rubocop
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 0.40.0
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 0.40.0
97
55
  description: manage menu with YAML for Active Admin
98
56
  email:
99
57
  - yhirano@me.com
@@ -108,6 +66,7 @@ files:
108
66
  - ".rubocop.yml"
109
67
  - ".ruby-style.yml"
110
68
  - ".travis.yml"
69
+ - Appraisals
111
70
  - Gemfile
112
71
  - LICENSE.txt
113
72
  - README.md
@@ -115,18 +74,20 @@ files:
115
74
  - active_admin_menu.gemspec
116
75
  - bin/console
117
76
  - bin/setup
77
+ - gemfiles/rails42.gemfile
78
+ - gemfiles/rails50.gemfile
118
79
  - lib/active_admin_menu.rb
119
- - lib/active_admin_menu/allocator.rb
80
+ - lib/active_admin_menu/active_admin/application.rb
81
+ - lib/active_admin_menu/active_admin/dsl.rb
120
82
  - lib/active_admin_menu/config.rb
121
- - lib/active_admin_menu/dsl.rb
122
83
  - lib/active_admin_menu/item.rb
123
84
  - lib/active_admin_menu/menu.rb
124
- - lib/active_admin_menu/railtie.rb
125
85
  - lib/active_admin_menu/version.rb
126
86
  - lib/generators/active_admin_menu/USAGE
127
87
  - lib/generators/active_admin_menu/install_generator.rb
128
88
  - lib/generators/active_admin_menu/templates/active_admin_menu.yml
129
89
  - lib/generators/active_admin_menu/templates/initializer.rb
90
+ - tasks/test.rake
130
91
  homepage: https://github.com/yhirano55/active_admin_menu
131
92
  licenses:
132
93
  - MIT
@@ -1,17 +0,0 @@
1
- module ActiveAdminMenu
2
- module Allocator
3
- def register(*arg, &block)
4
- super(*arg) do
5
- allocate_to_menu
6
- instance_eval(&block)
7
- end
8
- end
9
-
10
- def register_page(*args, &block)
11
- super(*args) do
12
- allocate_to_menu(is_page: true)
13
- instance_eval(&block)
14
- end
15
- end
16
- end
17
- end
@@ -1,18 +0,0 @@
1
- module ActiveAdminMenu
2
- module DSL
3
- def allocate_to_menu(is_page: false)
4
- if item = active_admin_menu.find_item_by(resource_name: config.resource_name.name)
5
- item.is_page = is_page
6
- menu(item.to_options)
7
- else
8
- menu(if: -> { false })
9
- end
10
- end
11
-
12
- private
13
-
14
- def active_admin_menu
15
- @_active_admin_menu ||= ::ActiveAdminMenu::Menu.build
16
- end
17
- end
18
- end
@@ -1,10 +0,0 @@
1
- require "rails"
2
-
3
- module ActiveAdminMenu
4
- class Railtie < ::Rails::Railtie
5
- config.after_initialize do
6
- ActiveAdmin::DSL.send :include, ActiveAdminMenu::DSL
7
- ActiveAdmin::Application.send :prepend, ActiveAdminMenu::Allocator
8
- end
9
- end
10
- end