jekyll-meetup 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f94d8f48ae91b7937a633d20fab6968db7b686cb1b90653bf74c967eea157964
4
+ data.tar.gz: bead666e76b4b45a1f0ae8dec096ff86018ceea5a98833dbd3876ec8a99a5c7b
5
+ SHA512:
6
+ metadata.gz: a55e09370bede1affe678f7e2cfaff02656e73c738951a22808c408f2221e71ba1420a551a8eb81971c9c9bb5c5895b61a5486866a99260295ec5c35f3a123b5
7
+ data.tar.gz: 25daa7deba0dbb96cf700efa5fa07f2e8311b345a96e17f0affa6dd67b564d4eb023f8eece0231e83a4f2992fd04fc0cca777542ac4e8f0330001cfe2269516e
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in jekyll-meetup.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Tom Dooner
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,39 @@
1
+ # Jekyll::Meetup
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/jekyll/meetup`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'jekyll-meetup'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install jekyll-meetup
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/jekyll-meetup.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "jekyll/meetup"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,25 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'jekyll/meetup/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "jekyll-meetup"
7
+ spec.version = Jekyll::Meetup::VERSION
8
+ spec.authors = ["Tom Dooner"]
9
+ spec.email = ["tomdooner@gmail.com"]
10
+
11
+ spec.summary = 'Jekyll plugin to download Meetup events.'
12
+ # spec.description = %q{TODO: Write a longer description or delete this line.}
13
+ # spec.homepage = "TODO: Put your gem's website or public repo URL here."
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.16"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ end
@@ -0,0 +1,22 @@
1
+ require 'net/http'
2
+ require 'json'
3
+
4
+ module Jekyll
5
+ module Meetup
6
+ # Simple API client for Meetup since there doesn't seem to be an open source
7
+ # one that supports OAuth.
8
+ class ApiClient
9
+ API_BASE = URI('https://api.meetup.com')
10
+
11
+ def self.events(urlname)
12
+ request_uri = API_BASE + format('%<urlname>s/events', urlname: urlname)
13
+ request_uri.query = URI.encode_www_form(
14
+ scroll: 'next_upcoming'
15
+ )
16
+
17
+ body = Net::HTTP.get(request_uri)
18
+ JSON.parse(body)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,64 @@
1
+ require 'json'
2
+ require 'yaml'
3
+ require 'net/https'
4
+
5
+ def filenamify(str)
6
+ str.strip.downcase.gsub(/[^a-z]+/, '-')
7
+ end
8
+
9
+ module Jekyll
10
+ module Meetup
11
+ # Add the `jekyll meetup` command which downloads from Meetup.
12
+ class Command < Jekyll::Command
13
+ class << self
14
+ def init_with_program(prog)
15
+ prog.command(:meetup) do |c|
16
+ c.syntax 'meetup download'
17
+ c.description 'Downloads events from meetup'
18
+ c.action do |args, options|
19
+ config = configuration_from_options(options)
20
+ validate_command!(args, options, config)
21
+ case args[0]
22
+ when 'download'
23
+ process_download(config)
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ def validate_command!(args, options, config)
30
+ # future-proof against other options like OAuth setup:
31
+ raise '`jekyll meetup` must be called with the download argument' \
32
+ unless args[0] == 'download'
33
+
34
+ # ensure required config is there:
35
+ raise 'No meetup.urlname found in config file.' \
36
+ unless config['meetup']['urlname']
37
+ raise 'No meetup.colleciton_name found in config file.' \
38
+ unless config['meetup']['collection_name']
39
+ end
40
+
41
+ def process_download(config)
42
+ collection = DataCollection.new(
43
+ config['data_dir'],
44
+ config['meetup']['collection_name']
45
+ )
46
+ collection.remove_existing_files!
47
+
48
+ Meetup::ApiClient
49
+ .events(config['meetup']['urlname'])
50
+ .each_with_index do |event, i|
51
+ filename = format(
52
+ '%<date>s-%<name>s.yml',
53
+ name: filenamify(event['name']),
54
+ date: event['local_date']
55
+ )
56
+
57
+ collection.create_file(filename) { |f| f.puts YAML.dump(event) }
58
+ collection.create_symlink(filename, 'upcoming.yml') if i.zero?
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,23 @@
1
+ module Jekyll
2
+ module Meetup
3
+ class DataCollection
4
+ def initialize(data_dir, collection_name)
5
+ @data_dir = data_dir
6
+ @collection_name = collection_name
7
+ @path = File.join(data_dir, collection_name)
8
+ end
9
+
10
+ def remove_existing_files!
11
+ File.delete(*Dir[File.join(@path, '*')])
12
+ end
13
+
14
+ def create_file(filename, &block)
15
+ File.open(File.join(@path, filename), 'w', &block)
16
+ end
17
+
18
+ def create_symlink(to_file, link_name)
19
+ File.link(File.join(@path, to_file), File.join(@path, link_name))
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ module Jekyll
2
+ module Meetup
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ require 'jekyll/meetup/command'
2
+ require 'jekyll/meetup/version'
3
+
4
+ module Jekyll
5
+ # The top-level module for the gem.
6
+ module Meetup
7
+ autoload :ApiClient, 'jekyll/meetup/api_client'
8
+ autoload :DataCollection, 'jekyll/meetup/data_collection'
9
+ end
10
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-meetup
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tom Dooner
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-08-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description:
42
+ email:
43
+ - tomdooner@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - bin/console
54
+ - bin/setup
55
+ - jekyll-meetup.gemspec
56
+ - lib/jekyll/meetup.rb
57
+ - lib/jekyll/meetup/api_client.rb
58
+ - lib/jekyll/meetup/command.rb
59
+ - lib/jekyll/meetup/data_collection.rb
60
+ - lib/jekyll/meetup/version.rb
61
+ homepage:
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 2.7.6
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: Jekyll plugin to download Meetup events.
85
+ test_files: []