middleman-strava 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ /Gemfile.lock
2
+ /pkg
3
+ /tmp
data/Gemfile ADDED
@@ -0,0 +1,21 @@
1
+ # If you do not have OpenSSL installed, update
2
+ # the following line to use "http://" instead
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in middleman-strava.gemspec
6
+ gemspec
7
+
8
+ gem 'strava-api-v3'
9
+
10
+ group :development do
11
+ gem 'rake'
12
+ gem 'rdoc'
13
+ gem 'yard'
14
+ end
15
+
16
+ group :test do
17
+ gem 'cucumber'
18
+ gem 'fivemat'
19
+ gem 'aruba'
20
+ gem 'rspec'
21
+ end
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) [year] [fullname]
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # Middleman Strava
2
+
3
+ `middleman-strava` is an extension for the [Middleman] static site generator that exposes helpers which return [Strava] API results inside your templates.
4
+
5
+ ## Dependencies
6
+
7
+ * [strava-api-v3]
8
+ * A valid Strava [access_token]
9
+
10
+ ## Installation
11
+
12
+ Add `middleman-strava` to your `Gemfile`:
13
+
14
+ ```ruby
15
+ gem 'middleman-strava'
16
+ ```
17
+
18
+ Then run `bundle install`.
19
+
20
+ Finally activate the extension within your `config.rb`:
21
+
22
+ ```ruby
23
+ activate :middleman_strava, :access_token => 'YOUR_PUBLIC_ACCESS_TOKEN'
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ Reference `middleman-strava` helpers from within your templates:
29
+
30
+ ### strava_athlete()
31
+ ```ruby
32
+ <img src="<%= strava_athlete['profile'] %>" />
33
+ ```
34
+
35
+ ### strava_activities(start_date, num_days)
36
+ ```ruby
37
+ <ul>
38
+ <% strava_activities('2014-08-01', 7).each do |activity| %>
39
+ <li><%= activity['name'] %></li>
40
+ <% end %>
41
+ </ul>
42
+ ```
43
+
44
+ [middleman]: http://middlemanapp.com
45
+ [strava]: http://strava.com
46
+ [strava-api-v3]: https://github.com/jaredholdcroft/strava-api-v3
47
+ [access_token]: http://www.strava.com/developers
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'cucumber/rake/task'
5
+
6
+ Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
7
+ t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'Fivemat'}"
8
+ end
9
+
10
+ require 'rake/clean'
11
+
12
+ task test: ['cucumber']
13
+
14
+ task default: :test
@@ -0,0 +1,13 @@
1
+ Feature: Strava Integration
2
+
3
+ Scenario: Strava config var `access_token` is not set
4
+ Given a fixture app "strava-app"
5
+ And a file named "config.rb" with:
6
+ """
7
+ activate :middleman_strava do |d|
8
+ d.access_token = nil
9
+ end
10
+ """
11
+ And the Server is running
12
+ When I go to "/"
13
+ Then I should see "0" lines
@@ -0,0 +1,4 @@
1
+ PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
2
+ require 'middleman-core'
3
+ require 'middleman-core/step_definitions'
4
+ require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-strava')
@@ -0,0 +1,3 @@
1
+ activate :middleman_strava do |d|
2
+ d.access_token = 'test-token'
3
+ end
@@ -0,0 +1 @@
1
+ <%= strava_athlete %>
@@ -0,0 +1,38 @@
1
+ require 'middleman-core'
2
+
3
+ module Middleman
4
+ class StravaExtension < ::Middleman::Extension
5
+ option :access_token, '', 'The access token required to use the Strava API'
6
+
7
+ cattr_accessor :client
8
+
9
+ def initialize(app, options_hash={}, &block)
10
+ super
11
+
12
+ if (options_hash[:access_token].present?)
13
+ options[:access_token] = options_hash[:access_token]
14
+ end
15
+ end
16
+
17
+ def after_configuration
18
+ StravaExtension.client = ::Strava::Api::V3::Client.new(:access_token => options[:access_token])
19
+ end
20
+
21
+ helpers do
22
+ def strava_athlete(athlete_id=nil)
23
+ if (athlete_id.present?)
24
+ StravaExtension.client.retrieve_another_athlete(athlete_id)
25
+ else
26
+ StravaExtension.client.retrieve_current_athlete
27
+ end
28
+ end
29
+
30
+ def strava_activities(start, num_days=7)
31
+ start_date = Date.parse(start)
32
+ end_date = start_date + num_days
33
+
34
+ StravaExtension.client.list_athlete_activities({:after => start_date.to_time.to_i, :before => end_date.to_time.to_i}).sort_by { |hash| hash['start_date'] }
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,5 @@
1
+ module Middleman
2
+ module Strava
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require 'middleman-core'
2
+ require 'middleman-strava/version'
3
+
4
+ ::Middleman::Extensions.register(:middleman_strava) do
5
+ require 'middleman-strava/extension'
6
+ ::Middleman::StravaExtension
7
+ end
@@ -0,0 +1 @@
1
+ require 'middleman-strava.rb'
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "middleman-strava"
6
+ s.version = "0.0.1"
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Dan Beghin"]
9
+ s.email = ["dan@begh.in"]
10
+ s.homepage = "https://github.com/dbeg/middleman-strava"
11
+ s.summary = %q{Strava API extension for Middleman}
12
+ s.description = %q{A Middleman extension that provides helpers to easily display Strava API data}
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ # The version of middleman-core your extension depends on
20
+ s.add_runtime_dependency("middleman-core", [">= 3.3.10"])
21
+
22
+ # Additional dependencies
23
+ s.add_runtime_dependency("strava-api-v3", "0.1.0")
24
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: middleman-strava
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dan Beghin
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-03-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: middleman-core
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 3.3.10
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.3.10
30
+ - !ruby/object:Gem::Dependency
31
+ name: strava-api-v3
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - '='
36
+ - !ruby/object:Gem::Version
37
+ version: 0.1.0
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - '='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.1.0
46
+ description: A Middleman extension that provides helpers to easily display Strava
47
+ API data
48
+ email:
49
+ - dan@begh.in
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - Gemfile
56
+ - LICENSE.md
57
+ - README.md
58
+ - Rakefile
59
+ - features/strava.feature
60
+ - features/support/env.rb
61
+ - fixtures/strava-app/config.rb
62
+ - fixtures/strava-app/source/index.html.erb
63
+ - lib/middleman-strava.rb
64
+ - lib/middleman-strava/extension.rb
65
+ - lib/middleman-strava/version.rb
66
+ - lib/middleman_extension.rb
67
+ - middleman-strava.gemspec
68
+ homepage: https://github.com/dbeg/middleman-strava
69
+ licenses: []
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project:
88
+ rubygems_version: 1.8.24
89
+ signing_key:
90
+ specification_version: 3
91
+ summary: Strava API extension for Middleman
92
+ test_files:
93
+ - features/strava.feature
94
+ - features/support/env.rb
95
+ has_rdoc: