atndr 0.0.2

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.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in atndr.gemspec
4
+ gemspec
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "atndr/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "atndr"
7
+ s.version = Atndr::VERSION
8
+ s.authors = ["t_ramu"]
9
+ s.email = ["dhanegm731@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{A Ruby wapper for ATND API.}
12
+ s.description = %q{A Ruby wapper for ATND API. It is very easy to use.}
13
+
14
+ s.rubyforge_project = "atndr"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ # s.add_runtime_dependency "rest-client"
24
+ end
@@ -0,0 +1,7 @@
1
+ require "open-uri"
2
+ require "json"
3
+
4
+ require "atndr/version"
5
+ require "atndr/event"
6
+ require "atndr/user"
7
+
@@ -0,0 +1,47 @@
1
+ # encoding: utf-8
2
+
3
+ module Atndr
4
+
5
+ class Event
6
+
7
+ URL_BASE = "http://api.atnd.org/events/"
8
+
9
+ attr_accessor :options
10
+
11
+ def initialize
12
+ @options = {}
13
+ end
14
+
15
+ def get_event(opt = {})
16
+ @options = opt
17
+ send_api
18
+ end
19
+
20
+ private
21
+ def send_api
22
+ response = nil
23
+ events = []
24
+ begin
25
+ open(create_uri) do |f|
26
+ response = JSON.parse(f.read)
27
+ response["events"].each do |event|
28
+ events << event
29
+ end
30
+ end
31
+ rescue OpenURI::HTTPError => e
32
+ events.clear
33
+ end
34
+ return events
35
+ end
36
+
37
+ def create_uri
38
+ URL_BASE + "?" + query
39
+ end
40
+
41
+ def query
42
+ @options[:format] = "json"
43
+ @options.map{|k, v| "#{k}=#{v}"}.join("&")
44
+ end
45
+ end
46
+ end
47
+
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ module Atndr
4
+
5
+ class User < Event
6
+
7
+ URL_BASE = "http://api.atnd.org/events/users/"
8
+
9
+ attr_accessor :options
10
+
11
+ def initialize
12
+ @options = {}
13
+ end
14
+
15
+ def get_user(opt = {})
16
+ @options = opt
17
+ send_api
18
+ end
19
+ end
20
+ end
21
+
@@ -0,0 +1,4 @@
1
+ module Atndr
2
+ VERSION = "0.0.2"
3
+ end
4
+
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: atndr
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - t_ramu
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-15 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: A Ruby wapper for ATND API. It is very easy to use.
15
+ email:
16
+ - dhanegm731@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - Rakefile
24
+ - atndr.gemspec
25
+ - lib/atndr.rb
26
+ - lib/atndr/event.rb
27
+ - lib/atndr/user.rb
28
+ - lib/atndr/version.rb
29
+ homepage: ''
30
+ licenses: []
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubyforge_project: atndr
49
+ rubygems_version: 1.8.15
50
+ signing_key:
51
+ specification_version: 3
52
+ summary: A Ruby wapper for ATND API.
53
+ test_files: []
54
+ has_rdoc: