flute 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/flute +5 -46
- data/lib/flute/cli.rb +49 -0
- data/lib/flute/version.rb +1 -1
- data/lib/template/main.rb +3 -3
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1db4b677a222342421cc64b8f08749ac55a71ae
|
4
|
+
data.tar.gz: 9c6218e16c8f88e6caf351f45a0d746a47bfa866
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e3f3c1b1c506f1b455770af4ff25caafbfd70ab9daa8370a9821829e1fd365c22a1c4ecc9be4266f1c1fbb7b9a324a4a91393cca9598e468b43264f67107254
|
7
|
+
data.tar.gz: f66a6bf3d3b9646233dfc3bddd73a44578d48f7162a35ffea99cd04fe789be9a52e0d9d16d36854f49a799fb02efa0176db497e2808e191ad49744c4add2064d
|
data/exe/flute
CHANGED
@@ -1,51 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
require 'fileutils'
|
3
|
+
git_path = File.expand_path("../../../.git", __FILE__)
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
dirs = [
|
10
|
-
'tmp',
|
11
|
-
'log',
|
12
|
-
'config',
|
13
|
-
'lib',
|
14
|
-
'app',
|
15
|
-
'app/utils',
|
16
|
-
]
|
17
|
-
create_dir(name, dirs)
|
18
|
-
FileUtils.touch "#{name}/tmp/.keep"
|
19
|
-
FileUtils.touch "#{name}/log/.keep"
|
20
|
-
|
21
|
-
copy_template 'Gemfile', "#{name}/Gemfile"
|
22
|
-
copy_template 'main.rb', "#{name}/main.rb"
|
23
|
-
copy_template 'Rakefile', "#{name}/Rakefile"
|
24
|
-
|
25
|
-
FileUtils.cp_r template_path('items'), "#{name}/app/items"
|
26
|
-
FileUtils.cp_r template_path('spiders'), "#{name}/app/spiders"
|
27
|
-
FileUtils.cp_r template_path('middlewares'), "#{name}/app/middlewares"
|
28
|
-
|
29
|
-
puts "cd #{name}"
|
30
|
-
puts "bundle install"
|
31
|
-
puts "rake start"
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
def create_dir(project_name, dirs)
|
36
|
-
Dir.mkdir(project_name)
|
37
|
-
dirs.each {|dir|
|
38
|
-
Dir.mkdir "#{project_name}/#{dir}"
|
39
|
-
}
|
40
|
-
end
|
41
|
-
|
42
|
-
def copy_template(name, dest)
|
43
|
-
FileUtils.cp template_path(name), dest
|
44
|
-
end
|
45
|
-
|
46
|
-
def template_path(name)
|
47
|
-
File.expand_path("../lib/template/#{name}", File.dirname(__FILE__))
|
48
|
-
end
|
5
|
+
if File.exist?(git_path)
|
6
|
+
railties_path = File.expand_path("../../lib", __FILE__)
|
7
|
+
$:.unshift(railties_path)
|
49
8
|
end
|
50
9
|
|
51
|
-
|
10
|
+
require "flute/cli"
|
data/lib/flute/cli.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
class FluteCLI < Thor
|
5
|
+
desc "new NAME", "create project"
|
6
|
+
def new(name)
|
7
|
+
dirs = [
|
8
|
+
'tmp',
|
9
|
+
'log',
|
10
|
+
'config',
|
11
|
+
'lib',
|
12
|
+
'app',
|
13
|
+
'app/utils',
|
14
|
+
]
|
15
|
+
create_dir(name, dirs)
|
16
|
+
FileUtils.touch "#{name}/tmp/.keep"
|
17
|
+
FileUtils.touch "#{name}/log/.keep"
|
18
|
+
|
19
|
+
copy_template 'Gemfile', "#{name}/Gemfile"
|
20
|
+
copy_template 'main.rb', "#{name}/main.rb"
|
21
|
+
copy_template 'Rakefile', "#{name}/Rakefile"
|
22
|
+
|
23
|
+
FileUtils.cp_r template_path('items'), "#{name}/app/items"
|
24
|
+
FileUtils.cp_r template_path('spiders'), "#{name}/app/spiders"
|
25
|
+
FileUtils.cp_r template_path('middlewares'), "#{name}/app/middlewares"
|
26
|
+
|
27
|
+
puts "cd #{name}"
|
28
|
+
puts "bundle install"
|
29
|
+
puts "rake start"
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
def create_dir(project_name, dirs)
|
34
|
+
Dir.mkdir(project_name)
|
35
|
+
dirs.each {|dir|
|
36
|
+
Dir.mkdir "#{project_name}/#{dir}"
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
def copy_template(name, dest)
|
41
|
+
FileUtils.cp template_path(name), dest
|
42
|
+
end
|
43
|
+
|
44
|
+
def template_path(name)
|
45
|
+
File.expand_path("../template/#{name}", File.dirname(__FILE__))
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
FluteCLI.start(ARGV)
|
data/lib/flute/version.rb
CHANGED
data/lib/template/main.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
|
1
|
+
CRAWLER_ENV = ENV['CRAWLER_ENV'] || 'development'
|
2
2
|
AREA = ENV['AREA_ENV'] || :cn
|
3
3
|
|
4
4
|
require 'rubygems'
|
5
5
|
require 'bundler'
|
6
|
-
Bundler.require(:default,
|
6
|
+
Bundler.require(:default, CRAWLER_ENV)
|
7
7
|
|
8
8
|
$project_root = Pathname.new File.dirname(__FILE__)
|
9
9
|
|
@@ -18,7 +18,7 @@ def start_ant
|
|
18
18
|
File.basename(path, '.rb').to_s.classify.constantize
|
19
19
|
end
|
20
20
|
spiders.each do |spiders|
|
21
|
-
if
|
21
|
+
if CRAWLER_ENV != 'production'
|
22
22
|
puts spiders.new.pipeline.map &:to_h
|
23
23
|
else
|
24
24
|
spiders.new.pipeline
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flute
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 'manjia
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- exe/flute
|
132
132
|
- flute.gemspec
|
133
133
|
- lib/flute.rb
|
134
|
+
- lib/flute/cli.rb
|
134
135
|
- lib/flute/document.rb
|
135
136
|
- lib/flute/network.rb
|
136
137
|
- lib/flute/request.rb
|