groupme 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: beee1256374c71c931f8ce107f28005b1da3aacf
4
- data.tar.gz: 46c04187b65b33274566b40d85499837d9573e46
3
+ metadata.gz: bafcaeb016ef037170f43fda32b853bed245c110
4
+ data.tar.gz: efb6d55971014bc124440f97eebab2d2d90a0485
5
5
  SHA512:
6
- metadata.gz: e44752ae6a85469077509891d97005744309705185db4d3712a2d968a17237be227c2c0b10f8d8d7104988a8788dd144aaecb4cec7ce86ab31d4de9eabda8672
7
- data.tar.gz: adf70ee47a11e9d7dfddce253443f80fab005b92b6fb9a3b138941e35415d8bb963d936881f40dbf85f890cf5934aa99dc9dcdbf9971fdb0e70d555ae6312a16
6
+ metadata.gz: 9d449e05ae02a1cd20cff7efab595b140e10a1ed223c5b27953d9d7cab28c588e4894a606b351691b1fef31999ca903159ca2403978f9bfb404f6c8eb3a3bb29
7
+ data.tar.gz: 17a4040f1de23972ea45fcae450ea5fe6f8e39edbf9d5be750db62d0963634ff0ccd8405312a0782d2d79f143284f2d90fcc16e6faf13174c6afe81c50f20215
@@ -16,3 +16,7 @@ Style/SpecialGlobalVars:
16
16
  Enabled: false
17
17
  Style/EmptyLinesAroundBlockBody:
18
18
  Enabled: false
19
+
20
+ # Disabled until RuboCop > 0.36.0
21
+ Style/FrozenStringLiteralComment:
22
+ Enabled: false
@@ -2,8 +2,9 @@ language: ruby
2
2
  sudo: false
3
3
  rvm:
4
4
  - 2.0
5
- - 2.1.6
6
- - 2.2.2
5
+ - 2.1.8
6
+ - 2.2.4
7
+ - 2.3.0
7
8
  - ruby-head
8
9
  - rbx-2
9
10
  - jruby
@@ -20,12 +20,11 @@ Gem::Specification.new do |gem|
20
20
 
21
21
  gem.add_development_dependency 'rake'
22
22
  gem.add_development_dependency 'rspec', '~> 3.0'
23
- gem.add_development_dependency 'webmock', '~> 1.19.0'
23
+ gem.add_development_dependency 'webmock', '~> 1.21.0'
24
24
  gem.add_development_dependency 'yard'
25
25
  gem.add_development_dependency 'pry'
26
26
  gem.add_development_dependency 'json', '~> 1.7'
27
- gem.add_development_dependency 'timecop', '~> 0.7'
28
- gem.add_development_dependency 'rubocop', '~> 0.33'
27
+ gem.add_development_dependency 'rubocop', '~> 0.36.0'
29
28
 
30
29
  gem.add_dependency 'faraday', '~> 0.9.0'
31
30
  gem.add_dependency 'faraday_middleware', '~> 0.9.0'
@@ -2,5 +2,5 @@ require 'groupme/version'
2
2
  require 'groupme/client'
3
3
 
4
4
  module GroupMe
5
- USER_AGENT = "dwradcliffe/groupme/#{GroupMe::VERSION}"
5
+ USER_AGENT = "dwradcliffe/groupme/#{GroupMe::VERSION}".freeze
6
6
  end
@@ -10,7 +10,7 @@ module GroupMe
10
10
  def bots
11
11
  get('/bots')
12
12
  end
13
- alias_method :list_bots, :bots
13
+ alias list_bots bots
14
14
 
15
15
  # Post a message from a bot.
16
16
  #
@@ -22,8 +22,8 @@ module GroupMe
22
22
 
23
23
  private
24
24
 
25
- def get(path)
26
- request(:get, path)
25
+ def get(path, options = {})
26
+ request(:get, path, options)
27
27
  end
28
28
 
29
29
  def post(path, data = {})
@@ -33,9 +33,9 @@ module GroupMe
33
33
  def request(method, path, data = {})
34
34
  res = connection.send(method, "v3/#{path}", data)
35
35
  if res.success? && !res.body.empty? && res.body != ' '
36
- return res.body.response
36
+ res.body.response
37
37
  else
38
- return res
38
+ res
39
39
  end
40
40
  end
41
41
 
@@ -10,7 +10,7 @@ module GroupMe
10
10
  def groups
11
11
  get '/groups'
12
12
  end
13
- alias_method :list_groups, :groups
13
+ alias list_groups groups
14
14
 
15
15
  # Load a specific group.
16
16
  #
@@ -34,7 +34,7 @@ module GroupMe
34
34
  def former_groups
35
35
  get '/groups/former'
36
36
  end
37
- alias_method :list_former_groups, :former_groups
37
+ alias list_former_groups former_groups
38
38
 
39
39
  # Create a new group.
40
40
  #
@@ -46,7 +46,7 @@ module GroupMe
46
46
  # @option options [String] :image_url GroupMe Image Service URL
47
47
  # @option options [Boolean] :share If you pass a true value, a share URL will be generated
48
48
  def create_group(name, options = {})
49
- options.merge! :name => name
49
+ options[:name] = name
50
50
  post '/groups', options
51
51
  end
52
52
 
@@ -1,3 +1,5 @@
1
+ require 'securerandom'
2
+
1
3
  module GroupMe
