meetup-wrapper 0.1.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c4dd8a0cbfe7d70ffff6d6444149193393f51081
4
+ data.tar.gz: 5508ad4dac068fc4ce73c470e30b11f7fa903b4a
5
+ SHA512:
6
+ metadata.gz: 9ffce6612e6131e684d61e555600480723dd1e0a7ecb2522dbd0e8f34a6722d13227a103f8efd493b674cd7acf41f4dcaf7b7123d3eea14b637b40736ecf7deb
7
+ data.tar.gz: 4b63ac57526a183c7853442dbfab1bc47eb36d7ecf960c2a65efc3db2634a7b0a65a0f77efcb7e4077d3e35e4352fba7626b7248fb7043e0471c56cadceb2067
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.3.0
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.0
4
+ script:
5
+ - bundle exec rake
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at vegijtha@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ group :development, :test do
5
+ gem 'polishgeeks-dev-tools'
6
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Marcin Gajewski
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # Meetup Wrapper Ruby Gem
2
+
3
+ [![Code Climate](https://codeclimate.com/github/gajewsky/meetup-api-client/badges/gpa.svg)](https://codeclimate.com/github/gajewsky/meetup-api-client)
4
+ [![Build Status](https://travis-ci.org/gajewsky/meetup-api-client.svg?branch=master)](https://travis-ci.org/gajewsky/meetup-api-client)
5
+
6
+ A Ruby wrapper for the http://www.meetup.com/meetup_api/ .
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'meetup_wrapper'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install meetup_wrapper
23
+
24
+ ## Setup
25
+ Create a new file config/initializers/meetup_wraper.rb, and put the following content in it:
26
+
27
+ ```ruby
28
+ MeetupWrapper.configure do |config|
29
+ config.api_key = MEETUP_API_KEY
30
+ end
31
+ ```
32
+
33
+ ## Usage Examples
34
+
35
+ **To get information about Krakow-Ruby-Users-Group**
36
+
37
+ ```ruby
38
+ client = MeetupWrapper.client
39
+ group = client.group('Krakow-Ruby-Users-Group')
40
+ ```
41
+ ## Contributing
42
+
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/meetup-api-client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
44
+
45
+
46
+ ## License
47
+
48
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,24 @@
1
+ require 'bundler'
2
+ require 'rake'
3
+ require 'polishgeeks-dev-tools'
4
+
5
+ Bundler::GemHelper.install_tasks
6
+
7
+ require 'rspec/core/rake_task'
8
+ RSpec::Core::RakeTask.new(:spec)
9
+ task default: :spec
10
+
11
+ PolishGeeks::DevTools.setup do |config|
12
+ config.brakeman = false
13
+ config.haml_lint = false
14
+ config.simplecov_threshold = 100
15
+ end
16
+
17
+ desc 'Self check using strike-dev-tools'
18
+ task :check do
19
+ PolishGeeks::DevTools::Runner.new.execute(
20
+ PolishGeeks::DevTools::Logger.new
21
+ )
22
+ end
23
+
24
+ task default: :check
@@ -0,0 +1,19 @@
1
+ require 'meetup_wrapper/configuration'
2
+ require 'meetup_wrapper/client'
3
+
4
+ # Module encapsulating MeetupWrapper specific code
5
+ module MeetupWrapper
6
+ class << self
7
+ attr_reader :config
8
+
9
+ def configure(&_block)
10
+ yield @config ||= ::MeetupWrapper::Configuration.new
11
+ end
12
+
13
+ # Alias for MeetupWrapper::Client.new
14
+ # @return [MeetupWrapper::Client]
15
+ def client
16
+ MeetupWrapper::Client.new
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,13 @@
1
+ require File.expand_path('../request', __FILE__)
2
+
3
+ module MeetupWrapper
4
+ # Wrapper for the Meetup REST API
5
+ class Client
6
+ include Request
7
+
8
+ base_path = File.dirname(__FILE__) + '/client/*.rb'
9
+ Dir[base_path].each { |file| require file }
10
+
11
+ include Groups
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ module MeetupWrapper
2
+ class Client
3
+ # Defines methods related to Meetup Groups
4
+ module Groups
5
+ # Returns information about single Meetup Group
6
+ # @param urlname [String] An Meetup group ID
7
+ # @return [Hash] The requested group information
8
+ # @example Return information for the Meetup group
9
+ # MeetupWrapper.client.group('Krakow-Ruby-Users-Group')
10
+ # => {"id"=>6594592, "name"=>"Krakow Ruby User Group (KRUG)"...}
11
+ def group(urlname)
12
+ get(urlname)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,6 @@
1
+ module MeetupWrapper
2
+ # Defines constants and methods related to configuration
3
+ class Configuration
4
+ attr_accessor :api_key
5
+ end
6
+ end
@@ -0,0 +1,39 @@
1
+ require 'meetup_wrapper/request/json_request'
2
+ require 'meetup_wrapper/request/http_requester'
3
+
4
+ module MeetupWrapper
5
+ # Defines HTTP request methods
6
+ module Request
7
+ # Base Url for accessing meetup api
8
+ BASE_URL = 'http://api.meetup.com/'.freeze
9
+
10
+ # Performs an HTTP GET request
11
+ # @param path [String] request path
12
+ # @param params [Hash] Hash with HTTP parameters
13
+ def get(path, params = {})
14
+ json_request = JsonRequest.new(remote_url(path, params))
15
+ requester = HttpRequester.new(json_request)
16
+ requester.execute_request
17
+ end
18
+
19
+ private
20
+
21
+ # Prepares remote url
22
+ # @param path [String] request path
23
+ # @param params [Hash] Hash with HTTP parameters
24
+ # @return [String] prepared url
25
+ def remote_url(path, params)
26
+ "#{BASE_URL}#{path}?#{query_string(params)}"
27
+ end
28
+
29
+ # Prepares params query
30
+ # @param params [Hash] Hash with HTTP parameters
31
+ # @return [String] prepared params query
32
+ def query_string(params)
33
+ params
34
+ .merge(key: ::MeetupWrapper.config.api_key)
35
+ .map { |k, v| "#{k}=#{v}" }
36
+ .join('&')
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,36 @@
1
+ module MeetupWrapper
2
+ # Module encapsulating api calling specific logic
3
+ module Request
4
+ # HTTP request
5
+ class HttpRequest
6
+ # Default charset
7
+ CHARSET = 'UTF-8'.freeze
8
+
9
+ def initialize(uri, method = 'get')
10
+ @in_uri = uri
11
+ @method = method
12
+ end
13
+
14
+ # Triggers HTTP request
15
+ # @return [JSON] response from api
16
+ def make_request
17
+ uri = URI.parse(@in_uri)
18
+ http = Net::HTTP.new(uri.host, uri.port)
19
+ response = http.request(class_to_call.new(uri.request_uri, headers))
20
+ response.body
21
+ end
22
+
23
+ private
24
+
25
+ # Prepares HTTP Headers
26
+ def headers
27
+ { 'Accept-Charset' => CHARSET }
28
+ end
29
+
30
+ # @return [Symbol] class name
31
+ def class_to_call
32
+ Net::HTTP.const_get(@method.capitalize)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,18 @@
1
+ require 'net/http'
2
+
3
+ module MeetupWrapper
4
+ # Module encapsulating api calling specific logics
5
+ module Request
6
+ # HTTP requester
7
+ class HttpRequester
8
+ def initialize(requester)
9
+ @requester = requester
10
+ end
11
+
12
+ # Executes request
13
+ def execute_request
14
+ @requester.make_request
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ require 'meetup_wrapper/request/http_request'
2
+ require 'json'
3
+ require 'pry'
4
+
5
+ module MeetupWrapper
6
+ # Module encapsulating api calling specific logic
7
+ module Request
8
+ # JSON request
9
+ class JsonRequest < HttpRequest
10
+ # Parse response
11
+ # @param response_body [JSON] JSON response from api
12
+ # @return [Hash] parsed response
13
+ def format_response(response_body)
14
+ JSON.parse(response_body)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,4 @@
1
+ module MeetupWrapper
2
+ # Current gem version
3
+ VERSION = '0.1.0'.freeze
4
+ end
@@ -0,0 +1,25 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'meetup_wrapper/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "meetup-wrapper"
7
+ s.version = MeetupWrapper::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = %w( "Marcin Gajewski" )
10
+ s.email = %w( "vegijtha@gmail.com" )
11
+ s.homepage = "https://github.com/gajewsky/meetup-api-client"
12
+
13
+ s.summary = %q{ Meetup Client Ruby Gem. }
14
+ s.description = %q{ A Ruby wrapper for the http://www.meetup.com/meetup_api }
15
+ s.license = "MIT"
16
+
17
+ s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ s.require_paths = %w( "lib" )
19
+
20
+ s.add_development_dependency "bundler"
21
+ s.add_development_dependency "rake"
22
+ s.add_development_dependency "rspec"
23
+ s.add_development_dependency "webmock"
24
+ s.add_development_dependency "pry"
25
+ end
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: meetup-wrapper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - "\"Marcin"
8
+ - Gajewski"
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-03-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: webmock
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: pry
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ description: " A Ruby wrapper for the http://www.meetup.com/meetup_api "
85
+ email:
86
+ - '"vegijtha@gmail.com"'
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".ruby-version"
94
+ - ".travis.yml"
95
+ - CODE_OF_CONDUCT.md
96
+ - Gemfile
97
+ - LICENSE.txt
98
+ - README.md
99
+ - Rakefile
100
+ - lib/meetup_wrapper.rb
101
+ - lib/meetup_wrapper/client.rb
102
+ - lib/meetup_wrapper/client/groups.rb
103
+ - lib/meetup_wrapper/configuration.rb
104
+ - lib/meetup_wrapper/request.rb
105
+ - lib/meetup_wrapper/request/http_request.rb
106
+ - lib/meetup_wrapper/request/http_requester.rb
107
+ - lib/meetup_wrapper/request/json_request.rb
108
+ - lib/meetup_wrapper/version.rb
109
+ - meetup_wrapper.gemspec
110
+ homepage: https://github.com/gajewsky/meetup-api-client
111
+ licenses:
112
+ - MIT
113
+ metadata: {}
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - '"lib"'
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 2.5.2
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: Meetup Client Ruby Gem.
134
+ test_files: []
135
+ has_rdoc: