code_metrics 0.0.2 → 0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4d6b9825dfbdc3ac0a8c0ccd8d6663e52cf6f34e
4
+ data.tar.gz: 1b084c6d626bbcc7d70d5fc61b34f4d597b6f5b0
5
+ SHA512:
6
+ metadata.gz: ad72309b4ce37ddfda8018763fb07858cc589486f7453cccef7b132cea04478df93646da21fa97225a7b40aa40425f675baf004402b00b61baf67d3fb37abb5e
7
+ data.tar.gz: 32fd57c33546ca5e14260167932f4f69ace5914213f315d88b8a2e2375879f787558b142134856687f5dd8b61123a42dd30ff08213b3f7aa068fd0d550ea442e
@@ -1,22 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'code_metrics'
3
3
  require 'code_metrics/statistics'
4
- # TODO, remove this duplicate code
5
- root = defined?(Rails) ? Rails.root : Dir.pwd
6
- STATS_DIRECTORIES = [
7
- %w(Controllers app/controllers),
8
- %w(Helpers app/helpers),
9
- %w(Models app/models),
10
- %w(Mailers app/mailers),
11
- %w(Javascripts app/assets/javascripts),
12
- %w(Libraries lib/),
13
- %w(APIs app/apis),
14
- %w(Controller\ tests test/controllers),
15
- %w(Helper\ tests test/helpers),
16
- %w(Model\ tests test/models),
17
- %w(Mailer\ tests test/mailers),
18
- %w(Integration\ tests test/integration),
19
- %w(Functional\ tests\ (old) test/functional),
20
- %w(Unit\ tests \ (old) test/unit)
21
- ].collect { |name, dir| [ name, "#{root}/#{dir}" ] }.select { |name, dir| File.directory?(dir) }
4
+ STATS_DIRECTORIES = CodeMetrics::StatsDirectories.new.directories
22
5
  CodeMetrics::Statistics.new(*STATS_DIRECTORIES).to_s
@@ -1,3 +1,3 @@
1
1
  module CodeMetrics
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,22 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code_metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
5
- prerelease:
4
+ version: 0.0.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - David Heinemeier Hansson
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-07-05 00:00:00.000000000 Z
11
+ date: 2013-07-10 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>'
17
+ - - '>'
20
18
  - !ruby/object:Gem::Version
21
19
  version: '3.0'
22
20
  - - <
@@ -25,9 +23,8 @@ dependencies:
25
23
  type: :development
26
24
  prerelease: false
27
25
  version_requirements: !ruby/object:Gem::Requirement
28
- none: false
29
26
  requirements:
30
- - - ! '>'
27
+ - - '>'
31
28
  - !ruby/object:Gem::Version
32
29
  version: '3.0'
33
30
  - - <
@@ -36,17 +33,15 @@ dependencies:
36
33
  - !ruby/object:Gem::Dependency
37
34
  name: sqlite3
38
35
  requirement: !ruby/object:Gem::Requirement
39
- none: false
40
36
  requirements:
41
- - - ! '>='
37
+ - - '>='
42
38
  - !ruby/object:Gem::Version
43
39
  version: '0'
44
40
  type: :development
45
41
  prerelease: false
46
42
  version_requirements: !ruby/object:Gem::Requirement
47
- none: false
48
43
  requirements:
49
- - - ! '>='
44
+ - - '>='
50
45
  - !ruby/object:Gem::Version
51
46
  version: '0'
52
47
  description: rake stats is great for looking at statistics on your code, displaying
@@ -69,8 +64,6 @@ files:
69
64
  - lib/tasks/statistics.rake
70
65
  - MIT-LICENSE
71
66
  - Rakefile
72
- - README.rdoc
73
- - test/active_support_testing_isolation.rb
74
67
  - test/code_metrics_test.rb
75
68
  - test/dummy/app/assets/javascripts/application.js
76
69
  - test/dummy/app/assets/stylesheets/application.css
@@ -105,7 +98,6 @@ files:
105
98
  - test/dummy/public/favicon.ico
106
99
  - test/dummy/Rakefile
107
100
  - test/dummy/README.rdoc
108
- - test/isolation_abstract_unit.rb
109
101
  - test/rake_test.rb
110
102
  - test/statistics_calculator_test.rb
