ronin-web-user_agents 0.1.0.beta1

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,140 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-web-user_agents - Yet another User-Agent string generator library.
4
+ #
5
+ # Copyright (c) 2006-2022 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # ronin-web-user_agents is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # ronin-web-user_agents is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with ronin-web-user_agents. If not, see <https://www.gnu.org/licenses/>
19
+ #
20
+
21
+ require 'ronin/web/user_agents/chrome'
22
+
23
+ module Ronin
24
+ module Web
25
+ module UserAgents
26
+ #
27
+ # Represents every possible `GoogleBot` `User-Agent` string.
28
+ #
29
+ module GoogleBot
30
+ # `GoogleBot` version
31
+ VERSION = '2.1'
32
+
33
+ # `GoogleBot' URL.
34
+ URL = 'http://www.google.com/bot.html'
35
+
36
+ # The Android version which `GoogleBot` Mobile uses.
37
+ ANDROID_VERSION = '6.0.1'
38
+
39
+ # The Android device which `GoogleBot` Mobile uses.
40
+ ANDROID_DEVICE = 'Nexus 5X Build/MMB29P'
41
+
42
+ #
43
+ # Builds a `GoogleBot` `User-Agent` string.
44
+ #
45
+ # @param [:search, :image, :video] crawler
46
+ # The type of `GoogleBot`.
47
+ #
48
+ # @param [:desktop, :mobile, nil] compatible
49
+ # Indicates whether to return a `(compatible: GoogleBot/...)`
50
+ # `User-Agent` string.
51
+ #
52
+ # @param [String, nil] chrome_version
53
+ # The optional Chrome version to include. Only is used when
54
+ # `compatible: true` is given.
55
+ #
56
+ # @return [String]
57
+ # The `GoogleBot` `User-Agent` string.
58
+ #
59
+ # @raise [ArgumentError]
60
+ # An unsupported `crawler:` or `compatible:` value was given.
61
+ #
62
+ # @see https://developers.google.com/search/docs/advanced/crawling/overview-google-crawlers
63
+ #
64
+ # @api public
65
+ #
66
+ def self.build(crawler: :search, compatible: nil, chrome_version: nil)
67
+
68
+ case crawler
69
+ when :image
70
+ "Googlebot-Image/1.0"
71
+ when :video
72
+ "Googlebot-Video/1.0"
73
+ when :search
74
+ case compatible
75
+ when :desktop
76
+ googlebot = "GoogleBot/#{VERSION}; +#{URL}"
77
+
78
+ if chrome_version
79
+ "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; #{googlebot}) Chrome/#{chrome_version} Safari/537.36"
80
+ else
81
+ "Mozilla/5.0 (compatible; #{googlebot})"
82
+ end
83
+ when :mobile
84
+ unless chrome_version
85
+ raise(ArgumentError,"compatible: :mobile also requires the chrome_version: keyword argument")
86
+ end
87
+
88
+ "Mozilla/5.0 (Linux; Android #{ANDROID_VERSION}; #{ANDROID_DEVICE}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/#{chrome_version} Mobile Safari/537.36 (compatible; GoogleBot/#{VERSION}; +#{URL})"
89
+ when nil
90
+ "GoogleBot/#{VERSION} (+#{URL})"
91
+ else
92
+ raise(ArgumentError,"unsupported compatible: value (#{compatible.inspect})")
93
+ end
94
+ else
95
+ raise(ArgumentError,"unsupported crawler: value (#{crawler.inspect})")
96
+ end
97
+ end
98
+
99
+ # Supported `crawler:` values.
100
+ SUPPORTED_CRAWLERS = [:search, :image, :video]
101
+
102
+ # Supported `compatible:` values.
103
+ SUPPORTED_COMPATIBILITY_MODES = [:desktop, :mobile, nil]
104
+
105
+ # Known Chrome versions.
106
+ #
107
+ # @return [Array<String>]
108
+ KNOWN_CHROME_VERSIONS = Chrome::KNOWN_VERSIONS
109
+
110
+ #
111
+ # Builds a random `GoogleBot` `User-Agent` string.
112
+ #
113
+ # @param [:search, :image, :video] crawler
114
+ # The type of `GoogleBot`.
115
+ #
116
+ # @param [:desktop, :mobile, nil] compatible
117
+ # Indicates whether to return a `(compatible: GoogleBot/...)`
118
+ # `User-Agent` string.
119
+ #
120
+ # @param [String, nil] chrome_version
121
+ # The optional Chrome version to include.
122
+ #
123
+ # @return [String]
124
+ # The `GoogleBot` `User-Agent` string.
125
+ #
126
+ # @api public
127
+ #
128
+ def self.random(crawler: SUPPORTED_CRAWLERS.sample,
129
+ compatible: SUPPORTED_COMPATIBILITY_MODES.sample,
130
+ chrome_version: KNOWN_CHROME_VERSIONS.sample)
131
+ build(
132
+ crawler: crawler,
133
+ compatible: compatible,
134
+ chrome_version: chrome_version
135
+ )
136
+ end
137
+ end
138
+ end
139
+ end
140
+ end
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-web-user_agents - Yet another User-Agent string generator library.
4
+ #
5
+ # Copyright (c) 2006-2022 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # ronin-web-user_agents is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # ronin-web-user_agents is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with ronin-web-user_agents. If not, see <https://www.gnu.org/licenses/>
19
+ #
20
+
21
+ require 'ronin/web/user_agents/data_dir'
22
+
23
+ module Ronin
24
+ module Web
25
+ module UserAgents
26
+ module OS
27
+ #
28
+ # Defines information about the Android Operating System (OS).
29
+ #
30
+ # @api private
31
+ #
32
+ module Android
33
+ # Known Android versions.
34
+ VERSIONS = %w[
35
+ 10
36
+ 10.0
37
+ 11
38
+ 11.0
39
+ 12
40
+ 12.1
41
+ 4.0.4
42
+ 4.1.2
43
+ 4.2.2
44
+ 4.4.2
45
+ 4.4.4
46
+ 5.0
47
+ 5.0.2
48
+ 5.1
49
+ 5.1.1
50
+ 6.0
51
+ 6.0.1
52
+ 7.0
53
+ 7.1.1
54
+ 7.1.2
55
+ 8.0
56
+ 8.0.0
57
+ 8.1
58
+ 8.1.0
59
+ 9
60
+ 9.0
61
+ ]
62
+
63
+ # Architectures supported by Android.
64
+ ARCHES = {
65
+ arm: 'arm',
66
+ arm64: 'arm_64',
67
+
68
+ nil => nil
69
+ }
70
+
71
+ # Known Android devices.
72
+ DEVICES = File.readlines(
73
+ File.join(DATA_DIR,'android','devices.txt'), chomp: true
74
+ )
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-web-user_agents - Yet another User-Agent string generator library.
4
+ #
5
+ # Copyright (c) 2006-2022 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # ronin-web-user_agents is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # ronin-web-user_agents is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with ronin-web-user_agents. If not, see <https://www.gnu.org/licenses/>
19
+ #
20
+
21
+ module Ronin
22
+ module Web
23
+ module UserAgents
24
+ module OS
25
+ #
26
+ # Defines information about the Linux Operating System (OS).
27
+ #
28
+ # @api private
29
+ #
30
+ module Linux
31
+ # Common Linux Distros.
32
+ DISTROS = {
33
+ ubuntu: 'Ubuntu',
34
+ fedora: 'Fedora',
35
+ arch: 'Arch',
36
+
37
+ nil => nil
38
+ }
39
+
40
+ # Architectures supported by Linux.
41
+ ARCHES = {
42
+ x86_64: 'x86_64',
43
+ aarch64: 'aarch64',
44
+ arm64: 'aarch64',
45
+ i686: 'i686',
46
+ x86: 'i686'
47
+ }
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,116 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-web-user_agents - Yet another User-Agent string generator library.
4
+ #
5
+ # Copyright (c) 2006-2022 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # ronin-web-user_agents is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # ronin-web-user_agents is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with ronin-web-user_agents. If not, see <https://www.gnu.org/licenses/>
19
+ #
20
+
21
+ module Ronin
22
+ module Web
23
+ module UserAgents
24
+ module OS
25
+ #
26
+ # Defines information about the macOS Operating System (OS).
27
+ #
28
+ # @api private
29
+ #
30
+ module MacOS
31
+ # Known macOS versions.
32
+ VERSIONS = %w[
33
+ 10.10
34
+ 10.10.3
35
+ 10.10.4
36
+ 10.11.6
37
+ 10.12.0
38
+ 10.12.1
39
+ 10.12.6
40
+ 10.13.4
41
+ 10.13.6
42
+ 10.14.0
43
+ 10.14.1
44
+ 10.14.2
45
+ 10.14.5
46
+ 10.14.6
47
+ 10.14.8
48
+ 10.15.1
49
+ 10.15.2
50
+ 10.15.4
51
+ 10.15.6
52
+ 10.15.7
53
+ 10.16
54
+ 10.16.0
55
+ 10.31.7
56
+ 10.4
57
+ 10.55
58
+ 10.7.0
59
+ 11.0.0
60
+ 11.15
61
+ 11.55
62
+ 11.6.3
63
+ 12.2.0
64
+ 16.55
65
+ ]
66
+
67
+ # Known macOS versions, but in underscored notation.
68
+ VERSIONS_UNDERSCORED = {
69
+ '10.10' => '10_10',
70
+ '10.10.3' => '10_10_3',
71
+ '10.10.4' => '10_10_4',
72
+ '10.11.6' => '10_11_6',
73
+ '10.12.0' => '10_12_0',
74
+ '10.12.1' => '10_12_1',
75
+ '10.12.6' => '10_12_6',
76
+ '10.13.4' => '10_13_4',
77
+ '10.13.6' => '10_13_6',
78
+ '10.14.0' => '10_14_0',
79
+ '10.14.1' => '10_14_1',
80
+ '10.14.2' => '10_14_2',
81
+ '10.14.5' => '10_14_5',
82
+ '10.14.6' => '10_14_6',
83
+ '10.14.8' => '10_14_8',
84
+ '10.15.1' => '10_15_1',
85
+ '10.15.2' => '10_15_2',
86
+ '10.15.4' => '10_15_4',
87
+ '10.15.6' => '10_15_6',
88
+ '10.15.7' => '10_15_7',
89
+ '10.16' => '10_16',
90
+ '10.16.0' => '10_16_0',
91
+ '10.31.7' => '10_31_7',
92
+ '10.4' => '10_4',
93
+ '10.55' => '10_55',
94
+ '10.7.0' => '10_7_0',
95
+ '11.0.0' => '11_0_0',
96
+ '11.15' => '11_15',
97
+ '11.55' => '11_55',
98
+ '11.6.3' => '11_6_3',
99
+ '12.2.0' => '12_2_0',
100
+ '16.55' => '16_55',
101
+ }
102
+ VERSIONS_UNDERSCORED.default_proc = ->(hash,version) {
103
+ version.tr('.','_')
104
+ }
105
+
106
+ # Architectures supported by macOS.
107
+ ARCHES = {
108
+ intel: 'Intel',
109
+ x86_64: 'Intel'
110
+ }
111
+
112
+ end
113
+ end
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-web-user_agents - Yet another User-Agent string generator library.
4
+ #
5
+ # Copyright (c) 2006-2022 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # ronin-web-user_agents is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # ronin-web-user_agents is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with ronin-web-user_agents. If not, see <https://www.gnu.org/licenses/>
19
+ #
20
+
21
+ module Ronin
22
+ module Web
23
+ module UserAgents
24
+ module OS
25
+ #
26
+ # Defines information about the Windows Operating System (OS).
27
+ #
28
+ # @api private
29
+ #
30
+ module Windows
31
+ # Common Windows versions.
32
+ VERSIONS = {
33
+ xp: '5.2',
34
+ vista: '6.0',
35
+ 7 => '6.1',
36
+ 8 => '6.2',
37
+ 8.1 => '6.3',
38
+ 10 => '10.0'
39
+ }
40
+
41
+ # Architectures supported by Windows.
42
+ ARCHES = {
43
+ wow64: 'WOW64',
44
+ win64: 'Win64; x64',
45
+ x86_64: 'Win64; x64',
46
+
47
+ nil => nil
48
+ }
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-web-user_agents - Yet another User-Agent string generator library.
4
+ #
5
+ # Copyright (c) 2006-2022 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # ronin-web-user_agents is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # ronin-web-user_agents is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with ronin-web-user_agents. If not, see <https://www.gnu.org/licenses/>
19
+ #
20
+
21
+ module Ronin
22
+ module Web
23
+ module UserAgents
24
+ # ronin-web-user_agents version
25
+ VERSION = '0.1.0.beta1'
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,142 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-web-user_agents - Yet another User-Agent string generator library.
4
+ #
5
+ # Copyright (c) 2006-2022 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # ronin-web-user_agents is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # ronin-web-user_agents is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with ronin-web-user_agents. If not, see <https://www.gnu.org/licenses/>
19
+ #
20
+
21
+ # browsers
22
+ require 'ronin/web/user_agents/chrome'
23
+ require 'ronin/web/user_agents/firefox'
24
+
25
+ # crawlers
26
+ require 'ronin/web/user_agents/google_bot'
27
+
28
+ require 'ronin/web/user_agents/version'
29
+
30
+ module Ronin
31
+ module Web
32
+ #
33
+ # Provides categories of common `User-Agent` strings.
34
+ #
35
+ # ## Example
36
+ #
37
+ # Get a random `User-Agent` string:
38
+ #
39
+ # user_agent = Ronin::Web::UserAgents.random
40
+ # # => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.230 Safari/537.36"
41
+ #
42
+ # Get a random Chrome `User-Agent` string:
43
+ #
44
+ # user_agent = Ronin::Web::UserAgents.chrome.random
45
+ # # => "Mozilla/5.0 (Linux; Android 5.1.1; Redmi Note 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4688.3 Mobile Safari/537.36"
46
+ #
47
+ # Get a random Firefox `User-Agent` string:
48
+ #
49
+ # user_agent = Ronin::Web::UserAgents.firefox.random
50
+ # # => "Mozilla/5.0 (Windows NT 6.1; rv:78.0.2) Gecko/20100101 Firefox/78.0.2"
51
+ #
52
+ # Get a random `GoogleBot` `User-Agent` string:
53
+ #
54
+ # user_agent = Ronin::Web::UserAgents.google_bot.random
55
+ # # => "GoogleBot/2.1 (+http://www.google.com/bot.html)"
56
+ #
57
+ module UserAgents
58
+
59
+ #
60
+ # Google Chrome `User-Agent` strings.
61
+ #
62
+ # @return [Chrome]
63
+ #
64
+ # @example
65
+ # user_agent = Ronin::Web::UserAgents.chrome.random
66
+ # # => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.2495.20 Safari/537.36"
67
+ #
68
+ # @api public
69
+ #
70
+ def self.chrome
71
+ Chrome
72
+ end
73
+
74
+ #
75
+ # Alias for {chrome}.
76
+ #
77
+ # @return [Chrome]
78
+ #
79
+ # @see chrome
80
+ #
81
+ # @api public
82
+ #
83
+ def self.google_chrome
84
+ Chrome
85
+ end
86
+
87
+ #
88
+ # Firefox `User-Agent` strings.
89
+ #
90
+ # @return [Firefox]
91
+ #
92
+ # @example
93
+ # user_agent = Ronin::Web::UserAgents.firefox.random
94
+ # # => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16.0; rv:52.55.07) Gecko/20100101 Firefox/52.55.07"
95
+ #
96
+ # @api public
97
+ #
98
+ def self.firefox
99
+ Firefox
100
+ end
101
+
102
+ #
103
+ # `GoogleBot` `User-Agent` strings.
104
+ #
105
+ # @return [GoogleBot]
106
+ #
107
+ # @example
108
+ # user_agent = Ronin::Web::UserAgents.google_bot.random
109
+ # # => "GoogleBot/2.1 (+http://www.google.com/bot.html)"
110
+ #
111
+ # @api public
112
+ #
113
+ def self.google_bot
114
+ GoogleBot
115
+ end
116
+
117
+ #
118
+ # Returns a random Browser `User-Agent` string from one of the following:
119
+ #
120
+ # * {chrome}
121
+ # * {firefox}
122
+ #
123
+ # @return [String, nil]
124
+ # A random `User-Agent` string from the category.
125
+ # Note, `nil` can be returned if the given block filter out all User
126
+ # Agents.
127
+ #
128
+ # @example
129
+ # Ronin::Web::UserAgents.random
130
+ # # => "Mozilla/5.0 (X11; Fedora; Linux i686; en-IE; rv:123.4) Gecko/20100101 Firefox/123.4"
131
+ #
132
+ def self.random(&block)
133
+ method = [
134
+ :chrome,
135
+ :firefox,
136
+ ].sample
137
+
138
+ return send(method).random(&block)
139
+ end
140
+ end
141
+ end
142
+ end
@@ -0,0 +1,61 @@
1
+ # encoding: utf-8
2
+
3
+ require 'yaml'
4
+
5
+ Gem::Specification.new do |gem|
6
+ gemspec = YAML.load_file('gemspec.yml')
7
+
8
+ gem.name = gemspec.fetch('name')
9
+ gem.version = gemspec.fetch('version') do
10
+ lib_dir = File.join(File.dirname(__FILE__),'lib')
11
+ $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
12
+
13
+ require 'ronin/web/user_agents/version'
14
+ Ronin::Web::UserAgents::VERSION
15
+ end
16
+
17
+ gem.summary = gemspec['summary']
18
+ gem.description = gemspec['description']
19
+ gem.licenses = Array(gemspec['license'])
20
+ gem.authors = Array(gemspec['authors'])
21
+ gem.email = gemspec['email']
22
+ gem.homepage = gemspec['homepage']
23
+ gem.metadata = gemspec['metadata'] if gemspec['metadata']
24
+
25
+ glob = lambda { |patterns| gem.files & Dir[*patterns] }
26
+
27
+ gem.files = `git ls-files`.split($/)
28
+ gem.files = glob[gemspec['files']] if gemspec['files']
29
+ gem.files += Array(gemspec['generated_files'])
30
+
31
+ gem.executables = gemspec.fetch('executables') do
32
+ glob['bin/*'].map { |path| File.basename(path) }
33
+ end
34
+
35
+ gem.extensions = glob[gemspec['extensions'] || 'ext/**/extconf.rb']
36
+ gem.test_files = glob[gemspec['test_files'] || 'spec/{**/}*_spec.rb']
37
+ gem.extra_rdoc_files = glob[gemspec['extra_doc_files'] || '*.{txt,md}']
38
+
39
+ gem.require_paths = Array(gemspec.fetch('require_paths') {
40
+ %w[ext lib].select { |dir| File.directory?(dir) }
41
+ })
42
+
43
+ gem.requirements = gemspec['requirements']
44
+ gem.required_ruby_version = gemspec['required_ruby_version']
45
+ gem.required_rubygems_version = gemspec['required_rubygems_version']
46
+ gem.post_install_message = gemspec['post_install_message']
47
+
48
+ split = lambda { |string| string.split(/,\s*/) }
49
+
50
+ if gemspec['dependencies']
51
+ gemspec['dependencies'].each do |name,versions|
52
+ gem.add_dependency(name,split[versions])
53
+ end
54
+ end
55
+
56
+ if gemspec['development_dependencies']
57
+ gemspec['development_dependencies'].each do |name,versions|
58
+ gem.add_development_dependency(name,split[versions])
59
+ end
60
+ end
61
+ end