almanack 1.1.0.beta1 → 1.1.0.beta2

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: 49d69b1b032ff7f536d34807c859021af3840f3e
4
- data.tar.gz: b5ea878e85c09b1e967054e7038400fcc0125120
3
+ metadata.gz: 10c99dfffb686948d337e833fb1e6b7ecb1f5158
4
+ data.tar.gz: c28448a2dd460493f2cbddbdec8a661e5c291726
5
5
  SHA512:
6
- metadata.gz: d40154226158a3bbf56e6de69e1cd495827eef1563cbf88e8823257cdf8653c2eec181070a6be6e2ae0f0b19d9fc9c56a5b02471945f6ae35bba68cecb6151b9
7
- data.tar.gz: 0a8723f866ee7403cd8d66044c16c6e93c197c5a9b7485d7af61da75a00a8cc31f9c2a04fc3cdfc40d22b80c903b9e9ebd703f2e8704ab34e8246b8a302bd024
6
+ metadata.gz: 41f12f532013e4ffe218a7f1cff3fbf794cf412c7f258e78a3a95ec5b9a5934619f7fb092fae6fa68a874ba6370f015499c1d66858bfc2d247cb6c075091110c
7
+ data.tar.gz: 8c7845973b5ab3bf7e81c508d7a4d249cb1390312008d0eff1d0c162ab98ae1ab1471ba6dc2db88d66cbe88a072bd2ca51f512265587c02fcfbc9235439d2cb0
data/.travis.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
+ - 2.1.5
4
5
  - 2.1.4
5
6
  - 2.1.3
6
7
  - 2.1.2
data/almanack.gemspec CHANGED
@@ -24,9 +24,12 @@ Gem::Specification.new do |spec|
24
24
  spec.add_dependency "addressable"
25
25
  spec.add_dependency "thor"
26
26
  spec.add_dependency "faraday"
27
+ spec.add_dependency "faraday_middleware"
27
28
  spec.add_dependency "rack-contrib"
29
+ spec.add_dependency "activesupport"
28
30
 
29
31
  spec.add_development_dependency "bundler", "~> 1.5"
32
+ spec.add_development_dependency "pry"
30
33
  spec.add_development_dependency "rake"
31
34
  spec.add_development_dependency "rspec"
32
35
  spec.add_development_dependency "rack-test"
data/lib/almanack/cli.rb CHANGED
@@ -35,12 +35,14 @@ module Almanack
35
35
  def new(path)
36
36
  @path = Pathname(path).cleanpath
37
37
 
38
- directory "templates/new", path
38
+ directory "templates/new", @path
39
39
 
40
40
  if options[:git]
41
41
  template('templates/gitignore', @path.join(".gitignore"))
42
42
  end
43
43
 
44
+ create_file @path.join('tmp/.keep')
45
+
44
46
  inside @path do
45
47
  say_status :installing, "bundler dependencies"
46
48
  system "bundle install --quiet"
@@ -2,9 +2,12 @@ module Almanack
2
2
  class Configuration
3
3
  class ThemeNotFound < StandardError; end
4
4
 
5
+ CACHE_DIR = "tmp"
5
6
  DEFAULT_THEME = "legacy"
6
7
  DEFAULT_DAYS_LOOKAHEAD = 30
7
8
  DEFAULT_FEED_LOOKAHEAD = 365
9
+ DEFAULT_CACHE_RESPONSES = false
10
+ DEFAULT_CACHE_EXPIRY = 900
8
11
 
9
12
  attr_reader :event_sources
10
13
  attr_accessor :title,
@@ -12,21 +15,28 @@ module Almanack
12
15
  :theme_paths,
13
16
  :theme_root,
14
17
  :days_lookahead,
15
- :feed_lookahead
18
+ :feed_lookahead,
19
+ :cache_responses,
20
+ :cache_expiry
16
21
 
17
22
  def initialize
18
23
  reset!
19
24
  end
20
25
 
21
26
  def connection
22
- @connection ||= Faraday.new
27
+ @connection ||= Faraday.new do |conn|
28
+ conn.response(:caching) { cache_store } if cache_responses
29
+ conn.adapter Faraday.default_adapter
30
+ end
23
31
  end
24
32
 
25
33
  def reset!
26
- @theme = DEFAULT_THEME
27
- @days_lookahead = DEFAULT_DAYS_LOOKAHEAD
28
- @feed_lookahead = DEFAULT_FEED_LOOKAHEAD
29
- @event_sources = []
34
+ @theme = DEFAULT_THEME
35
+ @days_lookahead = DEFAULT_DAYS_LOOKAHEAD
36
+ @feed_lookahead = DEFAULT_FEED_LOOKAHEAD
37
+ @event_sources = []
38
+ @cache_responses = DEFAULT_CACHE_RESPONSES
39
+ @cache_expiry = DEFAULT_CACHE_EXPIRY
30
40
 