111
103
  - test/test_helper.rb
@@ -114,30 +106,28 @@ files:
114
106
  homepage: https://github.com/bf4/code_metrics
115
107
  licenses:
116
108
  - MIT
109
+ metadata: {}
117
110
  post_install_message:
118
111
  rdoc_options: []
119
112
  require_paths:
120
113
  - lib
121
114
  required_ruby_version: !ruby/object:Gem::Requirement
122
- none: false
123
115
  requirements:
124
- - - ! '>='
116
+ - - '>='
125
117
  - !ruby/object:Gem::Version
126
118
  version: 1.9.3
127
119
  required_rubygems_version: !ruby/object:Gem::Requirement
128
- none: false
129
120
  requirements:
130
- - - ! '>='
121
+ - - '>='
131
122
  - !ruby/object:Gem::Version
132
123
  version: 1.8.11
133
124
  requirements: []
134
125
  rubyforge_project:
135
- rubygems_version: 1.8.25
126
+ rubygems_version: 2.0.3
136
127
  signing_key:
137
- specification_version: 3
128
+ specification_version: 4
138
129
  summary: Extraction of the rails rake stats task as a gem and rails plugin
139
130
  test_files:
140
- - test/active_support_testing_isolation.rb
141
131
  - test/code_metrics_test.rb
142
132
  - test/dummy/app/assets/javascripts/application.js
143
133
  - test/dummy/app/assets/stylesheets/application.css
@@ -172,7 +162,6 @@ test_files:
172
162
  - test/dummy/public/favicon.ico
173
163
  - test/dummy/Rakefile
174
164
  - test/dummy/README.rdoc
175
- - test/isolation_abstract_unit.rb
176
165
  - test/rake_test.rb
177
166
  - test/statistics_calculator_test.rb
178
167
  - test/test_helper.rb
