magnifier 0.0.1 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 566f64646236871263cabb77135b77131e4214a6
4
- data.tar.gz: 7a2359673ee66e9971f51586b65226ce8630fb4d
3
+ metadata.gz: 0386e1e55cd76eea5ccb2e630d9c74beda25f267
4
+ data.tar.gz: f08e29e09e25797eba6709d179a9b7659e7dee33
5
5
  SHA512:
6
- metadata.gz: 6347ffbd8b90e5b1c2d8be48fb79f597c19d64e7f99dbf0042776ef67ae8bcddef95629c005ef67d714cf2edf24706b88a843b7b203d9a582b8cb0552a68e87d
7
- data.tar.gz: 5590c57802581ceda6fb78017f69f904488e654bf2330689785ea60cc88245200513e8cbf575a4a36c44407cb3a61dab987f5a9b4a4706ec6bd0a272a1fd4808
6
+ metadata.gz: c45aad99e85ecb1508026099c13d89be3a81c7727a090314cc1b7663e342546373e23e18b51e6feb8533fa7a7459895ff74921328ea6116358a4da613a3df666
7
+ data.tar.gz: fef1f8d0c814c2ff3f373302b01c9b64488725a4831aafab4a7b29064c3133545edaeb01d17f457a5bc796a9d517eba76d1c4a228c7a1b0517bbfe7274e346ef
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Magnifier
2
2
 
3
- TODO: Write a gem description
3
+ Magnifier makes it possible to communicate with the Eskes Media Magazine Maker engine and perform various tasks (duplicate, make_preview, etc.) to projects, without having to deal with the API directly. To communicate with the API, you need an API-key, provided by the Magazine Maker.
4
4
 
5
5
  ## Installation
6
6
 
@@ -12,13 +12,23 @@ And then execute:
12
12
 
13
13
  $ bundle
14
14
 
15
+ # after installation, run this command to install the settings file (.yml)
16
+ $ rails generate magnifier
17
+
15
18
  Or install it yourself as:
16
19
 
17
20
  $ gem install magnifier
18
21
 
19
22
  ## Usage
20
23
 
21
- TODO: Write usage instructions here
24
+ ### Project
25
+ - To fetch a list of all projects: `Magnifier::Project.all`
26
+ - To fetch a project: `Magnifier::Project.find(123)`
27
+
28
+ #### Public methods
29
+ # duplicate
30
+ # duplicates the current project. Example:
31
+ new_project = Project.find(123).duplicate
22
32
 
23
33
  ## Contributing
24
34
 
@@ -0,0 +1,3 @@
1
+ magnifier_options:
2
+ site: "http://www.mijndagjeweg.nl/"
3
+ api_key: "your-api-key"
@@ -0,0 +1,30 @@
1
+ class MagnifierGenerator < Rails::Generators::Base
2
+
3
+ source_root File.join(File.dirname(__FILE__), "templates")
4
+
5
+ # Description:
6
+ # Copies the migration file into the application.
7
+ def install
8
+ # Example:
9
+ # rails generate magnifier
10
+
11
+ copy_options_file
12
+ end
13
+
14
+ private
15
+
16
+
17
+
18
+ def copy_options_file
19
+ copy_file File.join(config_path, 'magnifier_options.yml'), config_destination
20
+ end
21
+
22
+ def config_path
23
+ File.join(%w(.. .. .. config))
24
+ end
25
+
26
+ def config_destination
27
+ 'config/magnifier_options.yml'
28
+ end
29
+
30
+ end
@@ -1,4 +1,5 @@
1
1
  require "magnifier/version"
2
+
2
3
  require 'magnifier/railtie' if defined?(Rails)
3
4
 
4
5
  module Magnifier
@@ -20,20 +21,10 @@ module Magnifier
20
21
  end
21
22
  end
22
23
 
23
- class Project < ActiveResource::Base
24
- headers['X-AUTH-TOKEN'] = Settings.api_key
25
- self.site = Settings.site
26
- end
27
-
28
- class Page < ActiveResource::Base
29
- headers['X-AUTH-TOKEN'] = Settings.api_key
30
- self.site = Settings.site
31
- end
24
+ require "magnifier/project"
25
+ require "magnifier/page"
26
+ require "magnifier/page_element"
32
27
 
33
- class PageElement < ActiveResource::Base
34
- headers['X-AUTH-TOKEN'] = Settings.api_key
35
- self.site = Settings.site
36
- end
37
28
 
38
29
  # private
39
30
 
@@ -0,0 +1,11 @@
1
+ include Magnifier
2
+
3
+ class Page < ActiveResource::Base
4
+ headers['X-AUTH-TOKEN'] = Settings.api_key
5
+ self.site = Settings.site
6
+
7
+ # forces the magazin make engine to produce a new preview of this page
8
+ def make_preview
9
+ self.get :make_preview
10
+ end
11
+ end
@@ -0,0 +1,20 @@
1
+ include Magnifier
2
+ class PageElement < ActiveResource::Base
3
+ headers['X-AUTH-TOKEN'] = Settings.api_key
4
+ self.site = Settings.site
5
+
6
+ def replace_content(old_value, new_value)
7
+ if content.include? old_value
8
+ c = content.gsub(old_value, new_value)
9
+ self.content = c
10
+ self.save
11
+ else
12
+ return false
13
+ end
14
+ end
15
+
16
+ # upload or use a photo
17
+ def use_photo(url)
18
+ self.post :update_with_photo, url: url
19
+ end
20
+ end
@@ -0,0 +1,12 @@
1
+ include Magnifier
2
+ class Project < ActiveResource::Base
3
+ headers['X-AUTH-TOKEN'] = Settings.api_key
4
+ self.site = Settings.site
5
+
6
+ # make a copy of the project
7
+ def duplicate
8
+ new_project = self.get :pick_template
9
+ npid = new_project["id"]
10
+ return Project.find(npid)
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ require 'rails'
2
+ module Magnifier
3
+ class Railtie < Rails::Railtie
4
+ # config.magnify_auth_token = ""
5
+ # config.magnify_site = ""
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module Magnifier
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -10,9 +10,11 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["meijerhenk@gmail.com"]
11
11
  spec.description = %q{Communicate with the Eskes Media Magazine Maker}
12
12
  spec.summary = %q{This gem makes it realy easy to communicate to the Magazine Maker in a ruby-esque way.}
13
- spec.homepage = "http://www.mijndagjeweg.nl/"
13
+ spec.homepage = "https://bitbucket.org/eskes_media/magnify"
14
14
  spec.license = "MIT"
15
15
 
16
+ spec.post_install_message = "Thanks for installing! Please run 'rails generate magnifier' to install the options file."
17
+
16
18
  spec.files = `git ls-files`.split($/)
17
19
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
20
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magnifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henk Meijer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-07 00:00:00.000000000 Z
12
+ date: 2013-06-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -51,14 +51,21 @@ files:
51
51
  - LICENSE.txt
52
52
  - README.md
53
53
  - Rakefile
54
+ - config/magnifier_options.yml
55
+ - lib/generators/magnifier_generator.rb
54
56
  - lib/magnifier.rb
57
+ - lib/magnifier/page.rb
58
+ - lib/magnifier/page_element.rb
59
+ - lib/magnifier/project.rb
60
+ - lib/magnifier/railtie.rb
55
61
  - lib/magnifier/version.rb
56
62
  - magnifier.gemspec
57
- homepage: http://www.mijndagjeweg.nl/
63
+ homepage: https://bitbucket.org/eskes_media/magnify
58
64
  licenses:
59
65
  - MIT
60
66
  metadata: {}
61
- post_install_message:
67
+ post_install_message: Thanks for installing! Please run 'rails generate magnifier'
68
+ to install the options file.
62
69
  rdoc_options: []
63
70
  require_paths:
64
71
  - lib