class_lister 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .*.swp
6
+ .*.swo
7
+ coverage/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --colour
3
+ --tty
@@ -0,0 +1,4 @@
1
+ # develop
2
+
3
+ # v0.0.1
4
+ * First release!
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in class_lister.gemspec
4
+ gemspec
@@ -0,0 +1,5 @@
1
+ guard 'rspec', :version => 2, :cli => '--format documentation' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec/" }
5
+ end
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2012 Ben Langfeld
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,51 @@
1
+ class_lister
2
+ ===========
3
+
4
+ Lists all classes under a given module.
5
+
6
+ Install
7
+ -------
8
+
9
+ gem install class_lister
10
+
11
+ Examples
12
+ --------
13
+
14
+ ```ruby
15
+ require 'class_lister'
16
+
17
+ module Foo
18
+ VERSION = 2
19
+ class Bar; end
20
+ class Baz; end
21
+ end
22
+
23
+ ClassLister.list Foo
24
+ # => [Foo::Bar, Foo::Baz]
25
+ ```
26
+
27
+ Author
28
+ ------
29
+
30
+ Original author: Ben Langfeld
31
+
32
+ Links
33
+ -----
34
+ * [Source](https://github.com/benlangfeld/class_lister)
35
+ * [Documentation](http://rdoc.info/github/benlangfeld/class_lister/master/frames)
36
+ * [Bug Tracker](https://github.com/benlangfeld/class_lister/issues)
37
+
38
+ Note on Patches/Pull Requests
39
+ -----------------------------
40
+
41
+ * Fork the project.
42
+ * Make your feature addition or bug fix.
43
+ * Add tests for it. This is important so I don't break it in a future version unintentionally.
44
+ * Commit, do not mess with rakefile, version, or history.
45
+ * If you want to have your own version, that is fine but bump version in a commit by itself so I can ignore when I pull
46
+ * Send me a pull request. Bonus points for topic branches.
47
+
48
+ Copyright
49
+ ---------
50
+
51
+ Copyright (c) 2012 Ben Langfeld. MIT licence (see LICENSE for details).
@@ -0,0 +1,13 @@
1
+ require 'bundler/setup'
2
+ require 'bundler/gem_tasks'
3
+
4
+ task :default => :spec
5
+
6
+ require 'rspec/core'
7
+ require 'rspec/core/rake_task'
8
+ RSpec::Core::RakeTask.new(:spec) do |spec|
9
+ spec.pattern = 'spec/**/*_spec.rb'
10
+ end
11
+
12
+ require 'yard'
13
+ YARD::Rake::YardocTask.new
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "class_lister/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "class_lister"
7
+ s.version = ClassLister::VERSION
8
+ s.authors = ["Ben Langfeld"]
9
+ s.email = ["ben@langfeld.me"]
10
+ s.homepage = "http://github.com/benlangfeld/class_lister"
11
+ s.summary = %q{Lists all classes under a given module.}
12
+ s.description = %q{Lists all classes under a given module.}
13
+
14
+ s.rubyforge_project = "class_lister"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_development_dependency %q<bundler>, ["~> 1.1"]
22
+ s.add_development_dependency %q<rspec>, [">= 2.5.0"]
23
+ s.add_development_dependency %q<yard>, ["~> 0.6.0"]
24
+ s.add_development_dependency %q<rake>, [">= 0"]
25
+ s.add_development_dependency %q<guard-rspec>
26
+ end
@@ -0,0 +1,15 @@
1
+ require "class_lister/version"
2
+
3
+ module ClassLister
4
+ class << self
5
+ def list(mod, filter = true)
6
+ return [] unless mod.respond_to?(:constants)
7
+
8
+ mod.constants.inject([]) do |collection, name|
9
+ const = mod.const_get name
10
+ collection << const
11
+ collection += list const, false
12
+ end.tap { |c| c.select! { |c| c.is_a? Class } if filter }
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module ClassLister
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe ClassLister do
4
+ module TestModule
5
+ VERSION = :foo
6
+
7
+ class A
8
+ class C; end
9
+
10
+ module D
11
+ class E; end
12
+ end
13
+ end
14
+
15
+ module B
16
+ class F; end
17
+ end
18
+
19
+ module G; end
20
+ end
21
+
22
+ describe "#list" do
23
+ it "should list all classes within the specified namespace" do
24
+ described_class.list(TestModule).should be == [
25
+ TestModule::A,
26
+ TestModule::A::C,
27
+ TestModule::A::D::E,
28
+ TestModule::B::F
29
+ ]
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,8 @@
1
+ require 'class_lister'
2
+
3
+ Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f}
4
+
5
+ RSpec.configure do |config|
6
+ config.filter_run :focus => true
7
+ config.run_all_when_everything_filtered = true
8
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: class_lister
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ben Langfeld
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-01 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.1'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.1'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 2.5.0
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 2.5.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: yard
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.6.0
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.6.0
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: guard-rspec
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: Lists all classes under a given module.
95
+ email:
96
+ - ben@langfeld.me
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files: []
100
+ files:
101
+ - .gitignore
102
+ - .rspec
103
+ - CHANGELOG.md
104
+ - Gemfile
105
+ - Guardfile
106
+ - LICENSE.txt
107
+ - README.md
108
+ - Rakefile
109
+ - class_lister.gemspec
110
+ - lib/class_lister.rb
111
+ - lib/class_lister/version.rb
112
+ - spec/class_lister_spec.rb
113
+ - spec/spec_helper.rb
114
+ homepage: http://github.com/benlangfeld/class_lister
115
+ licenses: []
116
+ post_install_message:
117
+ rdoc_options: []
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ segments:
127
+ - 0
128
+ hash: -4475461530983700731
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ! '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ segments:
136
+ - 0
137
+ hash: -4475461530983700731
138
+ requirements: []
139
+ rubyforge_project: class_lister
140
+ rubygems_version: 1.8.21
141
+ signing_key:
142
+ specification_version: 3
143
+ summary: Lists all classes under a given module.
144
+ test_files:
145
+ - spec/class_lister_spec.rb
146
+ - spec/spec_helper.rb