@@ -1,3 +0,0 @@
1
- = CodeStatistics
2
-
3
- This project rocks and uses MIT-LICENSE.
@@ -1,136 +0,0 @@
1
- # require 'rbconfig'
2
- # require 'minitest/parallel_each'
3
- #
4
- # module ActiveSupport
5
- # module Testing
6
- # class RemoteError < StandardError
7
- #
8
- # attr_reader :message, :backtrace
9
- #
10
- # def initialize(exception)
11
- # @message = "caught #{exception.class.name}: #{exception.message}"
12
- # @backtrace = exception.backtrace
13
- # end
14
- # end
15
- #
16
- # class ProxyTestResult
17
- # def initialize(calls = [])
18
- # @calls = calls
19
- # end
20
- #
21
- # def add_error(e)
22
- # e = Test::Unit::Error.new(e.test_name, RemoteError.new(e.exception))
23
- # @calls << [:add_error, e]
24
- # end
25
- #
26
- # def __replay__(result)
27
- # @calls.each do |name, args|
28
- # result.send(name, *args)
29
- # end
30
- # end
31
- #
32
- # def marshal_dump
33
- # @calls
34
- # end
35
- #
36
- # def marshal_load(calls)
37
- # initialize(calls)
38
- # end
39
- #
40
- # def method_missing(name, *args)
41
- # @calls << [name, args]
42
- # end
43
- #
44
- # def info_signal
45
- # Signal.list['INFO']
46
- # end
47
- # end
48
- #
49
- # module Isolation
50
- # require 'thread'
51
- #
52
- # def self.included(klass) #:nodoc:
53
- # klass.extend(Module.new {
54
- # def test_methods
55
- # ParallelEach.new super
56
- # end
57
- # })
58
- # end
59
- #
60
- # def self.forking_env?
61
- # !ENV["NO_FORK"] && ((RbConfig::CONFIG['host_os'] !~ /mswin|mingw/) && (RUBY_PLATFORM !~ /java/))
62
- # end
63
- #
64
- # @@class_setup_mutex = Mutex.new
65
- #
66
- # def _run_class_setup # class setup method should only happen in parent
67
- # @@class_setup_mutex.synchronize do
68
- # unless defined?(@@ran_class_setup) || ENV['ISOLATION_TEST']
69
- # self.class.setup if self.class.respond_to?(:setup)
70
- # @@ran_class_setup = true
71
- # end
72
- # end
73
- # end
74
- #
75
- # def run
76
- # serialized = run_in_isolation do
77
- # super
78
- # end
79
- #
80
- # Marshal.load(serialized)
81
- # end
82
- #
83
- # module Forking
84
- # def run_in_isolation(&blk)
85
- # read, write = IO.pipe
86
- #
87
- # pid = fork do
88
- # read.close
89
- # yield
90
- # write.puts [Marshal.dump(self.dup)].pack("m")
91
- # exit!
92
- # end
93
- #
94
- # write.close
95
- # result = read.read
96
- # Process.wait2(pid)
97
- # return result.unpack("m")[0]
98
- # end
99
- # end
100
- #
101
- # module Subprocess
102
- # ORIG_ARGV = ARGV.dup unless defined?(ORIG_ARGV)
103
- #
104
- # # Crazy H4X to get this working in windows / jruby with
105
- # # no forking.
106
- # def run_in_isolation(&blk)
107
- # require "tempfile"
108
- #
109
- # if ENV["ISOLATION_TEST"]
110
- # proxy = ProxyTestResult.new
111
- # retval = yield proxy
112
- # File.open(ENV["ISOLATION_OUTPUT"], "w") do |file|
113
- # file.puts [Marshal.dump([retval, proxy])].pack("m")
114
- # end
115
- # exit!
116
- # else
117
- # Tempfile.open("isolation") do |tmpfile|
118
- # ENV["ISOLATION_TEST"] = @method_name
119
- # ENV["ISOLATION_OUTPUT"] = tmpfile.path
120
- #
121
- # load_paths = $-I.map {|p| "-I\"#{File.expand_path(p)}\"" }.join(" ")
122
- # `#{Gem.ruby} #{load_paths} #{$0} #{ORIG_ARGV.join(" ")} -t\"#{self.class}\"`
123
- #
124
- # ENV.delete("ISOLATION_TEST")
125
- # ENV.delete("ISOLATION_OUTPUT")
126
- #
127
- # return tmpfile.read.unpack("m")[0]
128
- # end
129
- # end
130
- # end
131
- # end
132
- #
133
- # include forking_env? ? Forking : Subprocess
134
- # end
135
- # end
136
- # end
@@ -1,287 +0,0 @@
1
- # # Note:
2
- # # It is important to keep this file as light as possible
3
- # # the goal for tests that require this is to test booting up
4
- # # rails from an empty state, so anything added here could
5
- # # hide potential failures
6
- # #
7
- # # It is also good to know what is the bare minimum to get
8
- # # Rails booted up.
9
- # require 'fileutils'
10
- #
11
- # require 'bundler/setup' unless defined?(Bundler)
12
- # require 'active_support/testing/autorun'
13
- # require 'active_support/test_case'
14
- #
15
- # RAILS_FRAMEWORK_ROOT = File.expand_path("#{File.dirname(__FILE__)}/../../..")
16
- #
17
- # # These files do not require any others and are needed
18
- # # to run the tests
19
- # require "active_support/testing/isolation"
20
- # require "active_support/core_ext/kernel/reporting"
21
- # require 'tmpdir'
22
- #
23
- # module TestHelpers
24
- # module Paths
25
- # def app_template_path
26
- # File.join Dir.tmpdir, 'app_template'
27
- # end
28
- #
29
- # def tmp_path(*args)
30
- # @tmp_path ||= File.realpath(Dir.mktmpdir)
31
- # File.join(@tmp_path, *args)
32
- # end
33
- #
34
- # def app_path(*args)
35
- # tmp_path(*%w[app] + args)
36
- # end
37
- #
38
- # def framework_path
39
- # RAILS_FRAMEWORK_ROOT
40
- # end
41
- #
42
- # def rails_root
43
- # app_path
44
- # end
45
- # end
46
- #
47
- # module Rack
48
- # def app(env = "production")
49
- # old_env = ENV["RAILS_ENV"]
50
- # @app ||= begin
51
- # ENV["RAILS_ENV"] = env
52
- # require "#{app_path}/config/environment"
53
- # Rails.application
54
- # end
55
- # ensure
56
- # ENV["RAILS_ENV"] = old_env
57
- # end
58
- #
59
- # def extract_body(response)
60
- # "".tap do |body|
61
- # response[2].each {|chunk| body << chunk }
62
- # end
63
- # end
64
- #
65
- # def get(path)
66
- # @app.call(::Rack::MockRequest.env_for(path))
67
- # end
68
- #
69
- # def assert_welcome(resp)
70
- # assert_equal 200, resp[0]
71
- # assert resp[1]["Content-Type"] = "text/html"
72
- # assert extract_body(resp).match(/Welcome aboard/)
73
- # end
74
- #
75
- # def assert_success(resp)
76
- # assert_equal 202, resp[0]
77
- # end
78
- #
79
- # def assert_missing(resp)
80
- # assert_equal 404, resp[0]
81
- # end
82
- #
83
- # def assert_header(key, value, resp)
84
- # assert_equal value, resp[1][key.to_s]
85
- # end
86
- #
87
- # def assert_body(expected, resp)
88
- # assert_equal expected, extract_body(resp)
89
- # end
90
- # end
91
- #
92
- # module Generation
93
- # # Build an application by invoking the generator and going through the whole stack.
94
- # def build_app(options = {})
95
- # @prev_rails_env = ENV['RAILS_ENV']
96
- # ENV['RAILS_ENV'] = 'development'
97
- #
98
- # FileUtils.rm_rf(app_path)
99
- # FileUtils.cp_r(app_template_path, app_path)
100
- #
101
- # # Delete the initializers unless requested
102
- # unless options[:initializers]
103
- # Dir["#{app_path}/config/initializers/*.rb"].each do |initializer|
104
- # File.delete(initializer)
105
- # end
106
- # end
107
- #
108
- # gemfile_path = "#{app_path}/Gemfile"
109
- # if options[:gemfile].blank? && File.exist?(gemfile_path)
110
- # File.delete gemfile_path
111
- # end
112
- #
113
- # routes = File.read("#{app_path}/config/routes.rb")
114
- # if routes =~ /(\n\s*end\s*)\Z/
115
- # File.open("#{app_path}/config/routes.rb", 'w') do |f|
116
- # f.puts $` + "\nmatch ':controller(/:action(/:id))(.:format)', via: :all\n" + $1
117
- # end
118
- # end
119
- #
120
- # add_to_config <<-RUBY
121
- # config.eager_load = false
122
- # config.secret_key_base = "3b7cd727ee24e8444053437c36cc66c4"
123
- # config.session_store :cookie_store, key: "_myapp_session"
124
- # config.active_support.deprecation = :log
125
- # config.action_controller.allow_forgery_protection = false
126
- # RUBY
127
- # end
128
- #
129
- # def teardown_app
130
- # ENV['RAILS_ENV'] = @prev_rails_env if @prev_rails_env
131
- # end
132
- #
133
- # # Make a very basic app, without creating the whole directory structure.
134
- # # This is faster and simpler than the method above.
135
- # def make_basic_app
136
- # require "rails"
137
- # require "action_controller/railtie"
138
- #
139
- # app = Class.new(Rails::Application)
140
- # app.config.eager_load = false
141
- # app.config.secret_key_base = "3b7cd727ee24e8444053437c36cc66c4"
142
- # app.config.session_store :cookie_store, key: "_myapp_session"
143
- # app.config.active_support.deprecation = :log
144
- #
145
- # yield app if block_given?
146
- # app.initialize!
147
- #
148
- # app.routes.draw do
149
- # get "/" => "omg#index"
150
- # end
151
- #
152
- # require 'rack/test'
153
- # extend ::Rack::Test::Methods
154
- # end
155
- #
156
- # def simple_controller
157
- # controller :foo, <<-RUBY
158
- # class FooController < ApplicationController
159
- # def index
160
- # render text: "foo"
161
- # end
162
- # end
163
- # RUBY
164
- #
165
- # app_file 'config/routes.rb', <<-RUBY
166
- # AppTemplate::Application.routes.draw do
167
- # get ':controller(/:action)'
168
- # end
169
- # RUBY
170
- # end
171
- #
172
- # class Bukkit
173
- # attr_reader :path
174
- #
175
- # def initialize(path)
176
- # @path = path
177
- # end
178
- #
179
- # def write(file, string)
180
- # path = "#{@path}/#{file}"
181
- # FileUtils.mkdir_p(File.dirname(path))
182
- # File.open(path, "w") {|f| f.puts string }
183
- # end
184
- #
185
- # def delete(file)
186
- # File.delete("#{@path}/#{file}")
187
- # end
188
- # end
189
- #
190
- # def engine(name)
191
- # dir = "#{app_path}/random/#{name}"
192
- # FileUtils.mkdir_p(dir)
193
- #
194
- # app = File.readlines("#{app_path}/config/application.rb")
195
- # app.insert(2, "$:.unshift(\"#{dir}/lib\")")
196
- # app.insert(3, "require #{name.inspect}")
197
- #
198
- # File.open("#{app_path}/config/application.rb", 'r+') do |f|
199
- # f.puts app
200
- # end
201
- #
202
- # Bukkit.new(dir).tap do |bukkit|
203
- # yield bukkit if block_given?
204
- # end
205
- # end
206
- #
207
- # def script(script)
208
- # Dir.chdir(app_path) do
209
- # `#{Gem.ruby} #{app_path}/bin/rails #{script}`
210
- # end
211
- # end
212
- #
213
- # def add_to_config(str)
214
- # environment = File.read("#{app_path}/config/application.rb")
215
- # if environment =~ /(\n\s*end\s*end\s*)\Z/
216
- # File.open("#{app_path}/config/application.rb", 'w') do |f|
217
- # f.puts $` + "\n#{str}\n" + $1
218
- # end
219
- # end
220
- # end
221
- #
222
- # def add_to_env_config(env, str)
223
- # environment = File.read("#{app_path}/config/environments/#{env}.rb")
224
- # if environment =~ /(\n\s*end\s*)\Z/
225
- # File.open("#{app_path}/config/environments/#{env}.rb", 'w') do |f|
226
- # f.puts $` + "\n#{str}\n" + $1
227
- # end
228
- # end
229
- # end
230
- #
231
- # def remove_from_config(str)
232
- # file = "#{app_path}/config/application.rb"
233
- # contents = File.read(file)
234
- # contents.sub!(/#{str}/, "")
235
- # File.open(file, "w+") { |f| f.puts contents }
236
- # end
237
- #
238
- # def app_file(path, contents)
239
- # FileUtils.mkdir_p File.dirname("#{app_path}/#{path}")
240
- # File.open("#{app_path}/#{path}", 'w') do |f|
241
- # f.puts contents
242
- # end
243
- # end
244
- #
245
- # def remove_file(path)
246
- # FileUtils.rm_rf "#{app_path}/#{path}"
247
- # end
248
- #
249
- # def controller(name, contents)
250
- # app_file("app/controllers/#{name}_controller.rb", contents)
251
- # end
252
- #
253
- # def use_frameworks(arr)
254
- # to_remove = [:actionmailer,
255
- # :activerecord] - arr
256
- # $:.reject! {|path| path =~ %r'/(#{to_remove.join('|')})/' }
257
- # end
258
- #
259
- # def boot_rails
260
- # require File.expand_path('../../../../load_paths', __FILE__)
261
- # end
262
- # end
263
- # end
264
- #
265
- # class ActiveSupport::TestCase
266
- # include TestHelpers::Paths
267
- # include TestHelpers::Rack
268
- # include TestHelpers::Generation
269
- # end
270
- #
271
- # # Create a scope and build a fixture rails app
272
- # Module.new do
273
- # extend TestHelpers::Paths
274
- #
275
- # # Build a rails app
276
- # FileUtils.rm_rf(app_template_path)
277
- # FileUtils.mkdir(app_template_path)
278
- #
279
- # environment = File.expand_path('../../../../load_paths', __FILE__)
280
- # require_environment = "-r #{environment}"
281
- #
282
- # `#{Gem.ruby} #{require_environment} #{RAILS_FRAMEWORK_ROOT}/railties/bin/rails new #{app_template_path} --skip-gemfile --no-rc`
283
- # File.open("#{app_template_path}/config/boot.rb", 'w') do |f|
284
- # f.puts "require '#{environment}'"
285
- # f.puts "require 'rails/all'"
286
- # end
287
- # end unless defined?(RAILS_ISOLATED_ENGINE)