milkode 1.6.1 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ef388fc3823334de6936be6caf2202fc5739c279
4
+ data.tar.gz: 8664bf3c752e15ad46a77924f7bc8a5cbb7bfbf0
5
+ SHA512:
6
+ metadata.gz: 7266759f8427dfea3e3e1e2fa0707d49aa74e4c0fdb14787b56de55e7ba98a8eaf1d8961a922086de6af0bfd5357b9b9b03c9a3914e3def56a6a70c95fa6a98e
7
+ data.tar.gz: d797d5c1ceae24946def6d121ebdedc425d6e9597cfdf14840a0db92094c9d41049f9805bd83f9186563b6bec4c32241811a3168ae8b3c121dc9701c250c4368
@@ -0,0 +1,24 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ .sass-cache
24
+ TAGS
@@ -12,4 +12,4 @@ rvm:
12
12
  - 2.0.0
13
13
 
14
14
  before_install:
15
- - curl https://raw.github.com/groonga/groonga/master/data/travis/setup.sh | sh
15
+ - curl --silent --location https://github.com/groonga/groonga/raw/master/data/travis/setup.sh | sh
data/Gemfile CHANGED
@@ -1,29 +1,4 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- # Add dependencies required to use your gem here.
4
- # Example:
5
- # gem "activesupport", ">= 2.3.5"
6
- # gemspec
7
- gem 'termcolor' , '>= 1.2.0' , '< 1.2.2'
8
- gem 'rroonga' , '>= 1.1.0'
9
- gem 'rack' , '>= 1.5.2'
10
- gem 'sinatra' , '>= 1.2.6'
11
- gem 'launchy' , '>= 0.3.7'
12
- gem 'coderay' , '>= 1.0.5'
13
- gem 'thin' , '>= 1.2.10', '< 2.0.0'
14
- gem 'archive-zip' , '>= 0.4.0'
15
- gem 'haml' , '>= 3.1.2'
16
- gem 'sass' , '>= 3.1.3'
17
- gem 'thor' , '>= 0.18.1'
18
- gem 'i18n' , '~> 0.6.5'
19
- gem 'whichr' , '~> 0.3'
20
-
21
- # Add dependencies to develop your gem here.
22
- # Include everything needed to run rake, tests, features, etc.
23
- group :development do
24
- gem 'bundler'
25
- gem 'jeweler'
26
- gem 'rack-test'
27
- gem 'sinatra-reloader'
28
- gem 'test-unit' , '>= 2.5.4'
29
- end
3
+ # Specify your gem's dependencies in milkode.gemspec
4
+ gemspec
@@ -1,3 +1,20 @@
1
+ === 1.7.0 2014/06/02
2
+
3
+ * milk web
4
+ * Support gomilk option (milk web -g)
5
+ * https://github.com/ongaeshi/gomilk
6
+ * Support i18n in the help.haml
7
+
8
+ * gmilk
9
+ * #66 gmilkでの検索結果のファイルのパス (thanks kazuna)
10
+
11
+ * etc
12
+ * Improve README
13
+ * Add a badge of gem version
14
+ * Change the setting of TravisCI [groonga-dev,02268]
15
+ * Change to Bundler a method of generating a gem
16
+ * Jeweler, Thanks for long support
17
+
1
18
  === 1.6.1 2014/04/15
2
19
 
3
20
  * milk
@@ -1,3 +1,20 @@
1
+ === 1.7.0 2014/06/02
2
+
3
+ * milk web
4
+ * Support gomilk option (milk web -g)
5
+ * https://github.com/ongaeshi/gomilk
6
+ * Support i18n in the help.haml
7
+
8
+ * gmilk
9
+ * #66 gmilk --expand-path (thanks kazuna)
10
+
11
+ * etc
12
+ * Improve README
13
+ * Add a badge of gem version
14
+ * Change the setting of TravisCI [groonga-dev,02268]
15
+ * Change to Bundler a method of generating a gem
16
+ * Jeweler, Thanks for long support
17
+
1
18
  === 1.6.1 2014/04/15
2
19
 
3
20
  * milk
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Milkode
2
2
 
