roro_support 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +0,0 @@
1
- require 'logger'
2
- module RoRoSupport
3
- module Error
4
- def put(exception, log_path)
5
- log = Logger.new(log_path)
6
- log.fatal(exception)
7
- log = Logger.new(STDOUT)
8
- log.fatal(exception)
9
- end
10
- end
11
- end
@@ -1,21 +0,0 @@
1
- module RoRoSupport
2
- module Methods
3
- class Format
4
- class << self
5
- def url(url, options = {})
6
- return url if url[/http/]
7
- if options[:local]
8
- return "file://#{url}"
9
- else
10
- "http://#{url}" unless url[/http:\/\//]
11
- end
12
- end
13
-
14
- def utf8(html)
15
- html.gsub! /charset='.+'/, "charset='utf-8'"
16
- html
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,37 +0,0 @@
1
- module RoRoSupport
2
- class Req
3
- attr_accessor :files
4
- # list all files in dir
5
-
6
- def initialize
7
- @files = {}
8
- end
9
-
10
- def that(dir)
11
- dir_load dir
12
- self
13
- end
14
-
15
- def self.all_files_in(dir_path)
16
- dirname = dir_path.split('/').last.gsub(/\.rb/, '')
17
- Dir[File.expand_path("../#{dirname}/**", dir_path)].each do |file|
18
- require file
19
- end
20
- end
21
-
22
- private
23
-
24
- def dir_load (dir_name)
25
- Dir["#{dir_name}/**"].each do |file|
26
- if Dir["#{file}/**"].length >= 1
27
- dirname = file
28
- $LOAD_PATH << dirname
29
- dir_load dirname
30
- else
31
- filename = File.basename(file).gsub /\..+/, ''
32
- @files[filename.to_sym] = file
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8">
5
- <title>Twitter Bootstrap Modals Example</title>
6
- <meta name="description" content="Creating Modal Window with Twitter Bootstrap">
7
- <link rel="stylesheet" href="css/bootstrap.css"/>
8
- <script type="text/javascript" src="js/jquery-1.9.1.js"></script>
9
- <script type="text/javascript" src='js/bootstrap.js'></script>
10
- </head>
11
- <body>
12
-
13
- </body>
14
- </html>
@@ -1 +0,0 @@
1
- p 'something'
@@ -1,16 +0,0 @@
1
- require 'spec_helper'
2
- describe Req do
3
- describe 'list' do
4
- before do
5
- @req = Req.new
6
- @req.that $FIXTURES
7
- end
8
- it 'should load fixtures dir' do
9
- expect(require 'req_test_list').to be true
10
- end
11
-
12
- it 'can read file with its filename' do
13
- expect(@req.files.length).to be >= 1
14
- end
15
- end
16
- end
@@ -1,13 +0,0 @@
1
- require 'spec_helper'
2
-
3
- include Crawler
4
- describe Crawler do
5
- let(:req) { Req.new }
6
-
7
- it 'get_html_from(path)' do
8
- fixes = req.that($FIXTURES).files
9
- expect do
10
- get_html_from(fixes[:spec])
11
- end.not_to raise_error
12
- end
13
- end
@@ -1,18 +0,0 @@
1
- require 'spec_helper'
2
-
3
- include Methods
4
- describe Methods do
5
- it 'format_url' do
6
- baidu_url = Regexp.new "^http://baidu.com$"
7
- local_url = Regexp.new "^file:///home/zxr/testfile$"
8
- expect(Format.url('baidu.com'))
9
- .to match baidu_url
10
- expect(Format.url('/home/zxr/testfile', local: true))
11
- .to match local_url
12
- end
13
-
14
- it 'format_encoding' do
15
- html = "charset='gbk'"
16
- expect(Format.utf8(html)).to match(/charset='utf-8'/)
17
- end
18
- end