rack-ketai 0.2.3 → 0.2.4

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.
@@ -1,87 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # -*- coding: utf-8 -*-
3
-
4
- # ke-tai.org の携帯端末スペック一覧をダウンロードして加工
5
-
6
- require 'open-uri'
7
- require 'nkf'
8
- require 'csv'
9
- require 'tempfile'
10
-
11
- csvdata = NKF.nkf('-Sw', open('http://ke-tai.org/moblist/csv_down.php').read)
12
- lines = csvdata.gsub(/\r?\n/, "\n").split(/\n/).collect{ |str| str.gsub(/([^,])"([^,])/u, '\1"\2') }
13
- lines.slice!(0, 2)
14
-
15
- table = {}
16
-
17
- # CSV
18
- # [ 0] 連番
19
- # [ 1] メーカ名
20
- # [ 2] 機種名
21
- # [ 3] 機種略名
22
- # [ 4] ユーザエージェント
23
- # [ 5] タイプ1
24
- # [ 6] タイプ2
25
- # [ 7] ブラウザ幅(x)
26
- # [ 8] ブラウザ高さ(y)
27
- # [ 9] 表示カラー数
28
- # [10] ブラウザキャッシュ
29
- # [11] GIF
30
- # [12] JPG
31
- # [13] PNG
32
- # [14] Flash
33
- # [15] Flashバージョン
34
- # [16] Flashワークメモリ
35
- # [17] Javaアプリ
36
- # [18] BREW
37
- # [19] HTML
38
- # [20] SSL
39
- # [21] ログイン
40
- # [22] クッキー
41
- # [23] CSS
42
- # [24] GPS
43
- # [25] 発売日
44
-
45
- enable_row_indexes = [1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]
46
- # [ 0] メーカ名
47
- # [ 1] 機種名
48
- # [ 2] ユーザエージェント
49
- # [ 3] タイプ1
50
- # [ 4] タイプ2
51
- # [ 5] ブラウザ幅(x)
52
- # [ 6] ブラウザ高さ(y)
53
- # [ 7] 表示カラー数
54
- # [ 8] ブラウザキャッシュ
55
- # [ 9] GIF
56
- # [10] JPG
57
- # [11] PNG
58
- # [12] Flash
59
- # [13] Flashバージョン
60
- # [14] Flashワークメモリ
61
- # [15] Javaアプリ
62
- # [16] BREW
63
- # [17] HTML
64
- # [18] SSL
65
- # [19] ログイン
66
- # [20] クッキー
67
- # [21] CSS
68
- # [22] GPS
69
- # [23] 発売日
70
-
71
- CSV::Reader.parse(lines.join("\n")).each do |row|
72
- row.slice!(26)
73
-
74
-
75
- table[row[1]] ||= { }
76
- table[row[1]][row[3]] ||= row.values_at(*enable_row_indexes)
77
- end
78
-
79
- [
80
- %w(DoCoMo Docomo docomo.rb),
81
- %w(au Au au.rb),
82
- %w(SoftBank Softbank softbank.rb)
83
- ].each do |carrier, classname, filename|
84
- File.open(File.join(File.dirname(__FILE__), '../lib/rack/ketai/carrier/specs', filename), 'w') do |f|
85
- f.write "Rack::Ketai::Carrier::#{classname}::SPECS = #{ table[carrier].inspect }"
86
- end
87
- end