3
- [![Build Status](https://travis-ci.org/ongaeshi/milkode.svg?branch=develop)](https://travis-ci.org/ongaeshi/milkode)
3
+ [![Version](https://img.shields.io/gem/v/milkode.svg)](https://rubygems.org/gems/milkode) [![Build Status](https://travis-ci.org/ongaeshi/milkode.svg?branch=develop)](https://travis-ci.org/ongaeshi/milkode)
4
4
 
5
5
  Milkode is "Line Based" local source code search engine written by Ruby. It have command line interface and web application. It will accelerate the code reading of your life.
6
6
 
@@ -10,10 +10,124 @@ Milkode is "見るコード". "See a code" is meaning.
10
10
 
11
11
  ![milk-web-01.jpg](http://milkode.ongaeshi.me/images/milk-web-01.jpg)
12
12
 
13
- ## DOCUMENTS
13
+ ## Installation
14
+
15
+ $ gem install milkode
16
+
17
+ When you faild to install Rroonga, Please refer.
18
+ * [File: install — rroonga - Ranguba](http://ranguba.org/rroonga/en/file.install.html)
19
+
20
+ ## Usage
21
+
22
+ ### Create a database
23
+
24
+ ```
25
+ $ milk init --default
26
+ create : /Users/auser/.milkode/milkode.yaml
27
+ create : /Users/auser/.milkode/db/milkode.db created.
28
+ ```
29
+
30
+ Create database to current dir.
31
+
32
+ ```
33
+ $ milk init
34
+ Create database to "/path/to/dir/db/honyomi.db"
35
+ ```
36
+
37
+ If you want to use custom database, Please specify `MILKODE_DEFAULT_DIR` variable.
38
+
39
+ ```
40
+ $ MILKODE_DEFAULT_DIR=/path/to/dir milk add /path/to/project
41
+ ```
42
+
43
+ ### Add packages
44
+
45
+ Add source code from local directory.
46
+
47
+ ```
48
+ $ milk add ~/Documents/codes/linux-3.10-rc4
49
+ package : linux-3.10-rc4
50
+ .
51
+ .
52
+ result : 1 packages, 42810 records, 42810 add.
53
+ *milkode* : 1 packages, 42810 records in /Users/ongaeshi/.milkode/db/milkode.db.
54
+ ```
55
+
56
+ Add source code from gem.
57
+
58
+ ```
59
+ $ milk add /opt/local/lib/ruby2.0/gems/2.0.0/gems/milkode-1.6.0/
60
+ ```
61
+
62
+ Add source code from GitHub.
63
+
64
+ ```
65
+ $ milk add https://github.com/ongaeshi/milkode.git -p git
66
+ $ milk add git://github.com/ongaeshi/milkode.git
67
+ $ milk add git://github.com/ongaeshi/milkode.git -b develop -n milkode_develop
68
+ ```
69
+
70
+ Add source code from http-zip.
71
+
72
+ ```
73
+ $ milk add http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.zip
74
+ ```
75
+
76
+ ### List packages
77
+
78
+ ```
79
+ $ milk list
80
+ a_project
81
+ milkode
82
+ milkode-1.6.0
83
+ ruby-2.1.2
84
+ ```
85
+
86
+ Filter by keyword.
87
+
88
+ ```
89
+ $ milk list milk
90
+ milkode-1.6.0
91
+ milkode
92
+ ```
93
+
94
+ ### Search command line
95
+
96
+ Gmilk command can use the AND search.
97
+
98
+ ```
99
+ $ cd ~/Documents/codes/linux-3.10-rc4
100
+ $ gmilk according prototypes
101
+ Documentation/cdrom/cdrom-standard.tex:977: according to prototypes listed in \cdromh, and specifications given
102
+ ```
103
+
104
+ Remember the project root.
105
+
106
+ ```
107
+ $ cd driver/acpi
108
+ $ gmilk according prototypes
109
+ ../../Documentation/cdrom/cdrom-standard.tex:977: according to prototypes listed in \cdromh, and specifications given
110
+ ```
111
+
112
+ [Gomilk](https://github.com/ongaeshi/gomilk) is faster version written by Go.
113
+
114
+ ### Web application
115
+
116
+ ```
117
+ $ milk web
118
+ ```
119
+
120
+ ![milk-web-02.jpg](http://milkode.ongaeshi.me/images/milk-web-02.jpg)
121
+
122
+ ## Documents
14
123
 
15
124
  * [Milkode - line based local source code search engine](http://milkode.ongaeshi.me/)
16
125
 
126
+ ## Plugins
127
+
128
+ * [emacs-milkode](https://github.com/ongaeshi/emacs-milkode)
129
+ * [anything-milkode](https://github.com/ongaeshi/anything-milkode)
130
+
17
131
  ## HISTORY
18
132
 
19
133
  * [History.rdoc](https://github.com/ongaeshi/milkode/blob/master/HISTORY.rdoc)
data/Rakefile CHANGED
@@ -1,66 +1,8 @@
1
- # -*- coding: utf-8 -*-
2
- require 'rubygems'
3
- require 'bundler'
4
- # begin
5
- # Bundler.setup(:default, :development)
6
- # rescue Bundler::BundlerError => e
7
- # $stderr.puts e.message
8
- # $stderr.puts "Run `bundle install` to install missing gems"
9
- # exit e.status_code
10
- # end
11
- require 'rake'
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
12
3
 
13
- require 'jeweler'
14
- Jeweler::Tasks.new do |gem|
15
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
16
- gem.name = "milkode"
17
- gem.homepage = "http://github.com/ongaeshi/milkode"
18
- gem.license = "MIT"
19
- gem.summary = %Q{Line based local source code search engine.}
20
- gem.description = %Q{Milkode is line based local source code search engine. It have command line interface and web application. It will accelerate the code reading of your life.}
21
- gem.email = "ongaeshi0621@gmail.com"
22
- gem.authors = ["ongaeshi"]
23
- # Dependencies move to 'Gemfile'
24
- end
25
- Jeweler::RubygemsDotOrgTasks.new
26
-
27
- require 'rake/testtask'
28
-
29
- # groonga関連のテストが通らないため、独自のrake_test_loaderを読み込む
30
- $LOAD_PATH.unshift '.'
31
- module Rake
32
- class TestTask < TaskLib
33
- def rake_loader # :nodoc:
34
- find_file('test/rake_test_loader') or
35
- fail "unable to find rake test loader"
36
- end
37
- end
38
- end
39
-
40
- Rake::TestTask.new(:test) do |test|
41
- test.libs << 'lib' << 'test'
42
- test.test_files = FileList['test/**/test_*.rb']
43
- test.verbose = true
44
- end
45
-
46
- task :test_all do
47
- puts "--- rvm 1.9.2@milkode ---"
48
- system('rvm 1.9.2@milkode')
49
- system('rake test')
50
-
51
- puts "--- rvm system ---"
52
- system('rvm system')
53
- system('rake test')
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
54
6
  end
55
7
 
56
8
  task :default => :test
57
-
58
- require 'rdoc/task'
59
- Rake::RDocTask.new do |rdoc|
60
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
61
-
62
- rdoc.rdoc_dir = 'rdoc'
63
- rdoc.title = "milkode #{version}"
64
- rdoc.rdoc_files.include('README*')
65
- rdoc.rdoc_files.include('lib/**/*.rb')
66
- end
data/bin/gmilk CHANGED
@@ -4,7 +4,8 @@
4
4
  #
5
5
 
6
6
  require 'rubygems'
7
+ require 'milkode'
7
8
  require 'milkode/grep/cli_grep'
8
9
 
9
- Version = "1.6.1"
10
+ Version = Milkode::VERSION
10
11
  Milkode::CLI_Grep.execute(STDOUT, ARGV)
data/bin/milk CHANGED
@@ -6,5 +6,4 @@
6
6
  require 'rubygems'
7
7
  require 'milkode/cli'
8
8
 
9
- Version = "1.6.1"
10
9
  Milkode::CLI.start(ARGV)
@@ -0,0 +1,6 @@
1
+ require "milkode/version"
2
+
3
+ module Milkode
4
+ # Your code goes here...
5
+ end
6
+
@@ -43,7 +43,7 @@ end
43
43
  get '/' do
44
44
  if Database.validate?
45
45
  @setting = WebSetting.new
46
- @version = "1.6.1"
46
+ @version = Milkode::VERSION
47
47
 
48
48
  @package_num = Database.instance.yaml_package_num
49
49
  @file_num = Database.instance.totalRecords
@@ -138,6 +138,7 @@ end
138
138
  get %r{/help} do
139
139
  @setting = WebSetting.new
140
140
  @path = ""
141
+ update_locale
141
142
  haml :help
142
143
  end
143
144
 
@@ -168,6 +169,14 @@ get '/info/:package' do
168
169
  haml :info_package
169
170
  end
170
171
 
172
+ get '/gomilk' do
173
+ if ENV['MILKODE_SUPPORT_GOMILK']
174
+ search_for_gomilk(params)
175
+ else
176
+ "Error: Need 'milk web --gomilk'"
177
+ end
178
+ end
179
+
171
180
  # -- helper function --
172
181
 
173
182
  helpers do
@@ -7,40 +7,6 @@ require 'milkode/cdweb/lib/database'
7
7
 
8
8
  module Milkode
9
9
  class CLI_Cdweb
10
- def self.execute(stdout, argv)
11
- options = {
12
- :environment => ENV['RACK_ENV'] || "development",
13
- :pid => nil,
14
- :Port => 9292,
15
- :Host => "0.0.0.0",
16
- :AccessLog => [],
17
- :config => "config.ru",
18
- # ----------------------------
19
- :server => "thin",
20
- :LaunchBrowser => true,
21
- :DbDir => select_dbdir,
22
- }
23
-
24
- opts = OptionParser.new("#{File.basename($0)}")
25
- opts.on('--db DB_DIR', 'Database dir (default : current_dir)') {|v| options[:DbDir] = v }
26
- opts.on("-o", "--host HOST", "listen on HOST (default: 0.0.0.0)") {|host| options[:Host] = host }
27
- opts.on('-p', '--port PORT', 'use PORT (default: 9292)') {|v| options[:Port] = v }
28
- opts.on("-s", "--server SERVER", "serve using SERVER (default : thin)") {|s| options[:server] = s }
29
- opts.on('-n', '--no-browser', 'No launch browser.') {|v| options[:LaunchBrowser] = false }
30
- opts.on('--customize', 'Create customize file.') {|v| options[:customize] = true }
31
-
32
- # --hostが'-h'を上書きするので、'-h'を再定義してあげる
33
- opts.on_tail("-h", "-?", "--help", "Show this message") do
34
- puts opts
35
- exit
36
- end
37
-
38
- opts.parse!(argv)
39
-
40
- # 実行!!
41
- execute_with_options(options)
42
- end
43
-
44
10
  def self.execute_with_options(stdout, options)
45
11
  dbdir = File.expand_path(options[:DbDir])
46
12
 
@@ -60,6 +26,9 @@ module Milkode
60
26
  # URL設定
61
27
  ENV['MILKODE_RELATIVE_URL'] = File.join('/', options[:url]) if options[:url]
62
28
 
29
+ # Allow "http://127.0.0.1:9292/gomilk"
30
+ ENV['MILKODE_SUPPORT_GOMILK'] = "true" if options[:gomilk]
31
+
63
32
  # 起動
64
33
  rack_server.start do
65
34
  # この時点でoptions[:Host]やoptions[:Port]などの値が壊れてしまっているため事前にURLを生成している
@@ -5,14 +5,15 @@
5
5
  # @author ongaeshi
6
6
  # @date 2011/07/11
7
7
 
8
- require 'milkode/cdweb/lib/database'
9
8
  require 'milkode/cdweb/lib/coderay_wrapper'
9
+ require 'milkode/cdweb/lib/database'
10
+ require 'milkode/cdweb/lib/mkurl'
10
11
  require 'milkode/cdweb/lib/search_contents'
11
12
  require 'milkode/cdweb/lib/search_files'
12
- require 'milkode/cdweb/lib/search_gotoline'
13
13
  require 'milkode/cdweb/lib/search_fuzzy_gotoline'
14
- require 'milkode/cdweb/lib/mkurl'
14
+ require 'milkode/cdweb/lib/search_gotoline'
15
15
  require 'milkode/common/util'
16
+ require 'milkode/grep/findgrep'
16
17
 
17
18
  module Milkode
18
19
  def view(record, params, before)
@@ -133,6 +134,26 @@ module Milkode
133
134
  haml :packages
134
135
  end
135
136
 
137
+ def search_for_gomilk(params)
138
+ documents = Database.instance.documents
139
+ grn = documents.table
140
+
141
+ query = params[:query]
142
+
143
+ unless params[:all]
144
+ begin
145
+ package = CLI_Grep.package_root(params[:dir].gsub("\\", "/"))
146
+ rescue CLI_Grep::NotFoundPackage
147
+ return "Error: Not package dir '#{params[:dir]}'"
148
+ end
149
+ query += " package: #{package.name}"
150
+ end
151
+
152
+ records = grn.select(query, default_column: "content")
153
+
154
+ records.map { |r| r.path }.join("\n")
155
+ end
156
+
136
157
  private
137
158
 
138
159
  def file_or_dirimg(is_file, suburl)