File tree Expand file tree Collapse file tree 5 files changed +3
-66
lines changed Expand file tree Collapse file tree 5 files changed +3
-66
lines changed Original file line number Diff line number Diff line change @@ -2,5 +2,3 @@ package feeder
2
2
3
3
var ExportItemConvert = (* Item ).convert
4
4
var ExportFeedConvert = (* Feed ).convert
5
-
6
- var ExportItemsLimitDescription = (* Items ).limitDescription
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ package feeder
2
2
3
3
import (
4
4
ogp "github.com/otiai10/opengraph"
5
- "golang.org/x/exp/utf8string"
6
5
"log"
7
6
"sync"
8
7
"time"
@@ -87,24 +86,11 @@ func Crawl(fetchers ...Fetcher) *Items {
87
86
}
88
87
wg .Wait ()
89
88
90
- items .limitDescription (200 )
91
-
92
89
fetchOGP (items )
93
90
94
91
return items
95
92
}
96
93
97
- func (items * Items ) limitDescription (limit int ) {
98
- for _ , i := range items .Items {
99
- length := utf8string .NewString (i .Description ).RuneCount ()
100
- maxLength := limit
101
- if length < limit {
102
- maxLength = length
103
- }
104
- i .Description = utf8string .NewString (i .Description ).Slice (0 , maxLength )
105
- }
106
- }
107
-
108
94
func fetchOGP (items * Items ) * Items {
109
95
wg := sync.WaitGroup {}
110
96
Original file line number Diff line number Diff line change 1
1
package feeder_test
2
2
3
3
import (
4
+ "github.com/kr/pretty"
5
+ "github.com/naoki-kishi/feeder"
4
6
"reflect"
5
7
"strconv"
6
- "strings"
7
8
"testing"
8
9
"time"
9
- "unicode/utf8"
10
-
11
- "github.com/kr/pretty"
12
- "github.com/naoki-kishi/feeder"
13
10
)
14
11
15
12
type mockFetcher struct {
@@ -96,40 +93,3 @@ func TestCrawl(t *testing.T) {
96
93
97
94
}
98
95
}
99
-
100
- func TestItems_limitDescription (t * testing.T ) {
101
- type fields struct {
102
- Items []* feeder.Item
103
- }
104
- type args struct {
105
- limit int
106
- }
107
- tests := []struct {
108
- name string
109
- fields fields
110
- args args
111
- }{
112
- {
113
- name : "longer than limit" ,
114
- fields : fields {Items : []* feeder.Item {
115
- {Description : strings .Repeat ("a" , 300 )},
116
- }},
117
- args : args {limit : 200 },
118
- },
119
- }
120
- for _ , tt := range tests {
121
- t .Run (tt .name , func (t * testing.T ) {
122
- items := & feeder.Items {
123
- Items : tt .fields .Items ,
124
- }
125
- feeder .ExportItemsLimitDescription (items , tt .args .limit )
126
-
127
- for _ , i := range items .Items {
128
- got := utf8 .RuneCountInString (i .Description )
129
- if tt .args .limit < got {
130
- t .Errorf ("Exceed string length limit. limit=%d got=%d" , tt .args .limit , got )
131
- }
132
- }
133
- })
134
- }
135
- }
Original file line number Diff line number Diff line change @@ -10,5 +10,5 @@ require (
10
10
github.com/otiai10/opengraph v1.0.0
11
11
github.com/pkg/errors v0.8.1
12
12
github.com/stretchr/testify v1.3.0 // indirect
13
- golang.org/x/exp v0.0.0-20190316020145-860388717186
13
+ golang.org/x/net v0.0.0-20190311183353-d8887717615a // indirect
14
14
)
Original file line number Diff line number Diff line change 1
1
bou.ke/monkey v1.0.1 h1:zEMLInw9xvNakzUUPjfS4Ds6jYPqCFx3m7bRmG5NH2U =
2
2
bou.ke/monkey v1.0.1 /go.mod h1:FgHuK96Rv2Nlf+0u1OOVDpCMdsWyOFmeeketDHE7LIg =
3
- github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802 /go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo =
4
3
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8 =
5
4
github.com/davecgh/go-spew v1.1.0 /go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38 =
6
5
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI =
@@ -26,13 +25,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
26
25
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q =
27
26
github.com/stretchr/testify v1.3.0 /go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI =
28
27
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 /go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w =
29
- golang.org/x/exp v0.0.0-20190316020145-860388717186 h1:WVLLpyUE5WfDFkoRe+vPPFxVzwDwXwwG197QU7doL0M =
30
- golang.org/x/exp v0.0.0-20190316020145-860388717186 /go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8 =
31
- golang.org/x/image v0.0.0-20190227222117-0694c2d4d067 /go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js =
32
- golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6 /go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE =
33
28
golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628 =
34
29
golang.org/x/net v0.0.0-20190311183353-d8887717615a /go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg =
35
30
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a /go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY =
36
- golang.org/x/sys v0.0.0-20190312061237-fead79001313 /go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs =
37
31
golang.org/x/text v0.3.0 /go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ =
38
- golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846 /go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs =
You can’t perform that action at this time.
0 commit comments