gem-codesearch 0.1 → 0.2

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: 3ba88fec2f6fc7cb946e0a1ba82b5296f41b8a14
4
- data.tar.gz: 4ca8bd6a6b62f3da81b3f2ace20f5a13fe0d4c45
3
+ metadata.gz: 6e8c7bb53fd63dd6e17be73b4539e85b56b375cb
4
+ data.tar.gz: f13479a2283c8f7d9644cc32da9d94581ba36bd3
5
5
  SHA512:
6
- metadata.gz: fd31437425bf9d8d8693af6784a2cbafe95f0caedc0a56f8ea095151144174f11e1ecf6ac2f35ba12aba3b45cc86e3a8c0d52eed760c35b8b6be2787d4ad081c
7
- data.tar.gz: 304fb9e178cd06cc2b8279bf1872b20fa30789e53ab5dca747f1442ebf131610782dc758fecdda6a13a4df64c94ce14ea87031e8160019ba2e9a7de80bcec076
6
+ metadata.gz: a85f76d92147d3071d17e9a48b0f32f54fb7966bbc62d3d9c270367ce573fc821dc0904bbefbb08c1453a134103a60dcfc68614f454d1a975da2a720ef272e22
7
+ data.tar.gz: e8289838b82d9a148154f77e5ebf74a160f0d0942bdc8f1ee39b745bb7b8cfad02584a72223fe1f52fe0ec4e081eb1230a0d4b82f84fecc2ba6b0c349701a218
data/README.md CHANGED
@@ -3,6 +3,10 @@
3
3
  gem-codesearch sets up a full text code search engine on mirror of rubygems.
4
4
  It use rubygems-mirror to mirror rubygems and milkode for search engine.
5
5
 
6
+ 300GB of free disk space is required to store the rubygems mirror,
7
+ unpacked gems and milkode index at 2015-01.
8
+ It will be larger in future.
9
+
6
10
  ## Usage
7
11
 
8
12
  This creates "latest-gem" package in milkode index.
@@ -14,7 +18,7 @@ This creates "latest-gem" package in milkode index.
14
18
  % gem-codesearch-setup all >& setup.log # It may take several days or more
15
19
 
16
20
  If "gem-codesearch-setup all" fails due to network or server errors,
17
- try again.
21
+ try again to continue.
18
22
 
19
23
  After the index is created, enjoy code search.
20
24
 
@@ -29,6 +33,11 @@ After the index is created, enjoy code search.
29
33
  % cd gem-codesearch
30
34
  % rake all >& setup.log # It may take several days or more
31
35
 
36
+ ## Links
37
+
38
+ - https://github.com/akr/gem-codesearch
39
+ - https://rubygems.org/gems/gem-codesearch
40
+
32
41
  ## Author
33
42
 
34
43
  Tanaka Akira
data/Rakefile CHANGED
@@ -18,26 +18,29 @@ end
18
18
 
19
19
  task :all => [:mirror, :unpack, :index]
20
20
 
21
- MIRROR_DIR = "#{Dir.pwd}/mirror"
22
- LATEST_DIR = "#{Dir.pwd}/latest-gem"
23
- LOG_DIR = "#{Dir.pwd}/log"
21
+ BASE_DIR = ENV['GEM_CODESEARCH_DIR'] || Dir.pwd
22
+ MIRROR_URL = ENV['GEM_CODESEARCH_URL'] || 'http://rubygems.org/'
23
+
24
+ MIRROR_DIR = "#{BASE_DIR}/mirror"
25
+ LATEST_DIR = "#{BASE_DIR}/latest-gem"
26
+ LOG_DIR = "#{BASE_DIR}/log"
24
27
 
25
28
  GEM_COMMAND = "#{RbConfig::CONFIG["bindir"]}/gem"
26
29
  MILK_COMMAND = "#{RbConfig::CONFIG["bindir"]}/milk"
27
30
 
28
- file ".gem/.mirrorrc" do |t|
31
+ file "#{BASE_DIR}/.gem/.mirrorrc" do |t|
29
32
  FileUtils.mkpath File.dirname(t.name)
30
33
  File.write(t.name, <<"End")
31
34
  ---
32
- - from: http://production.s3.rubygems.org
35
+ - from: #{MIRROR_URL}
33
36
  to: #{MIRROR_DIR}
34
37
  End
35
38
  end
