alpaca_complete 0.1.4 → 0.2.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 +15 -0
- data/.gitignore +48 -0
- data/Gemfile +4 -8
- data/Gemfile.lock +17 -16
- data/README.md +6 -4
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/alpaca_complete.gemspec +8 -8
- data/autoload/alpaca_complete.vim +43 -0
- data/autoload/neocomplcache/sources/assets_complete.vim +138 -0
- data/autoload/neocomplcache/sources/locale_complete.vim +21 -11
- data/bin/alpaca_complete +1 -8
- data/lib/AlpacaComplete.rb +1 -1
- data/lib/AlpacaComplete/utils.rb +31 -19
- data/spec/spec_helper.rb +1 -1
- data/spec/supports/rails_complete/app/assets/images/test/rails.png +0 -0
- metadata +24 -21
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NjJlYWM0OWVkNmViM2Q4MmJhZGZlMzc4MGNkZWEzOTVlMjZjZWYzMg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZDk4MDBmMzc0OTE4Y2Q2YmNmM2MyZWMzYzQ0MDU5Y2VmMGQyN2U3ZQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZTdiN2JjY2UxMGY1OGUxNmY2N2VkYzUwM2YyOGZkYTYzYzFkYThhNjA5NTY2
|
10
|
+
MTgzNjE3MTFlYTVjNzA4ZWEyY2FmOWNlN2U3YzhhMDRiZGM1MWRkMjU1ZmY4
|
11
|
+
YjIyOTRkOGM4OGEzYzBlNjAwZmUwNjJiZjQ3YjQwYWEyZTkzODU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MDMxZThmY2U5Y2JlMTRlZDczMTQxYzEwZjU2NDMyZTZmNmY0OGFhNWM2YTFi
|
14
|
+
YTQwYWQ4ZDdlNmQxZDVkYTFjOWUyMjYwMWJlMDQ0ZWYwM2ZlNzRlZDEyZDMx
|
15
|
+
OTI2M2EwMDBlOGZmODE1MTdjOTQyNjJiOTBhZGM2ODJjZGUxYmU=
|
data/.gitignore
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# rcov generated
|
2
|
+
coverage
|
3
|
+
coverage.data
|
4
|
+
|
5
|
+
# rdoc generated
|
6
|
+
rdoc
|
7
|
+
|
8
|
+
# yard generated
|
9
|
+
.yardoc
|
10
|
+
|
11
|
+
# bundler
|
12
|
+
.bundle
|
13
|
+
|
14
|
+
# jeweler generated
|
15
|
+
pkg
|
16
|
+
|
17
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
18
|
+
#
|
19
|
+
# * Create a file at ~/.gitignore
|
20
|
+
# * Include files you want ignored
|
21
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
22
|
+
#
|
23
|
+
# After doing this, these files will be ignored in all your git projects,
|
24
|
+
# saving you from having to 'pollute' every project you touch with them
|
25
|
+
#
|
26
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
27
|
+
#
|
28
|
+
# For MacOS:
|
29
|
+
#
|
30
|
+
#.DS_Store
|
31
|
+
|
32
|
+
# For TextMate
|
33
|
+
#*.tmproj
|
34
|
+
#tmtags
|
35
|
+
|
36
|
+
# For emacs:
|
37
|
+
#*~
|
38
|
+
#\#*
|
39
|
+
#.\#*
|
40
|
+
|
41
|
+
# For vim:
|
42
|
+
#*.swp
|
43
|
+
|
44
|
+
# For redcar:
|
45
|
+
#.redcar
|
46
|
+
|
47
|
+
# For rubinius:
|
48
|
+
#*.rbc
|
data/Gemfile
CHANGED
@@ -1,15 +1,11 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
|
-
# Add dependencies required to use your gem here.
|
3
|
-
# Example:
|
4
|
-
# gem "activesupport", ">= 2.3.5"
|
5
2
|
|
6
|
-
# Add dependencies to develop your gem here.
|
7
|
-
# Include everything needed to run rake, tests, features, etc.
|
8
3
|
group :development do
|
9
|
-
gem "
|
10
|
-
gem "
|
4
|
+
gem "rake"
|
5
|
+
gem "rspec"
|
6
|
+
gem "rdoc"
|
11
7
|
gem "bundler"
|
12
|
-
gem "jeweler"
|
8
|
+
gem "jeweler"
|
13
9
|
end
|
14
10
|
|
15
11
|
group :test do
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
diff-lcs (1.
|
4
|
+
diff-lcs (1.2.4)
|
5
5
|
fuubar (1.1.0)
|
6
6
|
rspec (~> 2.0)
|
7
7
|
rspec-instafail (~> 0.2.0)
|
@@ -12,20 +12,20 @@ GEM
|
|
12
12
|
git (>= 1.2.5)
|
13
13
|
rake
|
14
14
|
rdoc
|
15
|
-
json (1.7.
|
16
|
-
multi_json (1.
|
17
|
-
rake (10.0.
|
18
|
-
rdoc (
|
15
|
+
json (1.7.7)
|
16
|
+
multi_json (1.7.3)
|
17
|
+
rake (10.0.4)
|
18
|
+
rdoc (4.0.1)
|
19
19
|
json (~> 1.4)
|
20
|
-
rspec (2.
|
21
|
-
rspec-core (~> 2.
|
22
|
-
rspec-expectations (~> 2.
|
23
|
-
rspec-mocks (~> 2.
|
24
|
-
rspec-core (2.
|
25
|
-
rspec-expectations (2.
|
26
|
-
diff-lcs (
|
20
|
+
rspec (2.13.0)
|
21
|
+
rspec-core (~> 2.13.0)
|
22
|
+
rspec-expectations (~> 2.13.0)
|
23
|
+
rspec-mocks (~> 2.13.0)
|
24
|
+
rspec-core (2.13.1)
|
25
|
+
rspec-expectations (2.13.0)
|
26
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
27
27
|
rspec-instafail (0.2.4)
|
28
|
-
rspec-mocks (2.
|
28
|
+
rspec-mocks (2.13.1)
|
29
29
|
ruby-progressbar (1.0.2)
|
30
30
|
simplecov (0.7.1)
|
31
31
|
multi_json (~> 1.0)
|
@@ -38,7 +38,8 @@ PLATFORMS
|
|
38
38
|
DEPENDENCIES
|
39
39
|
bundler
|
40
40
|
fuubar
|
41
|
-
jeweler
|
42
|
-
|
43
|
-
|
41
|
+
jeweler
|
42
|
+
rake
|
43
|
+
rdoc
|
44
|
+
rspec
|
44
45
|
simplecov
|
data/README.md
CHANGED
@@ -6,8 +6,8 @@ RoR & vimユーザーの為の補完プラグインを作成しております
|
|
6
6
|
## install
|
7
7
|
|
8
8
|
```vim:.vimrc
|
9
|
-
NeoBundle 'taichouchou2/alpaca_complete',{
|
10
|
-
\ 'depends' : 'tpope/vim-rails',
|
9
|
+
NeoBundle 'taichouchou2/alpaca_complete', {
|
10
|
+
\ 'depends' : [ 'tpope/vim-rails', 'Shougo/neocomplcache'],
|
11
11
|
\ 'build' : {
|
12
12
|
\ 'mac' : 'gem install alpaca_complete',
|
13
13
|
\ 'unix' : 'gem install alpaca_complete',
|
@@ -17,6 +17,7 @@ NeoBundle 'taichouchou2/alpaca_complete',{
|
|
17
17
|

|
18
18
|
|
19
19
|
NeoBundle以外の人は、下記を実行してください
|
20
|
+
また、[neocomplcache]( https://github.com/Shougo/neocomplcache )が必要です。
|
20
21
|
|
21
22
|
```shell
|
22
23
|
`gem install alpaca_complete`
|
@@ -27,8 +28,9 @@ NeoBundle以外の人は、下記を実行してください
|
|
27
28
|
下記の機能を実装予定です。(優先順位順)
|
28
29
|
それぞれの補完は説明や引数付きで補完する予定です。
|
29
30
|
|
30
|
-
- locales(I18n.t)補完
|
31
|
-
- chaching機能
|
31
|
+
- locales(I18n.t)補完(完了)
|
32
|
+
- chaching機能(完了)
|
33
|
+
- assets補完(完了)
|
32
34
|
- migrate補完
|
33
35
|
- view補完
|
34
36
|
- controller補完
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require
|
3
|
+
require "rubygems"
|
4
4
|
require 'bundler'
|
5
5
|
begin
|
6
6
|
Bundler.setup(:default, :development)
|
@@ -9,8 +9,8 @@ rescue Bundler::BundlerError => e
|
|
9
9
|
$stderr.puts "Run `bundle install` to install missing gems"
|
10
10
|
exit e.status_code
|
11
11
|
end
|
12
|
-
require 'rake'
|
13
12
|
|
13
|
+
require 'rake'
|
14
14
|
require 'jeweler'
|
15
15
|
Jeweler::Tasks.new do |gem|
|
16
16
|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.2
|
data/alpaca_complete.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Hiroyuki Ishii"]
|
12
|
-
s.date = "
|
12
|
+
s.date = "2013-05-13"
|
13
13
|
s.description = "rails auto-complete for editor"
|
14
14
|
s.email = "alprhcp666@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.homepage = "http://github.com/taichouchou2/alpaca_complete"
|
21
21
|
s.licenses = ["MIT"]
|
22
22
|
s.require_paths = ["lib"]
|
23
|
-
s.rubygems_version = "
|
23
|
+
s.rubygems_version = "2.0.3"
|
24
24
|
s.summary = "rails complete for editor"
|
25
25
|
|
26
26
|
if s.respond_to? :specification_version then
|
@@ -33,16 +33,16 @@ Gem::Specification.new do |s|
|
|
33
33
|
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
34
34
|
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
35
35
|
else
|
36
|
-
s.add_dependency(%q<rspec>, ["~> 2.
|
37
|
-
s.add_dependency(%q<rdoc>, ["~>
|
38
|
-
s.add_dependency(%q<bundler>, [">=
|
36
|
+
s.add_dependency(%q<rspec>, ["~> 2.13.1"])
|
37
|
+
s.add_dependency(%q<rdoc>, ["~> 4.0.0"])
|
38
|
+
s.add_dependency(%q<bundler>, [">= 1.3.5"])
|
39
39
|
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
40
40
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
41
41
|
end
|
42
42
|
else
|
43
|
-
s.add_dependency(%q<rspec>, ["~> 2.
|
44
|
-
s.add_dependency(%q<rdoc>, ["~>
|
45
|
-
s.add_dependency(%q<bundler>, [">=
|
43
|
+
s.add_dependency(%q<rspec>, ["~> 2.13.1"])
|
44
|
+
s.add_dependency(%q<rdoc>, ["~> 4.0.0"])
|
45
|
+
s.add_dependency(%q<bundler>, [">= 1.3.5"])
|
46
46
|
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
47
47
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
48
48
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
function! s:let(scope, name, value) "{{{
|
2
|
+
let global_variable_name = a:scope . ':' . a:name
|
3
|
+
if !exists(global_variable_name)
|
4
|
+
let cmd = 'let ' . global_variable_name . ' = ' . string( a:value )
|
5
|
+
exe cmd
|
6
|
+
endif
|
7
|
+
endfunction"}}}
|
8
|
+
|
9
|
+
function! alpaca_complete#system(cmd, path)
|
10
|
+
let g:hoge = 'alpaca_complete -c ' . a:cmd . ' -f ' . a:path
|
11
|
+
return neocomplcache#system( 'alpaca_complete -c ' . a:cmd . ' -f ' . a:path )
|
12
|
+
endfunction
|
13
|
+
|
14
|
+
function! alpaca_complete#initialize()
|
15
|
+
" Create cache directory.
|
16
|
+
if !isdirectory(neocomplcache#get_temporary_directory() . '/alpaca_complete')
|
17
|
+
call mkdir(neocomplcache#get_temporary_directory() . '/alpaca_complete')
|
18
|
+
endif
|
19
|
+
endfunction
|
20
|
+
|
21
|
+
function! alpaca_complete#rails_root_join(path)
|
22
|
+
if alpaca_complete#enable()
|
23
|
+
if empty( a:path ) || a:path == '/'
|
24
|
+
return b:rails_root
|
25
|
+
endif
|
26
|
+
|
27
|
+
let real_path = b:rails_root . '/' . a:path
|
28
|
+
|
29
|
+
return substitute(real_path, '/$', '', 'g')
|
30
|
+
endif
|
31
|
+
endfunction
|
32
|
+
|
33
|
+
function! alpaca_complete#let_g:(name, value) "{{{
|
34
|
+
call s:let('g', a:name, a:value)
|
35
|
+
endfunction"}}}
|
36
|
+
|
37
|
+
function! alpaca_complete#enable() "{{{
|
38
|
+
if exists('b:rails_root')
|
39
|
+
return 1
|
40
|
+
else
|
41
|
+
return 0
|
42
|
+
endif
|
43
|
+
endfunction"}}}
|
@@ -0,0 +1,138 @@
|
|
1
|
+
"=============================================================================
|
2
|
+
" FILE: assets_complete.vim
|
3
|
+
" AUTHOR: alpaca taichou <alprhcp666@gmail.com>
|
4
|
+
" Last Modified: 2013-02-25
|
5
|
+
" License: MIT license {{{
|
6
|
+
" Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
" a copy of this software and associated documentation files (the
|
8
|
+
" "Software"), to deal in the Software without restriction, including
|
9
|
+
" without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
" distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
" permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
" the following conditions:
|
13
|
+
"
|
14
|
+
" The above copyright notice and this permission notice shall be included
|
15
|
+
" in all copies or substantial portions of the Software.
|
16
|
+
"
|
17
|
+
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
18
|
+
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
20
|
+
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
21
|
+
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
22
|
+
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
23
|
+
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
" }}}
|
25
|
+
"=============================================================================
|
26
|
+
|
27
|
+
let s:save_cpo = &cpo
|
28
|
+
set cpo&vim
|
29
|
+
|
30
|
+
let s:source = {
|
31
|
+
\ 'name' : 'assets_complete',
|
32
|
+
\ 'kind' : 'ftplugin',
|
33
|
+
\ 'filetypes' : { 'ruby' : 1, 'haml' : 1, 'eruby' : 1,
|
34
|
+
\ 'scss': 1, 'sass' : 1, 'yaml': 1, 'ruby.rspec' : 1 },
|
35
|
+
\ }
|
36
|
+
|
37
|
+
" let s:cached_regexp = {}
|
38
|
+
|
39
|
+
function! s:source.initialize() "{{{
|
40
|
+
call neocomplcache#set_completion_length(
|
41
|
+
\ 'assets_complete', g:neocomplcache_auto_completion_start_length)
|
42
|
+
call neocomplcache#util#set_default_dictionary(
|
43
|
+
\ 'g:neocomplcache_source_rank',
|
44
|
+
\ 'assets_complete', 3)
|
45
|
+
|
46
|
+
call alpaca_complete#let_g:('alpaca_complete_assets_dir', {
|
47
|
+
\ 'img' : 'app/assets/images',
|
48
|
+
\ 'js' : 'app/assets/javascripts',
|
49
|
+
\ 'style' : 'app/assets/stylesheets',
|
50
|
+
\})
|
51
|
+
|
52
|
+
call alpaca_complete#let_g:('alpaca_complete_trigger_method', {
|
53
|
+
\ 'img' : 'asset_path,asset_data_uri,image-url,image-path,image_tag',
|
54
|
+
\ 'js' : 'javascript_include_tag',
|
55
|
+
\ 'style' : 'stylesheet_link_tag',
|
56
|
+
\})
|
57
|
+
|
58
|
+
" Initialize.
|
59
|
+
call alpaca_complete#initialize()
|
60
|
+
endfunction"}}}
|
61
|
+
|
62
|
+
function! s:source.finalize() "{{{
|
63
|
+
endfunction"}}}
|
64
|
+
|
65
|
+
function! s:get_real_assets_path(type) "{{{
|
66
|
+
let type_path = g:alpaca_complete_assets_dir[a:type]
|
67
|
+
|
68
|
+
return alpaca_complete#rails_root_join(type_path)
|
69
|
+
endfunction"}}}
|
70
|
+
|
71
|
+
function! s:source.get_keyword_pos(cur_text) "{{{
|
72
|
+
" TODO assetsを使うfunctionに限定する
|
73
|
+
" Filename pattern.
|
74
|
+
let pattern = neocomplcache#get_keyword_pattern_end('filename')
|
75
|
+
let [cur_keyword_pos, cur_keyword_str] =
|
76
|
+
\ neocomplcache#match_word(a:cur_text, pattern)
|
77
|
+
|
78
|
+
if cur_keyword_str =~ '//' ||
|
79
|
+
\ (neocomplcache#is_auto_complete() &&
|
80
|
+
\ cur_keyword_str =~# '\*\|\.\.\+$\|/c\%[ygdrive/]$')
|
81
|
+
" Not Rails Project or Not filename pattern.
|
82
|
+
return -1
|
83
|
+
endif
|
84
|
+
|
85
|
+
if neocomplcache#is_sources_complete() && cur_keyword_pos < 0
|
86
|
+
let cur_keyword_pos = len(a:cur_text)
|
87
|
+
endif
|
88
|
+
|
89
|
+
return cur_keyword_pos
|
90
|
+
endfunction"}}}
|
91
|
+
|
92
|
+
function! s:source.get_complete_words(cur_keyword_pos, cur_keyword_str) "{{{
|
93
|
+
let result = []
|
94
|
+
|
95
|
+
for name in keys( g:alpaca_complete_assets_dir )
|
96
|
+
let result += s:get_glob_files(a:cur_keyword_str, name)
|
97
|
+
endfor
|
98
|
+
|
99
|
+
return result
|
100
|
+
endfunction"}}}
|
101
|
+
|
102
|
+
" baseを基準としたパス以下のファイルから、
|
103
|
+
" cur_keyword_strにマッチするパスのみを抜き出す
|
104
|
+
function! s:get_glob_files(cur_keyword_str, type) "{{{
|
105
|
+
let base = <SID>get_real_assets_path(a:type)
|
106
|
+
if base !~ '/$'
|
107
|
+
let base = base . '/'
|
108
|
+
endif
|
109
|
+
|
110
|
+
let image_list = neocomplcache#sources#filename_complete#get_complete_words(
|
111
|
+
\ base . a:cur_keyword_str,
|
112
|
+
\ base )
|
113
|
+
|
114
|
+
let result = []
|
115
|
+
for path in image_list
|
116
|
+
let relative_path = substitute(path.word, base, '', 'g')
|
117
|
+
let abbr = isdirectory(path.word) ? relative_path . '/' : relative_path
|
118
|
+
|
119
|
+
let dict = {
|
120
|
+
\ 'word': relative_path,
|
121
|
+
\ 'abbr': abbr,
|
122
|
+
\ 'menu' : '[ALP_' .toupper(a:type). ']'
|
123
|
+
\ }
|
124
|
+
|
125
|
+
call add(result, dict)
|
126
|
+
endfor
|
127
|
+
|
128
|
+
return result
|
129
|
+
endfunction"}}}
|
130
|
+
|
131
|
+
function! neocomplcache#sources#assets_complete#define() "{{{
|
132
|
+
return s:source
|
133
|
+
endfunction"}}}
|
134
|
+
|
135
|
+
let &cpo = s:save_cpo
|
136
|
+
unlet s:save_cpo
|
137
|
+
|
138
|
+
" vim: foldmethod=marker
|
@@ -28,13 +28,11 @@ if exists('g:loaded_alpaca_complete') || &cp || v:version < 700
|
|
28
28
|
finish
|
29
29
|
endif
|
30
30
|
|
31
|
-
|
31
|
+
let s:active = executable('alpaca_complete')
|
32
|
+
if !s:active "{{{
|
32
33
|
echohl ErrorMsg
|
33
34
|
echo 'requires gem ins alpaca_complete'
|
34
35
|
echohl None
|
35
|
-
if executable('gem')
|
36
|
-
call system('gem ins alpaca_complete')
|
37
|
-
endif
|
38
36
|
finish
|
39
37
|
endif "}}}
|
40
38
|
|
@@ -47,7 +45,8 @@ set cpo&vim
|
|
47
45
|
let g:alpaca_complete_caching_list = {}
|
48
46
|
let s:source = {
|
49
47
|
\ 'name' : 'locale_complete',
|
50
|
-
\ 'kind' : '
|
48
|
+
\ 'kind' : 'ftplugin',
|
49
|
+
\ 'filetypes' : { 'ruby' : 1, 'haml' : 1, 'eruby' : 1 },
|
51
50
|
\}
|
52
51
|
|
53
52
|
if !exists('g:source_locale_complete_length')
|
@@ -57,25 +56,33 @@ endif
|
|
57
56
|
if !exists('g:source_locale_complete_rank')
|
58
57
|
let g:source_locale_complete_rank = 200
|
59
58
|
endif
|
59
|
+
|
60
|
+
if !executable('alpaca_complete')
|
61
|
+
echohl ErrorMsg
|
62
|
+
echo 'requires gem ins alpaca_complete'
|
63
|
+
echohl None
|
64
|
+
if executable('gem')
|
65
|
+
call system('gem ins alpaca_complete')
|
66
|
+
endif
|
67
|
+
finish
|
68
|
+
endif
|
60
69
|
"}}}
|
61
70
|
|
62
71
|
function! s:source.initialize() "{{{
|
72
|
+
if !s:active |return -1|endif
|
63
73
|
call neocomplcache#set_completion_length('locale_complete', g:source_locale_complete_length)
|
64
74
|
call neocomplcache#set_dictionary_helper(g:neocomplcache_source_rank,
|
65
75
|
\ 'locale_complete', g:source_locale_complete_rank)
|
66
76
|
|
67
77
|
" Initialize.
|
68
|
-
|
69
|
-
" Create cache directory.
|
70
|
-
if !isdirectory(neocomplcache#get_temporary_directory() . '/alpaca_complete')
|
71
|
-
call mkdir(neocomplcache#get_temporary_directory() . '/alpaca_complete')
|
72
|
-
endif
|
78
|
+
call alpaca_complete#initialize()
|
73
79
|
endfunction "}}}
|
74
80
|
|
75
81
|
function! s:source.finalize() " {{{
|
76
82
|
endfunction " }}}
|
77
83
|
|
78
84
|
function! s:source.get_keyword_pos(cur_text) "{{{
|
85
|
+
if !s:active |return -1|endif
|
79
86
|
if exists('b:rails_root') && a:cur_text =~ '.*I18n\.t\A.*\|\(\A\|^\)t\A'
|
80
87
|
let cur_pos = match( a:cur_text, '[a-zA-Z]\+[a-zA-Z0-9._:-]*$' )
|
81
88
|
|
@@ -86,6 +93,7 @@ function! s:source.get_keyword_pos(cur_text) "{{{
|
|
86
93
|
endfunction "}}}
|
87
94
|
|
88
95
|
function! s:source.get_complete_words(cur_keyword_pos, cur_keyword_str) "{{{
|
96
|
+
if !s:active |return -1|endif
|
89
97
|
if !exists('b:rails_root')|return|endif
|
90
98
|
let line = a:cur_keyword_str
|
91
99
|
|
@@ -118,6 +126,7 @@ function! s:source.get_complete_words(cur_keyword_pos, cur_keyword_str) "{{{
|
|
118
126
|
endfunction "}}}
|
119
127
|
|
120
128
|
function! neocomplcache#sources#locale_complete#check_recache() "{{{
|
129
|
+
if !s:active |return -1|endif
|
121
130
|
let list_key = s:get_cache_name()
|
122
131
|
" if !list_key |return -1| endif
|
123
132
|
|
@@ -149,7 +158,7 @@ function! neocomplcache#sources#locale_complete#caching() "{{{
|
|
149
158
|
if !exists('b:rails_root')|return -1|endif
|
150
159
|
|
151
160
|
" RoRの補完プラグインalpaca_completeを使う
|
152
|
-
let mf0 =
|
161
|
+
let mf0 = alpaca_complete#system('locale', expand("%:p") )
|
153
162
|
let mf_list = split(mf0, '\n')
|
154
163
|
|
155
164
|
let result = []
|
@@ -157,6 +166,7 @@ function! neocomplcache#sources#locale_complete#caching() "{{{
|
|
157
166
|
let value_str = ':value =>'
|
158
167
|
let key_len = strlen(key_str)
|
159
168
|
let value_len = strlen(key_str)
|
169
|
+
|
160
170
|
for locale_name in mf_list
|
161
171
|
let key_end = match( locale_name, value_str) - 2 " ' :'という文字列分引く
|
162
172
|
let value_start = key_end + value_len + 2 + 2
|
data/bin/alpaca_complete
CHANGED
@@ -3,11 +3,4 @@
|
|
3
3
|
require 'AlpacaComplete'
|
4
4
|
|
5
5
|
opt = AlpacaComplete::Utils.option_parser ARGV
|
6
|
-
|
7
|
-
locales = AlpacaComplete::LocaleComplete.complete opt[:path], opt[:word]
|
8
|
-
locales.each do |k, v|
|
9
|
-
puts ":key =>#{k} :value =>#{v}"
|
10
|
-
end
|
11
|
-
elsif opt[:dict] == true
|
12
|
-
locales = AlpacaComplete::DictComplete.complete opt[:path], opt[:word]
|
13
|
-
end
|
6
|
+
AlpacaComplete::Utils.run( opt[:command], opt[:path], opt[:word] )
|
data/lib/AlpacaComplete.rb
CHANGED
data/lib/AlpacaComplete/utils.rb
CHANGED
@@ -4,20 +4,20 @@ require 'optparse'
|
|
4
4
|
|
5
5
|
module AlpacaComplete::Utils
|
6
6
|
class << self
|
7
|
-
def option_parser args
|
7
|
+
def option_parser( args )# {{{
|
8
8
|
args << '-h' if args.empty?
|
9
9
|
|
10
10
|
options = {}
|
11
11
|
optparse = OptionParser.new do |opts|
|
12
|
-
opts.banner = get_banner
|
12
|
+
opts.banner = get_banner
|
13
13
|
|
14
14
|
opts.on('-h','--help','HELP') do
|
15
15
|
puts opts
|
16
16
|
exit
|
17
17
|
end
|
18
18
|
|
19
|
-
opts.on('-
|
20
|
-
options[:
|
19
|
+
opts.on('-t CMD', '--type CMD', 'command type') do |l|
|
20
|
+
options[:command] = l.to_sym
|
21
21
|
end
|
22
22
|
|
23
23
|
opts.on('-w VAL', '--word VAL', 'uncomplete word') do |l|
|
@@ -38,33 +38,45 @@ module AlpacaComplete::Utils
|
|
38
38
|
options[:files] = args.to_a
|
39
39
|
|
40
40
|
{
|
41
|
-
|
41
|
+
command: options[:command],
|
42
42
|
path: options[:path],
|
43
43
|
word: options[:word],
|
44
44
|
uncomplete: options[:locale]
|
45
45
|
}
|
46
|
-
end
|
46
|
+
end# }}}
|
47
47
|
|
48
|
-
def get_banner
|
49
|
-
return <<-BANNAR
|
50
|
-
Usage:
|
51
|
-
alpacaComplete [OPTIONS]
|
52
|
-
---------------------------------------------------------------------
|
48
|
+
def get_banner# {{{
|
49
|
+
return <<-BANNAR.gsub(/^\s*/)
|
50
|
+
Usage:
|
51
|
+
alpacaComplete [OPTIONS]
|
52
|
+
---------------------------------------------------------------------
|
53
53
|
BANNAR
|
54
|
-
end
|
54
|
+
end# }}}
|
55
55
|
|
56
|
-
def run( cmd, path, uncomplete="" )
|
56
|
+
def run( cmd, path, uncomplete="" )# {{{
|
57
57
|
case cmd
|
58
|
-
when
|
59
|
-
|
58
|
+
when :locale
|
59
|
+
# TODO :権限を委譲する
|
60
|
+
locales = ::AlpacaComplete::LocaleComplete.complete( path, uncomplete )
|
61
|
+
|
62
|
+
locales.each do |k, v|
|
63
|
+
puts ":key =>#{k} :value =>#{v}"
|
64
|
+
end
|
65
|
+
|
66
|
+
when :assets_image
|
67
|
+
assets = ::AlpacaComplete::AssetsComplete.complete( path, uncomplete, :image )
|
68
|
+
assets.each { |file_path| puts file_path }
|
69
|
+
|
70
|
+
# when :assets_stylesheets
|
71
|
+
# when :assets_javascripts
|
60
72
|
end
|
61
|
-
end
|
73
|
+
end# }}}
|
62
74
|
|
63
|
-
def load_yaml( path )
|
75
|
+
def load_yaml( path )# {{{
|
64
76
|
return nil until File.exist?(path)
|
65
77
|
|
66
78
|
require 'yaml'
|
67
|
-
YAML::load_file( path )
|
68
|
-
end
|
79
|
+
::YAML::load_file( path )
|
80
|
+
end# }}}
|
69
81
|
end
|
70
82
|
end
|
data/spec/spec_helper.rb
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alpaca_complete
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Hiroyuki Ishii
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-05-13 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rdoc
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: bundler
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ! '>='
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ! '>='
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -62,7 +55,6 @@ dependencies:
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: jeweler
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ~>
|
68
60
|
- !ruby/object:Gem::Version
|
@@ -70,22 +62,34 @@ dependencies:
|
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - ~>
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: 1.8.4
|
78
|
-
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: rails auto-complete for editor
|
79
84
|
email: alprhcp666@gmail.com
|
80
|
-
executables:
|
81
|
-
- alpaca_complete
|
85
|
+
executables: []
|
82
86
|
extensions: []
|
83
87
|
extra_rdoc_files:
|
84
88
|
- LICENSE.txt
|
85
|
-
- README.md
|
86
89
|
- README.rdoc
|
87
90
|
files:
|
88
91
|
- .document
|
92
|
+
- .gitignore
|
89
93
|
- .rspec
|
90
94
|
- Gemfile
|
91
95
|
- Gemfile.lock
|
@@ -95,6 +99,8 @@ files:
|
|
95
99
|
- Rakefile
|
96
100
|
- VERSION
|
97
101
|
- alpaca_complete.gemspec
|
102
|
+
- autoload/alpaca_complete.vim
|
103
|
+
- autoload/neocomplcache/sources/assets_complete.vim
|
98
104
|
- autoload/neocomplcache/sources/locale_complete.vim
|
99
105
|
- bin/alpaca_complete
|
100
106
|
- lib/AlpacaComplete.rb
|
@@ -115,6 +121,7 @@ files:
|
|
115
121
|
- spec/supports/rails_complete/README.rdoc
|
116
122
|
- spec/supports/rails_complete/Rakefile
|
117
123
|
- spec/supports/rails_complete/app/assets/images/rails.png
|
124
|
+
- spec/supports/rails_complete/app/assets/images/test/rails.png
|
118
125
|
- spec/supports/rails_complete/app/assets/javascripts/application.js
|
119
126
|
- spec/supports/rails_complete/app/assets/stylesheets/application.css
|
120
127
|
- spec/supports/rails_complete/app/controllers/application_controller.rb
|
@@ -165,28 +172,24 @@ files:
|
|
165
172
|
homepage: http://github.com/taichouchou2/alpaca_complete
|
166
173
|
licenses:
|
167
174
|
- MIT
|
175
|
+
metadata: {}
|
168
176
|
post_install_message:
|
169
177
|
rdoc_options: []
|
170
178
|
require_paths:
|
171
179
|
- lib
|
172
180
|
required_ruby_version: !ruby/object:Gem::Requirement
|
173
|
-
none: false
|
174
181
|
requirements:
|
175
182
|
- - ! '>='
|
176
183
|
- !ruby/object:Gem::Version
|
177
184
|
version: '0'
|
178
|
-
segments:
|
179
|
-
- 0
|
180
|
-
hash: 3735223565893724275
|
181
185
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
|
-
none: false
|
183
186
|
requirements:
|
184
187
|
- - ! '>='
|
185
188
|
- !ruby/object:Gem::Version
|
186
189
|
version: '0'
|
187
190
|
requirements: []
|
188
191
|
rubyforge_project:
|
189
|
-
rubygems_version:
|
192
|
+
rubygems_version: 2.0.3
|
190
193
|
signing_key:
|
191
194
|
specification_version: 3
|
192
195
|
summary: rails complete for editor
|