31
41
  @theme_paths = [
32
42
  Pathname.pwd.join('themes'),
@@ -55,5 +65,15 @@ module Almanack
55
65
  def add_meetup_group(options)
56
66
  add_event_source EventSource::MeetupGroup.new(options.merge(connection: connection))
57
67
  end
68
+
69
+ def cache_store
70
+ @cache_store ||= ActiveSupport::Cache::FileStore.new(cache_dir, expires_in: cache_expiry)
71
+ end
72
+
73
+ private
74
+
75
+ def cache_dir
76
+ Pathname.pwd.join(CACHE_DIR)
77
+ end
58
78
  end
59
79
  end
@@ -37,7 +37,7 @@ module Almanack
37
37
  end
38
38
 
39
39
  def recurse(entity)
40
- cloned = case entity
40
+ case entity
41
41
  when Array
42
42
  entity.map { |child| recurse(child) }
43
43
  when Hash
@@ -1,6 +1,6 @@
1
1
  module Almanack
2
2
  CODENAME = "Garlick"
3
- VERSION = "1.1.0.beta1"
3
+ VERSION = "1.1.0.beta2"
4
4
  HOMEPAGE = "https://github.com/Aupajo/almanack"
5
5
  ISSUES = "https://github.com/Aupajo/almanack/issues"
6
6
  end
data/lib/almanack.rb CHANGED
@@ -3,6 +3,8 @@ require "json"
3
3
  require "ri_cal"
4
4
  require "addressable/uri"
5
5
  require "faraday"
6
+ require "faraday_middleware"
7
+ require "active_support/cache"
6
8
 
7
9
  require "almanack/base"
8
10
  require "almanack/version"
@@ -85,5 +85,29 @@ module Almanack
85
85
  end
86
86
  end
87
87
 
88
+ describe "#cache_expiry" do
89
+ it "is 15 minutes by default" do
90
+ expect(Configuration.new.cache_expiry).to eq(900)
91
+ end
92
+
93
+ it "can be set" do
94
+ config = Configuration.new
95
+ config.cache_expiry = 3600
96
+ expect(config.cache_expiry).to eq(3600)
97
+ end
98
+ end
99
+
100
+ describe "#cache_responses" do
101
+ it "is enabled by default" do
102
+ expect(Configuration.new.cache_responses).to be(false)
103
+ end
104
+
105
+ it "can be disabled" do
106
+ config = Configuration.new
107
+ config.cache_responses = true
108
+ expect(config.cache_responses).to be(true)
109
+ end
110
+ end
111
+
88
112
  end
89
113
  end
data/templates/gitignore CHANGED
@@ -5,3 +5,7 @@ Thumbs.db
5
5
  # Ignore cache files
6
6
  /.sass-cache
7
7
  /.cache
8
+ /tmp/*
9
+
10
+ # But not the tmp directory itself
11
+ !/tmp/.keep
@@ -5,6 +5,10 @@ Almanack.config do |c|
5
5
  c.theme = "<%= theme_name %>" # available: <%= available_themes.join(', ') %>
6
6
  c.days_lookahead = 30
7
7
 
8
+ # Don't fetch event information more than once every 15 minutes
9
+ c.cache_responses = true
10
+ c.cache_expiry = 900 # seconds
11
+
8
12
  # Your group's URL name is what you'd find at www.meetup.com/Your-Group-URL-Name/
9
13
  # You can get a Meetup API key from https://secure.meetup.com/meetup_api/key
10
14
  # c.add_meetup_group group_urlname: 'Christchurch-Ruby-Group', key: 'mysecretkey'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: almanack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0.beta1
4
+ version: 1.1.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Nicholls
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-08 00:00:00.000000000 Z
11
+ date: 2014-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: faraday_middleware
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: rack-contrib
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +136,20 @@ dependencies:
122
136
  - - ">="
123
137
  - !ruby/object:Gem::Version
124
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: activesupport
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
125
153
  - !ruby/object:Gem::Dependency
126
154
  name: bundler
127
155
  requirement: !ruby/object:Gem::Requirement
@@ -136,6 +164,20 @@ dependencies:
136
164
  - - "~>"
137
165
  - !ruby/object:Gem::Version
138
166
  version: '1.5'
167
+ - !ruby/object:Gem::Dependency
168
+ name: pry
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
139
181
  - !ruby/object:Gem::Dependency
140
182
  name: rake
141
183
  requirement: !ruby/object:Gem::Requirement