develry 0.0.2
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 +7 -0
- data/.gitignore +37 -0
- data/.rspec +5 -0
- data/.ruby-gemset +1 -0
- data/.travis.yml +30 -0
- data/Gemfile +7 -0
- data/Guardfile +32 -0
- data/LICENSE +20 -0
- data/README.md +71 -0
- data/Rakefile +5 -0
- data/TODO +0 -0
- data/bin/develry +18 -0
- data/config/flay.yml +3 -0
- data/config/flog.yml +2 -0
- data/config/mutant.yml +2 -0
- data/config/reek.yml +106 -0
- data/config/rubocop.yml +66 -0
- data/config/yardstick.yml +2 -0
- data/default/config/develry.yml +4 -0
- data/default/config/flay.yml +3 -0
- data/default/config/flog.yml +2 -0
- data/default/config/mutant.yml +3 -0
- data/default/config/reek.yml +103 -0
- data/default/config/rubocop.yml +58 -0
- data/default/config/yardstick.yml +2 -0
- data/develry.gemspec +53 -0
- data/lib/develry.rb +164 -0
- data/lib/develry/config.rb +167 -0
- data/lib/develry/platform.rb +118 -0
- data/lib/develry/project.rb +144 -0
- data/lib/develry/project/initializer.rb +21 -0
- data/lib/develry/project/initializer/rake.rb +19 -0
- data/lib/develry/project/initializer/rspec.rb +104 -0
- data/lib/develry/site.rb +64 -0
- data/lib/develry/site/initializer.rb +73 -0
- data/lib/develry/spec_helper.rb +5 -0
- data/shared/Gemfile +55 -0
- data/shared/spec/shared/abstract_type_behavior.rb +18 -0
- data/shared/spec/shared/command_method_behavior.rb +7 -0
- data/shared/spec/shared/each_method_behaviour.rb +15 -0
- data/shared/spec/shared/hash_method_behavior.rb +17 -0
- data/shared/spec/shared/idempotent_method_behavior.rb +9 -0
- data/shared/spec/support/ice_nine_config.rb +14 -0
- data/spec/spec_helper.rb +33 -0
- data/tasks/metrics/ci.rake +18 -0
- data/tasks/metrics/coverage.rake +13 -0
- data/tasks/metrics/flay.rake +66 -0
- data/tasks/metrics/flog.rake +59 -0
- data/tasks/metrics/mutant.rake +44 -0
- data/tasks/metrics/reek.rake +27 -0
- data/tasks/metrics/rubocop.rake +18 -0
- data/tasks/metrics/yardstick.rake +42 -0
- data/tasks/spec.rake +28 -0
- data/tasks/yard.rake +11 -0
- metadata +452 -0
@@ -0,0 +1,118 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Develry
|
4
|
+
|
5
|
+
# Provides methods to determine the ruby platform
|
6
|
+
module Platform
|
7
|
+
|
8
|
+
DEFAULT_RVM_NAME = 'mri'.freeze
|
9
|
+
|
10
|
+
# Return Ruby engine string
|
11
|
+
#
|
12
|
+
# @return [String]
|
13
|
+
#
|
14
|
+
# @api private
|
15
|
+
def ruby_engine
|
16
|
+
@ruby_engine ||= (defined?(RUBY_ENGINE) && RUBY_ENGINE || 'ruby').freeze
|
17
|
+
end
|
18
|
+
|
19
|
+
# Return RVM name
|
20
|
+
#
|
21
|
+
# @return [String]
|
22
|
+
#
|
23
|
+
# @api private
|
24
|
+
def rvm_name
|
25
|
+
@rvm_name ||= begin
|
26
|
+
engine = ruby_engine
|
27
|
+
engine == 'ruby' ? DEFAULT_RVM_NAME : engine
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Return RVM string
|
32
|
+
#
|
33
|
+
# @return [String]
|
34
|
+
#
|
35
|
+
# @api private
|
36
|
+
def rvm
|
37
|
+
@rvm ||= "#{rvm_name}-#{RUBY_VERSION}".freeze
|
38
|
+
end
|
39
|
+
|
40
|
+
# Test for being executed under JRuby
|
41
|
+
#
|
42
|
+
# @return [true]
|
43
|
+
# if running under JRuby
|
44
|
+
#
|
45
|
+
# @return [false]
|
46
|
+
# otherwise
|
47
|
+
#
|
48
|
+
# @api private
|
49
|
+
def jruby?
|
50
|
+
ruby_engine == 'jruby'
|
51
|
+
end
|
52
|
+
|
53
|
+
# Test for being executed under rbx
|
54
|
+
#
|
55
|
+
# @return [true]
|
56
|
+
# if running under rbx
|
57
|
+
#
|
58
|
+
# @return [false]
|
59
|
+
# otherwise
|
60
|
+
#
|
61
|
+
# @api private
|
62
|
+
def rbx?
|
63
|
+
ruby_engine == 'rbx'
|
64
|
+
end
|
65
|
+
|
66
|
+
# Test for being executed under rubies with a JIT
|
67
|
+
#
|
68
|
+
# @return [true]
|
69
|
+
# if running under JRuby or rbx
|
70
|
+
#
|
71
|
+
# @return [false]
|
72
|
+
# otherwise
|
73
|
+
#
|
74
|
+
# @api private
|
75
|
+
def jit?
|
76
|
+
jruby? || rbx?
|
77
|
+
end
|
78
|
+
|
79
|
+
# Test for 1.8 mode
|
80
|
+
#
|
81
|
+
# @return [true]
|
82
|
+
# if running under 1.8.x
|
83
|
+
#
|
84
|
+
# @return [false]
|
85
|
+
# otherwise
|
86
|
+
#
|
87
|
+
# @api private
|
88
|
+
def ruby18?
|
89
|
+
RUBY_VERSION.start_with?('1.8.')
|
90
|
+
end
|
91
|
+
|
92
|
+
# Test for 1.9 mode
|
93
|
+
#
|
94
|
+
# @return [true]
|
95
|
+
# if running under 1.9.x
|
96
|
+
#
|
97
|
+
# @return [false]
|
98
|
+
# otherwise
|
99
|
+
#
|
100
|
+
# @api private
|
101
|
+
def ruby19?
|
102
|
+
RUBY_VERSION.start_with?('1.9.')
|
103
|
+
end
|
104
|
+
|
105
|
+
# Test for 2.0 mode
|
106
|
+
#
|
107
|
+
# @return [true]
|
108
|
+
# if running under 2.0.x
|
109
|
+
#
|
110
|
+
# @return [false]
|
111
|
+
# otherwise
|
112
|
+
#
|
113
|
+
# @api private
|
114
|
+
def ruby20?
|
115
|
+
RUBY_VERSION.start_with?('2.0.')
|
116
|
+
end
|
117
|
+
end # module Platform
|
118
|
+
end # module Develry
|
@@ -0,0 +1,144 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Develry
|
4
|
+
|
5
|
+
# The project develry supports
|
6
|
+
class Project
|
7
|
+
|
8
|
+
# The reek configuration
|
9
|
+
#
|
10
|
+
# @return [Config::Reek]
|
11
|
+
#
|
12
|
+
# @api private
|
13
|
+
attr_reader :reek
|
14
|
+
|
15
|
+
# The rubocop configuration
|
16
|
+
#
|
17
|
+
# @return [Config::Rubocop]
|
18
|
+
#
|
19
|
+
# @api private
|
20
|
+
attr_reader :rubocop
|
21
|
+
|
22
|
+
# The flog configuration
|
23
|
+
#
|
24
|
+
# @return [Config::Flog]
|
25
|
+
#
|
26
|
+
# @api private
|
27
|
+
attr_reader :flog
|
28
|
+
|
29
|
+
# The yardstick configuration
|
30
|
+
#
|
31
|
+
# @return [Config::Yardstick]
|
32
|
+
#
|
33
|
+
# @api private
|
34
|
+
attr_reader :yardstick
|
35
|
+
|
36
|
+
# The flay configuration
|
37
|
+
#
|
38
|
+
# @return [Config::Flay]
|
39
|
+
#
|
40
|
+
# @api private
|
41
|
+
attr_reader :flay
|
42
|
+
|
43
|
+
# The mutant configuration
|
44
|
+
#
|
45
|
+
# @return [Config::Mutant]
|
46
|
+
#
|
47
|
+
# @api private
|
48
|
+
attr_reader :mutant
|
49
|
+
|
50
|
+
# The develry configuration
|
51
|
+
#
|
52
|
+
# @return [Config::Develry]
|
53
|
+
#
|
54
|
+
# @api private
|
55
|
+
attr_reader :develry
|
56
|
+
|
57
|
+
# Return project root
|
58
|
+
#
|
59
|
+
# @return [Pathname]
|
60
|
+
#
|
61
|
+
# @api private
|
62
|
+
#
|
63
|
+
attr_reader :root
|
64
|
+
|
65
|
+
# The shared gemfile path
|
66
|
+
#
|
67
|
+
# @return [Pathname]
|
68
|
+
#
|
69
|
+
# @api private
|
70
|
+
attr_reader :shared_gemfile_path
|
71
|
+
|
72
|
+
# The default config path
|
73
|
+
#
|
74
|
+
# @return [Pathname]
|
75
|
+
#
|
76
|
+
# @api private
|
77
|
+
attr_reader :default_config_path
|
78
|
+
|
79
|
+
# The lib directory
|
80
|
+
#
|
81
|
+
# @return [Pathname]
|
82
|
+
#
|
83
|
+
# @api private
|
84
|
+
attr_reader :lib_dir
|
85
|
+
|
86
|
+
# The Ruby file pattern
|
87
|
+
#
|
88
|
+
# @return [Pathname]
|
89
|
+
#
|
90
|
+
# @api private
|
91
|
+
attr_reader :file_pattern
|
92
|
+
|
93
|
+
# The spec root
|
94
|
+
#
|
95
|
+
# @return [Pathname]
|
96
|
+
#
|
97
|
+
# @api private
|
98
|
+
attr_reader :spec_root
|
99
|
+
|
100
|
+
# Return config directory
|
101
|
+
#
|
102
|
+
# @return [Pathname]
|
103
|
+
#
|
104
|
+
# @api private
|
105
|
+
attr_reader :config_dir
|
106
|
+
|
107
|
+
# The unit test timeout
|
108
|
+
#
|
109
|
+
# @return [Numeric]
|
110
|
+
#
|
111
|
+
# @api private
|
112
|
+
attr_reader :unit_test_timeout
|
113
|
+
|
114
|
+
# Initialize object
|
115
|
+
#
|
116
|
+
# @param [Pathname] root
|
117
|
+
#
|
118
|
+
# @return [undefined]
|
119
|
+
#
|
120
|
+
# @api private
|
121
|
+
#
|
122
|
+
def initialize(root)
|
123
|
+
@root = root
|
124
|
+
|
125
|
+
@shared_gemfile_path = @root.join(GEMFILE_NAME).freeze
|
126
|
+
@default_config_path = @root.join(DEFAULT_CONFIG_DIR_NAME).freeze
|
127
|
+
@lib_dir = @root.join(LIB_DIRECTORY_NAME).freeze
|
128
|
+
@spec_root = @root.join(SPEC_DIRECTORY_NAME).freeze
|
129
|
+
@file_pattern = @lib_dir.join(RB_FILE_PATTERN).freeze
|
130
|
+
@config_dir = @default_config_path
|
131
|
+
|
132
|
+
@reek = Config::Reek.new(self)
|
133
|
+
@rubocop = Config::Rubocop.new(self)
|
134
|
+
@flog = Config::Flog.new(self)
|
135
|
+
@yardstick = Config::Yardstick.new(self)
|
136
|
+
@flay = Config::Flay.new(self)
|
137
|
+
@mutant = Config::Mutant.new(self)
|
138
|
+
@develry = Config::Develry.new(self)
|
139
|
+
|
140
|
+
@unit_test_timeout = @develry.unit_test_timeout
|
141
|
+
end
|
142
|
+
|
143
|
+
end # class Project
|
144
|
+
end # module Develry
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Develry
|
4
|
+
class Project
|
5
|
+
|
6
|
+
# Base class for project initializers
|
7
|
+
class Initializer
|
8
|
+
|
9
|
+
attr_reader :project
|
10
|
+
protected :project
|
11
|
+
|
12
|
+
def initialize(project)
|
13
|
+
@project = project
|
14
|
+
end
|
15
|
+
|
16
|
+
def call
|
17
|
+
raise NotImplementedError, "#{self.class}##{__method__} must be implemented"
|
18
|
+
end
|
19
|
+
end # class Initializer
|
20
|
+
end # class Project
|
21
|
+
end # module Develry
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Develry
|
4
|
+
class Project
|
5
|
+
class Initializer
|
6
|
+
|
7
|
+
# Imports all develry rake tasks into a project
|
8
|
+
class Rake
|
9
|
+
|
10
|
+
extend ::Rake::DSL
|
11
|
+
|
12
|
+
def self.call
|
13
|
+
FileList[RAKE_FILES_GLOB].each { |task| import(task) }
|
14
|
+
end
|
15
|
+
|
16
|
+
end # class Rake
|
17
|
+
end # class Initializer
|
18
|
+
end # class Project
|
19
|
+
end # module Develry
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Develry
|
4
|
+
class Project
|
5
|
+
class Initializer
|
6
|
+
|
7
|
+
# Requires all shared specs in a project's spec_helper
|
8
|
+
# Also installs a configurable unit test timeout
|
9
|
+
class Rspec < self
|
10
|
+
|
11
|
+
def self.require_files(directory)
|
12
|
+
Develry.require_files(directory, SHARED_SPEC_PATTERN)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Initialize RSpec for +project+
|
16
|
+
#
|
17
|
+
# @param [Project] project
|
18
|
+
# the project to initialize
|
19
|
+
#
|
20
|
+
# @return [Rspec]
|
21
|
+
#
|
22
|
+
# @api private
|
23
|
+
def self.call(project)
|
24
|
+
new(project).call
|
25
|
+
end
|
26
|
+
|
27
|
+
# The spec root
|
28
|
+
#
|
29
|
+
# @return [Pathname]
|
30
|
+
#
|
31
|
+
# @api private
|
32
|
+
attr_reader :spec_root
|
33
|
+
private :spec_root
|
34
|
+
|
35
|
+
# The unit test timeout
|
36
|
+
#
|
37
|
+
# @return [Numeric]
|
38
|
+
#
|
39
|
+
# @api private
|
40
|
+
attr_reader :unit_test_timeout
|
41
|
+
private :unit_test_timeout
|
42
|
+
|
43
|
+
# Initialize a new instance
|
44
|
+
#
|
45
|
+
# @param [Project] project
|
46
|
+
# the project to initialize
|
47
|
+
#
|
48
|
+
# @param [Numeric] unit_test_timeout
|
49
|
+
# the maximum time a single unit test can take
|
50
|
+
#
|
51
|
+
# @return [undefined]
|
52
|
+
#
|
53
|
+
# @api private
|
54
|
+
def initialize(project)
|
55
|
+
super
|
56
|
+
@spec_root = project.spec_root
|
57
|
+
@unit_test_timeout = project.unit_test_timeout
|
58
|
+
end
|
59
|
+
|
60
|
+
# Setup RSpec for {#project}
|
61
|
+
#
|
62
|
+
# @return [self]
|
63
|
+
#
|
64
|
+
# @api private
|
65
|
+
def call
|
66
|
+
require 'rspec'
|
67
|
+
require_shared_spec_files
|
68
|
+
enable_unit_test_timeout unless Develry.jit?
|
69
|
+
self
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
# Timeout unit tests that take longer than 1/10th of a second
|
75
|
+
#
|
76
|
+
# @param [Numeric] timeout
|
77
|
+
#
|
78
|
+
# @return [undefined]
|
79
|
+
#
|
80
|
+
# @raise [Timeout::Error]
|
81
|
+
# raised when the times are outside the timeout
|
82
|
+
#
|
83
|
+
# @api private
|
84
|
+
#
|
85
|
+
def enable_unit_test_timeout
|
86
|
+
timeout = unit_test_timeout # support the closure
|
87
|
+
RSpec.configuration.around file_path: UNIT_TEST_PATH_REGEXP do |example|
|
88
|
+
Timeout.timeout(timeout, &example)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def require_shared_spec_files
|
93
|
+
require_files(SHARED_SPEC_PATH)
|
94
|
+
require_files(spec_root)
|
95
|
+
end
|
96
|
+
|
97
|
+
def require_files(directory)
|
98
|
+
self.class.require_files(directory)
|
99
|
+
end
|
100
|
+
|
101
|
+
end # class Rspec
|
102
|
+
end # class Initializer
|
103
|
+
end # class Project
|
104
|
+
end # module Develry
|
data/lib/develry/site.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Develry
|
4
|
+
|
5
|
+
# Encapsulates a specific {Project} develry is used for
|
6
|
+
class Site
|
7
|
+
|
8
|
+
attr_reader :root
|
9
|
+
|
10
|
+
attr_reader :project
|
11
|
+
|
12
|
+
def initialize(project)
|
13
|
+
@project = project
|
14
|
+
@root = project.root
|
15
|
+
end
|
16
|
+
|
17
|
+
# Initialize project and load shared specs
|
18
|
+
#
|
19
|
+
# Expects to be called from $application_root/spec/spec_helper.rb
|
20
|
+
#
|
21
|
+
# @return [self]
|
22
|
+
#
|
23
|
+
# @api private
|
24
|
+
def init_spec_helper
|
25
|
+
Project::Initializer::Rspec.call(project)
|
26
|
+
self
|
27
|
+
end
|
28
|
+
|
29
|
+
# Initialize develry using default config
|
30
|
+
#
|
31
|
+
# @return [undefined]
|
32
|
+
#
|
33
|
+
# @api private
|
34
|
+
def init
|
35
|
+
Initializer.call(self)
|
36
|
+
puts 'Run bundle install to complete the develry installation'
|
37
|
+
self
|
38
|
+
end
|
39
|
+
|
40
|
+
# Sync gemfiles
|
41
|
+
#
|
42
|
+
# @return [undefined]
|
43
|
+
#
|
44
|
+
# @api private
|
45
|
+
def sync
|
46
|
+
target = root.join(GEMFILE_NAME)
|
47
|
+
FileUtils.cp(SHARED_GEMFILE_PATH, target)
|
48
|
+
puts "Successfully synced #{target}"
|
49
|
+
self
|
50
|
+
end
|
51
|
+
|
52
|
+
# Sync gemfiles and run bundle update
|
53
|
+
#
|
54
|
+
# @return [undefined]
|
55
|
+
#
|
56
|
+
# @api private
|
57
|
+
def update
|
58
|
+
sync
|
59
|
+
system(BUNDLE_UPDATE)
|
60
|
+
self
|
61
|
+
end
|
62
|
+
|
63
|
+
end # class Site
|
64
|
+
end # module Develry
|