2
4
  module Messages
3
5
  # Create a message for a group
@@ -10,7 +12,7 @@ module GroupMe
10
12
  def create_message(group_id, text, attachments = [])
11
13
  data = {
12
14
  :message => {
13
- :source_guid => Time.now.to_s,
15
+ :source_guid => SecureRandom.uuid,
14
16
  :text => text
15
17
  }
16
18
  }
@@ -23,8 +25,14 @@ module GroupMe
23
25
  # @return [Array<Hashie::Mash>] Array of hashes representing the messages
24
26
  # @see https://dev.groupme.com/docs/v3#messages_index
25
27
  # @param group_id [String, Integer] Id of the group
26
- def messages(group_id)
27
- get("/groups/#{group_id}/messages").messages
28
+ # @param options [Hash] options hash that will be passed to the groupme call
29
+ # @param fetch_all [Boolean] if true, fetches all messages for the group
30
+ def messages(group_id, options = {}, fetch_all = false)
31
+ if fetch_all
32
+ get_all_messages(group_id)
33
+ else
34
+ get_messages(group_id, options)
35
+ end
28
36
  end
29
37
 
30
38
  # Get number of messages for a group
@@ -34,6 +42,27 @@ module GroupMe
34
42
  def messages_count(group_id)
35
43
  get("/groups/#{group_id}/messages")['count']
36
44
  end
37
- alias_method :message_count, :messages_count
45
+ alias message_count messages_count
46
+
47
+ private
48
+
49
+ def get_all_messages(group_id)
50
+ messages = []
51
+ last_id = ''
52
+ loop do
53
+ selection = get_messages(group_id, :before_id => last_id)
54
+ break if selection.empty?
55
+
56
+ last_id = selection.last.id
57
+ messages << selection
58
+ end
59
+
60
+ messages
61
+ end
62
+
63
+ def get_messages(group_id, options = {})
64
+ results = get("/groups/#{group_id}/messages", options)
65
+ results.is_a?(Faraday::Response) ? [] : results.messages
66
+ end
38
67
  end
39
68
  end
@@ -1,3 +1,3 @@
1
1
  module GroupMe
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'.freeze
3
3
  end
@@ -6,6 +6,7 @@ describe GroupMe::Messages do
6
6
 
7
7
  before do
8
8
  @client = GroupMe::Client.new(:token => 'TEST')
9
+ allow(SecureRandom).to receive(:uuid).and_return('GUID')
9
10
  end
10
11
 
11
12
  describe '.message_count' do
@@ -29,18 +30,10 @@ describe GroupMe::Messages do
29
30
 
30
31
  describe '.create_message' do
31
32
 
32
- before do
33
- Timecop.freeze(Time.new(2014, 10, 25, 22, 33, 44, 0000))
34
- end
35
-
36
- after do
37
- Timecop.return
38
- end
39
-
40
33
  it 'sends a text only message to a group' do
41
34
  message = {
42
35
  :message => {
43
- :source_guid => '2014-10-25 22:33:44 +0000',
36
+ :source_guid => 'GUID',
44
37
  :text => 'Hello world ☃☃'
45
38
  }
46
39
  }
@@ -52,7 +45,7 @@ describe GroupMe::Messages do
52
45
  it 'sends a message with location to a group' do
53
46
  message = {
54
47
  :message => {
55
- :source_guid => '2014-10-25 22:33:44 +0000',
48
+ :source_guid => 'GUID',
56
49
  :text => 'Hello world ☃☃',
57
50
  :attachments => [
58
51
  {
@@ -1,7 +1,6 @@
1
1
  require 'groupme'
2
2
  require 'multi_json'
3
3
  require 'webmock/rspec'
4
- require 'timecop'
5
4
 
6
5
  def stub_get(url)
7
6
  stub_request(:get, "https://api.groupme.com/v3#{url}")
@@ -28,7 +27,7 @@ def json_response(file, status = 200)
28
27
  :code => status,
29
28
  :errors => []
30
29
  }
31
- },
30
+ }.to_json,
32
31
  :headers => {
33
32
  :content_type => 'application/json; charset=utf-8'
34
33
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: groupme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Radcliffe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-17 00:00:00.000000000 Z
11
+ date: 2016-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.19.0
47
+ version: 1.21.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.19.0
54
+ version: 1.21.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: yard
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -94,34 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.7'
97
- - !ruby/object:Gem::Dependency
98
- name: timecop
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '0.7'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '0.7'
111
97
  - !ruby/object:Gem::Dependency
112
98
  name: rubocop
113
99
  requirement: !ruby/object:Gem::Requirement
114
100
  requirements:
115
101
  - - "~>"
116
102
  - !ruby/object:Gem::Version
117
- version: '0.33'
103
+ version: 0.36.0
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
107
  requirements:
122
108
  - - "~>"
123
109
  - !ruby/object:Gem::Version
124
- version: '0.33'
110
+ version: 0.36.0
125
111
  - !ruby/object:Gem::Dependency
126
112
  name: faraday
127
113
  requirement: !ruby/object:Gem::Requirement
@@ -259,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
259
245
  version: '0'
260
246
  requirements: []
261
247
  rubyforge_project:
262
- rubygems_version: 2.4.8
248
+ rubygems_version: 2.5.1
263
249
  signing_key:
264
250
  specification_version: 4
265
251
  summary: Simple wrapper for the GroupMe v3 API