gridcli 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gridcli/commands/update.rb +25 -20
- data/lib/gridcli/version.rb +1 -1
- metadata +65 -58
@@ -7,10 +7,27 @@ module GridCLI
|
|
7
7
|
|
8
8
|
def run(args)
|
9
9
|
parse_opts args
|
10
|
-
last_sha = @stats['last_sha']
|
11
10
|
|
11
|
+
posts = run_since_sha(@stats['last_sha'])
|
12
|
+
total_posts = posts.length
|
13
|
+
@stats['last_sha'] = save(posts) if posts.length > 0
|
14
|
+
|
15
|
+
# If we're doing this in chunks, get more
|
16
|
+
while posts.length == 300
|
17
|
+
posts = run_since_sha(@stats['last_sha'])
|
18
|
+
total_posts += posts.length
|
19
|
+
@stats['last_sha'] = save(posts) if posts.length > 0
|
20
|
+
end
|
21
|
+
|
22
|
+
@stats.save
|
23
|
+
puts "Saved #{total_posts} posts. Now up to date."
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
def run_since_sha(last_sha)
|
12
28
|
GridCLI.hooker.invoke :before_update
|
13
29
|
|
30
|
+
posts = []
|
14
31
|
begin
|
15
32
|
if last_sha.nil?
|
16
33
|
log "Trying to download all messages."
|
@@ -21,30 +38,18 @@ module GridCLI
|
|
21
38
|
end
|
22
39
|
rescue ActiveResource::ClientError
|
23
40
|
puts "There was an error updating your messages."
|
24
|
-
return
|
25
41
|
end
|
26
42
|
|
27
|
-
|
28
|
-
|
29
|
-
log "Saving #{posts ? posts.length : 0} posts."
|
30
|
-
save posts
|
43
|
+
GridCLI.hooker.invoke :after_update, posts
|
31
44
|
end
|
32
45
|
|
33
46
|
def save(posts)
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
pprint json
|
41
|
-
}
|
42
|
-
@stats['last_sha'] = GridCLI.storage.append(posts)
|
43
|
-
@stats.save
|
44
|
-
|
45
|
-
# run again if we got back 300 posts
|
46
|
-
run(args) if posts.length == 300
|
47
|
-
end
|
47
|
+
posts.each { |p|
|
48
|
+
type = p.known_attributes.first
|
49
|
+
json = p.send(type).to_json(:root => type)
|
50
|
+
pprint json
|
51
|
+
}
|
52
|
+
(posts.length > 0) ? GridCLI.storage.append(posts) : nil
|
48
53
|
end
|
49
54
|
end
|
50
55
|
|
data/lib/gridcli/version.rb
CHANGED
metadata
CHANGED
@@ -1,79 +1,82 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: gridcli
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0
|
3
|
+
version: !ruby/object:Gem::Version
|
5
4
|
prerelease:
|
5
|
+
version: 0.1.1
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Brian Muller
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
|
13
|
+
date: 2012-10-05 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
15
16
|
name: activeresource
|
16
|
-
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
19
|
none: false
|
18
|
-
requirements:
|
19
|
-
- -
|
20
|
-
- !ruby/object:Gem::Version
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
21
23
|
version: 3.0.10
|
22
24
|
type: :runtime
|
23
|
-
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
26
27
|
name: activesupport
|
27
|
-
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
28
30
|
none: false
|
29
|
-
requirements:
|
30
|
-
- -
|
31
|
-
- !ruby/object:Gem::Version
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
32
34
|
version: 3.0.10
|
33
35
|
type: :runtime
|
34
|
-
|
35
|
-
|
36
|
-
- !ruby/object:Gem::Dependency
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
37
38
|
name: chronic
|
38
|
-
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
39
41
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
43
45
|
version: 0.6.4
|
44
46
|
type: :runtime
|
45
|
-
|
46
|
-
|
47
|
-
- !ruby/object:Gem::Dependency
|
47
|
+
version_requirements: *id003
|
48
|
+
- !ruby/object:Gem::Dependency
|
48
49
|
name: json
|
49
|
-
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
50
52
|
none: false
|
51
|
-
requirements:
|
52
|
-
- -
|
53
|
-
- !ruby/object:Gem::Version
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
54
56
|
version: 1.6.1
|
55
57
|
type: :runtime
|
56
|
-
|
57
|
-
|
58
|
-
- !ruby/object:Gem::Dependency
|
58
|
+
version_requirements: *id004
|
59
|
+
- !ruby/object:Gem::Dependency
|
59
60
|
name: colorize
|
60
|
-
|
61
|
+
prerelease: false
|
62
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
61
63
|
none: false
|
62
|
-
requirements:
|
63
|
-
- -
|
64
|
-
- !ruby/object:Gem::Version
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
65
67
|
version: 0.5.8
|
66
68
|
type: :runtime
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
email:
|
69
|
+
version_requirements: *id005
|
70
|
+
description: "A command line interface to The Grid: Social Networking, Web 0.2"
|
71
|
+
email:
|
71
72
|
- bamuller@gmail.com
|
72
|
-
executables:
|
73
|
+
executables:
|
73
74
|
- grid
|
74
75
|
extensions: []
|
76
|
+
|
75
77
|
extra_rdoc_files: []
|
76
|
-
|
78
|
+
|
79
|
+
files:
|
77
80
|
- .gitignore
|
78
81
|
- .rvmrc
|
79
82
|
- Gemfile
|
@@ -117,26 +120,30 @@ files:
|
|
117
120
|
- lib/gridcli/ymlhash.rb
|
118
121
|
homepage: http://gridcli.com
|
119
122
|
licenses: []
|
123
|
+
|
120
124
|
post_install_message:
|
121
125
|
rdoc_options: []
|
122
|
-
|
126
|
+
|
127
|
+
require_paths:
|
123
128
|
- lib
|
124
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
130
|
none: false
|
126
|
-
requirements:
|
127
|
-
- -
|
128
|
-
- !ruby/object:Gem::Version
|
129
|
-
version:
|
130
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: "0"
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
136
|
none: false
|
132
|
-
requirements:
|
133
|
-
- -
|
134
|
-
- !ruby/object:Gem::Version
|
135
|
-
version:
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: "0"
|
136
141
|
requirements: []
|
142
|
+
|
137
143
|
rubyforge_project: gridcli
|
138
|
-
rubygems_version: 1.8.
|
144
|
+
rubygems_version: 1.8.24
|
139
145
|
signing_key:
|
140
146
|
specification_version: 3
|
141
|
-
summary:
|
147
|
+
summary: "A command line interface to The Grid: Social Networking, Web 0.2"
|
142
148
|
test_files: []
|
149
|
+
|