36
39
 
37
- task :mirror => ".gem/.mirrorrc" do
40
+ task :mirror => "#{BASE_DIR}/.gem/.mirrorrc" do
38
41
  FileUtils.mkpath MIRROR_DIR
39
42
  # HOME is set because gem mirror reads $HOME/.gem/.mirrorrc.
40
- sh "HOME=#{Dir.pwd} #{GEM_COMMAND} mirror --verbose"
43
+ sh "HOME=#{BASE_DIR} #{GEM_COMMAND} mirror --verbose"
41
44
  end
42
45
 
43
46
  task :unpack do
@@ -61,18 +64,17 @@ task :unpack do
61
64
  #all_specs = all_specs.reject {|name,version,platform| /\Afoo-/ !~ name }
62
65
 
63
66
  latest_vnames = []
64
- nonlatest_vnames = []
65
67
  h = all_specs.group_by {|name,version| name }
66
68
  h.each {|name, list|
67
69
  list = list.sort_by {|name,version| version }
68
70
  vnames = list.map {|name,version| "#{name}-#{version}" }
69
71
  latest_vnames << vnames.pop
70
- nonlatest_vnames.concat list
71
72
  }
72
73
 
73
74
  already_unpacked = Dir.entries(LATEST_DIR)
74
- (already_unpacked & nonlatest_vnames).each {|vname|
75
- puts "remove: #{vname}
75
+ already_unpacked = already_unpacked - %w[. ..]
76
+ (already_unpacked - latest_vnames).each {|vname|
77
+ puts "remove: #{vname}"
76
78
  FileUtils.rmtree("#{LATEST_DIR}/#{vname}")
77
79
  }
78
80
 
@@ -1,13 +1,15 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'gem-codesearch'
3
- s.version = '0.1'
4
- s.date = '2015-01-09'
3
+ s.version = '0.2'
4
+ s.date = '2015-01-13'
5
5
  s.author = 'Tanaka Akira'
6
6
  s.email = 'akr@fsij.org'
7
7
  s.required_ruby_version = '>= 2.2.0'
8
8
  s.add_runtime_dependency 'rubygems-mirror', '~> 1.0', '>= 1.0.1'
9
9
  s.add_runtime_dependency 'milkode', '~> 1.8', '>= 1.8.6'
10
10
  s.add_runtime_dependency 'rake', '~> 10.4', '>= 10.4.2'
11
+ s.add_development_dependency 'builder', '~> 3.2', '>= 3.2.2'
12
+ s.add_development_dependency 'test-unit', '~> 3.0', '>= 3.0.8'
11
13
  s.executables << 'gem-codesearch-setup'
12
14
  s.files = %w[
13
15
  .gitignore
@@ -17,6 +19,10 @@ Gem::Specification.new do |s|
17
19
  bin/gem-codesearch-setup
18
20
  gem-codesearch.gemspec
19
21
  ]
22
+ s.test_files = %w[
23
+ test/test_all.rb
24
+ test/test_bin.rb
25
+ ]
20
26
  s.homepage = 'https://github.com/akr/gem-codesearch'
21
27
  s.license = 'MIT'
22
28
  s.summary = 'Set up a full text code search engine for rubygems mirror'
@@ -0,0 +1,70 @@
1
+ require 'test/unit'
2
+ require 'tmpdir'
3
+ require 'fileutils'
4
+ require 'rbconfig'
5
+ require 'socket'
6
+ require 'pty'
7
+ require 'io/console'
8
+
9
+ GEM_COMMAND = "#{RbConfig::CONFIG["bindir"]}/gem"
10
+ MILK_COMMAND = "#{RbConfig::CONFIG["bindir"]}/milk"
11
+ RAKE_COMMAND = "#{RbConfig::CONFIG["bindir"]}/rake"
12
+
13
+ topdir = File.dirname(File.dirname(File.realpath(__FILE__)))
14
+ RAKEFILE = topdir + "/Rakefile"
15
+
16
+ class TestGemCodesearch < Test::Unit::TestCase
17
+ def setup
18
+ @workdir = Dir.mktmpdir('gem-codesearch')
19
+ ENV['MILKODE_DEFAULT_DIR'] = "#{@workdir}/milkode"
20
+ end
21
+
22
+ def test_milk_init
23
+ assert(!File.exist?("#{@workdir}/milkode"))
24
+ system(MILK_COMMAND, 'init', '--default', :out => IO::NULL)
25
+ assert($?.success?)
26
+ assert(File.exist?("#{@workdir}/milkode"))
27
+ end
28
+
29
+ def start_gem_server
30
+ # "gem server" serves gem files already installed.
31
+ gem_server_command = [GEM_COMMAND, 'server', '-b', '127.0.0.1', '-p', '0']
32
+ pid = nil
33
+ PTY.open {|m, s|
34
+ s.raw!
35
+ pid = spawn(*gem_server_command, :out => s, :err => IO::NULL)
36
+ line = m.gets
37
+ unless %r{Server started at (http:\S+)} =~ line
38
+ flunk "unexpected 'gem server' message: #{line.inspect}"
39
+ end
40
+ url = $1
41
+ yield [pid, url]
42
+ }
43
+ ensure
44
+ if pid
45
+ Process.kill :TERM, pid
46
+ Process.wait pid
47
+ end
48
+ end
49
+
50
+ def test_gem_server
51
+ start_gem_server {|pid, url| }
52
+ end
53
+
54
+ def test_all
55
+ start_gem_server {|pid, url|
56
+ ENV['GEM_CODESEARCH_URL'] = url
57
+ ENV['GEM_CODESEARCH_DIR'] = @workdir
58
+ system(MILK_COMMAND, 'init', '--default', :out => IO::NULL)
59
+ system(RAKE_COMMAND, '-f', RAKEFILE, 'all', [:out, :err] => IO::NULL)
60
+ system(RAKE_COMMAND, '-f', RAKEFILE, 'all', [:out, :err] => IO::NULL) # update exisiting index.
61
+ }
62
+ end
63
+
64
+ def teardown
65
+ FileUtils.rmtree @workdir
66
+ ENV['MILKODE_DEFAULT_DIR'] = nil
67
+ ENV['GEM_CODESEARCH_URL'] = nil
68
+ ENV['GEM_CODESEARCH_DIR'] = nil
69
+ end
70
+ end
@@ -0,0 +1,18 @@
1
+ require 'test/unit'
2
+ require 'rbconfig'
3
+
4
+ RUBY_COMMAND = RbConfig.ruby
5
+
6
+ topdir = File.dirname(File.dirname(File.realpath(__FILE__)))
7
+ GEM_CODESEARCH_SETUP_COMMAND = topdir + "/bin/gem-codesearch-setup"
8
+
9
+ class TestGemCodesearch < Test::Unit::TestCase
10
+ def test_setup_help
11
+ command = [RUBY_COMMAND, GEM_CODESEARCH_SETUP_COMMAND, 'help']
12
+ message = IO.popen(command) {|io|
13
+ io.read
14
+ }
15
+ assert_match(/rake help/, message)
16
+ assert_match(/rake all/, message)
17
+ end
18
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem-codesearch
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tanaka Akira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-09 00:00:00.000000000 Z
11
+ date: 2015-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubygems-mirror
@@ -70,6 +70,46 @@ dependencies:
70
70
  - - ">="
71
71
  - !ruby/object:Gem::Version
72
72
  version: 10.4.2
73
+ - !ruby/object:Gem::Dependency
74
+ name: builder
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '3.2'
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 3.2.2
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.2'
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 3.2.2
93
+ - !ruby/object:Gem::Dependency
94
+ name: test-unit
95
+ requirement: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '3.0'
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 3.0.8
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '3.0'
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 3.0.8
73
113
  description: |
74
114
  gem-codesearch sets up a full text code search engine for rubygems mirror.
75
115
  It use rubygems-mirror to mirror rubygems and
@@ -86,6 +126,8 @@ files:
86
126
  - Rakefile
87
127
  - bin/gem-codesearch-setup
88
128
  - gem-codesearch.gemspec
129
+ - test/test_all.rb
130
+ - test/test_bin.rb
89
131
  homepage: https://github.com/akr/gem-codesearch
90
132
  licenses:
91
133
  - MIT
@@ -110,4 +152,6 @@ rubygems_version: 2.4.5
110
152
  signing_key:
111
153
  specification_version: 4
112
154
  summary: Set up a full text code search engine for rubygems mirror
113
- test_files: []
155
+ test_files:
156
+ - test/test_all.rb
157
+ - test/test_bin.rb